ວິທີການຕິດຕັ້ງ Nagios 4.4.5 ໃນ RHEL/CentOS 8/7 ແລະ Fedora 30


Nagios ແມ່ນເຄື່ອງມືກວດສອບ Open Source ທີ່ ໜ້າ ຫວາດສຽວ, ມັນຊ່ວຍໃຫ້ທ່ານມີສະພາບແວດລ້ອມໃນການຕິດຕາມກວດກາທີ່ສົມບູນກວ່າເກົ່າເພື່ອຮັກສາທຸກໆ ເຄື່ອງຈັກ/ເຄືອຂ່າຍ ຂອງທ່ານບໍ່ວ່າທ່ານຈະຢູ່ໃນສູນຂໍ້ມູນຂອງທ່ານຫຼືຢູ່ໃນຫ້ອງທົດລອງນ້ອຍໆຂອງທ່ານ.

ດ້ວຍ Nagios, ທ່ານສາມາດຕິດຕາມກວດກາເຈົ້າພາບຫ່າງໄກສອກຫຼີກແລະການບໍລິການຂອງພວກເຂົາຫ່າງໄກສອກຫຼີກໃນປ່ອງຢ້ຽມດຽວ. ມັນສະແດງ ຄຳ ເຕືອນແລະຊີ້ບອກວ່າມີບາງສິ່ງບາງຢ່າງຜິດພາດໃນເຊີຟເວີຂອງທ່ານເຊິ່ງໃນທີ່ສຸດຈະຊ່ວຍໃຫ້ພວກເຮົາກວດພົບບາງບັນຫາກ່ອນທີ່ມັນຈະເກີດຂື້ນ. ມັນຊ່ວຍໃຫ້ພວກເຮົາຫຼຸດຜ່ອນການສູນເສຍເວລາແລະການສູນເສຍທຸລະກິດ.

ເມື່ອບໍ່ດົນມານີ້, Nagios ໄດ້ປ່ອຍ Nagios Core 4.4.5 ລຸ້ນລ້າສຸດແລະລຸ້ນທີ່ລ້າສຸດຂອງ Nagios plugins 2.2.1 ໃນວັນທີ 20 ສິງຫາ 2019.

ບົດຂຽນນີ້ມີຈຸດປະສົງເພື່ອ ນຳ ພາທ່ານດ້ວຍ ຄຳ ແນະ ນຳ ທີ່ງ່າຍໆກ່ຽວກັບວິທີຕິດຕັ້ງ Nagios Core 4.4.5 ລ້າສຸດຈາກແຫຼ່ງ (tarball) ໃນ RHEL 8/7/6, CentOS 8/7/6 ແລະ Fedora 26-30.

ພາຍໃນ 30 ນາທີທ່ານຈະໄດ້ຕິດຕາມກວດກາເຄື່ອງຂອງທ້ອງຖິ່ນຂອງທ່ານ, ບໍ່ມີຂັ້ນຕອນການຕິດຕັ້ງຂັ້ນສູງພຽງແຕ່ການຕິດຕັ້ງຂັ້ນພື້ນຖານເທົ່ານັ້ນທີ່ຈະເຮັດວຽກໄດ້ 100% ໃນເຄື່ອງແມ່ຂ່າຍ Linux ສ່ວນໃຫຍ່ຂອງມື້ນີ້.

ກະລຸນາ ໝາຍ ເຫດ: ຄຳ ແນະ ນຳ ໃນການຕິດຕັ້ງທີ່ສະແດງຢູ່ນີ້ແມ່ນຂຽນໂດຍອີງໃສ່ການແຈກຈ່າຍ Linux CentOS 7.5.

ຕິດຕັ້ງ Nagios 4.4.5 ແລະ Nagios Plugin 2.2.1

ຖ້າທ່ານປະຕິບັດຕາມ ຄຳ ແນະ ນຳ ເຫຼົ່ານີ້ຢ່າງຖືກຕ້ອງ, ທ່ານຈະຈົບລົງດ້ວຍຂໍ້ມູນຕໍ່ໄປນີ້.

<

  • Nagios ແລະປັinsກອິນຂອງມັນຈະຖືກຕິດຕັ້ງພາຍໃຕ້/usr/local/nagios.
  • Nagios ຈະຖືກ ກຳ ນົດໃຫ້ຕິດຕາມການບໍລິການຂອງເຄື່ອງຈັກໃນທ້ອງຖິ່ນຂອງທ່ານ (Disk Usage, CPU Load, ຜູ້ໃຊ້ໃນປະຈຸບັນ, ຂະບວນການທັງ ໝົດ, ແລະອື່ນໆ)
  • ໂຕ້ຕອບເວັບໄຊທ໌ Nagios ຈະມີຢູ່ http:// localhost/nagios
  • ພວກເຮົາ ຈຳ ເປັນຕ້ອງຕິດຕັ້ງ Apache, PHP ແລະຫ້ອງສະ ໝຸດ ຈຳ ນວນ ໜຶ່ງ ເຊັ່ນ gcc, glibc, glibc-common ແລະ GD libraries ແລະຫໍສະ ໝຸດ ການພັດທະນາຂອງມັນກ່ອນທີ່ຈະຕິດຕັ້ງ Nagios 4.4.5 ກັບແຫລ່ງທີ່ມາ. ແລະເພື່ອເຮັດແນວນັ້ນ, ພວກເຮົາສາມາດໃຊ້ຕົວຕິດຕັ້ງຊຸດ yum default.

     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
    

    ສ້າງຜູ້ໃຊ້ nagios ໃໝ່ ໂດຍໃຊ້ ຄຳ ສັ່ງ useradd ແລະບັນຊີກຸ່ມ nagcmd ແລະຕັ້ງລະຫັດຜ່ານ.

     useradd nagios
     groupadd nagcmd

    ຕໍ່ໄປ, ຕື່ມທັງຜູ້ໃຊ້ nagios ແລະຜູ້ໃຊ້ apache ເຂົ້າໃນກຸ່ມ nagcmd ໂດຍໃຊ້ ຄຳ ສັ່ງ usermod.

     usermod -G nagcmd nagios
     usermod -G nagcmd apache

    ສ້າງໄດເລກະທໍລີ ສຳ ລັບການຕິດຕັ້ງ Nagios ຂອງທ່ານແລະການດາວໂຫລດໃນອະນາຄົດຂອງມັນທັງ ໝົດ.

     mkdir /root/nagios
     cd /root/nagios

    ຕອນນີ້ດາວໂຫລດໂປແກຼມ Nagios Core 4.4.5 ລ້າສຸດແລະ Nagios plugins 2.2.1 ມີ ຄຳ ສັ່ງ wget.

     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
    

    ພວກເຮົາ ຈຳ ເປັນຕ້ອງສະກັດຊຸດທີ່ດາວໂຫລດມາພ້ອມດ້ວຍ ຄຳ ສັ່ງ tar ດັ່ງຕໍ່ໄປນີ້.

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

    ເມື່ອທ່ານສະກັດເອົາກະຕ່າດອກໄມ້ເຫລົ່ານີ້ດ້ວຍ ຄຳ ສັ່ງ tar, ສອງຟາຍ ໃໝ່ ຈະປາກົດຢູ່ໃນໄດເລກະທໍລີນັ້ນ.

     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
    

    ດຽວນີ້, ທຳ ອິດພວກເຮົາຈະຕັ້ງຄ່າ Nagios Core ແລະເພື່ອເຮັດແນວນັ້ນພວກເຮົາ ຈຳ ເປັນຕ້ອງໄປທີ່ໄດເລກະທໍລີ Nagios ແລະ ດຳ ເນີນການຕັ້ງຄ່າເອກະສານຕັ້ງຄ່າແລະຖ້າທຸກຢ່າງດີ, ມັນຈະສະແດງໃຫ້ເຫັນຜົນຜະລິດໃນທີ່ສຸດຄືກັບຜົນໄດ້ຮັບຂອງຕົວຢ່າງ. ກະລຸນາເບິ່ງຂ້າງລຸ່ມນີ້.

     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.
    

    ຫລັງຈາກມີການຕັ້ງຄ່າແລ້ວ, ພວກເຮົາ ຈຳ ເປັນຕ້ອງໄດ້ລວບລວມແລະຕິດຕັ້ງໄບນາລີທຸກຢ່າງພ້ອມທັງເຮັດແລະເຮັດ ຄຳ ສັ່ງຕິດຕັ້ງ, ມັນຈະຕິດຕັ້ງຫ້ອງສະຫມຸດທີ່ ຈຳ ເປັນທັງ ໝົດ ໃນເຄື່ອງຂອງທ່ານແລະພວກເຮົາສາມາດ ດຳ ເນີນການຕໍ່ໄປ.

     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
    

    ຄຳ ສັ່ງຕໍ່ໄປນີ້ຈະຕິດຕັ້ງ init scripts ສຳ ລັບ Nagios.

     make install-init

    ເພື່ອເຮັດໃຫ້ Nagios ເຮັດວຽກຈາກເສັ້ນ ຄຳ ສັ່ງພວກເຮົາຕ້ອງຕິດຕັ້ງໂຫມດ ຄຳ ສັ່ງ.

     make install-commandmode

    ຕໍ່ໄປ, ຕິດຕັ້ງແຟ້ມຕົວຢ່າງ Nagios, ກະລຸນາ ດຳ ເນີນການຕາມ ຄຳ ສັ່ງ.

     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.
    

    ເປີດເອກະສານ“ contacts.cfg” ກັບຕົວເລືອກບັນນາທິການຂອງທ່ານແລະຕັ້ງທີ່ຢູ່ອີເມວທີ່ກ່ຽວຂ້ອງກັບນິຍາມການຕິດຕໍ່ nagiosadmin ເພື່ອຮັບການແຈ້ງເຕືອນອີເມວ.

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

    ພວກເຮົາໄດ້ເຮັດ ສຳ ເລັດກັບການຕັ້ງຄ່າທັງ ໝົດ ໃນ backend, ດຽວນີ້ພວກເຮົາຈະ ກຳ ຫນົດຄ່າ Web Interface For Nagios ດ້ວຍ ຄຳ ສັ່ງຕໍ່ໄປນີ້. ຄຳ ສັ່ງຂ້າງລຸ່ມນີ້ຈະ ກຳ ຫນົດຄ່າອິນເຕີເຟດ ສຳ ລັບ Nagios ແລະຜູ້ ນຳ ເວັບ admin ຈະຖືກສ້າງ“ nagiosadmin”.

     make install-webconf

    ໃນບາດກ້າວນີ້, ພວກເຮົາຈະ ກຳ ລັງສ້າງລະຫັດລັບ ສຳ ລັບ“ nagiosadmin”. ຫຼັງຈາກປະຕິບັດ ຄຳ ສັ່ງນີ້, ກະລຸນາໃຫ້ລະຫັດຜ່ານສອງຄັ້ງແລະຈື່ໄວ້ເພາະວ່າລະຫັດຜ່ານນີ້ຈະຖືກໃຊ້ເມື່ອທ່ານເຂົ້າສູ່ລະບົບໃນ Nagios Web interface.

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

    Restart Apache ເພື່ອເຮັດໃຫ້ການຕັ້ງຄ່າ ໃໝ່ ມີຜົນ.

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

    ພວກເຮົາໄດ້ດາວໂຫລດໂປແກຼມ Nagios ໃນ/ຮາກ/nagios, ໄປທີ່ນັ້ນແລະຕັ້ງຄ່າແລະຕິດຕັ້ງມັນຕາມທີ່ໄດ້ກ່າວມາຂ້າງລຸ່ມນີ້.

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

    ຕອນນີ້ພວກເຮົາໄດ້ເຮັດທຸກຢ່າງດ້ວຍການຕັ້ງຄ່າຂອງ Nagios ແລະເວລາຂອງມັນເພື່ອກວດສອບມັນແລະເຮັດເຊັ່ນນັ້ນກະລຸນາໃສ່ ຄຳ ສັ່ງຕໍ່ໄປນີ້. ຖ້າທຸກຢ່າງ ດຳ ເນີນໄປກ້ຽງມັນຈະສະແດງອອກຄ້າຍກັບຜົນຜະລິດຂ້າງລຸ່ມ.

     /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 ສາມາດເຮັດວຽກໄດ້ທົ່ວ reboots, ພວກເຮົາຕ້ອງເພີ່ມ nagios ແລະ httpd ດ້ວຍ ຄຳ ສັ່ງ chkconfig ແລະ systemctl.

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

    Restart Nagios ເພື່ອໃຫ້ການຕັ້ງຄ່າ ໃໝ່ ມີຜົນ.

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

    Nagios ຂອງທ່ານພ້ອມແລ້ວທີ່ຈະເຮັດວຽກ, ກະລຸນາເປີດມັນຢູ່ໃນ browser ຂອງທ່ານດ້ວຍ“ http:// Your-server-IP-address/nagios” ຫຼື“ http:// FQDN/nagios” ແລະໃຫ້ຊື່ຜູ້ໃຊ້“ nagiosadmin” ແລະລະຫັດຜ່ານ.

    ຊົມເຊີຍ! ທ່ານໄດ້ຕິດຕັ້ງແລະຕັ້ງຄ່າ Nagios ແລະ Plugins ຂອງມັນແລ້ວ. ທ່ານຫາກໍ່ເລີ່ມຕົ້ນການຕິດຕາມຂອງທ່ານ.

    ຍົກລະດັບ Nagios 3.x ຂື້ນເປັນ Nagios 4.4.5

    ຖ້າທ່ານ ກຳ ລັງໃຊ້ Nagios ລຸ້ນເກົ່າ, ທ່ານສາມາດຍົກລະດັບໄດ້ທຸກເວລາ. ເພື່ອເຮັດແນວນັ້ນ, ທ່ານພຽງແຕ່ຕ້ອງການດາວໂຫລດຮວບຮວມ tar ຫຼ້າສຸດຂອງມັນແລະ ກຳ ຫນົດຄ່າຕາມທີ່ສະແດງໄວ້ຂ້າງລຸ່ມ.

     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

    ນັ້ນແມ່ນ ສຳ ລັບຕອນນີ້, ໃນບົດຂຽນທີ່ ກຳ ລັງຈະມາເຖິງຂອງຂ້ອຍ, ຂ້ອຍຈະສະແດງວິທີການເພີ່ມ Linux, Windows, ເຄື່ອງພິມ, ປ່ຽນແລະອຸປະກອນໃສ່ Nagios monitoring Server. ຖ້າທ່ານມີປັນຫາໃນຂະນະຕິດຕັ້ງ, ກະລຸນາຕິດຕໍ່ຫາພວກເຮົາໂດຍຜ່ານ ຄຳ ເຫັນ. ຈົນກວ່າຈະຕິດຕາມແລະເຊື່ອມຕໍ່ກັບ Tecmint ແລະຢ່າລືມທີ່ຈະກົດ Like ແລະແບ່ງປັນໃຫ້ພວກເຮົາເຜີຍແຜ່ທົ່ວ.

    ອ່ານອີກ:

    <

  • ວິທີການເພີ່ມ Linux ໂຮດຕິ້ງໃຫ້ກັບ Server Server Nagios
  • ວິທີການເພີ່ມ Windows ໂຮດຕິ້ງໃຫ້ກັບ Server Server Nagios