Page 1 of 1

check_esx did not exit properly!

Posted: Thu Dec 03, 2015 9:19 am
I used this script from nagios exchange https://exchange.nagios.org/directory/P ... st/details for many years in nagios2. now on a new server with debian 7 and nagios3 the plugin doesn't exit properly and i can't find the problem. the script is running perfectly in cli started a user root and as user nagios too.

Code: Select all

nagios@srvnag:~$ /usr/lib/nagios/plugins/check_esx.pl -H servername.domainname -u username -p password -l cpu
CHECK_ESX.PL OK - cpu usage=5546.00 MHz (34.66%) | cpu_usagemhz=5546.00Mhz;; cpu_usage=34.66%;;
Nagios Log and Debug output:

Code: Select all

[1449151076] Warning:  Check of service 'Check ESX CPU' on host 'SERVERNAME' did not exit properly!

[1449151101.175320] [2048.2] [pid=31249]   Uncleaned macro.  Running output (63): '/usr/lib/nagios/plugins/check_esx.pl -H servername.domainname'
[1449151101.175329] [2048.2] [pid=31249]   Just finished macro.  Running output (63): '/usr/lib/nagios/plugins/check_esx.pl -H servername.domainname'
[1449151101.175349] [2048.2] [pid=31249]   Not currently in macro.  Running output (91): '/usr/lib/nagios/plugins/check_esx.pl -H servername.domainname -u username -p password '
[1449151101.175409] [2048.2] [pid=31249]   Uncleaned macro.  Running output (91): '/usr/lib/nagios/plugins/check_esx.pl -H servername.domainname -u username -p password '
[1449151101.175417] [2048.2] [pid=31249]   Just finished macro.  Running output (91): '/usr/lib/nagios/plugins/check_esx.pl -H servername.domainname -u username -p password '
[1449151101.175442] [2048.2] [pid=31249]   Not currently in macro.  Running output (92): '/usr/lib/nagios/plugins/check_esx.pl -H servername.domainname -u username -p password  '
[1449151101.175491] [2048.2] [pid=31249]   Uncleaned macro.  Running output (98): '/usr/lib/nagios/plugins/check_esx.pl -H servername.domainname -u username -p password  -l cpu'
[1449151101.175506] [2048.2] [pid=31249]   Just finished macro.  Running output (98): '/usr/lib/nagios/plugins/check_esx.pl -H servername.domainname -u username -p password  -l cpu'
[1449151101.175522] [2048.2] [pid=31249]   Not currently in macro.  Running output (98): '/usr/lib/nagios/plugins/check_esx.pl -H servername.domainname -u username -p password  -l cpu'
[1449151101.175540] [2048.1] [pid=31249]   Done.  Final output: '/usr/lib/nagios/plugins/check_esx.pl -H servername.domainname -u username -p password  -l cpu'
when i copy & paste the Final output from Debug log to cli it's running.

here my config.

Code: Select all

define command{
        command_name    check_esx
        command_line    $USER1$/check_esx.pl -H $HOSTADDRESS$ -u username -p password $ARG1$ $ARG2$
        }

Code: Select all

define service{
        use                     generic-service
        hostgroup               esx-servers
        service_description     Check ESX CPU
        check_command           check_esx!-l cpu
        }
after i figured out a problem with $ARGn$ parameters with another script in nagios3 i tried to use the same syntax in service definition which fixes the other problem but without luck:

Code: Select all

define service{
        use                     generic-service
        hostgroup               esx-servers
        service_description     Check ESX CPU
        check_command           check_esx!!-l cpu
        }
here you have to give a ! for every $ARG$ in command definition but as i sayed it didn't work.

Re: check_esx did not exit properly!

Posted: Thu Dec 03, 2015 12:36 pm
by hsmith
Does the password have special characters? Can you try wrapping it in ' '?

Re: check_esx did not exit properly!

Posted: Fri Dec 04, 2015 3:26 am
yes i have special characters in the password and i tried single quotes before without luck and i have other passwords with the same special characters used by other plugins and they are working fine. i thought the problem is based on the output of the script because there i a | in the output so i changed the

Code: Select all

illegal_macro_output_chars=`~$^&"|'<>
and

Code: Select all

illegal_object_name_chars=`~!$%^&*|'"<>?,()=
in nagios.cfg but this doesn't work too.

i have set the maximum possible debug level but i didn't get a useful error message in the log.

Re: check_esx did not exit properly!

Posted: Fri Dec 04, 2015 1:07 pm
by rkennedy
Can you try to define the password in the resource.cfg file and reference that variable in your service check?

Re: check_esx did not exit properly!

Posted: Fri Dec 04, 2015 4:48 pm
i tried this without success but i figured out a working solution.
after trying to set the password in resource.cfg without luck it crossed my mind. i never tried to redirect the command into a new bash and that's the way it works. so here is the working command definition

Code: Select all

define command{
        command_name    check_esx
        command_line    /bin/bash | $USER1$/check_esx.pl -H $HOSTADDRESS$ -u $USER3$ -p $USER4$ $ARG1$ $ARG2$
        }
where $USER3$ and $USER4$ is set in recource.cfg. i didn't know that i can define variables myself. I like this very much and will use it. thank you very much for that.

Re: check_esx did not exit properly!

Posted: Mon Dec 07, 2015 10:21 am
by rkennedy
Thanks for posting your solution! You're welcome. I'll go ahead and close this post out, but feel free to open a new thread if you ever need assistance.