monitoringnagiosnagiosxi

Nagios won't create performace-data for plugin


I made a bash script for Nagios to test with Nagiosgraph. Rrd files are however not being created for this script. Default plugins that come with Nagios work well with Nagiosgraph and rrd files of those plugins are also present.

Here is the script:

#!/bin/bash

checkgpu=$( nvidia-smi --format=csv --query-gpu=utilization.gpu | awk '/[[:digit:]]+[[:space:]]%/ { tot+=$1;cnt++ } END { print tot/cnt }' | cut -d$

output="Load Average: $checkgpu"

if [ $checkgpu -ge 0 ]
then
    echo "OK- $output"
    exit 0
elif [ $checkgpu -eq 101 ]
then
    echo "WARNING- $output"
    exit 1
elif [ $checkgpu -eq 102 ]
then
    echo "CRITICAL- $output"
    exit 2
else
echo "UNKNOWN- $output"
exit 3
fi

What should i do to make this script work with Nagiosgraph/Performance data ?


Solution

  • Have a look at the development guidelines: https://nagios-plugins.org/doc/guidelines.html#AEN200

    The expected format for perfdata is 'label'=value[UOM];[warn];[crit];[min];[max] which can look something like this:

    PING ok - Packet loss = 0%, RTA = 0.80 ms | percent_packet_loss=0, rta=0.80
    

    The pipe (|) character tells Nagios that the plugin output has ended and performance data starts.

    Note that the above example does not specify UOM (unit of measurement, like percent), nor does it specify any warn/crit thresholds for the data, or min/max values for the graphs. These are all optional.