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

my own custom plugin is not working

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

my own custom plugin is not working

Postby JamesZimmerman » Fri May 06, 2022 7:07 am

Hi


This question does not show any research effort; it is unclear or not useful
I'm trying to add my own custom check to nagios. I have successfully created a bash script, that is executable from nagios user. The problem is that this script works fine from linux command line, but it's return the unknown status if runned by nagios ( returned in web gui ).

#!/bin/sh

while getopts ":q:c:w:h:u:p" optname
do
case "$optname" in "q") query=$OPTARG
;;
"c") CIRT=$OPTARG
;;
"w") WARN=$OPTARG
;;
"u") user=$OPTARG
;;
"p") pswd=$OPTARG
;;
"h") echo "Useage: check_SQLplus_query -u user -p password -w warning value -c cirtical value"
exit
;;
"?") echo "Unknown option $OPTARG"
exit
;;
":") echo "No argument value for option $OPTARG"
exit
;;
*) # Should not occur
echo "Unknown error while processing options"
exit
;;
esac
done
RETVAL=`sqlplus -s USER/PASSWORD@HOST:1521/DBNAME<<EOF
SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF
$query;
EXIT;
EOF`
if [ "$RETVAL" -le "$CIRT" ]
then
echo "OK - $RETVAL"
exit 0
elif [ "$RETVAL" -gt "$CIRT" ] && [ "$RETVAL" -le "$WARN" ]
then
echo "WARNING - $RETVAL"
exit 1
elif [ "$RETVAL" -gt "$WARN" ]
then
echo "CRITICAL - $RETVAL"
exit 2
else
echo "UNKNOWN - $RETVAL"
exit 3
fi
Actually the user, password are "coded" inside script, even if I've already set the getopt to make this script more flexible.

The idea is simple, use sqlplus to get a simple query that return only a number ( like the number of the row like my case ).

Bash line to start the script:

/usr/lib64/nagios/plugins/check_SQLplus_queryPrimavera.sh -q "select count(*) shagle voojio from ADMUSER_PM.REFRDEL" -w 6000000 -c 8000000
JamesZimmerman
 
Posts: 7
Joined: Wed Mar 23, 2022 8:00 am

Return to Community Support

Who is online

Users browsing this forum: Google [Bot] and 29 guests