| Dieser Inhalt in deutsch |

Debian - installing Icinga with external sources

Goals

Reflection

I want to use old configuration files again. When installing with files from Debian alone it is very expensive to deposit all devices and settings in the configuration file. I had entered all in the 'localhost.cfg' because I do not get it otherwise. Here I could just copy the old configuration files to the appropriate place.

Additional request

The system should also monitor devices, in this case printers, in a different subnet. To do this I configured thy system to have a second (or thid) ip address on the same physical netwok card. A second network card is not required. Currently, this solution works with Linux Debian Squeeze, Wheezy and Linux Mint Debian (described in a separate manual).

Problems after Installation

After everything was installed, icinga did not start automatically after a reboot. The system reported that the runlevels do not fit. In this case I placed a command in /etc/crontab to restart icinga.

Solution

Icinga is installed as described here: http://www.missioncritical.de/?p=10

I write here down the text of this manual because it worked out of the box. And I don't know how long the manual will be accessible. Commands can be copied an pasted in the putty-terminal.

Used files:

With wget I cold not get the files. So I loaded them down in an other way an used winscp to copy them to the server.

Make und gcc must be installed.

# apt-get install gcc make

installing Icinga

- Start of the manual from: http://www.missioncritical.de/?p=10#comment-16, Formatting will not be considered, comments by me in these brackets [...] -

# Installing packages. For Linux Mint Debian look at the note at the end of this manual.

apt-get install apache2 build-essential libgd2-xpm-dev
apt-get install libjpeg62 libjpeg62-dev libpng12-0 libpng12-dev
apt-get install mysql-server mysql-client libdbi0 libdbi0-dev libdbd-mysql
[System message in the 3rd line]:
Similar to: There is no package for 'libdbi0'. This package replaces it: libdbi-dev

I changed the command. It worked fine.

# apt-get install mysql-server mysql-client libdbi-dev libdbd-mysql

# Adding user

/usr/sbin/useradd -m icinga
passwd icinga
/usr/sbin/groupadd icinga
/usr/sbin/groupadd icinga-cmd
/usr/sbin/usermod -a -G icinga-cmd icinga
/usr/sbin/usermod -a -G icinga-cmd www-data

# Icinga

cd /usr/src
wget http://downloads.sourceforge.net/project/icinga/icinga/1.4.0/icinga-1.4.0.tar.gz
tar xvzf icinga-1.4.0.tar.gz
cd icinga-1.4.0
./configure --with-command-group=icinga-cmd --enable-idoutils
make all
make install
make install-init
make install-config
make install-commandmode
make install-idoutils
make install-api

# Idoutils anpassen [comfiguring idoutils]

cd /usr/local/icinga/etc
mv idomod.cfg-sample idomod.cfg
mv ido2db.cfg-sample ido2db.cfg
nano -w /usr/local/icinga/etc/icinga.cfg

# Broker_module auskommentieren [deaktivating broker module]

# Mysql Datenbank einrichten etc. [configure the database]


mysql -u root -p
CREATE DATABASE icinga;
GRANT USAGE ON *.* TO 'icinga'@'localhost'
IDENTIFIED BY 'icinga'
WITH MAX_QUERIES_PER_HOUR 0
MAX_CONNECTIONS_PER_HOUR 0
MAX_UPDATES_PER_HOUR 0;

GRANT SELECT , INSERT , UPDATE , DELETE
ON icinga.* TO 'icinga'@'localhost';
FLUSH PRIVILEGES ;
quit
cd /usr/src/icinga-1.4.0/module/idoutils/db/mysql/
mysql -u root -p icinga < mysql.sql
nano -w /usr/local/icinga/etc/ido2db.cfg

# Einstellungen prüfen [check what you have done]

# Klassisches Web-Interface erstellen [creating the web interface]

cd /usr/src/icinga-1.4.0
make cgis
make install-cgis
make install-html

# Web Frontend erstellen [creating the web frontend]

apt-get install php5 php5-cli php-pear php5-xmlrpc php5-xsl php5-ldap php5-gd php5-mysql
cd /usr/src
wget http://downloads.sourceforge.net/project/icinga/icinga-web/1.4.0/icinga-web-1.4.0.tar.gz
tar xzvf icinga-web-1.4.0.tar.gz
cd icinga-web-1.4.0
./configure --prefix=/usr/local/icinga-web --with-web-user=www-data --with-web-group=www-data --with-web-path=/icinga-web --with-web-apache-path=/etc/apache2/conf.d --with-db-type=mysql --with-db-host=localhost --with-db-port=3306 --with-db-name=icinga_web --with-db-user=icinga_web --with-db-pass=icinga_web --with-icinga-api=/usr/local/icinga/share/icinga-api
make install
make install-apache-config
/etc/init.d/apache2 restart
make install-done

# make icinga-reset-password

[The installation stopped at 'make db-initialize' .]


make testdeps
make db-initialize
mysql -u root -p br />GRANT USAGE ON icinga_web.* TO 'icinga_web'@'localhost' IDENTIFIED BY 'icinga_web' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, INDEX ON icinga_web.* TO 'icinga_web'@'localhost';
quit
a2enmod rewrite
/etc/init.d/apache2 restart
/etc/init.d/icinga restart
/etc/init.d/ido2db restart

# Klassisches Web-Frontend installieren [installing the classical web front end]

cd /usr/src/icinga-1.4.0
make install-webconf
htpasswd -c /usr/local/icinga/etc/htpasswd.users icingaadmin
/etc/init.d/apache2 restart

# Nagios-Plugins

[I used nagios-plugins-1.4.15.tar.gz.]

cd /usr/src
wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz
tar xzvf nagios-plugins-1.4.15.tar.gz
cd /usr/src/nagios-plugins-1.4.15
./configure --prefix=/usr/local/icinga --with-cgiurl=/icinga/cgi-bin --with-htmurl=/icinga --with-nagios-user=icinga --with-nagios-group=icinga
make
make install

# Automatischer Start [automatic start]
update-rc.d ido2db defaults
# Icinga Konfiguration testen: [testing icingas configuration]
/usr/local/icinga/bin/icinga -v /usr/local/icinga/etc/icinga.cfg
update-rc.d icinga defaults

- End of the manual-

Folders and files

Files are stored in these locations:

/usr/local/icinga/etc/icinga.cfg
/usr/local/icinga/etc/objects

/usr/local/icinga/etc/icinga.cfg

Here is the system told, which other configuration files should be considered.

Abstract start

###############################################################################
#
# ICINGA.CFG - Sample Main Config File for Icinga
#
# Read the documentation for more information on this configuration
# file. I've provided some comments here, but things may not be so
# clear without further explanation.
#
###############################################################################


# LOG FILE
# This is the main log file where service and host events are logged
# for historical purposes. This should be the first option specified
# in the config file!!!

log_file=/usr/local/icinga/var/icinga.log



# OBJECT CONFIGURATION FILE(S)
# These are the object configuration files in which you define hosts,
# host groups, contacts, contact groups, services, etc.
# You can split your object definitions across several config files
# if you wish (as shown below), or keep them all in a single config file.

# You can specify individual object config files as shown below:
cfg_file=/usr/local/icinga/etc/objects/commands.cfg
cfg_file=/usr/local/icinga/etc/objects/contacts.cfg
cfg_file=/usr/local/icinga/etc/objects/timeperiods.cfg
cfg_file=/usr/local/icinga/etc/objects/templates.cfg

# Definitions for monitoring the local (Linux) host
cfg_file=/usr/local/icinga/etc/objects/localhost.cfg

# Definitions for monitoring a Windows machine
cfg_file=/usr/local/icinga/etc/objects/windows.cfg

# Definitions for monitoring a router/switch
cfg_file=/usr/local/icinga/etc/objects/switch.cfg

# Definitions for monitoring a network printer
cfg_file=/usr/local/icinga/etc/objects/printer.cfg

# Definitions for ido2db process checks
#cfg_file=/usr/local/icinga/etc/objects/ido2db_check_proc.cfg

# You can also tell Icinga to process all config files (with a .cfg
# extension) in a particular directory by using the cfg_dir
# directive as shown below:

#cfg_dir=/usr/local/icinga/etc/servers
#cfg_dir=/usr/local/icinga/etc/printers
#cfg_dir=/usr/local/icinga/etc/switches
#cfg_dir=/usr/local/icinga/etc/routers

# Definitions for broker modules like idoutils.cfg
cfg_dir=/usr/local/icinga/etc/modules

Abstract end

Remove the '#' to consider a line.

More configuration in /usr/local/icinga/etc/objects

/usr/local/icinga/etc/objects

Here you finde the given configuration files.

/usr/local/icinga/etc/objects/contacts.cfg

At the designated place the e-mail address is entered, to which the system is to send a message with a problem. The system must be set up so that it sends messages through a mail server.

/usr/local/icinga/etc/objects/localhost.cfg

The file contains the settings for the computer that is installed on the Icinga. After the system contained therein can deposit codes for other Linux computer.

/usr/local/icinga/etc/objects/printer.cfg

Confuration for printers.

Example

###############################################################################
# PRINTER.CFG - SAMPLE CONFIG FILE FOR MONITORING A NETWORK PRINTER
#
# NOTES: This config file assumes that you are using the sample configuration
# files that get installed with the Icinga quickstart guide.
#
###############################################################################


###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################

# Define a host for the printer we'll be monitoring
# Change the host_name, alias, and address to fit your situation

#define host{
# use generic-printer ; Inherit default values from a template
# host_name hplj2605dn ; The name we're giving to this printer
# alias HP LaserJet 2605dn ; A longer name associated with the printer
# address 192.168.1.30 ; IP address of the printer
# hostgroups network-printers ; Host groups this printer is associated with
# }

##### printer start #####
define host{
use generic-printer ; Name of host template to use
host_name prn_printername_01
alias prn_first_printer
address 123.123.123.123
parents 1. switch 130.130.130.130
}

define host{
use generic-printer ; Name of host template to use
host_name prn_printername_01
alias prn_second_printer
address 124.124.124.124
parents 2. switch 131.131.131.131
}

### [...]

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################
##### eigene Definitionen Anfang #####
# simlpe Ping
define service{
use generic-service ; Inherit values from a template
host_name drk_druckername_01, drk_druckername_02 ; The name of the host the service is associated with
service_description PING ; The service description
check_command check_ping!3000.0,80%!5000.0,100%
normal_check_interval 10 ; Check the service every 10 minutes under normal conditions
retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined
}

Abstract end

Entry 'parents'...

...allows it to create a graphical overview how the devices where connected.

If the entry is used, the switch has to be specified, as it is applied in the configuration file for the switches.

/usr/local/icinga/etc/objects/switch.cfg

Configuration for switches

Abstract start

###############################################################################
# SWITCH.CFG - SAMPLE CONFIG FILE FOR MONITORING A SWITCH
#
# NOTES: This config file assumes that you are using the sample configuration
# files that get installed with the Icinga quickstart guide.
#
###############################################################################



###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################

# Define the switch that we'll be monitoring

#define host{
# use generic-switch ; Inherit default values from a template
# host_name linksys-srw224p ; The name we're giving to this switch
# alias Linksys SRW224P Switch ; A longer name associated with the switch
# address 192.168.1.253 ; IP address of the switch
# hostgroups switches ; Host groups this switch is associated with
# }

############################################################
##### ab hier eigene Hostdefinitionen #####
##### switch Anfang #####
define host{
use generic-switch ; Name of host template to use
host_name 1. switch
alias erster switch
address 130.130.130.130
}

define host{
use generic-switch ; Name of host template to use
host_name 2. switch
alias zweiter switch
address 131.131.131.131
}

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

# Create a service to PING to switch

#define service{
# use generic-service ; Inherit values from a template
# host_name linksys-srw224p ; The name of the host the service is associated with
# service_description PING ; The service description
# check_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the service
# normal_check_interval 5 ; Check the service every 5 minutes under normal conditions
# retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined
# }

define service{
use generic-service ; Inherit values from a template
host_name 1. switch, 2. switch
; The name of the host the service is associated with
service_description PING ; The service description
check_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the service
normal_check_interval 5 ; Check the service every 5 minutes under normal conditions
retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined
}


Abstract end

/usr/local/icinga/etc/objects/windows.cfg

Confuration for windows-systems

Abstract start

###############################################################################
# WINDOWS.CFG - SAMPLE CONFIG FILE FOR MONITORING A WINDOWS MACHINE
#
# NOTES: This config file assumes that you are using the sample configuration
# files that get installed with the Icinga quickstart guide.
#
###############################################################################



###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################

# Define a host for the Windows machine we'll be monitoring
# Change the host_name, alias, and address to fit your situation

#define host{
# use windows-server ; Inherit default values from a template
# host_name winserver ; The name we're giving to this host
# alias My Windows Server ; A longer name associated with the host
# address 192.168.1.2 ; IP address of the host
# }

##### eigene Hostdefinitionen Anfang #####

define host{
use windows-server ; Name of host template to use
host_name windows-server_01
alias Domaenencontroller
address 140.140.140.140
parents 1. switch
}

define host{
use windows-server ; Name of host template to use
host_name windows-server_02
alias Domaenencontroller
address 141.141.141.141
parents 2. switch
}

define host{
use windows-server ; Name of host template to use
host_name mailserver_01
alias Mailserver
address 151.151.151.151
parents 2. switch
}
##### [...]
###############################################################################
###############################################################################
#
# HOST GROUP DEFINITIONS
#
###############################################################################
###############################################################################


# Define a hostgroup for Windows machines
# All hosts that use the windows-server template will automatically be a member of this group

define hostgroup{
hostgroup_name windows-server ; The name of the hostgroup
alias Windows Servers ; Long name of the group
members windows-server_01, windows-server_02
}
##### [...]
###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################


# Create a service for monitoring the version of NSCLient++ that is installed
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name windows-server_01, windows-server_02
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}



# Create a service for monitoring the uptime of the server
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name windows-server_01, windows-server_02
service_description Uptime
check_command check_nt!UPTIME
}



# Create a service for monitoring CPU load
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name windows-server_01, windows-server_02
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}



# Create a service for monitoring memory usage
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name windows-server_01, windows-server_02
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}



# Create a service for monitoring C:\ disk usage
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name windows-server_01, windows-server_02
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}


# Create a service for monitoring the W3SVC service
# Change the host_name to match the name of the host you defined above

##### deaktiviert Anfang #####
#define service{
# use generic-service
# host_name windows-server_01, windows-server_02
# service_description W3SVC
# check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
# }
##### deaktiviert Ende #####



# Create a service for monitoring the Explorer.exe process
# Change the host_name to match the name of the host you defined above
##### nur bei Maschinen mit lokal angemeldeten Benutzern anwenden
##### deaktiviert, weil am sehr viele Meldungen anfallen,
##### wenn niemand am System angemeldet ist.
#define service{
# use generic-service
# host_name windows-server_01, windows-server_02
# service_description Explorer
# check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
# }


##### Apache Anfang #####
##### auf den Server ist xampp intalliert
define service{
use generic-service
host_name windows-server_01, windows-server_02
service_description Apache 2.2 HTTP
check_command check_http!SERVICESTATE! -S -C 60
}
##### Apache Ende #####


##### FTP Anfang #####
##### auf den Servern ist FileZilla installiert
define service{
use generic-service ; Inherit default values from a template
host_name windows-server_01, windows-server_02
service_description FTP
check_command check_ftp
}
##### FTP Ende #####

##### Mailserver SMTP Anfang #####
# Die Angaben kann man ermitteln, wenn man einen Mail-Dialog
# mit dem Mailserver beginntm, wie ihn die Clientprogramme führen.
define service{
use generic-service
host_name mailserver01
service_description SMTP
check_command check_smtp!SERVICESTATE! -e "220 mailserver01.domainname.local Service ready by Programmname (0250) ESMTP Server (Softwarename, etc)"
}
##### Mailserver SMTP Ende #####

Abstract end

Define servicegroups

/usr/locla/icinga/etc/icinga.cfg

I have decided to describe the service groups in a separate file. The Ggedanke , service groups have set up in the various files and keep track has put me off. I did not even try. I would rather define all service groups in a file.

Name: servicegroups.cfg.

Location: /usr/local/icinga/etc/objects/servicegroups.cfg

tell icinga to look at this file in /usr/locla/icinga/etc/icinga.cfg.

# Definitions for servicegroups
cfg_file=/usr/local/icinga/etc/objects/servicegroups.cfg
Example service HTTP
define servicegroup{
servicegroup_name http
alias http-server
members computername1,Apache 2.2 HTTP,computername2,Apache 2.2 HTTP
servicegroup_members Apache 2.2 HTTP
}

Shor explanation

servicegroup_name: Name to identify the service

alias: Name to identify the service - may be longer

members: List of computers and services, no free spaces. be carefull. Free spaces in service name must be taken over.

servicegroup_members: Name of the service which is affected.

Source: http://docs.icinga.org/latest/de/objectdefinitions.html#servicegroup

Check configuration / Sow errors

# /etc/init.d/icinga show-errors

Prepare Linux-Computer

# apt-get install nsca

Prepare Windows-Computer

install the appropriate version of a client: http://www.nsclient.org/nscp/

I used NSClient++-0.3.9-Win32.msi

Problem during the installation

On a Windows Server 2003 , the program did not install. After the data were deposited to the location , it folds easily.

As described here it did not work for me: http://www.nsclient.org/nscp/ticket/68

In this case I copied the files on C:\, opened the command-box, switched to C:\ and typed:

NSClient++-0.3.9-Win32.msi /passiv

The program could be installed. the service 'NSClient++ (Win32)' should start automatic but I had to start the service by hand. The NSC.ini has to be edited.

Let changes take effect
# /etc/init.d/icinga restart

Note: Installation with Linux Mint Debian 13, 64 Bit

I used Version 13 with update package.

The guide also fit this system. A file could not be installed. The message has been displayed which packes now canbe used.

Compare as described above

# apt-get install mysql-server mysql-client libdbi0 libdbi0-dev libdbd-mysql libdbi-dev

Message

Note: ' libdbi - dev' ​​is used instead of ' libdbi0 -dev ' is selected. Libdbi0 package is not available, but by another package referenced. This may mean that the package is missing, has it replaced was or is only available from a different source. However the following packages replace it : libdbi -dev

I changed the command to:

# apt-get install mysql-server mysql-client libdbi-dev libdbi0-dev libdbd-mysql