First time creating nagios plugin, how do i add perf data?

This forum is intended for the discussion of Nagios plugin development. Feature requests, patches, bug fixes, and all types of development-related discussions are welcome!

NOTE: The SourceForge.net nagiosplug-devel mailing list has been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

First time creating nagios plugin, how do i add perf data?

Postby danada » Tue Jun 20, 2017 6:33 am

Hi, i have tried making my first plugin. I can't seem to find out how to add perf data to my script, can someone tell me whats missing here?

Code: Select all
while getopts H:t:u:i:d:k: option
do
case "${option}"
in
H) eshost=${OPTARG};;
t) timeback=${OPTARG};;
u) credentials=${OPTARG};;
i) indexname=${OPTARG};;
d) datatype=${OPTARG};;
k) datename=${OPTARG};;
esac
done

# Debug code #
#echo $eshost
#echo $timeback
#echo $credentials
#echo $indexname
#echo $datatype
#echo $datename

index_count=`curl -s -XGET -u $credentials $eshost'/'$indexname'/'$datatype'/_search' \
             -H 'Content-Type: application/json' -d '{"query": { "range" : { "'$datename'" : { "gte" : "now-'$timeback'", "lt" : "now"}}}}' | \
             python -c "import sys, json; print json.load(sys.stdin)['hits']['total']"`

#echo "Index Count: $index_count"

#Debug value if you should need to check functionality.
#index_count=-11

if ((5<=$index_count))
then
    echo "OK - Index count is $index_count."
    exit 0
elif ((1<=$index_count && $index_count<=4))
then
    echo "WARNING - Index count is $index_count."
    exit 1
elif ((0==$index_count))
then
    echo "CRITICAL - Index count is $index_count."
    exit 2
else
    echo "UNKNOWN - Index count is $index_count."
    exit 3
fi
danada
 
Posts: 1
Joined: Tue Jul 05, 2016 4:20 am

Re: First time creating nagios plugin, how do i add perf dat

Postby scottwilkerson » Tue Jun 20, 2017 10:08 am

To include performance data your plugins output would need to have a pipe | followed by the performance data in the following format

Code: Select all
'label'=value[UOM];[warn];[crit];[min];[max]

https://nagios-plugins.org/doc/guidelines.html#AEN200
User avatar
scottwilkerson
CTO
 
Posts: 6999
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises


Return to Nagios Plugin Development

Who is online

Users browsing this forum: No registered users and 2 guests