In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
One of the monitoring tools Nagios: monitoring local NFS and external HTTP, MySQL services
Nagios is an open source free network monitoring tool that can effectively monitor the host status of Windows, Linux and Unix, network settings such as switches and routers, printers and so on. When the system or service status is abnormal, send an email or SMS alarm to notify the website operation and maintenance personnel as soon as possible, and send out a normal email or SMS notification after the status is restored.
Characteristics of Nagios:
1. Monitoring services such as http, MySQL, nfs, tcp, ping, etc.
2. Monitor the host resource cpu, load, I / O, virtual and memory disk utilization, etc.
3. Support email Wechat and other alarm communications.
4. Optional web meeting to check the current network status, etc.
The composition of Nagios:
Nagios monitoring software is a monitoring platform. Nagios monitoring generally consists of a main program (nagios), a plug-in (nagios-plugins), and some optional plug-ins.
1. NRPE component
Nrpe components generally work on the standby control side, and Zhu Yong is used to monitor local resources, including load (uptime), CPU (top, Sar), disk (df-hi), memory (free), Imax O (iostat), etc.
2 、 NSClient++
3 、 NDOUtils
Complete monitoring picture of Nagios:
The principle is as follows:
Usually, the request for obtaining data is initiated by the nagios server, and the command to be obtained is carried by the check_nrpe plug-in and passed to the nrpe daemon on the monitoring side. The default is port 5666. The nrpe process reads the command information sent by the corresponding server in the nrpe.Cfg, obtains the data by calling the local plug-in, and then returns it to the check_nrpe of the nagios server, and then transmits it to the web page of the nagios tactics.
One: experimental objectives
1. Monitor the external server NFS, and the server acts as the client
2. Monitor the MySQL service of the external server
3. Monitor external server httpd
4. Monitor the private information of external servers
Second, the experimental environment
VMare
Action
Hostnam
Ip address
Installed softwar
RHEL-6.5
Server side
Yu61
192.168.1.61
Nagios software, nagios plug-ins, nrpe,LAMP environment, NFS
RHEL-6.5
Client
Yu62
192.168.1.62
Nagios plug-ins, nrpe, mysql-server, IO
RHEL-6.5
Client
Yu63
192.168.1.63
Nagios plug-ins, nrpe, NFS, Http,
# all servers need to turn off the firewall
Three: experimental steps
Install the server environment
1. Install the LAMP environment
The Nagios server needs a web interface to display the monitoring effect, and the monitoring content is dynamic, so the LAMP environment is used, Apache is used for web to display monitoring effect, and PHP is used to display monitoring dynamic information.
[root@yu61 ~] # mkdir-p / home/yu/tools [root@yu61 ~] # yum install-y httpd gccglibc glibc-common php gd gd-devel libpng libmng libjpeg zlib mysql-server [root@yu61 ~] # service iptables stop [root@yu61 ~] # service httpd restart [root@yu61 ~] # vim / var/www/html/index.php
2. Add users
The Apache user exists by default, and the group defaults to daemon, which needs to be changed to nagios. Only in this way can it have permission to access the installed nagios directory and execute relevant cgi commands, such as closing nagios through the browser interface, stopping a faulty object from sending alarm messages, and so on.
Add a nagios account to run Nagios. Of course, it can also be run with root, but for security reasons, it can be run under an ordinary account, and this account is not assigned shell login rights.
[root@yu61 tools] # useradd-s / sbin/nollogin nagios [root@yu61 tools] # groupadd nagcmd [root@yu61 tools] # usermod-a-G nagcmd nagios [root@yu61 tools] # usermod-a-G nagcmd apache
3. Install the nagios main program
[root@yu61 tools] # tar jxvf nagios-cn-3.2.3.tar.bz2 [root@yu61 tools] # cd nagios-cn-3.2.3 [root@yu61 nagios-cn-3.2.3] #. / configure-- with-command-group=nagcmd [root@yu61 nagios-cn-3.2.3] # make all [root@yu61 nagios-cn-3.2.3] # make install [root@yu61 nagios-cn-3.2.3] # make install-init [root @ yu61 nagios-cn-3.2.3] # make install-commandmode [root@yu61 nagios-cn-3.2.3] # make install-config [root@yu61 nagios-cn-3.2.3] # make install-webconf [root@yu61 nagios-cn-3.2.3] # htpasswd-c / usr/local/nagios/etc/htpasswd.users mobanche
There are two ways to check the integrity of a file. One is the absolute path, the other is to start the detection.
The first kind:
[root@yu61 nagios] # / usr/local/nagios/bin/nagios-v / usr/local/nagios/etc/nagios.cfg
The second kind:
[root@yu61 nrpe-2.12] # vim / etc/init.d/nagios
# delete "> / dev/null 2 > & 1;" in line 178 of the startup item.
[root@yu61 objects] # vim / usr/local/nagios/etc/cgi.cfguse_authentication=0 # changed to 0 [root@yu61 nrpe-2.12] # / etc/init.d/nagios checkconfig Total Warnings: 0Total Errors: 0
4. Install the nagios-plugins plug-in package
The plug-in package of Nagios is to realize the command or program to obtain data information. After using these commands or programs, nagios can get the required data, and then give an alarm and display.
[root@yu61 tools] # yum install perl-devel openssl-devel-y [root@yu61 tools] # tar zxvf nagios-plugins-1.4.16.tar.gz [root@yu61 tools] # cd nagios-plugins-1.4.16 [root@yu61 nagios-plugins-1.4.16] #. / configure-with-nagios-user=nagios-with-nagios-group=nagcmd-enable-perl-modules-with-mysql [root@yu61 nagios-plugins-1.4.16] # make-j 4 [root@yu61 nagios-plugins-1.4.16] # make install
5. Install nrpe software package
Nrpe is usually used to install the monitored side, where the nrpe software is also installed on the server side, because the nagios server side needs the check_nrpe plug-in to do passive inspection, if the server side does not install the nrpe plug-in, then there is no such plug-in. Secondly, the local resources on the nagios server side also need to be monitored, so the nagios server side will also be regarded as the client side.
[root@yu61 tools] # tar zxvf nrpe-2.12.tar.gz [root@yu61 tools] # cd nrpe-2.12 [root@yu61 nrpe-2.12] #. / configure [root@yu61 nrpe-2.12] # make all & & make instll
6. Server attachment
(1) check the administrative account information of logging in to nagios
[root@yu61 nagios-cn-3.2.3] # grep AuthUserFile / etc/httpd/conf.d/nagios.conf AuthUserFile / usr/local/nagios/etc/htpasswd.users
(2) set nagios to boot automatically
[root@yu61 nagios-cn-3.2.3] # chkconfig postfix on [root@yu61 nagios-cn-3.2.3] # chkconfig postfix-- listpostfix 0: off 1: close 2: enable 3: enable 4: enable 5: enable 6: close
(3) Mail alarm
[root@yu61 nagios-cn-3.2.3] # / etc/init.d/httpd reload [root@yu61 nagios-cn-3.2.3] # sed-n '35p' / usr/local/nagios/etc/objects/contacts.cfg email 741215208roomqq.com; grant select on nagdb.* to yu@'192.168.1.61'
4. Restart mysqld and nagios services
[root@yu62] # / etc/init.d/httpd restart [root@yu62 ~] # / etc/init.d/mysqld restart [root@yu61 ~] # / etc/init.d/nagios restart [root@yu61 objects] # / usr/local/nagios/libexec/check_mysql-H 192.168.1.64-u nagdb-d nagdbUptime: 516 Threads: 1 Questions: 6 Slow queries: 0 Opens: 15 Flush tables: 1 Open tables:8 Queries per second avg: 0.11
# after the above command is executed, the following message appears, indicating that it is normal to connect users in the mysql of 192.168.1.64.
5) Test and view hosts and services:
Http://192.168.1.63/nagios/
Actual combat: monitoring external server NFS service
1. Install and configure NFS server
[root@yu61 objects] # service rpcbind statusrpcbind (pid 1614) is running. [root@yu61 ~] # vim / etc/exports/tmp * (rw) [root@yu61 ~] # / etc/init.d/nfs restart [root@yu61 ~] # showmount-e 192.168.1.61Export list for 192.168.1.61:/tmp *
2. Edit the check_nfs command script
[root@yu61 libexec] # pwd/usr/local/nagios/libexec [root@yu61 libexec] # cat check_nfs check_nfs#!/bin/bash. / data1/server/nagios/libexec/utils.shCHECKNAME= "Mount NFS" RESULT= "EXIT_STATUS=$STATE_OKNFSFSTAB= `LC _ ALL=C awk'! / ^ # / & & $3 ~ / ^ nfs/ & & $3! =" nfsd "& & $4! ~ / noauto/ {print $1}'/ etc/ Fstab`NFSMTAB = `LC _ ALL=C awk'$3 ~ / ^ nfs/ & & $3! =" nfsd "& $2! =" / "{print $1}'/ proc/ mounts`theend () {echo $RESULT exit $EXIT_ STATUS} CHECK_MOUNT () {LIST= "" for list in $NFSFSTAB do NFS_MOUNT=$ (LC_ALL=C cat / proc/mounts | cut-d ""-f 1 | grep "${list} $") if [- z "${NFS_MOUNT}"] Then LIST= "$LIST$list" fi done} if [- n "${NFSMTAB}"]; then CHECK_MOUNT if [- z "${LIST}"]; then RESULT= "$CHECKNAME OK-NFS BE MOUNTED PROPERLY" EXIT_STATUS=$STATE_OK else RESULT= "$CHECKNAME WARNING-${LIST} NOT BE MOUNTED" EXIT_STATUS=$STATE_WARNING fielse RESULT= "$CHECKNAME CRITICAL-ALL NFS NOT BE MOUNTED" EXIT_STATUS=$STATE_CRITICALfiTheend
Note: to modify permissions for security reasons, the default is 644 root.
[root@yu61 libexec] # chmod 755 check_nfs [root@yu61 libexec] # chown nagios:nagcmd check_nfs [root@yu61 libexec] # ll check_nfs-rwxr-xr-x 1 nagios nagcmd 973 May 22 13:27 check_nfs
3. Modify the configuration file
[root@yu61 objects] # cat hosts.cfg # # add # chreck_host##define host {use linux-server host_name yu61 alias at the end Nfs Service address 192.168.1.61 icon_p_w_picpath switch.gif statusmap_p_w_picpath switch.gd2 2d_coords 100200 3d_coords 100200100}
[root@yu61 objects] # cat service.cfg # # add # check_server_mysql##define service {use local-service host_name yu61 at the end Service_groups nfs service group service_description nfs service check_command checklists nrpeals checklists nfs} # # check_server_mysql_groups##define servicegroup { Servicegroup_name nfs Service Group alias nfs Server members yu61 Nfs Service}
[root@yu61 objects] # vim commands.cfg # # add # 'check_nrpe' command definitiondefinecommand {command_name check_nrpe command_line $USER1 $/ check_nrpe-H $HOSTADDRESS$-c$ARG1 $} definecommand {command_name check_nfs command_line $USER1 $/ check_nfs} at the end
4. Check service configuration and start service
[root@yu61 objects] # / etc/init.d/nagios checkconfigTotal Warnings: 0Total Errors: 0 [root@yu61 objects] # / etc/init.d/nagios reload
5. Test and view hosts and services
Http://192.168.1.63/nagios/
Actual combat: monitoring external server httpd service
1. Modify the configuration file
[root@yu61 objects] # cat hosts.cfg # # Last edit define host {use linux-server host_name yu63 alias http service address 192.168.1.63 icon_p_w_picpath switch.gif statusmap_p _ w_picpath switch.gd2 2d_coords 100200 3d_coords 100200100}
[root@yu61 objects] # cat service.cfg # # finally add # check_server_httpd-63##define service {use local-service host_name yu63 Service_groups http Service Group service_description http Service check_command check_http} # # check_server_http-63_groups## Define servicegroup {servicegroup_name http Service Group alias http Server members yu63 Http Service}
# Check_http commands are available by default
2. Check the configuration file and restart the service
[root@yu61 objects] # / etc/init.d/nagios checkconfig Total Warnings: 0Total Errors: 0 [root@yu63 nrpe-2.12] # service iptables stop [root@yu63 nrpe-2.12] # setenforce 1setenforce: SELinux is disabled [root@yu63 nrpe-2.12] # service httpd restart
3. Test and view hosts and services
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.