nagios mysql 监控,【MySQL】数据库监控(Nagios)

[root@wallet03 ~]# yum install -y perl-DBI perl-DBD-MySQL

[root@wallet03 ~]# tar zxvf check_mysql_health-2.2.2.tar.gz

[root@wallet03 ~]# cd check_mysql_health-2.2.2

[root@wallet03 check_mysql_health-2.2.2]# ./configure --prefix=/usr/local/nagios \

--with-nagios-user=nagios \

--with-nagios-group=nagios

[root@wallet03 check_mysql_health-2.2.2]# make

[root@wallet03 check_mysql_health-2.2.2]# make install

[root@wallet03 ~]# cd /usr/local/nagios/libexec/

[root@wallet03 libexec]# ./check_mysql_health

Please select a mode

Copyright (c) 2009 Gerhard Lausser

Check various parameters of MySQL databases

Usage:

check_mysql_health [-v] [-t ] [[--hostname ]

[--port  | --socket ]

--username  --password ] --mode 

[--method mysql]

[root@wallet03 libexec]# ./check_mysql_health --hostname 192.168.1.202 --username nagios --password nagios --mode connection-time

OK - 0.02 seconds to connect as nagios | connection_time=0.0169s;1;5

[root@wallet03 libexec]# ./check_mysql_health --hostname 192.168.1.202 --username nagios --password nagios --mode uptime

OK - database is up since 7542 minutes | uptime=452541s

[root@wallet03 ~]# cd /usr/local/nagios/etc/objects

[root@wallet03 objects]# vi commands.cfg

define command{

command_name    check_mysql

command_line    $USER1$/check_mysql_health --hostname $ARG1$ --username nagios --password nagios --mode $ARG2$

}

[root@wallet03 objects]# vi mysql.cfg

define host{

use                     linux-server

host_name               wallet01

alias                   wallet01

icon_image              redhat.gif

statusmap_image         redhat.gd2

address                 192.168.1.202

}

define hostgroup{

hostgroup_name  database

alias           database

members         wallet02

}

define service{

host_name                       wallet02

use                             generic-service

service_description             mysql connection time

check_command                   check_mysql!192.168.1.202!connection-time

}

define service{

host_name                       wallet02

use                             generic-service

service_description             mysql uptime

check_command                   check_mysql!192.168.1.202!uptime

}

define service{

host_name                       wallet02

use                             generic-service

service_description             mysql client-connected

check_command                   check_mysql!192.168.1.202!threads-connected

}

define service{

host_name                       wallet02

use                             generic-service

service_description             mysql slow-queries

check_command                   check_mysql!192.168.1.202!slow-queries

}

define service{

host_name                       wallet02

use                             generic-service

service_description             mysql tmp-disk-tables

check_command                   check_mysql!192.168.1.202!tmp-disk-tables

}

define service{

host_name                       wallet02

use                             generic-service

service_description             mysql slave-lag

check_command                   check_mysql!192.168.1.202!slave-lag

}

define service{

host_name                       wallet02

use                             generic-service

service_description             mysql slave-io-running

check_command                   check_mysql!192.168.1.202!slave-io-running

}

define service{

host_name                       wallet02

use                             generic-service

service_description             mysql slave-sql-running

check_command                   check_mysql!192.168.1.202!slave-sql-running

}

[root@wallet03 ~]# cd /usr/local/nagios/etc

[root@wallet03 etc]# vi icinga.cfg

cfg_file=/usr/local/nagios/etc/objects/mysql.cfg

[root@wallet03 ~]# service icinga restart

Running configuration check...OK

Stopping Icinga: Waiting for icinga to exit ..Stopping icinga done.

Starting icinga: Starting icinga done.

标签:wallet03,service,数据库,MySQL,Nagios,mysql,nagios,root,check

来源: https://blog.51cto.com/13598811/2356241

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值