CLI cmd works, but not in nagios


this check command works fine from command line:

it returns

Here’s my Service

define service { service_description Check MSSQL - Online check_command Check MSSQL - Online!user!password!DBName host_name SERVERNAME check_period 24x7 notification_period 24x7 contact_groups admins event_handler_enabled 0 notification_interval 15 notification_options w,u,c,r max_check_attempts 3 check_interval 5 retry_interval 1 active_checks_enabled 1 passive_checks_enabled 1 notifications_enabled 1 use generic-service }

Here’s the check command:

define command { command_name Check MSSQL - Online command_line $USER1$/ -H $HOSTADDRESS$ -U $ARG1$ -P $ARG2$ -D $ARG3$ -o }

Whatever is wrong here, I can’t figure it out.

Nagios shows “(null)” in the GUI for this service.


from CLI are you running the command as user nagios or root? try as nagios first.


it works fine from the CLI as root or nagios.


If it runs as user nagios from command line it’s probably some missing enviroment variable in your script. To checkj this you can create a small sh script which calls the script and saves the output, and run it via crontab.