We've moved to a new support system!

The Nagios Answer Hub is a place where you can get help with technical questions from our experts. There, you can quickly open tickets and join discussion boards.

Request Nagios Answer Hub access here: https://info.nagios.com/answer-hub-access-new-users

After completing the access form, you will be given access to a portal where new tickets can be created. We will keep the old customer forum sections and ticket system available for current cases to be resolved.

Go to the Answer Hub

Nagios plugins for the first time. How do i show performanc

Engage with the community of users including those using the open source solutions.
Includes Nagios Core, Plugins, and NCPA

Nagios plugins for the first time. How do i show performanc

Postby PhumeleleSJose96 » Wed Feb 23, 2022 2:46 am

Hi
I tried making my first nagios plugin, but i don't have any performance data, can someone tell me what i am missing to get it to show?
#!/bin/bash

eshost="elastic.domain.com"
timeback="15m"
credentials="elastic:changeme"
indexname="default"
datatype="default"
datename="indexdate"

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
PhumeleleSJose96
 
Posts: 7
Joined: Mon Feb 14, 2022 5:39 am

Re: Nagios plugins for the first time. How do i show perform

Postby gormank » Wed Feb 23, 2022 1:20 pm

Something like this for each echo...
echo "OK - Index count is $index_count.|Count=$index_count"
gormank
 
Posts: 992
Joined: Tue Dec 02, 2014 12:00 pm


Return to Community Support

Who is online

Users browsing this forum: No registered users and 21 guests

cron