Nagios Configuration Notes

As always, these are my personal notes that might help others. Your mileage may vary of course. I’m not a full-time sysadmin and forget this kind of stuff by the time six or twelve months have gone by.

HTTP WARNING: HTTP/1.1 403 Forbidden

By default, Nagios includes monitoring of the machine it’s running on (“localhost”). Right out of the gate I saw a HTTP WARNING: HTTP/1.1 403 Forbidden warning thus:

Nagios default HTTP warning

Nagios is checking the local web server by looking for a root web page. On a fresh install of CentOS, the default web director /var/www/html is empty, and directory listings are forbidden so Apache returns a 403 error.

A simple work-around is to simply:

$ touch /var/www/html/index.html

Little Helps

Tweaking Nagios configuration files seems to be a cycle of

  1. Edit configuration file.
  2. Check validity.
  3. Restart nagios.
  4. Ensure desired results are seen on the web UI.

Editing Configuration Files

First to cut down on typing. I put in my bash profile:

export NAGIOS="/usr/local/nagios"

Philosophically I don’t like to mix default configuration files with my changes. Separating out my changes from the mass of Nagios config files makes it a little easier to find my work six or twelve months after the fact.  In that spirit, instead of putting my changes in the $NAGIOS/etc/objects/ directory, I created a subdirectory under the nagios user account, ~/objects.

Checking Validity

In my bash profile I have:

export PATH="$PATH:$NAGIOS/bin"


alias check='nagios -v $NAGIOS/etc/nagios.cfg'

Thus the process of checking the configuration file is reduced down to

$ check

Restarting Nagios

In my bash profile I have:

alias restart='sudo /etc/init.d/nagios restart'

In the /etc/sudoers file I added the following so that user nagios does not need to enter a password to control the Nagios service.

nagios ALL = NOPASSWD:/etc/init.d/nagios

Thus the process of restarting Nagios is reduced down to

$ restart

These quick little helps seems to make things go pretty quick. I can focus on ensuring the configuration files are correct without having to remember anything other than check and restart.

This entry was posted in SysAdmin. Bookmark the permalink.

One Response to Nagios Configuration Notes

  1. Anthony Lee says:

    I had the error 403 problem and this info fixed this. Thank-you so much.

Leave a Reply