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: custom plugin is not working

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

Nagios: custom plugin is not working

Postby sheetal » Wed Jun 01, 2022 1:00 am

Hello, 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 the Linux command line, but it returns 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 and password are "coded" inside the 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 returns 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

Hope I will get quick answer. Thanks :)
sheetal
 
Posts: 1
Joined: Wed Jun 01, 2022 12:57 am

Re: Nagios: custom plugin is not working

Postby SalinaSJames » Mon Jun 13, 2022 6:39 am

Since running from command line is ok, from which user do you run the shell script? Is it nagios user? If not try running it like sudo -u nagios sh -c '/usr/lib64/nagios/plugins/check_SQLplus_queryPrimavera.sh -q "select count(*) from ADMUSER_PM.REFRDEL" -w 6000000 -c 8000000'

It's seams there is no problem of file permission, the user that I'm currently using via SSH is the same that nagios use to launch the script. Also, one important things that I've omitted before, the nagios GUI return unknown status, reporting UNKNOWN - . IT's seams that the nagios run my script but maybe there "nothings" inside the RETVAL. Now I put the full path of sqlplus in my script, but nothings change, It's seams that nagios when launch the check doesn't execute omegle shaglevoojio sqlplus
SalinaSJames
 
Posts: 11
Joined: Sat Feb 12, 2022 1:21 am


Return to Community Support

Who is online

Users browsing this forum: No registered users and 8 guests