How-To: Nagios 3 installation on Debian

Nagios is a great monitoring software. This is how I get it working on debian lenny.

Install packages:

apt-get install nagios3

You'll be asked some questions about samba client, just select defaults.

This will also install apache web server by default. If you want something lighter (e.g. for VPS use), follow this instructions, else skip to next section.


Remove apache:

apt-get remove apache2-mpm-worker
apt-get autoremove

Install lighttpd:

apt-get install lighttpd

Update /etc/lighttpd/lighttpd.conf:

server.modules = (

alias.url  += ("/cgi-bin/nagios3" => "/usr/lib/cgi-bin/nagios3")
alias.url  += ("/nagios3/stylesheets" => "/etc/nagios3/stylesheets")
alias.url  += ("/nagios3" => "/usr/share/nagios3/htdocs")

$HTTP["url"] =~ "^/cgi-bin/nagios3" {
  cgi.assign = ( "" => "" )

$HTTP["url"] =~ "nagios3" {
  auth.backend = "htpasswd"
  auth.backend.htpasswd.userfile = "/etc/nagios3/htpasswd.users"
  auth.require = ( "" => (
    "method" => "basic",
    "realm" => "Nagios",
    "require" => "user=nagiosadmin"
  setenv.add-environment = ( "REMOTE_USER" => "user" )

Restart lighttpd:

/etc/init.d/lighttpd restart

Basic Configuration

Create admin user:

htpasswd -c /etc/nagios3/htpasswd.users nagiosadmin

Now you should be able to log-in to admin interface via http://host_address/nagios3/

By default, two example hosts will be created during installation: localhost and gateway.

Their config files are located in /etc/nagios3/conf.d/localhost_nagios2.cfg and /etc/nagios3/conf.d/host-gateway_nagios3.cfg

For example, to change SSH port to 2222 for localhost, add this to /etc/nagios3/conf.d/localhost_nagios2.cfg:

define service {
 host_name                       localhost
 service_description             SSH
 check_command                   check_ssh_port!2222
 use                             generic-service

To change port for whole host group, edit /etc/nagios3/conf.d/services_nagios2.cfg.

SSH command is defined in /etc/nagios-plugins/config/ssh.cfg.

You probably want to receive mails on different address than default (root@localhost).  Edit file /etc/nagios3/conf.d/contacts_nagios2.cfg:

define contact{
  email                           myname@somedomain.tld

External commands

Checking for external commands (e.g.  re-scheduling the next check from admin interface) is disabled by default. Follow this steps to enable it:

Edit /etc/nagios3/nagios.cfg and update lines:


Change permissions:

dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw
dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3

And restart nagios deamon:

/etc/init.d/nagios3 restart

Useful tools / links