MySQL服务器部署nagios监控的方法详解

发布时间:2020-11-05编辑:脚本学堂
本文介绍下,在mysql服务器上部署nagios监控工具的具体方法,有需要的朋友参考下。

1,nagios安装
 

复制代码 代码示例:
[root@localhost nagios]# ll
总计 768
-rw-r--r-- 1 root root 713389 12-16 12:08 nagios-plugins-1.4.11-1.x86_64.rpm
-rw-r--r-- 1 root root  32706 12-16 12:09 nrpe-2.12-1.x86_64.rpm
-rw-r--r-- 1 root root  18997 12-16 12:08 nrpe-plugin-2.12-1.x86_64.rpm
Shell> rpm -ivh *.rpm --nodeps  --force

2,检测
 

复制代码 代码示例:
[root@rdb-s108 nagios]# /usr/lib64/nagios/plugins/check_mysql -unagios -P3306 -S -Hlocalhost -ppwdnagios -s/opt/mysql/product/mysql/mysql3306.sock -d
test -w 60 -c 100

3,加进配置文件里面去
 

复制代码 代码示例:
[root@rdb-s108 nagios]# vim /etc/nagios/nrpe.cfg
command[check_mysqlapi]=/usr/lib64/nagios/plugins/check_mysql -unagios -P3306 -S -Hlocalhost -ppwdnagios -s/opt/mysql/product/mysql/mysql3306.sock -d
test -w 60 -c 100
 

加监控主机服务器ip地址
 

复制代码 代码示例:
allowed_hosts = 127.0.0.1,192.168.188.110,10.80.98.2
-- 赋予权限
chmod 775 /usr/lib/nagios/plugins/check_mysql
-- 磁盘监控,查看
fdisk -l
Disk /dev/sda: 193.2 GB, 193273528320 bytes
255 heads, 63 sectors/track, 23497 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       23497   188635230   8e  Linux LVM
取 Disk 后面的 /dev/sda 作为磁盘监控

4,重启nagios,失败
5,先删除再启动
 

复制代码 代码示例:
[root@rdb-s108 bin]# killall nrpe 【】先删除
[root@rdb-s108 local]#  /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -d
[root@rdb-s108 local]#

6,vim "/etc/nagios/nrpe.cfg" 看情况
 

复制代码 代码示例:
注释:# command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1
打开:#command[check_disk]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
grant SUPER,REPLICATION CLIENT on *.* to nagios@'localhost' identified by 'pwdnagios';

 

7,检测状况
 

复制代码 代码示例:
service nrpe status

8,检查
 

复制代码 代码示例:
shell> vim /etc/nagios/nrpe.cfg
command[check_disk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda
shell> fdisk -l
shell> service nrpe restart