Wéi installéiert Nagios 4.4.5 op RHEL/CentOS 8/7 a Fedora 30


Nagios ass en fantastescht Open Source Iwwerwachungsinstrument, et bitt Iech méi ëmfaassend Iwwerwaachungsëmfeld fir ëmmer en Aa op Är all Maschinnen/Netzwierker ob Dir an Ärem Datenzenter sidd oder just Äre klenge Laboe.

Mat Nagios kënnt Dir Är Fernhosten an hir Servicer op afstand op enger eenzeger Fënster iwwerwaachen. Et weist Warnungen a weist ob eppes an Äre Serveren schief geet, wat eis schlussendlech hëlleft e puer Probleemer z'entdecken ier se optrieden. Et hëlleft eis Ausdauer a Geschäftsverloschter ze reduzéieren.

Viru kuerzem huet Nagios seng lescht Versiounen Nagios Core 4.4.5 verëffentlecht a seng lescht stabil Verëffentlechung vun Nagios Plugins 2.2.1 den 20. August 2019.

Dësen Artikel soll Iech mat einfachen Instruktioune guidéieren wéi Dir déi lescht Nagios Core 4.4.5 aus der Quell (tarball) op RHEL 8/7/6, CentOS 8/7/6 a Fedora 26-30 Verdeelungen installéiere wëllt.

Bannent 30 Minutten iwwerwaacht Dir Är lokal Maschinn, keng fortgeschratt Installatiounsprozedur nëmmen Basisinstallatioun déi 100% op de meeschte vun haut Linux Server funktionnéiert.

Notéiert w.e.g.: D'Installatiounsinstruktiounen, déi hei gewise goufen, gi geschriwwe baséiert op CentOS 7.5 Linux Verdeelung.

Installéiert Nagios 4.4.5 an Nagios Plugin 2.2.1

Wann Dir dës Instruktioune richteg befollegt, kënnt Dir déi folgend Informatioun ophalen.

  1. Nagios a seng Plugins ginn ënner /usr/local/nagios Verzeichnis installéiert.
  2. Nagios ginn konfiguréiert fir e puer Servicer vun Ärer lokaler Maschinn ze iwwerwaachen (Disknotzung, CPU Luet, Aktuell Benotzer, Total Prozesser, etc.)
  3. Nagios Web Interface wäert verfügbar sinn op http://localhost/nagios

Mir mussen Apache, PHP an e puer Bibliothéike wéi gcc, glibc, glibc-common a GD Bibliothéiken a seng Entwécklungsbibliothéiken installéieren ier Dir Nagios 4.4.5 mat der Quell installéiert. A fir dat ze maachen, kënne mir yum Standard Package Installer benotzen.

 yum install -y httpd httpd-tools php gcc glibc glibc-common gd gd-devel make net-snmp

-------------- On Fedora -------------- 
 dnf install -y httpd httpd-tools php gcc glibc glibc-common gd gd-devel make net-snmp

Erstellt en neien Nagios Benotzer mat useradd Kommando an nagcmd Grupp Kont a setzt e Passwuert.

 useradd nagios
 groupadd nagcmd

Als nächst füügt de Nagios Benotzer an den Apache Benotzer an d'nagcmd Grupp mat dem Usermod Kommando.

 usermod -G nagcmd nagios
 usermod -G nagcmd apache

Erstellt e Verzeechnes fir Är Nagios Installatioun an all seng zukünfteg Downloads.

 mkdir /root/nagios
 cd /root/nagios

Luet elo déi lescht Nagios Core 4.4.5 an Nagios Plugins 2.2.1 Packagen mat wget Kommando erof.

 wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz
 wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz

Mir mussen erofgeluede Pakete mat tar Kommando extrahéieren wéi follegt.

 tar -xvf nagios-4.4.5.tar.gz
 tar -xvf nagios-plugins-2.2.1.tar.gz

Wann Dir dës Tarballs mat Tar Kommando extrahéiert, erschéngen zwee nei Ordner an deem Verzeichnis.

 ls -l
total 13520
drwxrwxr-x 18 root root     4096 Aug 20 17:43 nagios-4.4.5
-rw-r--r--  1 root root 11101966 Aug 20 17:48 nagios-4.4.5.tar.gz
drwxr-xr-x 15 root root     4096 Apr 19 12:04 nagios-plugins-2.2.1
-rw-r--r--  1 root root  2728818 Apr 19 12:04 nagios-plugins-2.2.1.tar.gz

Elo, als éischt wäerte mir Nagios Core konfiguréieren a fir dat ze maachen musse mir an den Nagios Verzeechnes goen an d'Konfiguratiounsdatei lafen a wann alles gutt geet, weist et d'Ausgab um Enn als Probeoutput. Weg gesinn ënnert.

 cd nagios-4.4.5/
 ./configure --with-command-group=nagcmd
Creating sample config files in sample-config/ ...


*** Configuration summary for nagios 4.4.5 2019-08-20 ***:

 General Options:
 -------------------------
        Nagios executable:  nagios
        Nagios user/group:  nagios,nagios
       Command user/group:  nagios,nagcmd
             Event Broker:  yes
        Install ${prefix}:  /usr/local/nagios
    Install ${includedir}:  /usr/local/nagios/include/nagios
                Lock file:  /run/nagios.lock
   Check result directory:  /usr/local/nagios/var/spool/checkresults
           Init directory:  /lib/systemd/system
  Apache conf.d directory:  /etc/httpd/conf.d
             Mail program:  /usr/bin/mail
                  Host OS:  linux-gnu
          IOBroker Method:  epoll

 Web Interface Options:
 ------------------------
                 HTML URL:  http://localhost/nagios/
                  CGI URL:  http://localhost/nagios/cgi-bin/
 Traceroute (used by WAP):  /usr/bin/traceroute


Review the options above for accuracy.  If they look okay,
type 'make all' to compile the main program and CGIs.

No der Konfiguratioun musse mir all d'Binaeren kompiléieren an installéieren mat alles maachen an installéieren Kommando, et wäert all déi néideg Bibliothéiken op Ärer Maschinn installéieren a mir kënne weidergoen.

 make all
 make install
*** Compile finished ***

If the main program and CGIs compiled without any errors, you
can continue with testing or installing Nagios as follows (type
'make' without any arguments for a list of all possible options):

  make test
     - This runs the test suite

  make install
     - This installs the main program, CGIs, and HTML files

  make install-init
     - This installs the init script in /lib/systemd/system

  make install-daemoninit
     - This will initialize the init script
       in /lib/systemd/system

  make install-groups-users
     - This adds the users and groups if they do not exist

  make install-commandmode
     - This installs and configures permissions on the
       directory for holding the external command file

  make install-config
     - This installs *SAMPLE* config files in /usr/local/nagios/etc
       You'll have to modify these sample files before you can
       use Nagios.  Read the HTML documentation for more info
       on doing this.  Pay particular attention to the docs on
       object configuration files, as they determine what/how
       things get monitored!

  make install-webconf
     - This installs the Apache config file for the Nagios
       web interface

  make install-exfoliation
     - This installs the Exfoliation theme for the Nagios
       web interface

  make install-classicui
     - This installs the classic theme for the Nagios
       web interface

De folgende Kommando wäert d'Init-Skripte fir Nagios installéieren.

 make install-init

Fir Nagios aus der Kommandozeil ze schaffen, musse mir de Kommando-Modus installéieren.

 make install-commandmode

Als nächst, installéiere Probe Nagios Dateien, fuert w.e.g. folgend Kommando.

 make install-config
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg
/usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios/etc/objects/templates.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/objects/commands.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios/etc/objects/timeperiods.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/objects/localhost.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg

*** Config files installed ***

Remember, these are *SAMPLE* config files.  You'll need to read
the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.

Öffnen d'Datei contacts.cfg mat Ärem Choix vum Editor a setzt d'E-Mailadress, déi mat der Nagiosadmin Kontaktdefinitioun assoziéiert ass, fir E-Mail Alarmer ze kréien.

# vi /usr/local/nagios/etc/objects/contacts.cfg
###############################################################################
###############################################################################
#
# CONTACTS
#
###############################################################################
###############################################################################

# Just one contact defined by default - the Nagios admin (that's you)
# This contact definition inherits a lot of default values from the 'generic-contact'
# template which is defined elsewhere.

define contact{
       contact_name                    nagiosadmin             ; Short name of user
       use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
       alias                           Nagios Admin            ; Full name of user

       email                           [email      ; *** CHANGE THIS TO YOUR EMAIL ADDRESS ****
       }

Mir sinn mat all Konfiguratioun am Backend gemaach, elo wäerte mir Web Interface Fir Nagios mat dem folgenden Kommando konfiguréieren. De Kommando hei drënner wäert Web Interface fir Nagios konfiguréieren an e Web Admin Benotzer gëtt erstallt nagiosadmin.

 make install-webconf

An dësem Schrëtt wäerte mir e Passwuert fir \nagiosadmin erstellen. Nodeems Dir dëse Kommando ausgefouert hutt, gitt w.e.g. zweemol e Passwuert un a behalen et drun, well dëst Passwuert benotzt gëtt wann Dir Iech an der Nagios Web Interface aloggen.

 htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

Restart Apache fir déi nei Astellungen a Kraaft ze maachen.

 service httpd start               [On RHEL/CentOS 6]
 systemctl start httpd.service     [On RHEL/CentOS 7/8 and Fedora]

Mir hunn Nagios Plugins an /root/nagios erofgelueden, Gitt dohinner a konfiguréieren an installéieren wéi hei ënnendrënner.

 cd /root/nagios
 cd nagios-plugins-2.2.1/
 ./configure --with-nagios-user=nagios --with-nagios-group=nagios
 make
 make install

Elo si mir all fäerdeg mat der Nagios Konfiguratioun a seng Zäit et z'iwwerpréiwen an dat ze maachen, gitt w.e.g. folgend Kommando. Wann alles glat geet, gëtt et ähnlech wéi ënnen Ausgang.

 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios Core 4.4.5
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2019-08-20
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
	Checked 8 services.
	Checked 1 hosts.
	Checked 1 host groups.
	Checked 0 service groups.
	Checked 1 contacts.
	Checked 1 contact groups.
	Checked 24 commands.
	Checked 5 time periods.
	Checked 0 host escalations.
	Checked 0 service escalations.
Checking for circular paths...
	Checked 1 hosts
	Checked 0 service dependencies
	Checked 0 host dependencies
	Checked 5 timeperiods
Checking global event 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

Fir Nagios iwwer Neistarten ze maachen, musse mir Nagios an httpd mat chkconfig a systemctl Kommando addéieren.

 chkconfig --add nagios
 chkconfig --level 35 nagios on
 chkconfig --add httpd
 chkconfig --level 35 httpd on
 systemctl enable nagios
 systemctl enable httpd

Restart Nagios fir déi nei Astellungen a Kraaft ze maachen.

 service nagios start              [On RHEL/CentOS 6]
 systemctl start nagios.service    [On RHEL/CentOS 7/8 and Fedora]

Är Nagios ass prett fir ze schaffen, w.e.g. öffnen se an Ärem Browser mat \http://Your-server-IP-address/nagios oder \http://FQDN/nagios a gitt de Benotzernumm \nagiosadmin an Passwuert.

Gratulatioun! Dir hutt Nagios a seng Plugins erfollegräich installéiert a konfiguréiert. Dir hutt just Är Rees an d'Iwwerwaachung ugefaang.

Upgrade Nagios 3.x op Nagios 4.4.5

Wann Dir schonn eng al Versioun vun Nagios leeft, kënnt Dir et zu all Moment upgrade. Fir dat ze maachen, musst Dir just dat lescht Tararchiv eroflueden an et konfiguréieren wéi hei ënnendrënner.

 service nagios stop
 wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz
 tar -zxvf nagios-4.4.5.tar.gz
 cd nagios-4.4.5
 ./configure
 make all
 make install
 service nagios start

Dat ass et fir de Moment, a menge kommend Artikelen, wäert ech Iech weisen wéi Dir Linux, Windows, Drécker, Schalter an Apparater op den Nagios Iwwerwaachungsserver addéiere kënnt. Wann Dir Probleemer hutt beim Installéieren, kontaktéiert eis w.e.g. iwwer Kommentarer. Bis dann bleift ofgeschloss a verbonne mat Tecmint a vergiesst net eis ze liken an deelen fir ronderëm ze verbreeden.

Liest och:

  1. Wéi Dir Linux Host op den Nagios Monitoring Server addéiere kënnt
  2. Wéi füügt Windows Host op Nagios Iwwerwaachungsserver