This article refers to the http://wangzan18.blog.51cto.com/8021085/1628984
http://linuxnote.blog.51cto.com/9876511/1637773
First, Nagios overview
Nagios is a plug-in structure, it does not have any monitoring function, all the monitoring is through the plug-in, so it is highly modular and flexible. Nagios monitors objects into two categories: Hosts and services. Hosts typically refer to physical hosts, such as servers, routers, workstations, and printers, where hosts can also be virtual devices, such as Xen virtual Linux systems, and services typically refer to a particular feature, such as the httpd process that provides HTTP services. In order to manage the convenience, the host and services can also be planned as the main unit and service groups.
Nagios does not monitor any specific numeric indicators, such as the number of processes on the operating system, and it only describes the state of the monitored objects in four abstract properties: OK, WARNING, critical, and unknown. As a result, administrators only need to focus on and define the thresholds for the warning and critical states of a monitored object. Nagios passes the thresholds for warting and crtical to the plug-in and is responsible for monitoring and analyzing the results of a specific object by the plug-in, with output information such as status information (Ok,warning,critical or Unkown) and additional detailed information.
Second, the environment
System: CentOS 6.4x64 Minimized installation
nagios-server:192.168.3.71
nagios-client:192.168.3.72
Iii. installation of Nagios
Nagios is typically comprised of a main program (Nagios), a plug-in program (Nagios-plugins), and four optional addon (NRPE, NSCA, nsclient++, and Ndoutils). Nagios's monitoring work is done through plug-ins, so Nagios and nagios-plugins are the necessary components for server-side work. In four addon, Nrpe is used to execute script plug-ins on the monitored remote Linux/unix hosts to monitor these host resources, NSCA is used to enable the monitored remote Linux/unix host to proactively send monitoring information to the Nagios server ( This is especially useful in redundant monitoring modes); nsclient++ is a component that is installed on Windows hosts when Windows hosts are monitored, while ndoutils is used to store the configuration information of Nagios and the data generated by each event into the database. To enable rapid retrieval and processing of these data. Of these four addon (attachments), Nrpe and nsclient++ work on the client, ndoutils work on the server side, and NSCA need to be installed both on the server side and on the client.
Currently, Nagios can only be installed on a Linux system host, and its compilation requires GCC. At the same time, if you intend to use the Web interface management tools, you also need to have Apache server and GD graphics library support
Installing Nagios Dependencies
[[email protected] ~]# yum-y install httpd gcc glibc glibc-common gd gd-devel php php-mysql MySQL mysql-devel mysql-serve R NTP
Sync time
[Email protected] ~]# ntpdate asia.pool.ntp.org25 may 10:45:35 ntpdate[22419]: Step time server 118.67.201.10 offset 140. 952903 Sec[[email protected] ~]# hwclock-w[[email protected] ~]# crontab-lmailto= "" */10 * * * */usr/sbin/ntpdate ASIA.P ool.ntp.org
Add users and groups required for Nagios run
[Email protected] ~]# groupadd nagcmd[[email protected] ~]# useradd-g nagcmd Nagios
Add Apache to
[Email protected] ~]# usermod-a-G nagcmd Apache
download Nagios, and install
[[email protected] ~]# wget http://sourceforge.net/projects/nagios/files/nagios-3.x/ nagios-3.3.1/nagios-3.3.1.tar.gz/download[[email protected] ~]# tar xf nagios-3.3.1.tar.gz [[email protected] ~]# cd nagios[[email protected] nagios]# ./configure --with-command-group=nagcmd --enable-event-broker [[email protected] nagios]# make all #安装所有主程序 [[email protected] nagios]# make install #安装主程序, Chi and HTML files [[email protected] nagios]# make install-init #安装启动脚本 [[Email protected] nagios]# make install-commandmode #配置目录权限 [[email protected] nagios]# make install-config #安装示例文件 [[email protected] nagios]# make install-webconf # Install the Nagios web site configuration file
Email address to configure the alert information for Nagios
#编辑文件前, first backup [[email protected] nagios]# cp/usr/local/nagios/etc/objects/contacts.cfg/usr/local/nagios/etc/objects/ contacts.cfg.$ (date +%f). bak# Email address modified to the address you want to set [[email protected] nagios]# sed-i ' S#[email protected]#[email protected]# '/usr/local/nagios/etc/objects/contacts.cfg[[email protected] nagios]# grep [email protected]/usr/local/nagios/etc/ objects/contacts.cfg email [email protected]; <<***** change YOUR EMAIL ADDRESS ******
Create a user and password to authenticate to a login
#这里设置密码weyee2014 [[email protected] nagios]# htpasswd-c/usr/local/nagios/etc/htpasswd.users nagiosadmin
Turn off iptables and start httpd
[[Email protected] nagios]# service iptables stop[[email protected] nagios]# service httpd start
Installing Nagios-plugins
#下载nagios-plugins[[email protected] ~]# wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz[[email Protected] ~]# tar xf nagios-plugins-2.0.3.tar.gz [[email protected] ~]# CD Nagios-plugins-2.0.3[[email protected] Nagios -plugins-2.0.3]#./configure--with-nagios-user=nagios--with-nagios-group=nagios[[email protected] nagios-plugins-2.0.3]# make && make install
Configuring the Nagios Boot level
#将nagios添加到开机自启动 [[email protected] ~]# chkconfig -- add nagios[[email protected] ~]# chkconfig nagios on# checking the configuration file [[email protected] ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg [[ Email protected] ~]# service nagios startstarting nagios: done. [[email protected] ~]# ps aux |grep nagiosnagios 45840 0.0 0.1 28048 1396 ? ssl 11:25 0:00 /usr/local/nagios/bin/nagios -d /usr/local/ nagios/etc/nagios.cfgroot 45852 0.0 0.0 103248 832 pts/0 s+ 11:25 0:00 grep nagios
Access Http://192.168.3.71/nagios, username and password are set in the nagiosadmin:weyee2014 above
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/5F/wKiom1VilvjQa-lYAAZTSwYNjbg238.jpg "title=" Nagios-admin. JPG "alt=" Wkiom1vilvjqa-lyaaztswynjbg238.jpg "/>
Iv. installation of Nrpe
Nrpe needs Nagios-pluin support.
[Email protected] ~]# wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz/ Download[[email protected] ~]# tar xf nrpe-2.15.tar.gz [[email protected] ~]# CD Nrpe-2.15[[email protected] nrpe-2.15]#. /configure--with-nrpe-user=nagios--with-nrpe-group=nagios--with-nagios-user=nagios--with-nagios-group=nagios-- Enable-command-args--enable-ssl[[email protected] nrpe-2.15]# make All[[email protected] nrpe-2.15]# make Install-plugin[[email protected] nrpe-2.15]# make Install-daemon[[email protected] nrpe-2.15]# make Install-daemon-config
Configure Nrpe
#编辑NRPE的配置文件 [[email protected] ~]# egrep -v "^$|^#" /usr/local/nagios/etc/ nrpe.cfg log_facility=daemonpid_file=/var/run/nrpe.pidserver_port=5666server_address=192.168.3.71 #修改这里nrpe_user =nagiosnrpe_group=nagiosallowed_hosts=192.168.3.0/24 #修改这里 dont_blame_nrpe=0allow_bash_command_substitution=0debug= 0command_timeout=60connection_timeout=300command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Zcommand[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
Start Nrpe
[Email protected] ~]#/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d[[email protected] ~]# netstat- ANPT |grep 5666tcp 0 0 192.168.3.71:5666 0.0.0.0:* LISTEN 48946/nrpe
Write the Nrpce startup script and place the script under the/ETC/INIT.D path
[[email protected] ~]# cat /etc/init.d/nrped #!/bin/bash# chkconfig: 2345 88 12# description: nrpe daemonnrpe=/usr/local/nagios/bin/nrpenrpeconf=/usr/local/ nagios/etc/nrpe.cfgcase "$" instart) echo -n "Starting nrpe daemon ..." $NRPE -c $NRPECONF -decho " done.";; Stop) echo -n "Stopping nrpe daemon ..." pkill -u nagios nrpeecho " Done. ";; Restart) $0 stopsleep 2$0 start;; *) echo "Usage: $0 start|stop|restart";; esacexit 0# gives the script permission and tests [[email protected] ~]# chmod +x /etc/init.d/nrped [[ email protected] ~]# chkconfig --add nrped[[email protected] ~]# chkconfig nrped on[[email protected] ~]# service nrped stopstopping Nrpe daemon... done. [[Email protected] ~]# netstat -anpt |grep nrpe[[email protected] ~]# pidof nrpe# Restart nrpe[[email protected] ~]# service nrped startstarting nrpe daemon... done. [[email protected] ~]# netstat -anpt |grep nrpetcp 0 0 192.168.3.71:5666 0.0.0.0:* listen 49019/nrpe [[email protected] ~]# pidof nrpe49019[[email protected] ~]# ps aux |grep nrpe |grep -v grepnagios 49019 0.0 0.1 39240 1312 ? ss 11:53 0:00 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/ nrpe.cfg -d
V. Installing NRPE on the client
Installing the Nrpe on the nagios-client requires first installing the Nagios-plugin
[[email protected] ~]# yum install ntpdate gcc* openssl openssl-devel -y[[email protected] ~]# ntpdate asia.pool.ntp.org25 may 13:52:18 ntpdate[22302]: step time server 212.26.18.41 offset 2955.354923 sec[[email protected] ~]# hwclock -w[[email protected] ~]# crontab -lmialto= "" */10 * * * * /usr/sbin/ntpdate asia.pool.ntp.org[[email protected] ~]# useradd -s /sbin/nologin nagios[[email protected] ~]# wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz[[email protected] ~]# tar xf nagios-plugins-2.0.3.tar.gz [[email protected] ~]# cd nagios-plugins-2.0.3[[email protected] nagios-plugins-2.0.3]# ./configure -- With-nagios-user=nagios --with-nagios-group=nagios[[email protected] nagios-plugins-2.0.3]# make all[[email protected] Nagios-plugins-2.0.3]# make install
Install Nrpe
[[email protected] ~]# wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/ nrpe-2.15/nrpe-2.15.tar.gz/download[[email protected] nrpe-2.15]# ./configure -- with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group= Nagios --enable-command-args --enable-ssl[[email protected] nrpe-2.15]# make all [[email protected] nrpe-2.15]# make install-plugin[[email protected] nrpe-2.15]# make install-daemon[[email protected] nrpe-2.15]# make install-daemon-config# Modify the configuration file [[email protected] nrpe-2.15]# egrep -v "^#|^$" /usr/local/nagios/etc/ nrpe.cfg log_facility=daemonpid_file=/var/run/nrpe.pidserver_port=5666server_address=192.168.3.72 #监控本机哪个IPnrpe_user =nagiosnrpe_group= Nagiosallowed_hosts=192.168.3.71 #允许哪个IP对本机进行监控 # Write Nrpe startup script [[email protected] ~]# cat /etc/init.d/nrped #!/bin/bash# chkconfig: 2345 88 12# description: nrpe daemonnrpe=/usr/local/nagios/bin/nrpenrpeconf=/usr/local/nagios/etc/ nrpe.cfgcase "$" instart) echo -n "Starting nrpe daemon ..." $NRPE -c $ nrpeconf -decho " done.";; Stop) echo -n "Stopping nrpe daemon ..." pkill -u nagios nrpeecho " Done. ";; Restart) $0 stopsleep 2$0 start;; *) echo "Usage: $0 start|stop|restart";; esacexit 0[[email protected] ~]# chmod +x /etc/init.d/nrped [[email protected] ~]# chkconfig --add nrped[[email protected] ~]# chkconfig Nrped on[[email protected] ~]# service nrped startstarting nrpe daemon... done. [[email protected] ~]# netstat -anpt |grep nrpetcp 0 0 192.168.3.72:5666 0.0.0.0:* listen 46882/nrpe
To this nagios and the client installation is complete
This article is from the "ly36843" blog, please be sure to keep this source http://ly36843.blog.51cto.com/3120113/1654887
CentOS 6.4x64 Installation Deployment Nagios