Page 2 of 2
Re: how to enable performance graph on a custom service
Posted: Wed Aug 16, 2017 6:04 am
by lpereira
scottwilkerson wrote:lpereira wrote:yes but one output says "drive OK" and the other one "Drive Critical". i have 2 different responses from the same query
What I added didn't change nothing on the script that would change that logic.
Can you post the whole file so we can see the logic in the file?
This is the whole content of the modified file:
Code: Select all
FREESPACE=`/usr/local/nagios/libexec/check_nt -H $2 -p 12489 \
-v USEDDISKSPACE -l $4 | awk -F"- " '{ print $4 }' | awk -F "|" '{ print $1 }'`
SIZE=`echo $FREESPACE | awk '{ print $2 }'`
UNIT=`echo $FREESPACE | awk '{ print $3 }'`
if [ $UNIT == "Gb" ]; then
SIZE=`echo $SIZE \* 1024 | bc`
fi
echo "$4:\ Drive Space OK - $FREESPACE | free=$SIZE"
exit 0
elif [ `echo "$SIZE < $6" | bc` -eq 1 -a `echo "$SIZE > $8" | bc` -eq 1 ]; then
echo "$4:\ Drive Space WARNING - $FREESPACE | free=$SIZE"
exit 1
elif [ `echo "$SIZE <= $8" | bc` -eq 1 ]; then
echo "$4:\ Drive Space CRITICAL - $FREESPACE | free=$SIZE"
exit 2
fi
Re: how to enable performance graph on a custom service
Posted: Wed Aug 16, 2017 10:18 am
by scottwilkerson
[root@Nagios testin]# ./check_disk_by_size.sh -H Xxxx.xxx.xxx.xxx -l e -w 24000000 -c 23000000
e:\ Drive Space OK - free 234.80 Gb (7%) |free=240435.20
I have no idea how the old one worked because you don't even have a valid "if" statement at the bottom, but this should be closer, checking critical, then warning, else OK:
Code: Select all
FREESPACE=`/usr/local/nagios/libexec/check_nt -H $2 -p 12489 \
-v USEDDISKSPACE -l $4 | awk -F"- " '{ print $4 }' | awk -F "|" '{ print $1 }'`
SIZE=`echo $FREESPACE | awk '{ print $2 }'`
UNIT=`echo $FREESPACE | awk '{ print $3 }'`
if [ $UNIT == "Gb" ]; then
SIZE=`echo $SIZE \* 1024 | bc`
fi
if [ `echo "$SIZE <= $8" | bc` -eq 1 ]; then
echo "$4:\ Drive Space CRITICAL - $FREESPACE | free=$SIZE"
exit 2
elif [ `echo "$SIZE < $6" | bc` -eq 1 -a `echo "$SIZE > $8" | bc` -eq 1 ]; then
echo "$4:\ Drive Space WARNING - $FREESPACE | free=$SIZE"
exit 1
else
echo "$4:\ Drive Space OK - $FREESPACE | free=$SIZE"
exit 0
fi
Re: how to enable performance graph on a custom service
Posted: Wed Aug 16, 2017 1:45 pm
by lpereira
scottwilkerson wrote:[root@Nagios testin]# ./check_disk_by_size.sh -H Xxxx.xxx.xxx.xxx -l e -w 24000000 -c 23000000
e:\ Drive Space OK - free 234.80 Gb (7%) |free=240435.20
I have no idea how the old one worked because you don't even have a valid "if" statement at the bottom, but this should be closer, checking critical, then warning, else OK:
Code: Select all
FREESPACE=`/usr/local/nagios/libexec/check_nt -H $2 -p 12489 \
-v USEDDISKSPACE -l $4 | awk -F"- " '{ print $4 }' | awk -F "|" '{ print $1 }'`
SIZE=`echo $FREESPACE | awk '{ print $2 }'`
UNIT=`echo $FREESPACE | awk '{ print $3 }'`
if [ $UNIT == "Gb" ]; then
SIZE=`echo $SIZE \* 1024 | bc`
fi
if [ `echo "$SIZE <= $8" | bc` -eq 1 ]; then
echo "$4:\ Drive Space CRITICAL - $FREESPACE | free=$SIZE"
exit 2
elif [ `echo "$SIZE < $6" | bc` -eq 1 -a `echo "$SIZE > $8" | bc` -eq 1 ]; then
echo "$4:\ Drive Space WARNING - $FREESPACE | free=$SIZE"
exit 1
else
echo "$4:\ Drive Space OK - $FREESPACE | free=$SIZE"
exit 0
fi
Excellent!!!! now is working as expected and the performance graph is being populated.
Thanks for your support!
Re: how to enable performance graph on a custom service
Posted: Wed Aug 16, 2017 3:06 pm
by scottwilkerson
Glad we were able to solve this for you!