Unsaon Pag-instalar sa Nagios 4.4.5 sa RHEL/CentOS 8/7 ug Fedora 30


Ang Nagios usa ka katingad-an nga tool sa pagmonitor sa Open Source, naghatag kini kanimo nga labi ka komprehensibo nga palibot sa pagmonitor aron kanunay nga mabantayan ang imong tanan nga mga makina/network naa ka sa imong data center o sa imong gagmay nga mga lab.

Uban sa Nagios, mahimo nimong bantayan ang imong hilit nga mga host ug ang ilang mga serbisyo sa layo sa usa ka bintana. Nagpakita kini og mga pasidaan ug nagpakita kung adunay sayup sa imong mga server nga sa katapusan makatabang kanamo nga makit-an ang pipila ka mga problema sa wala pa kini mahitabo. Nakatabang kini kanamo nga makunhuran ang downtime ug pagkawala sa negosyo.

Bag-ohay lang, gipagawas sa Nagios ang pinakabag-o nga bersyon niini Nagios Core 4.4.5 ug ang pinakabag-o nga stable nga pagpagawas sa Nagios plugins 2.2.1 kaniadtong Agosto 20, 2019.

Kini nga artikulo gituyo sa paggiya kanimo sa sayon nga mga instruksyon kon unsaon pag-instalar sa pinakabag-o nga Nagios Core 4.4.5 gikan sa tinubdan (tarball) sa RHEL 8/7/6, CentOS 8/7/6 ug Fedora 26-30 distribusyon.

Sulod sa 30 ka minuto imong bantayan ang imong lokal nga makina, wala’y advanced nga pamaagi sa pag-install lamang ang sukaranan nga pag-install nga molihok 100% sa kadaghanan sa mga server sa Linux karon.

Palihug Hinumdomi: Ang mga panudlo sa pag-install nga gipakita dinhi gisulat base sa pag-apod-apod sa CentOS 7.5 Linux.

Pag-instalar sa Nagios 4.4.5 ug Nagios Plugin 2.2.1

Kung gisunod nimo kini nga mga panudlo sa husto, maabut nimo ang mosunod nga kasayuran.

  1. Ang Nagios ug ang mga plugin niini i-install ubos sa /usr/local/nagios nga direktoryo.
  2. Ang Nagios i-configure aron ma-monitor ang pipila ka mga serbisyo sa imong lokal nga makina (Paggamit sa Disk, Pag-load sa CPU, Kasamtangang Gumagamit, Total nga Proseso, ug uban pa)
  3. Ang nagios web interface mahimong magamit sa http://localhost/nagios

Kinahanglan natong i-install ang Apache, PHP ug pipila ka librarya sama sa gcc, glibc, glibc-common ug GD nga mga librarya ug ang development library niini sa dili pa i-install ang Nagios 4.4.5 uban sa tinubdan. Ug aron mahimo kini, magamit namon ang yum default package installer.

 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

Paghimo ug bag-ong nagios user gamit ang useradd command ug nagcmd group account ug magbutang ug password.

 useradd nagios
 groupadd nagcmd

Sunod, idugang ang nagios user ug ang apache user sa nagcmd nga grupo gamit ang usermod command.

 usermod -G nagcmd nagios
 usermod -G nagcmd apache

Paghimo usa ka direktoryo alang sa imong pag-install sa Nagios ug tanan nga mga pag-download sa umaabot.

 mkdir /root/nagios
 cd /root/nagios

Karon i-download ang pinakabag-o nga Nagios Core 4.4.5 ug Nagios plugins 2.2.1 nga mga pakete nga adunay wget command.

 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

Kinahanglan namon nga makuha ang na-download nga mga pakete nga adunay tar command sama sa mosunod.

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

Kung gikuha nimo kini nga mga tarball gamit ang tar command, duha ka bag-ong folder ang makita sa kana nga direktoryo.

 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

Karon, una namong i-configure ang Nagios Core ug aron mahimo kini kinahanglan namon nga moadto sa direktoryo sa Nagios ug magpadagan sa pag-configure sa file ug kung maayo ang tanan, ipakita niini ang output sa katapusan ingon sample output. Palihug tan-awa sa ubos.

 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.

Pagkahuman sa pag-configure, kinahanglan namon nga i-compile ug i-install ang tanan nga mga binary gamit ang paghimo sa tanan ug paghimo sa pag-install nga mando, kini mag-install sa tanan nga gikinahanglan nga mga librarya sa imong makina ug makapadayon kami.

 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

Ang mosunod nga sugo mag-instalar sa init nga mga script para sa Nagios.

 make install-init

Aron mahimo ang Nagios nga magtrabaho gikan sa command line kinahanglan namon nga i-install ang command-mode.

 make install-commandmode

Sunod, i-install ang mga sample nga Nagios nga mga file, palihug pagdagan ang pagsunod sa mando.

 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.

Ablihi ang “contacts.cfg” nga payl sa imong gipili nga editor ug itakda ang email address nga may kalabotan sa nagiosadmin contact definition sa pagdawat sa email alerts.

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

Nahuman na kami sa tanan nga pagsumpo sa backend, karon among i-configure ang Web Interface Para sa Nagios uban ang mosunod nga sugo. Ang ubos nga sugo mao ang I-configure ang Web interface para sa Nagios ug usa ka web admin user ang pagabuhaton \nagiosadmin.

 make install-webconf

Niini nga lakang, maghimo kami ug password para sa \nagiosadmin. Human sa pagpatuman niini nga sugo, palihug paghatag ug password sa makaduha ug hinumdomi kini tungod kay kini nga password gamiton sa dihang mag-log in ka sa Nagios Web interface.

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

I-restart ang Apache aron ma-epekto ang bag-ong mga setting.

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

Among gi-download ang Nagios nga mga plugins sa /root/nagios, Lakaw didto ug i-configure ug i-install kini sumala sa gimando sa ubos.

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

Karon nahuman na ang tanan sa pag-configure sa Nagios ug ang oras niini aron mapamatud-an kini ug buhaton kini palihug isulud ang pagsunod sa mando. Kung ang tanan hapsay kini magpakita nga parehas sa ubos nga output.

 /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

Aron mahimo ang Nagios nga molihok sa mga reboot, kinahanglan namon nga idugang ang nagios ug httpd nga adunay chkconfig ug systemctl nga mando.

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

I-restart ang Nagios aron ma-epekto ang bag-ong mga setting.

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

Ang imong Nagios andam na sa pagtrabaho, palihug ablihi kini sa imong browser gamit ang \http://Your-server-IP-address/nagios o \http://FQDN/nagios ug Ihatag ang username \nagiosadmin ug password.

Mga pahalipay! Malampuson nimo nga na-install ug gi-configure ang Nagios ug ang mga Plugin niini. Bag-o lang nimo gisugdan ang imong panaw sa pag-monitor.

Pag-upgrade sa Nagios 3.x ngadto sa Nagios 4.4.5

Kung nagdagan ka na sa usa ka daan nga bersyon sa Nagios, mahimo nimo kini i-upgrade bisan unsang orasa. Aron mahimo kini, kinahanglan nimo nga i-download ang pinakabag-o nga tar archive niini ug i-configure kini sama sa gipakita sa ubos.

 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

Mao ra kana sa karon, sa akong umaabot nga mga artikulo, ipakita ko kanimo kung giunsa pagdugang ang Linux, Windows, Printers, Switch, ug Device sa Nagios monitoring Server. Kung adunay ka problema samtang nag-install, palihug kontaka kami pinaagi sa mga komento. Hangtud unya magpabilin nga tuned ug konektado sa Tecmint ug ayaw kalimti ang Pag-like ug Pag-share kanamo aron ipakaylap sa palibot.

Basaha usab:

  1. Unsaon Pagdugang Linux Host sa Nagios Monitoring Server
  2. Unsaon Pagdugang sa Windows Host sa Nagios Monitoring Server