Page 1 of 2

Nagios does not recognize that it has applied config

Posted: Tue Feb 19, 2019 10:04 am
by redacted
CentOS Linux release 7.6.1810 (Core)
3.10.0-957.1.3.el7.x86_64
Nagios XI 5.5.7
Manual Install

This morning Nagios started behaving strangely. We updated hosts via the API (/nagiosxi/api/v1/config/host) and attempted to apply configuration. Nagios has successfully updated the correct host files, but the CCM still shows that the configuration needs to be applied:

Image

When applying the configuration everything seems to work:

Image

The host files in /usr/local/nagios/etc/hosts were updated correctly.

I did notice a problem when tailing /usr/local/nagiosxi/var/cmdsubsys.log, but I am not sure if this is an existing error:

Code: Select all

> Verifying configuration with Nagios Core
> Output: 
Nagios Core 4.4.2
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2018-08-16
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
	Checked 2959 services.
	Checked 3006 hosts.
	Checked 2172 host groups.
	Checked 4 service groups.
	Checked 38 contacts.
	Checked 40 contact groups.
	Checked 128 commands.
	Checked 42 time periods.
	Checked 0 host escalations.
	Checked 0 service escalations.
Checking for circular paths...
	Checked 3006 hosts
	Checked 0 service dependencies
	Checked 0 host dependencies
	Checked 42 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check
> Return Code: 0
--------------------------------------
.OUTPUT=--------------------------------------
RETURNCODE=0
.
PROCESSED 1 COMMANDS
PROCESSING COMMAND ID 13083...
PROCESS COMMAND: CMD=1150, DATA=remove
CMDLINE=php /usr/local/nagiosxi/html/includes/components/nagiosbpi/api_tool.php --cmd=syncall 
...............................PHP Notice:  Undefined variable: err in /usr/local/nagiosxi/html/includes/components/nagiosbpi/api_tool.php on line 146
CMD: syncall
MSG: Could not get data for objects. NDO or Core may not be running.
OUTPUT=MSG: Could not get data for objects. NDO or Core may not be running.
RETURNCODE=0
The Nagios Core service is running:

Code: Select all

● nagios.service - Nagios Core 4.4.2
   Loaded: loaded (/usr/lib/systemd/system/nagios.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2019-02-19 09:54:28 EST; 4min 15s ago
     Docs: https://www.nagios.org/documentation
  Process: 3631 ExecStopPost=/bin/rm -f /usr/local/nagios/var/rw/nagios.cmd (code=exited, status=0/SUCCESS)
  Process: 3628 ExecStop=/bin/kill -s TERM ${MAINPID} (code=exited, status=0/SUCCESS)
  Process: 3636 ExecStart=/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
  Process: 3634 ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
 Main PID: 3638 (nagios)
   CGroup: /system.slice/nagios.service
           ├─3638 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
           ├─3639 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
           ├─3640 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
           ├─3641 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
           ├─3642 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
           ├─3643 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
           ├─3644 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
           ├─3718 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
           ├─6244 /usr/local/nagios/libexec/check_icmp -H 172.24.80.229 -w 3000.0 80 -c 5000.0 100 -p 5
           ├─6247 /usr/local/nagios/libexec/check_icmp -H 172.31.254.8 -w 3000.0 80 -c 5000.0 100 -p 5
           └─6258 /usr/local/nagios/libexec/check_icmp -H 172.31.250.7 -w 3000.0 80 -c 5000.0 100 -p 5
Also, the ndo2db service is running:

Code: Select all

● ndo2db.service - Nagios Data Out Daemon
   Loaded: loaded (/usr/lib/systemd/system/ndo2db.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2019-02-19 09:01:22 EST; 58min ago
     Docs: http://www.nagios.org/documentation
  Process: 20916 ExecStopPost=/bin/rm -f /usr/local/nagios/var/ndo2db.lock (code=exited, status=0/SUCCESS)
  Process: 20922 ExecStartPre=/bin/rm -f /usr/local/nagios/var/ndo.sock (code=exited, status=0/SUCCESS)
  Process: 20920 ExecStartPre=/bin/rm -f /usr/local/nagios/var/ndo2db.lock (code=exited, status=0/SUCCESS)
 Main PID: 20925 (ndo2db)
   CGroup: /system.slice/ndo2db.service
           ├─ 3650 /usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg -f
           ├─ 3652 /usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg -f
           └─20925 /usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg -f
The system, PHP, and MySQL times seem to be synced (this solution was proposed here https://support.nagios.com/forum/viewto ... 16&t=41725):

Code: Select all

Tue Feb 19 10:00:45 EST 2019
Tue Feb 19 10:00:45 EST 2019
+---------------------+
| NOW()               |
+---------------------+
| 2019-02-19 10:00:45 |
+---------------------+

Re: Nagios does not recognize that it has applied config

Posted: Tue Feb 19, 2019 10:14 am
by redacted
Replacing line 146 of /usr/local/nagiosxi/html/includes/components/nagiosbpi/api_tool.php with 'var_dump($data)' gives:

Code: Select all

array(25) {
  ["instance_id"]=>
  NULL
  ["instance_name"]=>
  string(9) "localhost"
  ["status_update_time"]=>
  NULL
  ["program_start_time"]=>
  NULL
  ["program_run_time"]=>
  NULL
  ["program_end_time"]=>
  NULL
  ["is_currently_running"]=>
  NULL
  ["process_id"]=>
  NULL
  ["daemon_mode"]=>
  NULL
  ["last_command_check"]=>
  NULL
  ["last_log_rotation"]=>
  NULL
  ["notifications_enabled"]=>
  NULL
  ["active_service_checks_enabled"]=>
  NULL
  ["passive_service_checks_enabled"]=>
  NULL
  ["active_host_checks_enabled"]=>
  NULL
  ["passive_host_checks_enabled"]=>
  NULL
  ["event_handlers_enabled"]=>
  NULL
  ["flap_detection_enabled"]=>
  NULL
  ["process_performance_data"]=>
  NULL
  ["obsess_over_hosts"]=>
  NULL
  ["obsess_over_services"]=>
  NULL
  ["modified_host_attributes"]=>
  NULL
  ["modified_service_attributes"]=>
  NULL
  ["global_host_event_handler"]=>
  NULL
  ["global_service_event_handler"]=>
  NULL
}
Querying the nagios_programstatus table gives me:

Code: Select all

MariaDB [nagios]> select count(*) from nagios_programstatus;
+----------+
| count(*) |
+----------+
|        1 |
+----------+
1 row in set (0.00 sec)

MariaDB [nagios]> select * from nagios_programstatus\G
*************************** 1. row ***************************
              programstatus_id: 1054
                   instance_id: 1
            status_update_time: 2018-11-06 10:19:44
            program_start_time: 2018-11-06 08:00:15
              program_end_time: 1970-01-01 00:00:01
          is_currently_running: 1
                    process_id: 17508
                   daemon_mode: 1
            last_command_check: 1970-01-01 00:00:00
             last_log_rotation: 1970-01-01 00:00:00
         notifications_enabled: 1
 active_service_checks_enabled: 1
passive_service_checks_enabled: 1
    active_host_checks_enabled: 1
   passive_host_checks_enabled: 1
        event_handlers_enabled: 1
        flap_detection_enabled: 1
    failure_prediction_enabled: 0
      process_performance_data: 1
             obsess_over_hosts: 0
          obsess_over_services: 0
      modified_host_attributes: 0
   modified_service_attributes: 0
     global_host_event_handler: xi_host_event_handler
  global_service_event_handler: xi_service_event_handler
1 row in set (0.00 sec)

Re: Nagios does not recognize that it has applied config

Posted: Tue Feb 19, 2019 10:55 am
by redacted
Went to Core Config Manager > Tools > Write Config Files and deleted, wrote, verified and restarted.

Image

/usr/local/nagios/etc/hosts is then empty.

Image

/usr/local/nagios/etc/hosts is now populated with the correct number of config files. Config files look OK.

Image

Image

However, Nagios still thinks it needs to apply configuration:

Image

Re: Nagios does not recognize that it has applied config

Posted: Tue Feb 19, 2019 11:24 am
by redacted
Adding

Code: Select all

var_dump($sql)
to /usr/local/nagiosxi/html/includes/utils-xmlstatus.inc.php line 56 shows that the query being run is:

Code: Select all

SELECT nagios_instances.instance_id AS datasource_id, nagios_instances.instance_name,  (TIMESTAMPDIFF(SECOND,nagios_programstatus.program_start_time,NOW())) AS program_run_time, nagios_programstatus.* FROM nagios_instances  LEFT JOIN nagios_programstatus on nagios_instances.instance_id=nagios_programstatus.instance_id WHERE TRUE AND nagios_instances.instance_id = '1' ORDER BY nagios_instances.instance_id DESC LIMIT 100000
Running this query manually produces:

Code: Select all

MariaDB [nagios]> SELECT nagios_instances.instance_id AS datasource_id, nagios_instances.instance_name,  (TIMESTAMPDIFF(SECOND,nagios_programstatus.program_start_time,NOW())) AS program_run_time, nagios_programstatus.* FROM nagios_instances  LEFT JOIN nagios_programstatus on nagios_instances.instance_id=nagios_programstatus.instance_id WHERE TRUE AND nagios_instances.instance_id = '1' ORDER BY nagios_instances.instance_id DESC LIMIT 100000\G
*************************** 1. row ***************************
                 datasource_id: 1
                 instance_name: localhost
              program_run_time: 9083179
              programstatus_id: 1054
                   instance_id: 1
            status_update_time: 2018-11-06 10:19:44
            program_start_time: 2018-11-06 08:00:15
              program_end_time: 1970-01-01 00:00:01
          is_currently_running: 1
                    process_id: 17508
                   daemon_mode: 1
            last_command_check: 1970-01-01 00:00:00
             last_log_rotation: 1970-01-01 00:00:00
         notifications_enabled: 1
 active_service_checks_enabled: 1
passive_service_checks_enabled: 1
    active_host_checks_enabled: 1
   passive_host_checks_enabled: 1
        event_handlers_enabled: 1
        flap_detection_enabled: 1
    failure_prediction_enabled: 0
      process_performance_data: 1
             obsess_over_hosts: 0
          obsess_over_services: 0
      modified_host_attributes: 0
   modified_service_attributes: 0
     global_host_event_handler: xi_host_event_handler
  global_service_event_handler: xi_service_event_handler
1 row in set (0.00 sec)
Dumping the return value of exec_sql_query() results in:

Code: Select all

object(ADORecordSet_mysqli)#9 (29) {
  ["databaseType"]=>
  string(6) "mysqli"
  ["canSeek"]=>
  bool(true)
  ["dataProvider"]=>
  string(6) "native"
  ["fields"]=>
  array(28) {
    ["datasource_id"]=>
    string(1) "1"
    ["instance_name"]=>
    string(9) "localhost"
    ["program_run_time"]=>
    NULL
    ["programstatus_id"]=>
    NULL
    ["instance_id"]=>
    NULL
    ["status_update_time"]=>
    NULL
    ["program_start_time"]=>
    NULL
    ["program_end_time"]=>
    NULL
    ["is_currently_running"]=>
    NULL
    ["process_id"]=>
    NULL
    ["daemon_mode"]=>
    NULL
    ["last_command_check"]=>
    NULL
    ["last_log_rotation"]=>
    NULL
    ["notifications_enabled"]=>
    NULL
    ["active_service_checks_enabled"]=>
    NULL
    ["passive_service_checks_enabled"]=>
    NULL
    ["active_host_checks_enabled"]=>
    NULL
    ["passive_host_checks_enabled"]=>
    NULL
    ["event_handlers_enabled"]=>
    NULL
    ["flap_detection_enabled"]=>
    NULL
    ["failure_prediction_enabled"]=>
    NULL
    ["process_performance_data"]=>
    NULL
    ["obsess_over_hosts"]=>
    NULL
    ["obsess_over_services"]=>
    NULL
    ["modified_host_attributes"]=>
    NULL
    ["modified_service_attributes"]=>
    NULL
    ["global_host_event_handler"]=>
    NULL
    ["global_service_event_handler"]=>
    NULL
  }
  ["blobSize"]=>
  int(100)
  ["sql"]=>
  string(425) "SELECT nagios_instances.instance_id AS datasource_id, nagios_instances.instance_name,  (TIMESTAMPDIFF(SECOND,nagios_programstatus.program_start_time,NOW())) AS program_run_time, nagios_programstatus.* FROM nagios_instances  LEFT JOIN nagios_programstatus on nagios_instances.instance_id=nagios_programstatus.instance_id WHERE TRUE AND nagios_instances.instance_id = '1' ORDER BY nagios_instances.instance_id DESC LIMIT 100000"
  ["EOF"]=>
  bool(false)
  ["emptyTimeStamp"]=>
  string(6) " "
  ["emptyDate"]=>
  string(6) " "
  ["debug"]=>
  bool(false)
  ["timeCreated"]=>
  int(0)
  ["bind"]=>
  bool(false)
  ["fetchMode"]=>
  int(1)
  ["connection"]=>
  object(ADODB_mysqli)#7 (92) {
    ["databaseType"]=>
    string(6) "mysqli"
    ["dataProvider"]=>
    string(5) "mysql"
    ["hasInsertID"]=>
    bool(true)
    ["hasAffectedRows"]=>
    bool(true)
    ["metaTablesSQL"]=>
    string(131) "SELECT
			TABLE_NAME,
			CASE WHEN TABLE_TYPE = 'VIEW' THEN 'V' ELSE 'T' END
		FROM INFORMATION_SCHEMA.TABLES
		WHERE TABLE_SCHEMA="
    ["metaColumnsSQL"]=>
    string(22) "SHOW COLUMNS FROM `%s`"
    ["fmtTimeStamp"]=>
    string(13) "'Y-m-d H:i:s'"
    ["hasLimit"]=>
    bool(true)
    ["hasMoveFirst"]=>
    bool(true)
    ["hasGenID"]=>
    bool(true)
    ["isoDates"]=>
    bool(true)
    ["sysDate"]=>
    string(9) "CURDATE()"
    ["sysTimeStamp"]=>
    string(5) "NOW()"
    ["hasTransactions"]=>
    bool(true)
    ["forceNewConnect"]=>
    bool(false)
    ["poorAffectedRows"]=>
    bool(true)
    ["clientFlags"]=>
    int(0)
    ["substr"]=>
    string(9) "substring"
    ["port"]=>
    int(3306)
    ["socket"]=>
    string(0) ""
    ["_bindInputArray"]=>
    bool(false)
    ["nameQuote"]=>
    string(1) "`"
    ["optionFlags"]=>
    array(1) {
      [0]=>
      array(2) {
        [0]=>
        int(5)
        [1]=>
        int(0)
      }
    }
    ["arrayClass"]=>
    string(25) "ADORecordSet_array_mysqli"
    ["multiQuery"]=>
    bool(false)
    ["_genIDSQL"]=>
    string(38) "update %s set id=LAST_INSERT_ID(id+1);"
    ["_genSeqSQL"]=>
    string(47) "create table if not exists %s (id int not null)"
    ["_genSeqCountSQL"]=>
    string(23) "select count(*) from %s"
    ["_genSeq2SQL"]=>
    string(26) "insert into %s values (%s)"
    ["_dropSeqSQL"]=>
    string(23) "drop table if exists %s"
    ["database"]=>
    string(6) "nagios"
    ["host"]=>
    string(58) "nmsproddb.cluster-ckuy5haxorqq.us-east-2.rds.amazonaws.com"
    ["user"]=>
    string(6) "nagios"
    ["password"]=>
    string(10) "not stored"
    ["debug"]=>
    bool(false)
    ["maxblobsize"]=>
    int(262144)
    ["concat_operator"]=>
    string(1) "+"
    ["length"]=>
    string(6) "length"
    ["random"]=>
    string(6) "rand()"
    ["upperCase"]=>
    string(5) "upper"
    ["fmtDate"]=>
    string(7) "'Y-m-d'"
    ["true"]=>
    string(1) "1"
    ["false"]=>
    string(1) "0"
    ["replaceQuote"]=>
    string(2) "\'"
    ["charSet"]=>
    string(6) "latin1"
    ["metaDatabasesSQL"]=>
    string(0) ""
    ["uniqueOrderBy"]=>
    bool(false)
    ["emptyDate"]=>
    string(6) " "
    ["emptyTimeStamp"]=>
    string(6) " "
    ["lastInsID"]=>
    bool(false)
    ["hasTop"]=>
    bool(false)
    ["readOnly"]=>
    bool(false)
    ["genID"]=>
    int(0)
    ["raiseErrorFn"]=>
    bool(false)
    ["cacheSecs"]=>
    int(3600)
    ["memCache"]=>
    bool(false)
    ["memCacheHost"]=>
    NULL
    ["memCachePort"]=>
    int(11211)
    ["memCacheCompress"]=>
    bool(false)
    ["sysUTimeStamp"]=>
    bool(false)
    ["noNullStrings"]=>
    bool(false)
    ["numCacheHits"]=>
    int(0)
    ["numCacheMisses"]=>
    int(0)
    ["pageExecuteCountRows"]=>
    bool(true)
    ["uniqueSort"]=>
    bool(false)
    ["leftOuter"]=>
    bool(false)
    ["rightOuter"]=>
    bool(false)
    ["ansiOuter"]=>
    bool(false)
    ["autoRollback"]=>
    bool(true)
    ["fnExecute"]=>
    bool(false)
    ["fnCacheExecute"]=>
    bool(false)
    ["blobEncodeType"]=>
    bool(false)
    ["rsPrefix"]=>
    string(13) "ADORecordSet_"
    ["autoCommit"]=>
    bool(true)
    ["transOff"]=>
    int(0)
    ["transCnt"]=>
    int(0)
    ["fetchMode"]=>
    int(2)
    ["null2null"]=>
    string(4) "null"
    ["bulkBind"]=>
    bool(false)
    ["_oldRaiseFn"]=>
    bool(false)
    ["_transOK"]=>
    NULL
    ["_connectionID"]=>
    object(mysqli)#3 (19) {
      ["affected_rows"]=>
      int(1)
      ["client_info"]=>
      string(14) "5.5.60-MariaDB"
      ["client_version"]=>
      int(50560)
      ["connect_errno"]=>
      int(0)
      ["connect_error"]=>
      NULL
      ["errno"]=>
      int(0)
      ["error"]=>
      string(0) ""
      ["error_list"]=>
      array(0) {
      }
      ["field_count"]=>
      int(28)
      ["host_info"]=>
      string(69) "nmsproddb.cluster-ckuy5haxorqq.us-east-2.rds.amazonaws.com via TCP/IP"
      ["info"]=>
      NULL
      ["insert_id"]=>
      int(0)
      ["server_info"]=>
      string(6) "5.6.10"
      ["server_version"]=>
      int(50610)
      ["stat"]=>
      string(146) "Uptime: 8511  Threads: 75  Questions: 4603873  Slow queries: 723  Opens: 3739  Flush tables: 1  Open tables: 2028  Queries per second avg: 540.932"
      ["sqlstate"]=>
      string(5) "00000"
      ["protocol_version"]=>
      int(10)
      ["thread_id"]=>
      int(30869)
      ["warning_count"]=>
      int(0)
    }
    ["_errorMsg"]=>
    bool(false)
    ["_errorCode"]=>
    bool(false)
    ["_queryID"]=>
    object(mysqli_result)#6 (5) {
      ["current_field"]=>
      int(0)
      ["field_count"]=>
      int(28)
      ["lengths"]=>
      array(28) {
        [0]=>
        int(1)
        [1]=>
        int(9)
        [2]=>
        int(0)
        [3]=>
        int(0)
        [4]=>
        int(0)
        [5]=>
        int(0)
        [6]=>
        int(0)
        [7]=>
        int(0)
        [8]=>
        int(0)
        [9]=>
        int(0)
        [10]=>
        int(0)
        [11]=>
        int(0)
        [12]=>
        int(0)
        [13]=>
        int(0)
        [14]=>
        int(0)
        [15]=>
        int(0)
        [16]=>
        int(0)
        [17]=>
        int(0)
        [18]=>
        int(0)
        [19]=>
        int(0)
        [20]=>
        int(0)
        [21]=>
        int(0)
        [22]=>
        int(0)
        [23]=>
        int(0)
        [24]=>
        int(0)
        [25]=>
        int(0)
        [26]=>
        int(0)
        [27]=>
        int(0)
      }
      ["num_rows"]=>
      int(1)
      ["type"]=>
      int(0)
    }
    ["_isPersistentConnection"]=>
    bool(true)
    ["_evalAll"]=>
    bool(false)
    ["_affected"]=>
    bool(false)
    ["_logsql"]=>
    bool(false)
    ["_transmode"]=>
    string(0) ""
    ["connectionParameters":protected]=>
    array(0) {
    }
    ["databaseName"]=>
    string(6) "nagios"
  }
  ["_numOfRows"]=>
  int(1)
  ["_numOfFields"]=>
  int(28)
  ["_queryID"]=>
  object(mysqli_result)#6 (5) {
    ["current_field"]=>
    int(0)
    ["field_count"]=>
    int(28)
    ["lengths"]=>
    array(28) {
      [0]=>
      int(1)
      [1]=>
      int(9)
      [2]=>
      int(0)
      [3]=>
      int(0)
      [4]=>
      int(0)
      [5]=>
      int(0)
      [6]=>
      int(0)
      [7]=>
      int(0)
      [8]=>
      int(0)
      [9]=>
      int(0)
      [10]=>
      int(0)
      [11]=>
      int(0)
      [12]=>
      int(0)
      [13]=>
      int(0)
      [14]=>
      int(0)
      [15]=>
      int(0)
      [16]=>
      int(0)
      [17]=>
      int(0)
      [18]=>
      int(0)
      [19]=>
      int(0)
      [20]=>
      int(0)
      [21]=>
      int(0)
      [22]=>
      int(0)
      [23]=>
      int(0)
      [24]=>
      int(0)
      [25]=>
      int(0)
      [26]=>
      int(0)
      [27]=>
      int(0)
    }
    ["num_rows"]=>
    int(1)
    ["type"]=>
    int(0)
  }
  ["_currentRow"]=>
  int(0)
  ["_closed"]=>
  bool(false)
  ["_inited"]=>
  bool(true)
  ["_obj"]=>
  NULL
  ["_names"]=>
  NULL
  ["_currentPage"]=>
  int(-1)
  ["_atFirstPage"]=>
  bool(false)
  ["_atLastPage"]=>
  bool(false)
  ["_lastPageNo"]=>
  int(-1)
  ["_maxRecordCount"]=>
  int(0)
  ["datetime"]=>
  bool(false)
  ["adodbFetchMode"]=>
  int(2)
}

Running /usr/local/nagiosxi/html/includes/components/nagioscpi/api_tool.php php --cmd=syncall --no-delete and dumping the return value of get_program_status_xml_output() (line 134) gives:

Code: Select all

[nagios@prod nagiosbpi]$ php ./api_tool.php --cmd=syncall --no-delete
array(25) {
  ["instance_id"]=>
  string(1) "1"
  ["instance_name"]=>
  string(9) "localhost"
  ["status_update_time"]=>
  string(19) "2019-02-19 16:18:56"
  ["program_start_time"]=>
  string(19) "2019-02-19 16:17:34"
  ["program_run_time"]=>
  string(3) "161"
  ["program_end_time"]=>
  string(19) "1970-01-01 00:00:01"
  ["is_currently_running"]=>
  string(1) "1"
  ["process_id"]=>
  string(5) "29606"
  ["daemon_mode"]=>
  string(1) "1"
  ["last_command_check"]=>
  string(19) "1970-01-01 00:00:00"
  ["last_log_rotation"]=>
  string(19) "1970-01-01 00:00:00"
  ["notifications_enabled"]=>
  string(1) "1"
  ["active_service_checks_enabled"]=>
  string(1) "1"
  ["passive_service_checks_enabled"]=>
  string(1) "1"
  ["active_host_checks_enabled"]=>
  string(1) "1"
  ["passive_host_checks_enabled"]=>
  string(1) "1"
  ["event_handlers_enabled"]=>
  string(1) "1"
  ["flap_detection_enabled"]=>
  string(1) "1"
  ["process_performance_data"]=>
  string(1) "1"
  ["obsess_over_hosts"]=>
  string(1) "0"
  ["obsess_over_services"]=>
  string(1) "0"
  ["modified_host_attributes"]=>
  string(1) "0"
  ["modified_service_attributes"]=>
  string(1) "0"
  ["global_host_event_handler"]=>
  string(21) "xi_host_event_handler"
  ["global_service_event_handler"]=>
  string(24) "xi_service_event_handler"
}
However, leaving the var_dump in and running the command via CCM causes this to show up in /usr/local/nagiosxi/var/cmdsubsys.log:

Code: Select all

PROCESS COMMAND: CMD=1150, DATA=remove
CMDLINE=php /usr/local/nagiosxi/html/includes/components/nagiosbpi/api_tool.php --cmd=syncall 
array(25) {
  ["instance_id"]=>
  NULL
  ["instance_name"]=>
  string(9) "localhost"
  ["status_update_time"]=>
  NULL
  ["program_start_time"]=>
  NULL
  ["program_run_time"]=>
  NULL
  ["program_end_time"]=>
  NULL
  ["is_currently_running"]=>
  NULL
  ["process_id"]=>
  NULL
  ["daemon_mode"]=>
  NULL
  ["last_command_check"]=>
  NULL
  ["last_log_rotation"]=>
  NULL
  ["notifications_enabled"]=>
  NULL
  ["active_service_checks_enabled"]=>
  NULL
  ["passive_service_checks_enabled"]=>
  NULL
  ["active_host_checks_enabled"]=>
  NULL
  ["passive_host_checks_enabled"]=>
  NULL
  ["event_handlers_enabled"]=>
  NULL
  ["flap_detection_enabled"]=>
  NULL
  ["process_performance_data"]=>
  NULL
  ["obsess_over_hosts"]=>
  NULL
  ["obsess_over_services"]=>
  NULL
  ["modified_host_attributes"]=>
  NULL
  ["modified_service_attributes"]=>
  NULL
  ["global_host_event_handler"]=>
  NULL
  ["global_service_event_handler"]=>
  NULL
}
array(25) {
  ["instance_id"]=>
  NULL
  ["instance_name"]=>
  string(9) "localhost"
  ["status_update_time"]=>
  NULL
  ["program_start_time"]=>
  NULL
  ["program_run_time"]=>
  NULL
  ["program_end_time"]=>
  NULL
  ["is_currently_running"]=>
  NULL
  ["process_id"]=>
  NULL
  ["daemon_mode"]=>
  NULL
  ["last_command_check"]=>
  NULL
  ["last_log_rotation"]=>
  NULL
  ["notifications_enabled"]=>
  NULL
  ["active_service_checks_enabled"]=>
  NULL
  ["passive_service_checks_enabled"]=>
  NULL
  ["active_host_checks_enabled"]=>
  NULL
  ["passive_host_checks_enabled"]=>
  NULL
  ["event_handlers_enabled"]=>
  NULL
  ["flap_detection_enabled"]=>
  NULL
  ["process_performance_data"]=>
  NULL
  ["obsess_over_hosts"]=>
  NULL
  ["obsess_over_services"]=>
  NULL
  ["modified_host_attributes"]=>
  NULL
  ["modified_service_attributes"]=>
  NULL
  ["global_host_event_handler"]=>
  NULL
  ["global_service_event_handler"]=>
  NULL
}

Re: Nagios does not recognize that it has applied config

Posted: Tue Feb 19, 2019 1:47 pm
by redacted
Alright, well I think we have figured this out. We had contracted a company to create a custom theme for us, and it seems like something they did hid the error messages on the apply configuration screen. The error was that we created hosts that belongs to non-existent groups, which created the groups. The groups are not active by default however, and when attempting to apply configuration, Nagios did not like the fact that some hosts belonged to groups that had not previously been activated via apply configuration.

The solution was to remove hosts from groups and then apply configuration for the newly created host groups. Then add the hosts back to the groups.


Even after fixing the grouping errors and applying config Nagios still shows the hosts as 'not applied'. However, there is no longer an error message above the host list:

Image

Re: Nagios does not recognize that it has applied config

Posted: Tue Feb 19, 2019 2:36 pm
by benjaminsmith
Hi @redacted,
The solution was to remove hosts from groups and then apply configuration for the newly created host groups. Then add the hosts back to the groups.
Thanks for the update. Glad to know you got this worked out. Let us know if you need anything else or if it's ok to close this thread.

Re: Nagios does not recognize that it has applied config

Posted: Tue Feb 19, 2019 3:01 pm
by redacted
benjaminsmith wrote:Hi @redacted,
The solution was to remove hosts from groups and then apply configuration for the newly created host groups. Then add the hosts back to the groups.
Thanks for the update. Glad to know you got this worked out. Let us know if you need anything else or if it's ok to close this thread.
Hey Ben, thanks for posting. See my edited comment above. Everything works fine with monitoring etc., so we are not panicked about anything. But, the hosts still show up as 'not applied', which is really bugging us. Let me know if you have any ideas.

:D

Re: Nagios does not recognize that it has applied config

Posted: Tue Feb 19, 2019 3:21 pm
by benjaminsmith
Hi @redacted,

I'd like to review your system and profile and also tail the log file while running apply configuration.

1. Run the following from command line, apply configuration, and then post the output.

Code: Select all

tail -f /usr/local/nagiosxi/var/cmdsubsys.log
2. Send over your system profile in a private message.

To Send Over a System ProfileTo send us your system profile
Login to the Nagios XI GUI using a web browser.
Click the "Admin" > "System Profile" Menu
Click the "Download Profile" button

Thank you.

Re: Nagios does not recognize that it has applied config

Posted: Wed Feb 20, 2019 9:32 am
by redacted

Code: Select all

......................................PROCESSING COMMAND ID 13191...
PROCESS COMMAND: CMD=17, DATA=
APPLYING NAGIOSCORE CONFIG...
CMDLINE=cd /usr/local/nagiosxi/scripts && ./reconfigure_nagios.sh
.No entry for terminal type "unknown";
using dumb terminal settings.

--- reset_config_perms.sh ------------
> Setting CCM script permissions
> Setting script permissions
> Setting special component script permissions
> Setting configuration file/directory permissions
> Setting perfdata directory and RRD permissions
> Setting NOM checkpoint user:group permissions
> + Setting Nagios Core corelog.newobjects user:group permissions
> + Setting CCM configuration file user:group permissions
> + Setting Recurring Downtime file user:group permissions
> + Setting BPI configuration file user:group permissions
--------------------------------------

--- ccm_import.php -------------------
> Setting import directory: /usr/local/nagios/etc/import/
> Importing config files into the CCM
  No files to import
--------------------------------------

--- ccm_export.php -------------------
> Writing CCM configuration to Nagios files
.......
PROCESSED 0 COMMANDS
..  Finished writing out configuraton
--------------------------------------
......
--------------------------------------
> Verifying configuration with Nagios Core
> Output: 
Nagios Core 4.4.3
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2019-01-15
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
	Checked 3007 services.
	Checked 3050 hosts.
	Checked 2213 host groups.
	Checked 4 service groups.
	Checked 38 contacts.
	Checked 40 contact groups.
	Checked 128 commands.
	Checked 42 time periods.
	Checked 0 host escalations.
	Checked 0 service escalations.
Checking for circular paths...
	Checked 3050 hosts
	Checked 0 service dependencies
	Checked 0 host dependencies
	Checked 42 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check
> Return Code: 0
--------------------------------------
OUTPUT=--------------------------------------
RETURNCODE=0
.
PROCESSED 2 COMMANDS
PROCESSING COMMAND ID 13192...
PROCESS COMMAND: CMD=1150, DATA=remove
CMDLINE=php /usr/local/nagiosxi/html/includes/components/nagiosbpi/api_tool.php --cmd=syncall 
..............................PHP Notice:  Undefined variable: err in /usr/local/nagiosxi/html/includes/components/nagiosbpi/api_tool.php on line 146
CMD: syncall
MSG: Could not get data for objects. NDO or Core may not be running.
OUTPUT=MSG: Could not get data for objects. NDO or Core may not be running.
RETURNCODE=0


Re: Nagios does not recognize that it has applied config

Posted: Wed Feb 20, 2019 2:00 pm
by benjaminsmith
Hello @redacted,

I see you have an offloaded database. If the server /php time settings of this server are not in sync with the Nagios Xi server this can cause a number issues.

1. Please verify that the time, timezone and php time settings are correct. Run the following commands on each server to verify the settings.

Code: Select all

grep "date.timezone" /etc/php.ini
ls -l /etc/localtime
php -r 'echo date("D M j G:i:s T Y")."\n";' 
date 
echo "SELECT NOW();" | mysql -u root -pnagiosxi
2. I don't have the database error log, but you may want run a check command on the database.

Code: Select all

mysqlcheck -r -f -uroot -pnagiosxi --all-databases --use_frm
3. Run the following to clear the message queue and restart the Nagios XI Server.

Code: Select all

systemctl stop crond
systemctl stop npcd
systemctl stop nagios
systemctl stop ndo2db
pkill -9 -u nagios
for i in $(ipcs -q | grep nagios |awk '{print $2}'); do ipcrm -q $i; done
rm -rf /usr/local/nagiosxi/var/dbmaint.lock
rm -rf /usr/local/nagiosxi/var/event_handler.lock
rm -rf /usr/local/nagiosxi/scripts/reconfigure_nagios.lock
systemctl restart mariadb
systemctl start ndo2db
systemctl start nagios
systemctl start npcd
systemctl start crond

Let me know if the issue gets resolved.

References:
Changing The System Time
NDOUtils - Message Queue Exceeded