how to enable performance graph on a custom service

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Re: how to enable performance graph on a custom service

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: how to enable performance graph on a custom service

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Re: how to enable performance graph on a custom service

Post 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!
You do not have the required permissions to view the files attached to this post.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: how to enable performance graph on a custom service

Post by scottwilkerson »

Glad we were able to solve this for you!
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked