Nagios jest znanym, darmowym systemem monitorowania dostępności hostów, jednakże dzięki aktywnemu zaangażowaniu społeczności w jego rozwój, powstało wiele rozszerzeń, które uzupełniają system Nagios o nową funkcjonalność.
Najnowsza wersja nagiosa oraz pluginów znajduje się tu:
nagios core: https://www.nagios.org/downloads/nagios-core/
nagios plugins: http://nagios-plugins.org/download/
1. Instalacja potrzebnych pakietów
Zaloguj się przez SSH do serwera, a następnie przeloguj sie na root’a.
1
2
|
apt–get update–y
apt–get upgrade–y
|
Teraz instalujemy potrzebne pakiety:
1
|
apt–get install–ywget build–essential unzip open–vm–tools
|
1
|
apt–get install–yapache2 php5–gd libgd2–xpm–dev libapache2–mod–php5
|
2. Sciaganie źródeł nagiosa
1
2
|
cd/tmp
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz
|
3. Konfiguracja
1
2
3
|
useradd nagios
groupadd nagcmd
usermod–a–Gnagcmd nagios
|
rozpakuj archiwum i wejdź do katalogu z nagiosem:
1
2
|
tar–zxf nagios–4.1.1.tar.gz
cd nagios–4.1.1/
|
4. Uruchamianie skryptu instalacyjnego
1
2
3
4
5
6
|
./configure—with–nagios–group=nagios—with–command–group=nagcmd
make all
make install
make install–init
make install–commandmode
make install–config
|
Konfiguracja apacha
1
|
install–c–m644sample–config/httpd.conf.in/etc/apache2/sites–enabled/nagios.conf
|
oraz ustalenie domyślnego hasła dla nagiosadmin
1
|
htpasswd–c/usr/local/nagios/etc/htpasswd.users nagiosadmin
|
5. Kroki poinstalacyjne
Kopiowanie event handlers do katalogu nagiosa
1
|
cp–Rcontrib/eventhandlers//usr/local/nagios/libexec/
|
Sciagnij i rozapkuj pluginy nagiosa do katalogu /tmp:
1
2
3
|
wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
tar–zxf nagios–plugins–2.1.1.tar.gz
cd nagios–plugins–2.1.1
|
i uruchom skrypt instalacyjny:
1
2
3
|
./configure—with–nagios–user=nagios—with–nagios–group=nagios
make
make install
|
Ustaw potrzebne prawa:
1
2
3
|
chown–Rnagios:nagios/usr/local/nagios/etc/nagios.cfg
chown–Rnagios:www–data/usr/local/nagios/var/rw/
chmod+x/etc/init.d/nagios
|
A teraz przetestuj konfiguracje nagiosa:
1
|
/usr/local/nagios/bin/nagios–v/usr/local/nagios/etc/nagios.cfg
|
Jeśli wynik jest jak poniżej – to wygrałeś tą rundę;)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
Nagios Core4.1.1
Copyright(c)2009–present Nagios Core Development Team andCommunity Contributors
Copyright(c)1999–2009Ethan Galstad
Last Modified:08–19–2015
License:GPL
Website:https://www.nagios.org
Reading configuration data...
Read main config file okay...
Read objectconfig files okay...
Running pre–flight check on configuration data...
Checking objects...
Checked8services.
Checked1hosts.
Checked1host groups.
Checked0service groups.
Checked1contacts.
Checked1contact groups.
Checked24commands.
Checked5time periods.
Checked0host escalations.
Checked0service escalations.
Checking forcircular paths...
Checked1hosts
Checked0service dependencies
Checked0host dependencies
Checked5timeperiods
Checking globalevent handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...
Total Warnings:0
Total Errors:0
Things look okay–No serious problems were detected during the pre–flight check
|
If something is wrong, check and correct errors
Teraz włącz moduły apache i dodaj nagiosa do „autostartu”;):
1
2
3
|
a2enmod rewrite
a2enmod cgi
ln–s/etc/init.d/nagios/etc/rcS.d/S99nagios
|
Teraz zmienimy trochę nagios.conf by dostosować go do naszego środowiska.
1
2
3
|
root@nagios–core–test3:/tmp/nagios–plugins–2.1.1# /etc/init.d/nagios start
[fusion_builder_container hundred_percent=„yes”overflow=„visible”][fusion_builder_row][fusion_builder_column type=„1_1”background_position=„left top”background_color=„”border_size=„”border_color=„”border_style=„solid”spacing=„yes”background_image=„”background_repeat=„no-repeat”padding=„”margin_top=„0px”margin_bottom=„0px”class=„”id=„”animation_type=„”animation_speed=„0.3”animation_direction=„left”hide_on_mobile=„no”center_content=„no”min_height=„none”][....]Starting nagios(via systemctl):nagios.serviceFailed tostart nagios.service:Unit nagios.service failed toload:No such file ordirectory.
failed!
|
Zmień w pliku /etc/apache2/sites-enabled/nagios.conf:
row number | Original value | Changed value |
---|---|---|
8 | @cgiurl@ | /nagios/cgi-bin |
8 | „@sbindir@” | „/usr/local/nagios/sbin” |
10 | „@sbindir@” | „/usr/local/nagios/sbin” |
21 | @sysconfdir@/htpasswd.users | /usr/local/nagios/etc/htpasswd.users |
34 | @sysconfdir@/htpasswd.users | /usr/local/nagios/etc/htpasswd.users |
39 | @htmurl@ | /nagios |
39 | „@datadir@” | „/usr/local/nagios/share” |
41 | „@datadir@” | „/usr/local/nagios/share” |
52 | @sysconfdir@/htpasswd.users | /usr/local/nagios/etc/htpasswd.users |
65 | @sysconfdir@/htpasswd.users | /usr/local/nagios/etc/htpasswd.users |
Zrestartuj apache oraz nagiosa.
1
2
|
service apache2 status
service nagios status
|
Wynik powinien być jak poniżej:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
root@nagios–test04:/home/milosz# service apache2 status
●apache2.service–LSB:Apache2 web server
Loaded:loaded(/etc/init.d/apache2)
Active:active(running)since Tue2015–11–2414:27:41CST;1min17sago
Process:527ExecStart=/etc/init.d/apache2 start(code=exited,status=0/SUCCESS)
CGroup:/system.slice/apache2.service
├─801/usr/sbin/apache2–kstart
├─821/usr/sbin/apache2–kstart
├─822/usr/sbin/apache2–kstart
├─823/usr/sbin/apache2–kstart
├─824/usr/sbin/apache2–kstart
└─825/usr/sbin/apache2–kstart
Nov2414:27:41nagios–test04 apache2[527]:Starting web server:apache2.
|
a dla nagiosa:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
root@nagios–test04:/home/milosz# service nagios status
●nagios.service–LSB:Starts andstops the Nagios monitoring server
Loaded:loaded(/etc/init.d/nagios)
Active:active(running)since Tue2015–11–2414:27:34CST;2min21sago
Process:460ExecStart=/etc/init.d/nagios start(code=exited,status=0/SUCCESS)
CGroup:/system.slice/nagios.service
├─497/usr/local/nagios/bin/nagios–d/usr/local/nagios/etc/nagios.cfg
├─499/usr/local/nagios/bin/nagios—worker/usr/local/nagios/var/rw/nagios.qh
├─500/usr/local/nagios/bin/nagios—worker/usr/local/nagios/var/rw/nagios.qh
├─501/usr/local/nagios/bin/nagios—worker/usr/local/nagios/var/rw/nagios.qh
├─502/usr/local/nagios/bin/nagios—worker/usr/local/nagios/var/rw/nagios.qh
└─805/usr/local/nagios/bin/nagios–d/usr/local/nagios/etc/nagios.cfg
Nov2414:27:34nagios–test04 nagios[497]:nerd:Channel servicechecks registered successfully
Nov2414:27:34nagios–test04 nagios[497]:nerd:Channel opathchecks registered successfully
Nov2414:27:34nagios–test04 nagios[497]:nerd:Fully initialized andready torock!
Nov2414:27:34nagios–test04 nagios[497]:wproc:Successfully registered manager as@wproc with query handler
Nov2414:27:34nagios–test04 nagios[497]:wproc:Registry request:name=Core Worker501;pid=501
Nov2414:27:34nagios–test04 nagios[497]:wproc:Registry request:name=Core Worker499;pid=499
Nov2414:27:34nagios–test04 nagios[497]:wproc:Registry request:name=Core Worker502;pid=502
Nov2414:27:34nagios–test04 nagios[497]:wproc:Registry request:name=Core Worker500;pid=500
Nov2414:27:34nagios–test04 nagios[460]:Starting nagios:done.
Nov2414:27:40nagios–test04 nagios[497]:Successfully launched command file worker with pid805
|
No i mamy działającego nagiosa!!!
W następnych odcinkach pokażę co jeszcze warto doinstalować, jakie rozszerzenia oraz triki warto dodać oraz jak podkręcić konfigurację nagiosa by otrzymać najszybszy oraz najbardziej optymalny system do monitoringu.