check_esx did not exit properly!

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
[email protected]
Posts: 3
Joined: Thu Sep 17, 2015 6:17 am

check_esx did not exit properly!

Post by [email protected] »

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.
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: check_esx did not exit properly!

Post by hsmith »

Does the password have special characters? Can you try wrapping it in ' '?
Former Nagios Employee.
me.
[email protected]
Posts: 3
Joined: Thu Sep 17, 2015 6:17 am

Re: check_esx did not exit properly!

Post by [email protected] »

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.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: check_esx did not exit properly!

Post by rkennedy »

Can you try to define the password in the resource.cfg file and reference that variable in your service check?
Former Nagios Employee
[email protected]
Posts: 3
Joined: Thu Sep 17, 2015 6:17 am

Re: check_esx did not exit properly!

Post by [email protected] »

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.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: check_esx did not exit properly!

Post 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.
Former Nagios Employee
Locked