In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Nagios monitoring system
1: how ngios works
The function of 1.Nagios is to monitor the service and host, but it does not include this part of the function. All the monitoring and detection functions are completed through various plug-ins.
After starting Nagios, it will periodically automatically call plug-ins to detect the status of the server. At the same time, Nagios will maintain a queue, and the status information returned by all plug-ins will enter the queue. Nagios will read the information from the head of the queue every time, and after processing, the status result will be displayed through web.
Nagios provides many plug-ins, which can be used to easily monitor the status of many services. After the installation is completed, all the plug-ins that can be used by nagios are placed in the / libexec under the nagios home directory, for example, check_disk is a plug-in to check disk space, check_load is to check CPU load, and so on. Each plug-in can view its usage and functionality by running. / check_xxx-h.
2.Nagios can recognize four kinds of status return information: 0 (OK) indicates normal / green status, 1 (WARNING) indicates warning / × × ×, 2 (CRITICAL) indicates very serious error / red, and 3 (UNKNOWN) indicates unknown error / deep × ×. Nagios judges the status of the monitoring object according to the value returned by the plug-in, and displays it through web, so that the administrator can find the fault in time.
Four monitoring statu
3.Nagios manages services remotely through NRPE
1. Nagios executes the check_nrpe plug-in installed in it and tells check_nrpe which services to detect.
two。 Connect the NRPE daemon on the remote computer through SSL,check_nrpe
3. NRPE runs various local plug-ins to detect local services and status (check_disk,..etc)
4. Finally, NRPE sends the test results to the check_nrpe,check_nrpe on the host side and sends the results to the Nagios status queue.
5. Nagios reads the information in the queue in turn, and then displays the results.
The way 4.nagios monitors a service or host
1. [passive Monitoring] nagios carries out passive monitoring through nsca. So what is passive surveillance? Passive monitoring: refers to the active upload of data to the nagios monitoring system by the monitored server. This monitoring method improves real-time performance (when there is a problem, the monitored server can upload data in time to notify nagios, so that the administrator can deal with it as soon as possible, instead of waiting until the next monitoring cycle to know the status of the monitored server, as in active monitoring). NSCA is a program that can realize passive monitoring of Nagios. As far as we know, the linux/unix server can only be passively monitored through the nsca plug-in. No plug-ins available for the windows server have been found yet.
2. [active Monitoring] nagios actively monitors through nrpe plug-in and snmp protocol. As for what is active monitoring, you can refer to the above. The simple solution is that nagios actively acquires the data of the remote host according to the detection cycle. In this way, the real-time performance will be worse. Nagios realizes the monitoring of linux/unix server through nrpe plug-in and snmp protocol, and the monitoring of windows server, switch and printer through snmp protocol. In addition, nagios can also monitor windows through the NSClient++ client
4. Ways in which nagios monitors a service or host
Nagios itself does not have the monitoring function, all monitoring is completed by the plug-in, the plug-in will return the monitoring results to nagios,nagios analysis of these results to show us in the way of web, at the same time provide the corresponding alarm function (this alarm function is also completed by the corresponding plug-in).
According to the figure above, you can see that there are several categories. These are the types of plug-ins to be called by nagios.
1.snmp class
[can monitor local / remote linux/unix hosts and remote windows servers, switches, printers]
2.nrpe class
[mainly monitors the status of services on local and remote hosts, keeping in mind that they are targeted at services]
3.nsca class
[nsca mainly implements passive monitoring]
4.nagios-plugins class
Nagios-plugins is a set of plug-ins officially provided by nagios. The functions of nagios monitoring hosts are actually realized by executing plug-ins. ]
All of these plug-ins are executable programs that implement specific functions, and the default installation path is /
The process of the experiment:
First, build a nagios monitoring system
1. Turn off the firewall
# service iptables stop
# chkconfig iptables off
two。 Create nagios users and groups
[root@centos1] # useradd-s / sbin/nologin nagios
[root@centos1 ~] # mkdir / usr/local/nagios
[root@centos1] # chown-R nagios:nagios / usr/local/nagios
[root@centos1 ~] #
3. Install dependency packages
[root@centos1 ~] # yum-y install php httpd mysql-devel
4. Compile and install nagios
[root@centos1 nagios-4.0.1] # tar zxf / mnt/nagios-4.0.1.tar.gz-C / usr/src
[root@centos1 nagios-4.0.1] # cd / usr/src/nagios-4.0.1/
[root@centos1 nagios-4.0.1] #. / configure-prefix=/usr/local/nagios
[root@centos1 nagios-4.0.1] # make all / / compile
[root@centos1 nagios-4.0.1] # make install / / cgi and html of the main program that installs nagios
[root@centos1 nagios-4.0.1] # make install-init / / generate service script / etc/rc.d/init.d
[root@centos1 nagios-4.0.1] # make install-commandmode / / assign permissions to external programs to access nagios
[root@centos1 nagios-4.0.1] # make install-config / / generate a sample nagios configuration file, and install it in / usr/local/nagios/etc directory
[root@centos1 nagios-4.0.1] # make install-webconf// generates an access web interface file, and automatically modifies the httpd.conf file so that the web monitoring page of nagios must be authorized to access
[root@centos1 nagios-4.0.1] # chkconfig-- add nagios
[root@centos1 nagios-4.0.1] # chkconfig-- level 35 nagios on
[root@centos1 nagios-4.0.1] #
5. Verify that the installation was successful to check the / usr/local/nagiso directory as follows:
[root@centos1 nagios-4.0.1] # ls / usr/local/nagios
Bin etc libexec sbin share var
6. Install the nagios plug-in
① installs the nagions plug-in
[root@centos1 nagios-plugins-1.5] # tar zxvf / mnt/nagios-plugins-1.5.tar.gz-C / usr/src
[root@centos1 nagios-plugins-1.5] # cd / usr/src/nagios-plugins-1.5/
Make [1]: Leaving directory `/ usr/src/nagios-plugins-1.5'
[root@centos1 nagios-plugins-1.5] #. / configure-prefix=/usr/local/ngios
[root@centos1 nagios-plugins-1.5] # make&&make install
If you want to obtain the local resources or attributes of a remote host, such as cpu utilization, disk resources, etc., you need to borrow an external build NRPE to complete it.
The ssl security channel is used between the ② monitoring end and the monitored side. Need to install openssl-devel first
[root@centos1 nagios-plugins-1.5] # yum-y install openssl-devel
# tar zxvf / mnt/nrpe-2.15.tar.gz-C / usr/src
# cd / usr/src/nrpe-2.15
#. / configure
# make all
# make install-plugin / / install the check_nrpe plug-in to the / usr/local/nagios/libexec directory
③ for security reasons, generally speaking, the web monitoring page of nagios must be authorized to access. This requires additional authentication configuration. Install-webconfig was installed when Nagios was installed, so there is no need to manually modify the httpd.conf file, just create an authentication account to access the web page of nagios
[root@centos1 nrpe-2.15] # / usr/bin/htpasswd-c / usr/local/nagios/etc/htpasswd.users nagiosadm
④ authentication, open the browser on the client
2. Configure nagios monitoring system
1. Profile introduction
[root@centos1 etc] # cd / usr/local/nagios/etc
Cgi.cfg / / profile that controls cgi access
Nagios.cfg / / nagios main configuration file
Resource.cfg / / variable definition files, also known as resource files, can only give defined variables in these files. Can be used in other configuration files, such as $USER1 $= / usr/local/nagios/libexec
Objects / / objects is a directory in which there are many configuration file templates that define nagios objects.
Objects/commands.cfg / / defines a command configuration file, in which defined commands can be referenced by other configuration files
Objects/contacts.cfg / / profile that defines contacts and contact groups
Objects/localhost.cfg / / define configuration files for monitoring landlords and
Objects/printer.cfg / / defines a profile template for monitoring printers. This file is not enabled by default
Objects/switch.cfg / / defines a configuration file that monitors the router, which is not enabled by default
Objects/templates.cfg / / defines a template profile for hosts and services, which can be referenced in other configuration files
Objects/timeperiods.cfg / / A configuration file that defines the nagios monitoring period
Objects/windows.cfg / / defines a profile template for monitoring windows hosts. This file is not started by default.
two。 Association between profiles
Four points:
L define which hosts, host groups, services, and service groups to monitor
L define what command implementation is required for this monitoring
L define the time period for monitoring
L define contacts and groups of contacts to be notified when there is a problem with the host or service
3 modify the configuration file
① / usr/local/nagios/etc/nagios.cfg / / main configuration file
Cfg_file=/usr/local/nagios/etc/objects/commands.cfg / / defaults to
Cfg_file=/usr/local/nagios/etc/objects/contacts.cfg / / defaults to
Cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg / / defaults to
Cfg_file=/usr/local/nagios/etc/objects/templates.cfg / / defaults to
Cfg_file=/usr/local/nagios/etc/objects/hostgroups.cfg / / handwritten
Cfg_dir=/usr/local/nagios/etc/conf / / the directory where the host configuration is stored
You need to add it manually:
[root@centos1 etc] # mkdir / usr/local/nagios/etc/conf
② / usr/local/nagios/etc/objects/commands.cfg / / plus email, Fetion and nrpe plug-ins, this example mainly adds a nrpe plug-in, the other is not defined (Fetion, email, etc.)
③ / usr/local/nagios/etc/objects/contacts.cfg / / define the contact person for monitoring service
Define contactgroup {/ / add manually
Contactgroup_name yumwei
Alias yunwei
Members ywgcsz
}
/ usr/local/nagios/etc/objects/hostgroups.cfg / / define the host group to be created manually
Define hostgroup {
Hostgroup_name mysqlserver
Alias mysqlserver
Members 192.168.1.2
}
4. Let's start to monitor the survival, load and process of mysql and http hosts.
[root@centos1 conf] # vim 192.168.1.2.cfg
Define host {
Host_name 192.168.1.2
Alias 192.168.1.2
Address 192.168.1.2
Check_command check-host-alive
Max_check_attempts 5
Check_period 24x7
Contact_groups yunwei
Notification_period 24x7
Notification_options d,u,r
}
Define service {
Host_name 192.168.1.2
Service_description check-host-alive
Check_command check-host-alive
Max_check_attempts 3
Normal_check_interval 2
Retry_check_interval 2
Check_period 24x7
Notification_interval 10
Contact_groups yunwei
Notification_period 24x7
Notification_options w,u,c,r
}
Define service {
Host_name 192.168.1.2
Service_description check-procs
Check_command check_nrpe!check_total_procs
Max_chacek_attempts 3
Normal_check_interval 2
Retry_check_interval 2
Check_period 24x7
Notification_interval 10
Contact_groups yunwei
}
Define service {
Host_name 192.168.1.2
Service_description check-load
Check_command check_nrpe!check_load
Max_chacek_attempts 3
Normal_check_interval 2
Retry_check_interval 2
Check_period 24x7
Notification_interval 10
Contact_groups yunwei
Notification_period 24x7
Notification_options w,u,c,r
}
Define service {
Host_name 192.168.1.2
Service_description check-space
Check_command check_nrpe!check_disk_space_free
Max_check_attempts 3
Normal_check_interval 2
Retry_check_interval 2
Check_period 24x7
Notification_interval 10
Notification_period 24x7
Contact_groups yunwei
Notification_options w,u,c,r
}
Define service {
Host_name 192.168.1.2
Service_description check-http
Check_command check_nrpe!check_http
Max_check_attempts 3
Normal_check_interval 2
Retry_check_interval 2
Check_period 24x7
Notification_interval 10
Notification_period 24x7
Contact_groups yunwei
}
Define service {
Host_name 192.168.1.2
Service_description check-user
Check_command check_nrpe!check_user
Max_check_attempts 3
Normal_check_interval 2
Retry_check_interval 2
Check_period 24x7
Notification_interval 10
Notification_period 24x7
Contact_groups yunwei
}
5. Modify / usr/local/nagios/etc/cgi.cfg
Use_authentication=0
Third, the configuration of the controlled side (the configuration and management server are basically the same as the following command)
[root@centos2 ~] # yum-y install openssl openssl-devel
[root@centos2] # useradd nagios-s / sbin/nologin
[root@centos2 nagios-plugins-1.5] # tar zxvf / mnt/nagios-plugins-1.5.tar.gz-C / usr/src
[root@centos2 nagios-plugins-1.5] # cd / usr/src/nagios-plugins-1.5/
[root@centos2 nagios-plugins-1.5] #. / configure-prefix=/usr/local/nagios
[root@centos2 nagios-plugins-1.5] # make&&make install
[root@centos2 nagios-plugins-1.5] # chown-R nagios:nagios / usr/local/nagios
[root@centos2 nagios-plugins-1.5] # tar zxvf / mnt/nrpe-2.15.tar.gz-C / usr/src
# cd / usr/src/nrpe-2.15
#. / configure-prefix=/usr/local/nagios
[root@centos2 nrpe-2.15] # make all & & make install-plugin & & make install-daemon
[root@centos2 nrpe-2.15] # make install-daemon-config
[root@centos2 nrpe-2.15] # ps-ef | wc-l
[root@centos2 nrpe-2.15] # more / proc/cpuinfo | grep proc | wc-l
[root@centos2 nrpe-2.15] # vim / usr/local/nagios/etc/nrpe.cfg
Allowed_hosts=127.0.0.1192.168.1.1 (main control terminal)
Commanded [check _ total_procs] = / usr/local/nagios/libexec/check_procs-w 150-c 170
Commad [check _ load] = / usr/local/nagios/libexec/check_load-w 15leg10 relegation 5-c 30pyrmage 25recover20
Commanded [check _ disk_space_free] = / usr/local/nagios/libexec/check_disk-w 95%-c 98%-p /
Commander [check _ http] = / usr/local/nagios/libexec/check_tcp-H 192.168.1.1 Murp 80
Commanded [check _ user] = / usr/local/nagios/libexec/check_users-w 2-c 3
Then test whether the nrpe is running properly on the server side
Connect to host 192.168.1.1 port 5666: Connection refused [root@centos1 conf] # / usr/local/nagios/libexec/check_nrpe-H 192.168.1.2 (controlled side)
4. Start the ngios service of the main control terminal
# / etc/init.d/nagios restart
5. After starting nagios, observe the monitoring display interface
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.