Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
973 views
in Technique[技术] by (71.8m points)

monitoring - 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 ?

question from:https://stackoverflow.com/questions/65917271/nagios-wont-create-performace-data-for-plugin

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...