Page 1 of 1

Graphing in Nagios XI

Posted: Wed Feb 06, 2013 5:03 pm
by yaanatech
I am having an issue where data is not graphing, below is a test script I wrote to graph some disk usage; using the Graph Explorer plugin to watch this on a single graph.

Test works fine, Status Ok is of course returned, under advanced I see there is perfdata; but it isn't graphing. Am I missing something in how NagiosXI graphs data? I have seen this work on other scripts.

Code: Select all

#!/bin/bash

STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3

AA=`df -H | grep /dev/sda2 | awk '{print $5}'| sed 's/%//g'`
AB=`df -H | grep /dev/sdb1 | awk '{print $5}'| sed 's/%//g'`
AC=`df -H | grep /dev/sdb2 | awk '{print $5}'| sed 's/%//g'`
AD=`df -H | grep /dev/sdc1 | awk '{print $5}'| sed 's/%//g'`
AE=`df -H | grep /dev/sdc2 | awk '{print $5}'| sed 's/%//g'`
AF=`df -H | grep /dev/sdd1 | awk '{print $5}'| sed 's/%//g'`
AG=`df -H | grep /dev/sdd2 | awk '{print $5}'| sed 's/%//g'`

echo "Status Ok: /dev/sda2 $AA, /dev/sdb1 $AB, /dev/sdb2 $AC, /dev/sdc1 $AD, /dev/sdc2 $AE, /dev/sdd1 $AF, /dev/sdd2 $AG | sda2=$AA;sdb1=$AB,sdb2=$AC;sdc1=$AD;sdc2=$AE;sdd1=$AF;sdd2=$AG"
exit $STATE_OK

Re: Graphing in Nagios XI

Posted: Wed Feb 06, 2013 5:18 pm
by abrist
You may want to specify your unit of measurement in percents as that is the metric you are awking.

Code: Select all

sda2=$AA%;sdb1=$AB%,sdb2=$AC%;sdc1=$AD%;sdc2=$AE%;sdd1=$AF%;sdd2=$AG%

Re: Graphing in Nagios XI

Posted: Thu Feb 07, 2013 12:52 pm
by yaanatech
I had a comma where I need an ; in the graphing portion.

Nagios is using the default graphing .xml, how do I change the units to be a % in the graph? Instead of 68.002 as an example - it just shows 68. Given how Nagios can break if you touch default configs, i have avoided touching files I don't fully understand.

Re: Graphing in Nagios XI

Posted: Thu Feb 07, 2013 12:55 pm
by abrist
Good catch on the comma. In order to make the graph use percentage, you just need to declare the value's unit of measurement as a percent in the perfdata. In my example above, I added a percent sign after the values, this should be enough for the perfdata to be treated as a percentage rather than a float or int value.

Re: Graphing in Nagios XI

Posted: Fri Feb 08, 2013 2:10 pm
by yaanatech
Oh right, sweet. I'll try that. Thanks for the suggestion.

Re: Graphing in Nagios XI

Posted: Fri Feb 08, 2013 2:32 pm
by slansing
Good catch, let us know if this resolves the issue.