NRPE is not able to parse the argument properly
Posted: Mon Jul 17, 2017 8:28 pm
Hi,
I have tomcat 8 installed in my application server with 3-4 applications deployed under that. I am using check_nrpe to use check_tomcatApplication plugin to monitor the service status for each application.
Here is my entry from command.cfg :
command[check_tomcatApplication]=/usr/local/nagiosxi/libexec/check_tomcatApplication $ARG1$
Here is the service check defined:
I was using generic-service template earlier which was having check interval set to 10 mins ,, retry interval to 1 min and max_check_attempts to 3. The issue is:
When I was doing a test run check from ui, everything works fine with status as application running. when nagios is having its scheduled checks, it will say status running and then even before the next check (which is after 10 min) , the status will still be green but with following output:
I thought of changing the service template and check intervals but its the same issue. Here is the plugin content:
I have tomcat 8 installed in my application server with 3-4 applications deployed under that. I am using check_nrpe to use check_tomcatApplication plugin to monitor the service status for each application.
Here is my entry from command.cfg :
command[check_tomcatApplication]=/usr/local/nagiosxi/libexec/check_tomcatApplication $ARG1$
Here is the service check defined:
Code: Select all
define service {
service_description checkHOMEApp
use xiwizard_nrpe_service
hostgroup_name testHostGroup
check_command check_nrpe!check_tomcatApplication!-a '-H localhost -P 28080 -u admin -p admin -V 8 -a home'!!!!!!!
max_check_attempts 3
check_interval 5
retry_interval 1
check_period xi_timeperiod_24x7
notification_interval 1440
notification_period xi_timeperiod_24x7
contact_groups admins
register 1
}
When I was doing a test run check from ui, everything works fine with status as application running. when nagios is having its scheduled checks, it will say status running and then even before the next check (which is after 10 min) , the status will still be green but with following output:
Code: Select all
Unknown argument: home
Version 1.02
check_tomcatApplication is a Nagios plugin to check a specific Tomcat Application.
check_tomcatApplication -u user -p password -h host -P port -a application
Options:
-u/--user)
User name for authentication on Tomcat Manager Application
-p/--password)
Password for authentication on Tomcat Manager Application
-H/--host)
Host Name of the server
-P/--port)
Port Number Tomcat service is listening on
-a/--appname)
Application name to be checked
-V/--tomcat_version)
Version of the Tomcat. Default is Tomcat 6
Code: Select all
#!/bin/sh
#VARIAVEIS NAGIOS
NAGIOS_OK=0
NAGIOS_WARNING=1
NAGIOS_CRITICAL=2
NAGIOS_UNKNOWN=3
PROGNAME=`basename $0 .sh`
VERSION="Version 1.02"
TOMCAT_VERSION="6"
WGET=/usr/bin/wget
GREP=/bin/grep
print_version() {
echo "$VERSION"
}
print_help() {
print_version $PROGNAME $VERSION
echo ""
echo "$PROGNAME is a Nagios plugin to check a specific Tomcat Application."
echo ""
echo "$PROGNAME -u user -p password -h host -P port -a application"
echo ""
echo "Options:"
echo " -u/--user)"
echo " User name for authentication on Tomcat Manager Application"
echo " -p/--password)"
echo " Password for authentication on Tomcat Manager Application"
echo " -H/--host)"
echo " Host Name of the server"
echo " -P/--port)"
echo " Port Number Tomcat service is listening on"
echo " -a/--appname)"
echo " Application name to be checked"
echo " -V/--tomcat_version)"
echo " Version of the Tomcat. Default is Tomcat 6"
exit $ST_UK
}
if [ ! -x "$WGET" ]
then
echo "wget not found!"
exit $NAGIOS_CRITICAL
fi
if [ ! -x "$GREP" ]
then
echo "grep not found!"
exit $NAGIOS_CRITICAL
fi
if test -z "$1"
then
print_help
exit $NAGIOS_CRITICAL
fi
while test -n "$1"; do
case "$1" in
--help|-h)
print_help
exit $ST_UK
;;
--version|-v)
print_version $PROGNAME $VERSION
exit $ST_UK
;;
--user|-u)
USER=$2
shift
;;
--password|-p)
PASSWORD=$2
shift
;;
shift
;;
shift
;;
--appname|-a)
APP=$2
shift
;;
--tomcat_version|-V)
TOMCAT_VERSION=$2
shift
;;
*)
echo "Unknown argument: $1"
print_help
exit $ST_UK
;;
esac
shift
done
# Default URL - Tomcat 6
URL="http://$USER:$PASSWORD@$HOST:$PORT/manager/list"
if [ $TOMCAT_VERSION = 7 -o $TOMCAT_VERSION = 8 ]
then
URL="http://$USER:$PASSWORD@$HOST:$PORT/manager/text/list"
fi
if wget -o /dev/null -O - $URL | grep -q "^/$APP:running"
then
echo "OK: Application $APP is running!"
# wget -o /dev/null -O - http://$USER:$PASSWORD@$HOST:$PORT/manager/status?XML=true |sed -e "s/\/>/\/>\n/g"|egrep "(connector|requestInfo|<memory)"|sed -e "s/\"//g"|sed -e "s/'//g"|awk -v app=$APP '{
# if ($0 ~ "connector name=") { value=$2; all=substr(value,6,13); ncount=index(all,"<")-2; connector=substr(all,0,ncount);}
# if ($0 ~ "<memory ") { jm=$9; ccount=index(jm,"/")-1; jmax=substr($9,0,ccount); print app"_JVM_OK:|" app"_JVM_"$7"MB;;;0 "app"_JVM_"$8"MB;;;0 "app"_JVM_"jmax"MB;;;0"};
# if ($0 ~ "<requestInfo") { print app"_"connector" OK:|"connector"_"$2"ms;;;0 "connector"_"$3"ms;;;0 "connector"_"$4"ms;;;0 "connector"_"$5"ms;;;0 "connector"_"$6"ms;;;0 "connector"_"$7"ms;;;0"; } ;}'
exit $NAGIOS_OK
else
echo "CRITICAL: Application $APP is not running!"
exit $NAGIOS_CRITICAL
fi