Nagios Core 4.3.4自定义配置生效异常:Web界面未更新
Problem Background
You've completed the following custom configuration steps for Nagios Core 4.3.4:
- Added these lines to
/usr/local/nagios/etc/nagios.cfg:cfg_file=/usr/local/nagios/etc/objects/newhost.cfg cfg_dir=/usr/local/nagios/etc/servers - Created
/usr/local/nagios/etc/servers/ubuntu_host.cfgwith:define host { use linux-server host_name ubuntu_host alias Ubuntu Host address 192.168.1.10 register 1 } - Created
/usr/local/nagios/etc/objects/newhost.cfgwith:# Define a host for the local machine define host{ use linux-server host_name google.com alias google.com address www.google.com } # Define a service to "ping" the local machine define service{ use generic-service host_name google.com service_description PING check_command check_ping!100.0,20%!500.0,60% } define service{ use generic-service host_name google.com service_description HTTP check_command check_http notifications_enabled 0 }
The pre-flight check passed successfully, detecting 3 hosts:
Running pre-flight check on configuration data...
Checking objects...
Checked 7 services.
Checked 3 hosts.
Checked 0 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 3 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
You've restarted nrpe, nagios, and httpd services, but the Nagios Web UI still shows only the original information and hasn't loaded the new configurations.
Troubleshooting Steps
1. Verify Nagios Service Actually Loaded the New Config
Don't rely solely on the restart command's exit code—dig deeper to confirm:
- Check the service status directly:
Look for "active (running)" in the output, and scan recent logs for any startup errors.# For systemd-based systems systemctl status nagios # For SysVinit systems service nagios status - Inspect the Nagios log file (default path:
/usr/local/nagios/var/nagios.log):
Look for entries liketail -20 /usr/local/nagios/var/nagios.logSuccessfully reloaded configuration. If this line is missing, the log will likely detail why the config failed to load.
2. Clear Browser Cache
Browsers often cache old UI content—this is one of the most overlooked fixes:
- Force-refresh the page: Use
Ctrl+F5(Windows/Linux) orCmd+Shift+F5(Mac) - Open the Nagios UI in incognito/private browsing mode to bypass local cache entirely
3. Fix Configuration File Permissions
The Nagios user (typically nagios) needs read access to all your custom config files. Even if the pre-flight check passes, missing permissions will block the service from loading them:
- Check current permissions:
ls -l /usr/local/nagios/etc/servers/ubuntu_host.cfg /usr/local/nagios/etc/objects/newhost.cfg - Correct permissions if needed:
Restart Nagios after making these changes.chown nagios:nagios /usr/local/nagios/etc/servers/*.cfg /usr/local/nagios/etc/objects/newhost.cfg chmod 644 /usr/local/nagios/etc/servers/*.cfg /usr/local/nagios/etc/objects/newhost.cfg
4. Validate Web UI User Permissions
If you're not logged in as the default nagiosadmin, your user might lack access to the new hosts/services:
- Confirm your user's contact group is associated with the new hosts. For example, your
google.comhost inherits settings from thelinux-servertemplate—check that the template'scontact_groupsincludes your user's group. - For
nagiosadmin, verify thecontacts.cfgfile correctly links them to theadmincontact group (which should have full access to all objects).
5. Double-Check Config Inclusion in nagios.cfg
Reconfirm your nagios.cfg settings to ensure files are being included properly:
- Make sure
cfg_file=/usr/local/nagios/etc/objects/newhost.cfgis not commented out (no leading#) - Ensure
cfg_dir=/usr/local/nagios/etc/serverspoints to an existing directory, and all files inside have a.cfgextension (Nagios ignores non-.cfg files in cfg directories)
6. Trigger a Manual Config Reload
Sometimes standard restart commands don't work as expected—try a direct reload:
- Re-run the pre-flight check to confirm config validity:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg - Manually reload or start Nagios:
# Systemd systemctl reload nagios # SysVinit service nagios reload # Or manual start command /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
内容的提问来源于stack exchange,提问作者Frodogus

