Nagios's installation

Source: Internet
Author: User

Monitoring is very important for the daily operation of the System Manager, and the more well-known open-source monitoring software has ganglia, Cacti, Nagios, Zabbix, and so on, and this time simply said Nagios installation deployment, Because Nagios is managed based on Web page view, it can be implemented using either lamp or LNMP, the more easily implemented Web system framework, Nagios's official website is: https://www.nagios.org/downloads/, Of course the download version is recommended with the latest stable version. Nagios monitoring implementation is done by the various plug-ins itself is not monitoring function, so nagios use very flexible, and in need of monitoring different platform host, hardware with different plug-ins, the following from the page to find a picture can be very good description: 650) this.width=650; Src= "Https://s4.51cto.com/wyfs02/M02/92/19/wKioL1j7lDqDYCBXAADwVryoOFM808.jpg-wh_500x0-wm_3-wmp_4-s_ 2697766514.jpg "title=" nagios.jpg "alt=" Wkiol1j7ldqdycbxaadwvryoofm808.jpg-wh_50 "/>

learned that Nagios monitoring plug-in SNMP in different platforms of the host, hardware, and Linux has Send-nsca and Nrpe generally we commonly used is Nrpe, listening to TCP port 5666, and on the Windows host is used nsclient+ +, listening is 12489 and 5666 ports, which is important to be sure to open these ports on the monitored host.

Before installing Nagios, you need to install the Nagios monitoring host (server side) before installing the appropriate plug-ins on the monitored host (clinet side).

1. Server side:

Check for dependent packages before installing

[[email protected] ~]# yum-y groupinstall "Development Tools" "Development Libraries" #在配置好yum源的主机上, first check if the development package group is installed [[email Protected] ~]# yum-y install httpd php php-mysql gd gd-devel sendmail openssl-devel# Here is the test without compiling the package PHP and Apache, generally recommended to use the compilation package

Start a normal Nagios installation after a dependency is resolved, first installing Nagios's core engine and Web page

[[email protected] ~]# groupadd -r nagcmd# Add Nagcmd Group [[email protected] ~]#  useradd -m -g nagcmd -r -s /sbin/nologin nagios[[email protected ] ~]# passwd nagios[[email protected] ~]# usermod -a -g nagcmd  apache# attached the Nagcmd group to the Apache group [[email protected] ~]# cd /usr/local/src/nagios-4.3.1[[ email protected] nagios-4.3.1]# ./configure --sysconfdir=/etc/nagios --prefix=/usr/ local/nagios --with-command-group=nagcmd --enable-event-broker[[email protected]  nagios-4.3.1]# make all && make install[[email protected]  nagios-4.3.1]# make install-init && make install-commandmode &&  make install-config# add the appropriate plug-in [[email protected] nagios-4.3.1]# vim /etc/nagios/ objects/contacts.cfg# Modify the message recipient's profile, do not do too much in thisDescription, the configuration file in the comments, the main change is the e-mail address [[email protected] nagios-4.3.1]# make install-webconf# Configuration Web configuration file [[ email protected] nagios-4.3.1]# htpasswd -c /etc/nagios/htpasswd.users  nagiosadmin# Configuring Nagios's page password New password: re-type new password: adding password  for user nagiosadmin

To this Nagios core engine and Basic Web page has been installed, in this direct launch httpd after using browser test under 650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/93/ 31/wkiol1kjpeoztm_jaabs_kz_u8m327.png-wh_500x0-wm_3-wmp_4-s_262265194.png "title=" Nagios_web.png "alt=" Wkiol1kjpeoztm_jaabs_kz_u8m327.png-wh_50 "/>

Nagios at this time does not have any monitoring function, because this Nagios host is a Linux server, so the monitoring plug-in here to choose the more common Nrpe, before installing Nrpe to install the Nagios plugin plugins

[[email protected] nagios-4.3.1]# cd .. /nagios-plugins-2.1.4[[email protected] nagios-plugins-2.1.4]# ./configure -- with-nagios-user=nagios --with-nagios-group=nagios[[email protected] nagios-plugins-2.1.4]#  make && make install[[email protected] nagios-plugins-2.1.4]#  chkconfig --add nagios# adding Nagios services [[Email protected] nagios-plugins-2.1.4]# chkconfig  nagios on#nagios boot from boot [[Email protected] nagios-plugins-2.1.4]# /etc/init.d/nagios  start[[email protected] nagios-plugins-2.1.4]# getenforce# here to check if you have SELinux on the server, If you have to choose to turn it off or add the Nagios file in SELinux to a tab that can be executed enforcing[[email protected] nagios-plugins-2.1.4]#  chcon -r -t httpd_sys_content_t /usr/local/nagios/sbin/[[email protected]  Nagios-plugins-2.1.4]# chcon -r -t httpd_sys_content_t /usr/local/nagiOs/share/ 

The Nagios plugin on the server side is now installed and you can install the Nagios Nrpe plugin

[Email protected] nagios-plugins-2.1.4]# CD. /nrpe-3.0.1/[[email protected] nrpe-3.0.1]#./configure--with-nrpe-user=nagios--with-nrpe-group=nagios-- With-nagios-user=nagios--with-nagios-group=nagios--enable-command-args--enable-ssl--sysconfdir=/etc/nagios[[ Email protected] nrpe-3.0.1]# make all && make Install-plugin

The Nagios on the server side has already been deployed, and Nagios is now able to monitor the machine itself. 650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/93/51/wKiom1kJ_bqSAe7YAADyYaRHjR0700.png-wh_500x0-wm_ 3-wmp_4-s_2080015648.png "title=" Nagios_server.png "alt=" Wkiom1kj_bqsae7yaadyyarhjr0700.png-wh_50 "/>

2, Clinet end:

The client here is built with another Linux server for a quick and easy deployment implementation. Similarly, the user is added to the Nagios client side. Of course, you have to install the Nagios plugin first.

[[email protected] ~]# useradd-m-r-s/sbin/nologin nagios[[email protected] ~]# Cd/usr/local/src/[[email protected] Sr c]# CD Nagios-plugins-2.1.4[[email protected] nagios-plugins-2.1.4]#./configure--with-nagios-user=nagios-- With-nagios-group=nagios[[email protected] nagios-plugins-2.1.4]# make all && make install

Install Nrpe after plug-in installation is complete

[Email protected] nagios-plugins-2.1.4]# CD. /nrpe-3.0.1/[[email protected] nrpe-3.0.1]#./configure--with-nrpe-user=nagios--with-nrpe-group=nagios-- With-nagios-user=nagios--with-nagios-group=nagios--enable-command-args--enable-ssl--sysconfdir=/etc/nagios[[ Email protected] nrpe-3.0.1]# make all && make Install-plugin[[email protected] nrpe-3.0.1]# make Install-daemon & amp;& make Install-config && make Install-init && make Install-inet

Here, the Nrpe section of Nagios is finished, and here are some basic configurations

[Email protected] nrpe-3.0.1]# vim/etc/nagios/nrpe.cfg ... allowed_hosts=192.168.218.128# here IP changed to server-side Nagios monitor IP ... Command[check_hda1]=/usr/local/nagios/libexec/check_disk-w 20%-C 10%-p/dev/hda1# here is modified based on the actual drive letter used by the disk ... Slightly... [[email protected] nrpe-3.0.1]#/etc/init.d/nrpe start

To do some basic verification after the installation, it is important to note that these authentication needs to be done on the monitoring server host, the monitored host needs to open 5666 port

[Email protected] nrpe-3.0.1]# Cd/usr/local/nagios/libexec/[[email protected] libexec]#./check_nrpe-h 192.168.218.129# Check the IP of the monitored host, so the print out version number is normal Nrpe v3.0.1

The Nagios installation is complete, and the meaning of Nagios's home directory or file is simple, as follows:

directory
explanation
b In
nagios the directory of the binary files
sbin nagios the directory where the CGI files are located, i.e. the directory where the files required to execute the external command are located
share nagios Web page files in the directory, it is recommended to find the Chinese information for easy access
libexec nagios external plug-in directory
var nagios log files, lock and other files in the same directory
var/archives nagios Log Auto archive directory
va R/RW

Of course I'm here to specify Nagios's profile path under the/etc/nagios path, if not specified, default is in Nagios's home directory, and some of the configured files or directories have a simple meaning, as follows:

file name or directory name use
Cgi.cfg Control the configuration file for CGI access
Nagios.cfg Nagios Master configuration file
Resource.cfg A variable definition file, also known as a resource file, defines variables in some files so that they can be referenced by other configuration files, such as $user1$
Objects Objects is a directory with many profile templates in this directory that define the Nagios object
Objects/commands.cfg Command definition configuration file, where defined commands can be referenced by other configuration files
Objects/contacts.cfg
Define profiles for contacts and contact groups
Objects/localhost.cfg Define a configuration file that monitors the local host
Objects/printer.cfg Define a profile template for the monitoring printer, which is not enabled by default
Objects/switch.cfg Define a profile template for the monitoring router, which is not enabled by default
Objects/templates.cfg Defines a template configuration file for hosts and services that can be referenced in other configuration files
Objects/timeperiods.cfg Define the configuration file for the Nagios monitoring time period
Objects/windows.cfg Monitor a profile template for a Windows host that is not enabled by default

Nagios is still unavailable at this time. There are some basic configuration needs to be modified to normal use, on the server side into the Sysconfigdir directory, the first to modify the Commandss.cfg file according to the actual situation, add the following:

[Email protected] nagios]# vim objects/commands.cfgdefine command{command_name Check_nrpe command_line $USER 1$/check_nrpe-h $HOSTADDRESS $-C $ARG 1$}

There is no Linux configuration file under Nagios's default profile so if you are monitoring a Linux host, you need to define your own write profile, where you can simply write a template that is used under Linux:

[[email protected] nagios]# vim objects/linux.cfgdefine host{         use              linux-server        host_name        linuxhost        alias            My linux Server        address          192.168.218.129    ; fill in the ip  of the monitored host        }define service{         use                      generic-service        host_name                linuxhost         service_description     check_users         check_command           check_nrpe!check_users         }define service{         use                      generic-service        host_name                linuxhost         service_description     CHECK_LOAD         check_command            check_nrpe!check_load  &nbSp;     }define service{        use                       generic-service        host_name                linuxhost         service_description     CHECK_SDA1         check_command           check_ nrpe!check_sda1        }define service{         use                      generic-service         host_name               linuxhost         service_description     CHECK_ZOMBIE_PROCS         check_command           check_nrpe! check_zombie_procs        }define service{         use                      generic-service         host_name                linuxhost        service_description      CHECK_TOTAL_PROCS        check_command            check_nrpe!check_total_procs        }[[email protected]  Nagios]# chown nagios:nagios linux.cfg# modifying the genus group under configuration file

You also need to add environment variables in nagios.cfg after the linux.cfg configuration file is modified:

[Email protected] nagios]# vim nagios.cfg ... A little ... cfg_file=/etc/nagios/objects/linux.cfg ... Slightly...

You can use Nagios's profile validation check after you are modifying it

[[email protected] nagios]# /usr/local/nagios/bin/nagios -v /etc/nagios/ nagios.cfgnagios core 4.3.1copyright  (c)  2009-present Nagios Core  development team and community contributorscopyright  (c)  1999-2009 Ethan  galstadlast modified: 02-23-2017license: gplwebsite: https://www.nagios.orgreading  configuration data...   Read main config file okay...    read object config files okay ... Running pre-flight check on configuration data ... checking objects...        checked 13 services.         Checked 2 hosts.         checked 1 host groups.        checked 0  service groups.        checked 1 contacts.         Checked 1 contact groups.         checked 25 commands.        checked 5 time  periods.        Checked 0 host escalations.         checked 0 service escalations. Checking for circular paths...        checked 2  hosts        Checked 0 service dependencies         Checked 0 host dependencies         checked 5 timeperiodschecking global event handlers ... checking obsessive compulsive processor&Nbsp;commands ... Checking misc settings ... Total warnings: 0total errors:   0things look okay - no  serious problems were detected during the pre-flight check[[email  protected] nagios]# /etc/init.d/nagios restart

Like this is no error, and then restart Nagios on it, so the basic Nagios installation is complete, it is important to note that in Nagios server side need to open 80, 443 port for Web Management page Normal browsing, of course, this is also some basic configuration deployment, Further modifications to the configuration file are required if more functionality is to be implemented.

This article from "Technical essay" blog, declined reprint!

Nagios's installation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.