Page 1 of 2

Error: Could not read host and service status information!

Posted: Thu Jan 03, 2019 1:54 pm
by brt24574
You've seen this one a million times. I am sorry to bother you with it again.

Version 4.3.4
Installed by yum (epel) via Puppet

At this time, I have only gotten as far as installing your software, with the default cfg files and monitoring the localhost

nagios -v /etc/nagios/nagios.cfg

Code: Select all

[root@sls-hwn nagios]# nagios -v nagios.cfg

Nagios Core 4.3.4
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2017-08-24
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 8 services.
        Checked 1 hosts.
        Checked 1 host groups.
        Checked 0 service groups.
        Checked 1 contacts.
        Checked 1 contact groups.
        Checked 24 commands.
        Checked 5 time periods.
        Checked 0 host escalations.
        Checked 0 service escalations.
Checking for circular paths...
        Checked 1 hosts
        Checked 0 service dependencies
        Checked 0 host dependencies
        Checked 5 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
Taking a look at the Nagios Log file, the only thing that stood out was the connection refused by the localhost. I have resolved this by adding a bit of code to my apache vhost to Allow from 127.0.0.1

Code: Select all

[root@sls-hwn brt24574]# tail -f /var/log/nagios/nagios.log
[1546534210] wproc: Registry request: name=Core Worker 32242;pid=32242
[1546534210] wproc: Registry request: name=Core Worker 32239;pid=32239
[1546534210] wproc: Registry request: name=Core Worker 32240;pid=32240
[1546534210] Successfully launched command file worker with pid 32244
[1546534416] SERVICE ALERT: localhost;HTTP;CRITICAL;SOFT;1;connect to address 127.0.0.1 and port 80: Connection refused
[1546534476] SERVICE ALERT: localhost;HTTP;CRITICAL;SOFT;2;connect to address 127.0.0.1 and port 80: Connection refused
[1546534536] SERVICE ALERT: localhost;HTTP;CRITICAL;SOFT;3;connect to address 127.0.0.1 and port 80: Connection refused
[1546534596] SERVICE ALERT: localhost;HTTP;CRITICAL;HARD;4;connect to address 127.0.0.1 and port 80: Connection refused
[1546537810] Auto-save of retention data completed successfully.
[1546537896] SERVICE ALERT: localhost;HTTP;OK;HARD;4;HTTP OK: HTTP/1.1 200 OK - 1275 bytes in 0.003 second response time
cgi.cfg knows where the main config file is located.
main_config_file=/etc/nagios/nagios.cfg

I have looked at every post on this forum, plus others online related to this problem.

It looks like a permission error, so I temporarily changed permissions to 755 on all .dat files and .cfg files
Also, set the owner and group to nagios


Would you kindly help me troubleshoot this issue?

Thank you!

Re: Error: Could not read host and service status informatio

Posted: Thu Jan 03, 2019 2:51 pm
by scottwilkerson
In your nagios.cfg are these 2 directives pointing to the correct files and have appropriate rights?

Code: Select all

state_retention_file=/usr/local/nagios/var/retention.dat
status_file=/usr/local/nagios/var/status.dat
Is selinux enabled on the system

Code: Select all

getenforce
What error are you seeing in the httpd error_log?

Re: Error: Could not read host and service status informatio

Posted: Thu Jan 03, 2019 3:02 pm
by brt24574
nagios.cfg has valid paths. files are being appended. as I said before, I opened up permissions on the .dat & .cfg files to eliminate that as the cause.

getenforce

Code: Select all

[root@sls-hwn nagios]# getenforce
Disabled
Here is what my httpd error_log shows

Code: Select all

[root@sls-hwn nagios]# tail -f /etc/httpd/logs/error_log
[Thu Jan 03 10:49:53.492015 2019] [mpm_prefork:notice] [pid 31543] AH00170: caught SIGWINCH, shutting down gracefully
[Thu Jan 03 11:49:52.862040 2019] [suexec:notice] [pid 33242] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Thu Jan 03 11:49:52.888574 2019] [auth_digest:notice] [pid 33242] AH01757: generating secret for digest authentication ...
[Thu Jan 03 11:49:52.918460 2019] [mpm_prefork:notice] [pid 33242] AH00163: Apache/2.4.6 () PHP/5.4.16 configured -- resuming normal operations
[Thu Jan 03 11:49:52.918511 2019] [core:notice] [pid 33242] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Thu Jan 03 13:01:21.972767 2019] [mpm_prefork:notice] [pid 33242] AH00170: caught SIGWINCH, shutting down gracefully
[Thu Jan 03 13:01:23.060251 2019] [suexec:notice] [pid 34671] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Thu Jan 03 13:01:23.086523 2019] [auth_digest:notice] [pid 34671] AH01757: generating secret for digest authentication ...
[Thu Jan 03 13:01:23.116019 2019] [mpm_prefork:notice] [pid 34671] AH00163: Apache/2.4.6 () PHP/5.4.16 configured -- resuming normal operations
[Thu Jan 03 13:01:23.116071 2019] [core:notice] [pid 34671] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

THANK YOU

Re: Error: Could not read host and service status informatio

Posted: Thu Jan 03, 2019 3:03 pm
by brt24574
Also to note.. the homepage of Nagios Core shows it is unable to get process status.

Unable to get process status

Re: Error: Could not read host and service status informatio

Posted: Thu Jan 03, 2019 3:19 pm
by scottwilkerson
Can you show the output of the following

Code: Select all

cat /etc/nagios/nagios.cfg  | grep -v '^#' | grep -v '^$'
grep nag /etc/group

Re: Error: Could not read host and service status informatio

Posted: Thu Jan 03, 2019 3:24 pm
by brt24574
cat /etc/nagios/nagios.cfg | grep -v '^#' | grep -v '^$'
log_file=/var/log/nagios/nagios.log
cfg_file=/etc/nagios/objects/commands.cfg
cfg_file=/etc/nagios/objects/contacts.cfg
cfg_file=/etc/nagios/objects/timeperiods.cfg
cfg_file=/etc/nagios/objects/templates.cfg
cfg_file=/etc/nagios/objects/localhost.cfg
cfg_dir=/etc/nagios/conf.d
object_cache_file=/var/spool/nagios/objects.cache
precached_object_file=/var/spool/nagios/objects.precache
resource_file=/etc/nagios/private/resource.cfg
status_file=/var/log/nagios/status.dat
status_update_interval=10
nagios_user=nagios
nagios_group=nagios
check_external_commands=1
command_file=/var/spool/nagios/cmd/nagios.cmd
lock_file=/var/run/nagios/nagios.pid
temp_file=/var/spool/nagios/nagios.tmp
temp_path=/tmp
event_broker_options=-1
log_rotation_method=d
log_archive_path=/var/log/nagios/archives
use_syslog=1
log_notifications=1
log_service_retries=1
log_host_retries=1
log_event_handlers=1
log_initial_states=0
log_current_states=1
log_external_commands=1
log_passive_checks=1
service_inter_check_delay_method=s
max_service_check_spread=30
service_interleave_factor=s
host_inter_check_delay_method=s
max_host_check_spread=30
max_concurrent_checks=0
check_result_reaper_frequency=10
max_check_result_reaper_time=30
check_result_path=/var/spool/nagios/checkresults
max_check_result_file_age=3600
cached_host_check_horizon=15
cached_service_check_horizon=15
enable_predictive_host_dependency_checks=1
enable_predictive_service_dependency_checks=1
soft_state_dependencies=0
auto_reschedule_checks=0
auto_rescheduling_interval=30
auto_rescheduling_window=180
service_check_timeout=60
host_check_timeout=30
event_handler_timeout=30
notification_timeout=30
ocsp_timeout=5
perfdata_timeout=5
retain_state_information=1
state_retention_file=/var/log/nagios/retention.dat
retention_update_interval=60
use_retained_program_state=1
use_retained_scheduling_info=1
retained_host_attribute_mask=0
retained_service_attribute_mask=0
retained_process_host_attribute_mask=0
retained_process_service_attribute_mask=0
retained_contact_host_attribute_mask=0
retained_contact_service_attribute_mask=0
interval_length=60
check_for_updates=1
bare_update_check=0
use_aggressive_host_checking=0
execute_service_checks=1
accept_passive_service_checks=1
execute_host_checks=1
accept_passive_host_checks=1
enable_notifications=1
enable_event_handlers=1
process_performance_data=0
obsess_over_services=0
obsess_over_hosts=0
translate_passive_host_checks=0
passive_host_checks_are_soft=0
check_for_orphaned_services=1
check_for_orphaned_hosts=1
check_service_freshness=1
service_freshness_check_interval=60
service_check_timeout_state=c
check_host_freshness=0
host_freshness_check_interval=60
additional_freshness_latency=15
enable_flap_detection=1
low_service_flap_threshold=5.0
high_service_flap_threshold=20.0
low_host_flap_threshold=5.0
high_host_flap_threshold=20.0
date_format=us
illegal_object_name_chars=`~!$%^&*|'"<>?,()=
illegal_macro_output_chars=`~$&|'"<>
use_regexp_matching=0
use_true_regexp_matching=0
admin_email=nagios@localhost
admin_pager=pagenagios@localhost
daemon_dumps_core=0
use_large_installation_tweaks=0
enable_environment_macros=0
debug_level=0
debug_verbosity=1
debug_file=/var/log/nagios/nagios.debug
max_debug_file_size=1000000
allow_empty_hostgroup_assignment=0
grep nag /etc/group
nagios:x:994:nrpe

Re: Error: Could not read host and service status informatio

Posted: Thu Jan 03, 2019 3:52 pm
by scottwilkerson
You need to add your apache user to the nagios group.

this will vary by OS, but something like this

Code: Select all

sudo useradd -g nagios apache
Also, can we verify these permissions

Code: Select all

ls -l /var/run/nagios/nagios.pid
ls -l /var/log/nagios/status.dat
ls -ld /var/log/nagios
ls -ld /var/log
ls -ld /var

Re: Error: Could not read host and service status informatio

Posted: Thu Jan 03, 2019 4:04 pm
by brt24574

Code: Select all

# usermod -G nagios apache
# ls -l /var/run/nagios/nagios.pid
-rw-r--r-- 1 nagios nagios 6 Jan  3 14:43 /var/run/nagios/nagios.pid
# ls -l /var/log/nagios/status.dat
-rw-rw-r-- 1 nagios nagios 13528 Jan  3 14:57 /var/log/nagios/status.dat
# ls -ld /var/log/nagios/
drwxr-x--- 3 nagios nagios 4096 Jan  3 14:57 /var/log/nagios/
# ls -ld /var/log/
drwxr-xr-x. 13 root root 4096 Jan  3 09:08 /var/log/
# ls -ld /var
drwxr-xr-x. 20 root root 4096 Jan  3 08:35 /var
grep nag /etc/group
nagios:x:994:nrpe,apache

Re: Error: Could not read host and service status informatio

Posted: Thu Jan 03, 2019 4:07 pm
by scottwilkerson
somehow nagios isn't part of the nagios group either

Code: Select all

sudo useradd -g nagios nagios
that said, did adding the apache user resolve the issue?

Re: Error: Could not read host and service status informatio

Posted: Thu Jan 03, 2019 4:26 pm
by brt24574
That did resolve this issue, there seems to be (maybe) lingering effect of this.

The home page now shows the PID info. Going to any page no longer shows the WHOA! Error message.

I now see this after clicking on the left menu, Hosts | Services

It appears as though you do not have permission to view information for any of the hosts you requested...
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI
and check the authorization options in your CGI configuration file.