Page 1 of 1

Error in commands.cfg

Posted: Wed Nov 22, 2017 5:32 pm
by brobeck
Hi, I am new to Nagios and just installed on my RHEL6 server. I am running into this error below. I can see in this file that the command line is NULL, but I don't know where to find the service to make it inactive. I have looked through the service templates and disabled all that have "ping" in the name. Here is the snippet of line 161

-Is there anyway to restore defaults? Any help would be appreciated.

Code: Select all

---commands.cfg:
define command {
       command_name                             check_xi_host_ping
}

-here are a couple of more in the commands.cfg file as well
define command {
       command_name                             check_xi_service_ftp
}

define command {
       command_name                             check_xi_service_http
}
---------


I have been through the services templates trying to find the service that controls this command -with no luck.
Can anyone point me to the service?



Code: Select all

Error: Command name of command line is NULL 
Error: Could not register command (config file '/usr/local/nagios/etc/commands.cfg', starting on line 161) 
 
Nagios Core 4.2.4 
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors 
Copyright (c) 1999-2009 Ethan Galstad 
Last Modified: 12-07-2016 
License: GPL 

Website: https://www.nagios.org 
Reading configuration data... 
 Read main config file okay... 
Error: Command name of command line is NULL 
Error: Could not register command (config file '/usr/local/nagios/etc/commands.cfg', starting on line 161) 
 Error processing object config files! 


***> One or more problems was encountered while processing the config files... 

 Check your configuration file(s) to ensure that they contain valid 
 directives and data defintions. If you are upgrading from a previous 
 version of Nagios, you should be aware that some variables/definitions 
 may have been removed or modified in this version. Make sure to read 
 the HTML documentation regarding the config files, as well as the 
 'Whats New' section to find out what has changed.

Re: Error in commands.cfg

Posted: Mon Nov 27, 2017 12:32 pm
by kyang
Could your post your whole commands.cfg file?

Code: Select all

/usr/local/nagios/etc/commands.cfg
We can go from there.

Re: Error in commands.cfg

Posted: Mon Nov 27, 2017 4:22 pm
by brobeck

Code: Select all

###############################################################################
#
# Check command configuration file
#
# Created by: Nagios Core Config Manager 2.6.10
# Date:	      2017-11-22 14:41:37
# Version:    Nagios 3.x config file
#
# --- DO NOT EDIT THIS FILE BY HAND --- 
# Nagios CCM will overwrite all manual settings during the next update if you 
# would like to edit files manually, place them in the 'static' directory or 
# import your configs into the CCM by placing them in the 'import' directory.
#
###############################################################################

define command {
       command_name                  		check-host-alive-tftp
       command_line                  		tftp $HOSTNAME$ 69
}

define command {
       command_name                  		check_bpi
       command_line                  		/usr/bin/php $USER1$/check_bpi.php $ARG1$
}

define command {
       command_name                  		check_em01_humidity
       command_line                  		$USER1$/check_em01.pl --type=hum --hum=$ARG1$,$ARG2$ $HOSTADDRESS$
}

define command {
       command_name                  		check_em01_light
       command_line                  		$USER1$/check_em01.pl --type=illum --illum=$ARG1$,$ARG2$ $HOSTADDRESS$
}

define command {
       command_name                  		check_em01_temp
       command_line                  		$USER1$/check_em01.pl --type=temp --temp=$ARG1$,$ARG2$ $HOSTADDRESS$
}

define command {
       command_name                  		check_em08_contacts
       command_line                  		$USER1$/check_em08 $HOSTADDRESS$ C
}

define command {
       command_name                  		check_em08_humidity
       command_line                  		$USER1$/check_em08 $HOSTADDRESS$ H $ARG1$ $ARG2$ $ARG3$
}

define command {
       command_name                  		check_em08_light
       command_line                  		$USER1$/check_em08 $HOSTADDRESS$ I $ARG1$ $ARG2$ $ARG3$
}

define command {
       command_name                  		check_em08_rtd
       command_line                  		$USER1$/check_em08 $HOSTADDRESS$ R $ARG1$ $ARG2$ $ARG3$
}

define command {
       command_name                  		check_em08_temp
       command_line                  		$USER1$/check_em08 $HOSTADDRESS$ T $ARG1$ $ARG2$ $ARG3$
}

define command {
       command_name                  		check_em08_voltage
       command_line                  		$USER1$/check_em08 $HOSTADDRESS$ V $ARG1$ $ARG2$ $ARG3$
}

define command {
       command_name                  		check_email_delivery
       command_line                  		$USER1$/check_email_delivery $ARG1$
}

define command {
       command_name                  		check_esx3_guest
       command_line                  		$USER1$/check_esx3.pl -H "$HOSTADDRESS$" -f "$ARG1$" -N "$ARG2$" -l "$ARG3$" $ARG4$
}

define command {
       command_name                  		check_esx3_host
       command_line                  		$USER1$/check_esx3.pl -H "$HOSTADDRESS$" -f "$ARG1$" -l "$ARG2$" $ARG3$
}

define command {
       command_name                  		check_exchange_rbl
       command_line                  		$USER1$/check_bl -H $HOSTADDRESS$ $ARG1$
}

define command {
       command_name                  		check_file_service
       command_line                  		$USER1$/folder_watch.pl $ARG1$ $ARG2$ -f
}

define command {
       command_name                  		check_file_size_age
       command_line                  		$USER1$/folder_watch.pl $ARG1$ $ARG2$ -f
}

define command {
       command_name                  		check_ftp_fully
       command_line                  		$USER1$/check_ftp_fully "$ARG1$" "$ARG2$" "$ARG3$" $HOSTNAME$
}

define command {
       command_name                  		check_mailserver_rbl
       command_line                  		$USER1$/check_bl -H $HOSTADDRESS$ $ARG1$
}

define command {
       command_name                  		check_mongodb_database
       command_line                  		$USER1$/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -u $ARG5$ -p $ARG6$ -d $ARG7$ -D
}

define command {
       command_name                  		check_mongodb_server
       command_line                  		$USER1$/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -u $ARG5$ -p $ARG6$ -D --all-databases
}

define command {
       command_name                  		check_mountpoint
       command_line                  		$USER1$/check_mountpoints.sh $ARG1$
}

define command {
       command_name                  		check_nagiosxi_performance
       command_line                  		/usr/bin/php $USER1$/check_nagios_performance.php $ARG1$ $ARG2$ $ARG3$
}

define command {
       command_name                  		check_radius_server_py
       command_line                  		$USER1$/check_radius.py -H $HOSTADDRESS$ $ARG1$
}

define command {
       command_name                  		check_tftp_connect
       command_line                  		$USER1$/check_tftp.sh --connect $ARG1$
}

define command {
       command_name                  		check_tftp_get
       command_line                  		$USER1$/check_tftp.sh --get $ARG1$ '$ARG2$' $ARG3$
}

define command {
       command_name                  		check_xi_by_ssh
       command_line                  		$USER1$/check_by_ssh -H $HOSTADDRESS$ $ARG1$ $ARG2$
}

define command {
       command_name                  		check_xi_deface
       command_line                  		$USER1$/check_http -H $HOSTADDRESS$ -r '$ARG1$' -u '$ARG2$' $ARG3$
}

define command {
       command_name                  		check_xi_domain_v2
       command_line                  		$USER1$/check_domain.php -d $ARG1$ $ARG2$ $ARG3$
}

define command {
       command_name                  		check_xi_host_ping
}

define command {
       command_name                  		check_xi_mssql_database
       command_line                  		$USER1$/check_mssql_database.py -H $HOSTADDRESS$ $ARG1$
}

define command {
       command_name                  		check_xi_mssql_query
       command_line                  		$USER1$/check_mssql -H $HOSTADDRESS$ $ARG1$
}

define command {
       command_name                  		check_xi_mssql_server
       command_line                  		$USER1$/check_mssql_server.py -H $HOSTADDRESS$ $ARG1$
}

define command {
       command_name                  		check_xi_mysql_health
       command_line                  		$USER1$/check_mysql_health $ARG1$
}

define command {
       command_name                  		check_xi_mysql_query
       command_line                  		$USER1$/check_mysql_health $ARG1$
}

define command {
       command_name                  		check_xi_nagiosxiserver
       command_line                  		/usr/bin/php $USER1$/check_nagiosxiserver.php $ARG1$
}

define command {
       command_name                  		check_xi_ncpa
       command_line                  		$USER1$/check_ncpa.py -H $HOSTADDRESS$ $ARG1$
}

define command {
       command_name                  		check_xi_nna
       command_line                  		$USER1$/check_nna.py -H $HOSTADDRESS$ -K $ARG1$ $ARG2$
}

define command {
       command_name                  		check_xi_oraclequery
       command_line                  		/usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib ORACLE_HOME=/usr/lib/oracle/11.2/client $USER1$/check_oracle_health $ARG1$
}

define command {
       command_name                  		check_xi_oracleserverspace
       command_line                  		/usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib ORACLE_HOME=/usr/lib/oracle/11.2/client $USER1$/check_oracle_health $ARG1$
}

define command {
       command_name                  		check_xi_oracletablespace
       command_line                  		/usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib ORACLE_HOME=/usr/lib/oracle/11.2/client $USER1$/check_oracle_health $ARG1$
}

define command {
       command_name                  		check_xi_postgres
       command_line                  		$USER1$/check_postgres.pl $ARG1$
}

define command {
       command_name                  		check_xi_postgres_db
       command_line                  		$USER1$/check_postgres.pl $ARG1$
}

define command {
       command_name                  		check_xi_postgres_query
       command_line                  		$USER1$/check_postgres.pl $ARG1$
}

define command {
       command_name                  		check_xi_service_dnsquery
       command_line                  		$USER1$/check_dns $ARG1$
}

define command {
       command_name                  		check_xi_service_ftp
}

define command {
       command_name                  		check_xi_service_http
}

define command {
       command_name                  		check_xi_service_ifoperstatus
       command_line                  		$USER1$/check_ifoperstatus -H $HOSTADDRESS$ -C $ARG1$ -k $ARG2$ $ARG3$
}

define command {
       command_name                  		check_xi_service_ifoperstatusnag
       command_line                  		$USER1$/check_ifoperstatnag $ARG1$ $ARG2$ $HOSTADDRESS$
}

define command {
       command_name                  		check_xi_service_ldap
       command_line                  		$USER1$/check_ldap -H $HOSTADDRESS$ $ARG1$
}

define command {
       command_name                  		check_xi_service_nagioslogserver
       command_line                  		$USER1$/check_nagioslogserver.php $ARG1$
}

define command {
       command_name                  		check_xi_service_snmp_linux_load
       command_line                  		$USER1$/check_snmp_load_wizard.pl -H $HOSTADDRESS$ $ARG1$
}

define command {
       command_name                  		check_xi_service_snmp_linux_process
       command_line                  		$USER1$/check_snmp_process_wizard.pl -H $HOSTADDRESS$ $ARG1$
}

define command {
       command_name                  		check_xi_service_snmp_linux_storage
       command_line                  		$USER1$/check_snmp_storage_wizard.pl -H $HOSTADDRESS$ $ARG1$
}

define command {
       command_name                  		check_xi_service_snmp_watchguard
       command_line                  		$USER1$/check_snmp_generic.pl -H $HOSTADDRESS$ $ARG1$
}

define command {
       command_name                  		check_xi_service_snmp_win_load
       command_line                  		$USER1$/check_snmp_load.pl -H $HOSTADDRESS$ $ARG1$
}

define command {
       command_name                  		check_xi_service_snmp_win_process
       command_line                  		$USER1$/check_snmp_process.pl -H $HOSTADDRESS$ $ARG1$
}

define command {
       command_name                  		check_xi_service_snmp_win_service
       command_line                  		$USER1$/check_snmp_win.pl -H $HOSTADDRESS$ $ARG1$
}

define command {
       command_name                  		check_xi_service_snmp_win_storage
       command_line                  		$USER1$/check_snmp_storage.pl -H $HOSTADDRESS$ $ARG1$
}

define command {
       command_name                  		check_xi_service_wmiplus
       command_line                  		$USER1$/check_wmi_plus.pl -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -m $ARG3$ $ARG4$
}

define command {
       command_name                  		check_xi_service_wmiplus_authfile
       command_line                  		$USER1$/check_wmi_plus.pl -H $HOSTADDRESS$ -A $ARG1$ -m $ARG2$ $ARG3$
}

define command {
       command_name                  		check_xi_sla
       command_line                  		$USER1$/check_xisla.php $ARG1$
}

###############################################################################
#
# Check command configuration file
#
# END OF FILE
#
###############################################################################

Re: Error in commands.cfg

Posted: Mon Nov 27, 2017 5:26 pm
by lmiltchev
You can revert to a previous (good) snapshot, created prior to making these changes by going to CCM > Configuration Snapshots, and clicking on the "Restore" button next to the snapshot.

You can also fix the "broken" commands manually, provided you don't have any other config errors. Go to the CCM > Commands > Commands, find the commands in question one-by-one, click on the "Edit" button, and set the command name & command line to look like this:

Code: Select all

check_xi_host_ping 	$USER1$/check_icmp -H $HOSTADDRESS$ -w $ARG1$,$ARG2$ -c $ARG3$,$ARG4$ -p 5
check_xi_service_ftp 	$USER1$/check_ftp -H $HOSTADDRESS$ $ARG1$
check_xi_service_http 	$USER1$/check_http -H $HOSTADDRESS$ $ARG1$
Click on Apply Configuration.

Re: Error in commands.cfg

Posted: Mon Nov 27, 2017 5:36 pm
by brobeck
That cleaned up that mess. Now I get:

Error: There are no services defined!
Error: Contact 'controls' has no service notification commands defined!
Error: Contact 'controls' has no host notification commands defined!
Error: Global host event handler command 'xi_host_event_handler' is not defined anywhere!
Error: Global service event handler command 'xi_service_event_handler' is not defined anywhere!

Is there a way to set all back to default?

Re: Error in commands.cfg

Posted: Mon Nov 27, 2017 6:50 pm
by brobeck
I did get rid of the first 2 issues, now I am working on:

Error: There are no services defined!
Error: Global host event handler command 'xi_host_event_handler' is not defined anywhere!
Error: Global service event handler command 'xi_service_event_handler' is not defined anywhere

Re: Error in commands.cfg

Posted: Tue Nov 28, 2017 11:35 am
by lmiltchev
I was hoping that you had only 3 "broken" commands, but as new errors started to show up, I believe your best bet would be to revert to the last good known snapshot.

Go to Configure > Core Config Manager > Quick Tools > Configuration Snapshots, find the newest "good" snapshot, and click on the "Restore" button next to it.

Example:
example01.PNG
Let us know if this helped.

Re: Error in commands.cfg

Posted: Tue Nov 28, 2017 11:52 am
by brobeck
I can't do that. Because I was doing so many things to try and fix I deleted my snapshots. Will something like this work:
********************************************
rm -f /usr/local/nagios/etc/hosts/*.*
rm -f /usr/local/nagios/etc/services/*.*
cd /usr/local/nagiosxi/scripts/
./reconfigure_nagios.sh
********************************************

Re: Error in commands.cfg

Posted: Tue Nov 28, 2017 12:09 pm
by brobeck
My Global Event handlers are disabled. Did I check a box or something to try and use the event handlers? Where can I deassign the global event handlers and global service event handlers in my config?

Re: Error in commands.cfg

Posted: Tue Nov 28, 2017 2:27 pm
by lmiltchev
Try the following:

1. Open a ssh(putty) session to your Nagios XI server, and create a new directory, called cfgprep:

Code: Select all

cd /usr/local/nagios/etc/
mkdir cfgprep
2. Download the file below, unzip it, and place it in the newly created directory via FileZilla or similar program.
commands.zip
Note: This is a commands.cfg file from a "clean" system.

3. Go to the CCM > Tools > Import Config Files, select the newly copied file (/usr/local/nagios/etc/cfgprep/commands.cfg), and click on "Import". Leave the "Overwrite Database" check-box selected!

4. Go to CCM > Tools > Config File Management, and click on "Write Configs" then "Verify Files".

If you get any config errors, post them on the forum. If there are no errors, apply configuration.