How to install Nagios3 on a Debian Lenny Server

This tutorial will show you how to install Nagios3 on a Debian Lenny Server a.k.a Nagios on Debian Lenny Walkthrough


* a physical or virtual server
* The first Debian Installation cd –
* Basic Linux & Nagios Knowledge
* One to two hours of time
* Copy & Paste Skills ūüôā

====== Debian Lenny Installation ======
* Get the first cd Image from [[]]
* Boot the cd
* Choose “Install”
* Choose your Language (english)
* Choose Country
* Choose Keymap
* Choose Hostname
* Choose Domain Name
* Choose “use entire Disk” (if you are not familiar with linux partitioning) (you need ~ 8 GB of space)
* The last Nagios Server that i have installed look like this

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             327M  129M  182M  42% /
tmpfs                 494M     0  494M   0% /lib/init/rw
udev                   10M   96K   10M   1% /dev
tmpfs                 494M     0  494M   0% /dev/shm
/dev/sda6             2.1G  1.5G  539M  74% /home
/dev/sda8             373M   13M  341M   4% /tmp
/dev/sda5             4.2G  645M  3.4G  16% /usr
/dev/sda9             4.2G  510M  3.5G  13% /var

* Choose Root Password
* Choose Full Name and Username for new user
* Scan another cd / no
* Use a network mirror / no
* Software selection: choose “Webserver and Standard System”
* Install Grup to the master boot record “yes”
* After the installation is finished reboot and login with root credentials

===== Proxy Authentication =====

If you are behind a firewall with Active Directory Proxy Authentication you have to make sure that the Nagios Server knows the credentials for the proxy server.
Create the following file ///etc/apt/apt.conf//

Acquire::http::Proxy “http://windowsdomainname\username:password@proxy-servername:proxyport/”;

===== Debian repositories – Sources.list =====
replace your existing /etc/apt/sources.list with this one
You can replace // with your home country (like // for hungary , // for poland etc.

# deb cdrom:[Debian GNU/Linux 5.0.1 _Lenny_ – Official i386 CD Binary-1 20090413-00:10]/ lenny main
deb lenny main
deb-src lenny main
deb lenny main contrib non-free
deb lenny/updates main
deb-src lenny/updates main

Afterwards Update System with

apt-get update
apt-get upgrade

It is possible that you get a error message after the first apt-get update stating that you have duplicate entries. Simply type in a//pt-get update// and it will work.

===== Optional РVMWare Tools  =====
In case you are using your linux server on a virtual machine running on VMWare ESX you can / should install the vmware tools.
Make sure you are Logged on to the console (don’t use a ssh session – as it will not work)

apt-get install open-vm-tools

see: for details

===== SSH Access, Additional tools & additional packages =====

apt-get install openssh-server
apt-get install build-essential mc vim ntpdate smbfs
apt-get install nagios3
apt-get install libsnmp-perl libsnmp-session-perl

Hey you finally installed Nagios ūüėČ

===== Nagios @ Debian Bugfixes =====

chmod -R g+s /etc/nagios3
dpkg-statoverride –update –add nagios www-data 2710 /var/lib/nagios3/rw
dpkg-statoverride –update –add nagios nagios 751 /var/lib/nagios3

===== Nagios Configuration =====
the the following in ///etc/nagios3/nagios.cfg//

# change 0 to 1

Reload nagios afterwards with

/etc/init.d/nagios3 restart

===== Configure NTP =====

vim /etc/cron.hourly/
ntpdate -t 60 NTPServer; hwclock -u –systohc

set permissions with

chmod +x /etc/cron.hourly/

===== Install Postfix =====

apt-get install postfix

===== Install Nagiosgrapher =====

apt-get install nagiosgrapher

To tell nagios to write service perfdata change line 1 and add line 2 in /etc/nagios3/nagios.cfg

# change from 0 to 1
# add this line

===== Nagios SNMP Plugins =====
Get additional plugins to monitor:

disks, memory, swap, everthing in hrStorage table, interface state and usage, check memory and cpu usage of processes, the number (can be 1) of processes matching a perl regexp, cpu or average load etc.

from here

Copy the plugins to the Nagios Plugin Directory and change the path within the scripts as shown below

# Nagios specific
use lib “/usr/lib/nagios/plugins”;

===== Configure Access to the Nagios Webpage =====

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

Try to connect to Nagios with the following url: http://your-nagios-server/nagios3

===== SNMP configuration for Windows Servers =====
We will use SNMP to monitor most of the services so make sure that SNMP is configured on the servers that you would like to monitor.

A documentation about how to Install and Enable SNMP Service in Windows XP, Vista and 2003 can be found here

====== Adding Hosts & Hostgroups and Services ======
===== Commands.cfg Definition =====

Add the following to your /etc/nagios3/commands.cfg file

define command {
command_name check_snmp_storage
command_line $USER1$/ -H $HOSTADDRESS$ -C $ARG1$ -m $ARG2$ -w 95 -c 97 -f
# comment Community, storage, warn, crit, arguments

define command {
command_name check_snmp_memory
command_line $USER1$/ -H $HOSTADDRESS$ -C $ARG1$ -m Memory -w $ARG2$ -c $ARG3$ -f
# comment Community, storage, warn, crit, arguments

define command {
command_name check_snmp_load
command_line $USER1$/ -H $HOSTADDRESS$ -C $ARG1$ -w $ARG2$ -c $ARG3$
# comment Comunity, process

define command {
command_name check_snmp_process
command_line $USER1$/ -H $HOSTADDRESS$ -C $ARG1$ -n $ARG2$
# comment Comunity, process

# Microsoft SQL Server
# check_mssql command definition
define command{
command_name check_mssql
command_line /usr/lib/nagios/plugins/ $HOSTNAME$ $ARG1$ $ARG2$ $ARG3$

Create a new Service Template <sitename>.cfg in the /etc/nagios3/conf.d directory

Hint: Rename hostgroups_nagios2.cfg to <sitename>.cfg this will make is easier to have everything in one file.

# Service Templates
define service {
name template1 ; The ‘name’ of this service template
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service ‘freshness’
notifications_enabled 1 ; Service notifications are enabled
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
#service_description Check Disk Space
is_volatile 0
check_period 24×7
max_check_attempts 2
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_options w,c,u
notification_interval 960
notification_period 24×7

===== Define Hosts =====

# hosts
define host{
use                generic-host
host_name            clusternode1
alias                Cluster Node 1
check_command            check-host-alive

define host{
use                generic-host
host_name            clusternode2
alias                Cluster Node 2
check_command            check-host-alive

===== Create Hostgroups =====
Based on this Hostgroups we choose which services are being monitored

# nagios doesn’t like monitoring hosts without services, so this is a group for devices that have no other “services” monitorable(like routers w/out snmp for example)

define hostgroup {
hostgroup_name  ping-servers
alias           Pingable servers
members         gateway,router, clusternode1, clusternode2

define hostgroup {
hostgroup_name  windows-servers
alias           Windows Servers
members         clusternode1, clusternode2

===== Service Definitions =====

==== Check Disk Space ====

# Check Disk Space Drive C
define service{
use template1
hostgroup_name windows-servers
check_command check_snmp_storage!snmp-community-name!”^C:”
service_description Check Disk Space C:

# Check Disk Space Drive F
define service{
use template1
host_name SRV0002554
check_command check_snmp_storage!snmp-community-name!”^F:”
service_description Check Disk Space F:

==== Memory usage ====

define service{
use template1
hostgroup_name    windows-servers
check_command check_snmp_memory!snmp-community-name!95!97
service_description Memory usage

==== CPU usage ====

define service{
use template1
hostgroup_name    windows-servers
check_command check_snmp_load!snmp-community-name!90%!95%
service_description CPU usage

==== RDP Port ====

define service{
name rdp_connect
service_description Remote Desktop Connection
use template1
hostgroup_name    windows-servers
check_command check_tcp!3389

==== Citrix ICA ====

define service{
name citrix_ica_listener
service_description Citrix ICA
use template1
hostgroup_name    Terminalserver
check_command check_tcp!1494

==== MS-SQL Servers ====

Nagios should try to logon to the SQL Servers. We need some libaries from the freetds project to make this work.

=== Freetds Installation to monitor MS-SQL ===

Download the freetds Client from the project homepage at

tar -xzf freetds-stable.tgz
cd freetds-0.82
#if not already installed
apt-get install build-essential

export SYBASE=/usr/local/bin
make install

Create the following file

vim /etc/freetds.conf

and list your SQL Servers here

Use the Hostname from the hosts defintion within the brackets.

Make sure that you use the correct TCP/IP Port (see this Microsoft Article for details

; Microsoft SQL Protokoll Version. SQL7 = 7.0, SQL2000 = 8.0
;tds version = 8.0

host =
port = 1433
tds version = 8.0

host =
port = 1469
tds version = 8.0
define service{
name check_mssql
service_description Check logon to SQL Servers
use template1
hostgroup_name database-servers
check_command check_mssql!SQLServerUsername!Password!2000

===== VMWare Virtual Center =====
Important Services on a VMWare Virtual Center

define service {
use template1
name check_process_vpxd.exe
service_description VMWare VirtualCenter Service
host_name  ESX01
check_command check_snmp_process!SNMP-COMMUNITY-NAME!vpxd.exe
define service {
use template1
name check_process_tomcat5.exe
service_description VMWare Infrastructure Web Access
host_name  ESX01
check_command check_snmp_process!SNMP-COMMUNITY-NAME!tomcat5.exe

define service {
use template1
name check_process_lmgrd.exe
service_description VMWare Licence Server
host_name  ESX01
check_command check_snmp_process!SNMP-COMMUNITY-NAME!lmgrd.exe
define service {
use template1
name check_process_sqlservr.exe
service_description MS SQL Service
host_name  ESX01
check_command check_snmp_process!SNMP-COMMUNITY-NAME!sqlservr.exe

====== Nagios configuration check ======
As i am lazy i always create two files in /usr/local/bin


# Check nagios config

/usr/sbin/nagios3 -v /etc/nagios3/nagios.cfg


# Check nagios config
/etc/init.d/nagios3 restart

Don’t forget to make the files executable with

chmod +x /usr/local/bin/
chmod +x /usr/local/bin/

====== Backups ======
Finally – if everything works as expected you should configure a daily backup.

Perform a backup each day at 5:00

vim /etc/cron.d/backup

5 0 * * * root /usr/local/bin/

vim /usr/local/bin/

# Backup Script – Create Tar Files on BACKUPSERVERNAME (Backup Server)
# don’t forget to create the mountmount /mnt/BACKUPSERVERNAME/




tar -czf /mnt/BACKUPSERVERNAME/NAGIOSSERVERNAME/NAGIOSSERVERNAME-plugins.tar.gz /usr/lib/nagios/plugins/*

tar -czf /mnt/BACKUPSERVERNAME/NAGIOSSERVERNAME/nagios-full.tar.gz /* –exclude=/proc –exclude=/sys¬† –exclude=/dev –exclude=/media –exclude=/mnt/BACKUPSERVERNAME


Make the script executable

vim /usr/local/bin/

That’s it.

Happy Monitoring !


4 thoughts on “How to install Nagios3 on a Debian Lenny Server

  1. Hello
    I have to install Nagios in an debian server which already has apache2 (installed from source with default configurations, with support for so modules), perl and request tracker installed. If I use apt-get or aptitude to install Nagios requirements (libphp5 and libgd2-xpm-dev), it installs an older apache version. If I try to install it via dpkg -i, a lot of packages are broken. Im using Debian, but since Ubuntu is Debian based and there is no Debian quickstart guide I am using Ubuntu’s Documentation. This guide says that I should install lib php, but I can not install it via aptitude or apt because it does not detect my apache (source installed) web server. ¬ŅIs there any official documentation on how to install nagios and all its requirements from source code?¬ŅDo I have to use php as nagios interpreter or can I use perl module which is alread installed? Thanks for the help.

  2. hello there, i just found your site listed on google, and i would like to say that you express awesomely good via your web portal. i am very impressed by the method that you express yourself, and the subject is superb. anyways, i would also like to acknowledge whether you would love to exchange links with my web portal? i will be more than happy to reciprocate and drop your link on in the blogroll. waiting for your answer, thanks and enjoy your day!

  3. Thanks for the instructions. I already had a nagios installation running, but run into problem with nagiosgrapher. Turns out that the installation was dead simple, but it took some time before there was anything to graph, and until then I could not see anything working…

  4. Thanks for the excellent instructions. I have had problems installing nagios following other tutorials, but yours was clear and installed correctly the first time. I only have one question; when changing the paths within the scripts for the downloaded plugin, what scripts are you referring to?

    Thanks again!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s