RHEL/CentOS 8/7 we Fedora 30-da Nagios 4.4.5-i nädip gurmaly


Nagios ajaýyp açyk çeşme gözegçilik guralydyr, maglumat merkeziňizde ýa-da diňe kiçi laboratoriýalaryňyzda bolsun, ähli maşynlaryňyza/torlaryňyza gözegçilik etmek üçin has giňişleýin gözegçilik gurşawyny üpjün edýär.

Nagios bilen uzakdaky ýer eýelerine we hyzmatlaryna bir penjireden uzakdan gözegçilik edip bilersiňiz. Duýduryşlary görkezýär we serwerleriňizde näsazlyklaryň ýüze çykmazyndan ozal ýüze çykmagyna kömek edýän bir näsazlygyň bardygyny görkezýär. Iş wagty we iş ýitgilerini azaltmaga kömek edýär.

Golaýda Nagios iň soňky wersiýalary Nagios Core 4.4.5 we 2019-njy ýylyň 20-nji awgustynda Nagios plugin 2.2.1-iň soňky durnukly çykarylyşyny çykardy.

Bu makala, RHEL 8/7/6, CentOS 8/7/6 we Fedora 26-30 paýlamalarynda iň täze Nagios Core 4.4.5 çeşmesinden (tarboldan) nädip gurmalydygy barada aňsat görkezmeler bermek üçin niýetlenendir.

30 minutyň içinde ýerli enjamyňyza gözegçilik edersiňiz, ösen gurnama prosedurasy ýok, diňe şu günki Linux serwerleriniň köpüsinde 100% işleýän esasy gurnama.

Üns beriň: Bu ýerde gurnama görkezmeleri CentOS 7.5 Linux paýlanyşyna esaslanýar.

Nagios 4.4.5 we Nagios Plugin 2.2.1 gurmak

Bu görkezmeleri dogry ýerine ýetirseňiz, aşakdaky maglumatlar bilen gutarsyňyz.

  1. Nagios we onuň pluginleri/usr/local/nagios katalogynyň aşagynda gurlar.
  2. Nagios ýerli enjamyňyzyň az hyzmatlaryna gözegçilik etmek üçin düzüler (Disk ulanylyşy, CPU ýüklemesi, häzirki ulanyjylar, jemi amallar we ş.m.)
  3. Nagios web interfeýsi http:// localhost/nagios
  4. elýeterli bolar

Çeşme bilen Nagios 4.4.5 gurmazdan ozal Apache, PHP we gcc, glibc, glibc-common we GD kitaphanalary we ösüş kitaphanalary ýaly käbir kitaphanalary gurmalydyrys. Munuň üçin ýum default paket gurnaýjysyny ulanyp bileris.

 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

Useradd buýrugyny we nagcmd topar hasaby ulanyp, täze nagios ulanyjysyny dörediň we parol goýuň.

 useradd nagios
 groupadd nagcmd

Ondan soň, usermod buýrugyny ulanyp, nagcmd toparyna nagios ulanyjysyny we apache ulanyjysyny goşuň.

 usermod -G nagcmd nagios
 usermod -G nagcmd apache

Nagios gurmak we geljekdäki ähli göçürip almak üçin katalog dörediň.

 mkdir /root/nagios
 cd /root/nagios

Indi iň soňky Nagios Core 4.4.5 we Nagios plugin 2.2.1 paketlerini wget buýrugy bilen göçürip alyň.

 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

Göçürilen paketleri tar buýrugy bilen aşakdaky ýaly çykarmaly.

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

Bu tarlary tar buýrugy bilen çykaranyňyzda, şol bukjada iki sany täze bukja peýda bolar.

 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

Indi, ilki bilen “Nagios Core” -ni düzeris we munuň üçin “Nagios” katalogyna girip, konfigurasiýa faýlyny işletmeli we hemme zat gowy bolsa, ahyrynda çykyşy nusga çykyşy hökmünde görkezer. Aşakda görmegiňizi haýyş edýäris.

 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.

Sazlanylandan soň, hemmesini düzmek we gurnamak buýrugy bilen ähli ikilikleri düzmeli we gurmaly, bu enjamyňyza ähli zerur kitaphanalary gurar we hasam dowam edip bileris.

 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

Aşakdaky buýruk Nagios üçin init skriptlerini gurar.

 make install-init

Nagios-yň buýruk setirinden işlemegi üçin buýruk re modeimini gurmaly.

 make install-commandmode

Ondan soň, Nagios faýllaryny guruň, aşakdaky buýrugy işlediň.

 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.

Redaktoryňyzy saýlap, “contacts.cfg” faýly açyň we nagiosadmin kontakt kesgitlemesi bilen baglanyşykly e-poçta salgysyny e-poçta duýduryşlaryny kabul ediň.

# 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 ****
       }

Arka tarapdaky ähli konfigurasiýa bilen tamamlandyk, indi aşakdaky buýruk bilen Nagios For Web Interfeýsini düzeris. Aşakdaky buýruk Nagios üçin web interfeýsini düzer we web administrator ulanyjy\nagiosadmin dörediler.

 make install-webconf

Bu ädimde\nagiosadmin üçin parol dörederis. Bu buýrugy ýerine ýetireniňizden soň, iki gezek parol beriň we ýadyňyzda saklaň, sebäbi bu parol Nagios web interfeýsine gireniňizde ulanylar.

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

Täze sazlamalaryň güýje girmegi üçin Apache-i täzeden açyň.

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

Nagios pluginlerini/root/nagios-a göçürip aldyk, Şol ýere gidiň we aşakda görkezilişi ýaly sazlaň we guruň.

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

Indi hemmämiz Nagios konfigurasiýasy we ony barlamak we wagty bilen ýerine ýetirdik, aşakdaky buýrugy goýmagyňyzy haýyş edýäris. Everythinghli zat oňaýly bolsa, aşakdaky çykyşa meňzeýär.

 /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

Nagios-y täzeden açmak üçin işlemek üçin, chkconfig we systemctl buýrugy bilen nagios we httpd goşmaly.

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

Täze sazlamalaryň güýje girmegi üçin Nagios-ny täzeden açyň.

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

Nagiosyňyz işlemäge taýyn, brauzeriňizde\http:// Serwer-IP-adres/nagios ýa-da\http:// FQDN/nagios bilen açyň we ulanyjy adyny\nagiosadmin we parol

Gutlaýarys! Nagios we onuň pluginlerini üstünlikli gurnadyňyz we düzdüňiz. Gözegçilige ýaňy syýahatyňyzy başladyňyz.

Nagios 3.x-ni Nagios-a 4.4.5-e çykaryň

“Nagios” -yň köne wersiýasyny işleýän bolsaňyz, islän wagtyňyz täzeläp bilersiňiz. Munuň üçin diňe iň soňky tar arhiwini göçürip almaly we aşakda görkezilişi ýaly düzmeli.

 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

Häzirlikçe, indiki makalalarymda Nagios gözegçilik serwerine Linux, Windows, printerler, wyklýuçateller we enjamlary nädip goşmalydygyny görkezerin. Gurmakda haýsydyr bir kynçylyk çekýän bolsaňyz, teswirler arkaly bize ýüz tutmagyňyzy haýyş edýäris. Soňra “Tecmint” -e birikdiriň we ýaýramagyňyzy halamagy we paýlaşmagy ýatdan çykarmaň.

Şeýle hem okaň:

  1. Nagios Monitoring Serwerine Linux Hostyny nädip goşmaly
  2. Nagios Monitoring Serwerine Windows Host-y nädip goşmaly