
Nagios - Assistant in monitoring services and hosts
There are various free systems for monitoring the status of systems and networks such as: Munin , Zabbix , etc. I want to share with the IT community an example of configuring the Nagios monitoring system on the Arch Linux operating system.
The following Nagios installation example was done on the Arch linux x64 distribution, but this material can also be used for the Arch i686.
1. Make sure your system is up to date!
2. Install LAMP.
To install LAMP, you can use the user manual in Russian .
3. Presets.
To successfully build packages, you need the installed ones: freetype2, gd, glib2, libtool.
4. Installing Nagios.
On the computer with ArchLinux installed, create the ~ / build directory and go to it, here we will collect our packages.
Nagios can be found in the AUR repository. Therefore, we do the following:
- Go to the search page for the AUR repository http://aur.archlinux.org/
- In the search bar (Search Critetia), enter nagios and press [GO]
- Select the nagios package and load it into the ~ / build directory :
-Unpack:
-Go to the unpacked directory and upload the necessary files to it (which are on the nagios download page): -Now you need to generate the package, for this we will execute the command: (it can be a fight if you are from under the root, then if you are sure reliability packages use makepkg --asroot - it's not safe!).
When the package is assembled, run the command:
this will install the package into the system.
We will perform similar operations (starting from searching the AUR repository) with the nagios-plugin package:
cd ~ / build
wget -c downloads.sourceforge.net/nagiosplug/nagios-plugins-1.4.14.tar.gz
tar -xvzf nagios-plugins- 1.4.14.tar.gz cd nagios-plugins
wget -c aur.archlinux.org/packages/nagios-plugins/nagios-plugins/PKGBUILD
makepkg
pacman -U nagios-plugins-1.4.14-1-x86_64.pkg.tar .gz
5. Configuring Nagios
Copy the configuration files with examples to the “combat” location : Set permissions to access the / etc / nagios directory: Create a file that will be used for web authorization of the nagios panel:
(despite the correct path in the nagios.conf file of the httpd configuration, authorization did not work when using the htpasswd.users file, so I made htpasswd -c / etc / nagios / users nagiosadmin and corrected the corresponding line in / etc / httpd / conf / extra /nagios.conf)
Let's set the permissions on the directory with the nagios files:
This is the configuration of Nagios finished, now you need to configure Apache.
6. Configure Apache.
Edit the file /etc/httpd/conf/httpd.conf , add the line:
and execute:
7. PHP configuration.
Connect in the file /etc/php/php.ini Nagios, open_basedir, for this in the line open_basedir we will add: / usr / share / nagios:
All settings are complete, now you need to restart httpd and nagios: Now, following the localhost / nagios link (or the IP address of the server on which everything was configured instead of localhost), you will see an authorization window in which you must enter the nagiosadmin username and password that you assigned to it. Configuring control over services and hosts. Add UNIX hosts. in the directory / etc / nagios / create the servers directory in which all configuration files will be stored: After that, be sure to uncomment the line cfg_dir = / etc / nagios / servers in the file /etc/nagios/nagios.cfg Create in the directory / etc / nagios / servers file
unix-servers.cfg responsible for the unix host group of the following contents: hostgroup_name - describe the host group alias - display the group in the dashboard members - hosts within the group (written as a comma) Now create the host configuration files srv_www - this is the server on which the website is running (nagios including) and a proxy server on port 3128: Add Windows hosts. To monitor windows hosts, use the NSClient program . Install it with the default settings on the windows host and configure it for nagios. Windows host group, /etc/nagios/servers/windows-servers.cfg: and /etc/nagios/servers/win-srv_host06.cfg:
icon_image and statusmap_image can be found at exchange.nagios.org/directory/Images-and-Logos/ placed in the directory / usr / share / nagios / share / images / logos /
After writing the host configuration files, restart nagios:
/ etc / rc .d / nagios restart
Now we monitor the status of servers and services on these nodes. It all looks like this: I am not a master at writing such articles, but I will be sincerely glad if she helps someone or maybe someone wants to supplement it, because it is very brief and fluent on setting up a monster called Nagios. The article was written by my good friend! All laurels actually to him)




Unfortunately, I don’t have enough karma for an invite, so I ask you, dear hawkers, to treat my friend with an invitational - yarofrost@gmail.com
The following Nagios installation example was done on the Arch linux x64 distribution, but this material can also be used for the Arch i686.
1. Make sure your system is up to date!
pacman -Syu
2. Install LAMP.
To install LAMP, you can use the user manual in Russian .
3. Presets.
To successfully build packages, you need the installed ones: freetype2, gd, glib2, libtool.
pacman -S freetype2 gd glib2 libtool
4. Installing Nagios.
On the computer with ArchLinux installed, create the ~ / build directory and go to it, here we will collect our packages.
mkdir ~/build cd ~/build
Nagios can be found in the AUR repository. Therefore, we do the following:
- Go to the search page for the AUR repository http://aur.archlinux.org/
- In the search bar (Search Critetia), enter nagios and press [GO]
- Select the nagios package and load it into the ~ / build directory :
wget -c downloads.sourceforge.net/nagios/nagios-3.2.0.tar.gz
-Unpack:
tar -xvzf nagios-3.2.0.tar.gz
-Go to the unpacked directory and upload the necessary files to it (which are on the nagios download page): -Now you need to generate the package, for this we will execute the command: (it can be a fight if you are from under the root, then if you are sure reliability packages use makepkg --asroot - it's not safe!).
cd ~/build/nagios
wget -c aur.archlinux.org/packages/nagios/nagios/PKGBUILD
wget -c aur.archlinux.org/packages/nagios/nagios/nagios.install
wget -c aur.archlinux.org/packages/nagios/nagios/rc.nagios
makepkg
When the package is assembled, run the command:
pacman -U "имя собранного пакета"
this will install the package into the system.
We will perform similar operations (starting from searching the AUR repository) with the nagios-plugin package:
cd ~ / build
wget -c downloads.sourceforge.net/nagiosplug/nagios-plugins-1.4.14.tar.gz
tar -xvzf nagios-plugins- 1.4.14.tar.gz cd nagios-plugins
wget -c aur.archlinux.org/packages/nagios-plugins/nagios-plugins/PKGBUILD
makepkg
pacman -U nagios-plugins-1.4.14-1-x86_64.pkg.tar .gz
5. Configuring Nagios
Copy the configuration files with examples to the “combat” location : Set permissions to access the / etc / nagios directory: Create a file that will be used for web authorization of the nagios panel:
# cp /etc/nagios/cgi.cfg.sample /etc/nagios/cgi.cfg
# cp /etc/nagios/resource.cfg.sample /etc/nagios/resource.cfg
# cp /etc/nagios/nagios.cfg.sample /etc/nagios/nagios.cfg
# cp /etc/nagios/objects/commands.cfg.sample /etc/nagios/objects/commands.cfg
# cp /etc/nagios/objects/contacts.cfg.sample /etc/nagios/objects/contacts.cfg
# cp /etc/nagios/objects/localhost.cfg.sample /etc/nagios/objects/localhost.cfg
# cp /etc/nagios/objects/templates.cfg.sample /etc/nagios/objects/templates.cfg
# cp /etc/nagios/objects/timeperiods.cfg.sample /etc/nagios/objects/timeperiods.cfg
chown -R nagios:nagios /etc/nagios
# htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
(despite the correct path in the nagios.conf file of the httpd configuration, authorization did not work when using the htpasswd.users file, so I made htpasswd -c / etc / nagios / users nagiosadmin and corrected the corresponding line in / etc / httpd / conf / extra /nagios.conf)
Let's set the permissions on the directory with the nagios files:
# chown -R nagios:nagios /usr/share/nagios
This is the configuration of Nagios finished, now you need to configure Apache.
6. Configure Apache.
Edit the file /etc/httpd/conf/httpd.conf , add the line:
Include /etc/httpd/conf/extra/nagios.conf
and execute:
# usermod -G nagios -a http
7. PHP configuration.
Connect in the file /etc/php/php.ini Nagios, open_basedir, for this in the line open_basedir we will add: / usr / share / nagios:
open_basedir = /srv/http/:/usr/share/nagios
All settings are complete, now you need to restart httpd and nagios: Now, following the localhost / nagios link (or the IP address of the server on which everything was configured instead of localhost), you will see an authorization window in which you must enter the nagiosadmin username and password that you assigned to it. Configuring control over services and hosts. Add UNIX hosts. in the directory / etc / nagios / create the servers directory in which all configuration files will be stored: After that, be sure to uncomment the line cfg_dir = / etc / nagios / servers in the file /etc/nagios/nagios.cfg Create in the directory / etc / nagios / servers file
/etc/rc.d/nagios restart
/etc/rc.d/httpd restart
mkdir /etc/nagios/servers
unix-servers.cfg responsible for the unix host group of the following contents: hostgroup_name - describe the host group alias - display the group in the dashboard members - hosts within the group (written as a comma) Now create the host configuration files srv_www - this is the server on which the website is running (nagios including) and a proxy server on port 3128: Add Windows hosts. To monitor windows hosts, use the NSClient program . Install it with the default settings on the windows host and configure it for nagios. Windows host group, /etc/nagios/servers/windows-servers.cfg: and /etc/nagios/servers/win-srv_host06.cfg:
define hostgroup{
hostgroup_name unix ;
alias UNIX Servers ;
members srv_www, srv_mail;
}
# HOST
define host{
use linux-server
host_name srv_www ; имя сервера
icon_image linux.png
statusmap_image linux.gd2
address 10.1.1.7 ; Ip адрес сервера
}
# SERVICE
# проверяем доступность сервера
define service{
use local-service
host_name srv_www
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
# Проверяем доступность ssh
define service{
use local-service
host_name srv_www
service_description SSH
check_command check_ssh
}
# Проверяем доступность tcp соединения на 3128 порту
define service{
use local-service
host_name srv_www
service_description tcp
check_command check_tcp!3128
}
# Проверяем доступность http (по умолчанию 80 порт)
define service{
use local-service
host_name srv_www ;
service_description HTTP
check_command check_http
}
define hostgroup{
hostgroup_name windows ;
alias Windows Servers ;
members srv_host06;
}
# HOST
define host{
use win-servers
host_name srv_host06
icon_image windows_server.png
statusmap_image windows_server.gd2
address 10.1.1.212
}
######
# SERVICE
define service{
use local-service
host_name srv_host06 ;
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
#Загрузку процессора (при 80% - warning, при 90% critical)
define service{
use generic-service
host_name srv_host06 ;
service_description CPU Load
check_command check_nt!CPULOAD!-l 1,80,90
}
# Мониторим свободное место на диске
define service{
use generic-service
host_name srv_host06 ;
service_description DISK space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
icon_image and statusmap_image can be found at exchange.nagios.org/directory/Images-and-Logos/ placed in the directory / usr / share / nagios / share / images / logos /
After writing the host configuration files, restart nagios:
/ etc / rc .d / nagios restart
Now we monitor the status of servers and services on these nodes. It all looks like this: I am not a master at writing such articles, but I will be sincerely glad if she helps someone or maybe someone wants to supplement it, because it is very brief and fluent on setting up a monster called Nagios. The article was written by my good friend! All laurels actually to him)




Unfortunately, I don’t have enough karma for an invite, so I ask you, dear hawkers, to treat my friend with an invitational - yarofrost@gmail.com