check_wmic
by
tseward
—
last modified
2007-11-09 05:21
A script that allows you to pass variables to check_wmic via a Zenoss Command within a Template.
Click here to get the file
Size
1 kB
-
File type
text/x-sh
File contents
#!/bin/sh
# $1 = namespace
# $2 = domain\username
# $3 = password
# $4 = target host
# $5 = WQL
# $6 = Number of | to cut to get desired result
# $7 = Result Name
RAW=$(wmic --namespace=$1 -U $2%$3 //$4 "$5")
ERROR=`echo $RAW | cut -f2- -d\ | tr ' ' '\n' | grep 'ERROR' | cut -f1 -d: | head -1`
if [ "$ERROR" != "ERROR" ]
then
RESULT=`echo $RAW | cut -d \| -f $6`
RESULT=`echo $RESULT | cut -d \| -f 1`
echo -n $RESULT | awk '{print "OK|'"$7"'=" $1}'
else
echo -n $RAW | awk '{print $RAW}'
fi