Nagios is a mature Linux monitoring system running state and network information Kaiyuan IT Infrastructure monitoring system, Nagios can monitor the designated local or remote host and services, such as HTTP services, FTP services, and provide exception notification, event handling and other functions, When the host or service failure, Nagios can also be in the form of mail, SMS, etc. in the first time to notify. Nagios can be run on Linux and UNIX platforms, while providing an optional browser-based Web interface to allow system administrators to view the system's operating status, network status, various system problems, and log anomalies.
Environment: 192.168.0.201 MySQL host rhel6.4
192.186.0.202 Nagios Host rhel6.4
Install related packages:
Yum install httpd gcc make perl-extutils-embed.x86_64-y yum localinstall gd-devel-2.0.35-11.el6.x86_64.rpm- y
Install Nagios:
Useradd nagios
usermod-g nagios Apache
#编译所需软件包
#运行 nagios service user
#使 Apache user has write access to the Nagios directory, otherwise web page operation Failed
tar jxf nagios-cn-3.2.3.tar.bz2
#nagios Software Installation
CD nagios-cn-3.2.3
./configure– Enable-embedded-perl make all //Follow the prompts to complete the installation make
install make
install-init
make Install-commandmode
make Install-config
makes install-webconf //Under Apache This command allows for rapid integration
Install Nagios-plugins:
Yum install mysql-devel openssl-devel-y
tar zxf nagios-plugins-1.4.15.tar.gz
CD nagios-plugins-1.4.15
./configure--with-nagios-user=nagios--with-nagios-group=nagios--enable-extra-opts--enable-libtap- Enable-perl-modules make make
install
Configure Nagios:
Vi/usr/local/nagios/etc/nagios.cfg
#cfg_file =/usr/local/nagios/etc/objects/localhost.cfg #注释掉localhost. cfg file
cfg_file=/usr/local/nagios/etc/ Objects/services.cfg #新建 services.cfg file, store service and service group definition
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg #新建 hosts.cfg files, hosting and host group definitions
Configure HOSTS.CFG:
Vi/usr/local/nagios/etc/objects/hosts.cfg
Define host{ //Host management use Linux-server//using default host Rule
host_name vm2.example.com //host name
alias Nagios vm2 //host alias
address 127.0.0.1 //Host IP addresses
icon_image switch.gif //Icon
STATUSMAP_ Image switch.gd2
2d_coords 100,200 //2d images coordinates
3d_coords 100,200,100 //3d image coordinates
}
define hostgroup{ //host group Management
hostgroup_name linux-servers //host group name
alias Linux servers// alias
Members * //* represent all the above hosts
Configure MySQL
----Establish a NAGDB dedicated database
Mysql> CREATE DATABASE nagdb default Charset=utf8;
Query OK, 1 row affected (0.01 sec)
Mysql> Grant Select on nagdb.* to ' nagios ' @ '% ';
Query OK, 0 rows Affected (0.00 sec)
mysql> update mysql.user set ' Password ' = Password (' Nagios ') where ' user ' = ' nagios ';
Error 1064 (42000): You have a error in your SQL syntax; Check the manual that corresponds to your MySQL server version for the right syntax to use near ' Password ' = Password (' NA Gios ') where ' User ' = ' Nagios ' at line 1
mysql> update mysql.user Set Password = Password (' Nagios ') where user= ' Nagi Os ';
Query OK, 1 row affected (0.03 sec)
Rows matched:1 changed:1 warnings:0
Query OK, 0 rows Affected (0.00 sec)
----Use the command to verify:
[Root@node2 etc]#/usr/local/nagios/libexec/check_mysql-h 192.168.1.152-u nagios-d nagdb-p
uptime:3374 threads:1 questions:11 Slow queries:0 opens:33 Flush tables:1 Open tables:26 queries per second avg:0. 003
Note: If present:/usr/local/nagios/libexec/check_mysql:error while loading shared libraries:libmysqlclient.so.18:cannot open Shared object File:no such file or directory
Please check the $mysql_home/lib
[Root@node2 lib]# ln-s./libmysqlclient.so.18.0.0/usr/lib/libmysqlclient.so.18
Configure Nrpe.cfg
[Root@node2 etc]# Tail/usr/local/nagios/etc/nrpe.cfg
Command[check_mysql]=/usr/local/nagios/libexec/check_mysql-h 192.168.1.152-u nagios-d nagdb-p nagios //Join this trip
Configuring the Nagios service side
[Root@node1 etc]# cat services.cfg //Add below
Define service{
use local-service
host_name node2
service_description MySQL
Check_command check_nrpe!check_mysql
notifications_enabled 1
}
Finally, restart the Nrpe and service-side Nagios.