6.自定义Nagios监控项
1、流程简介
nagios带有大量的插件,一般常见的服务均可在nagios官网下载到插件,也会有些自带的插件,却未直接被定义的,所以需要大家手动定义下
简单点说就是在commands.cfg中定义命令,如果需要变量可以在resource.cfg中定义(如数据库密码等),最后在需要监控的服务器配置文件中(如localhost.cfg)添加相应的服务即可
2、配置check_mysql服务
2.1、配置commands.cfg
在commands.cfg最后加入如下命令
1
2
3
4
5
6
|
vi
/
usr
/
local
/
nagios
/
etc
/
object
/
commands
.
cfg
# 'check_mysql ' command definition
define
command
{
command_name
check_mysql
command
_line
$
USER1
$
/
check_mysql
-
H
$
HOSTADDRESS
$
-
u
root
-
p
$
USER7
$
}
|
2.2、配置resource.cfg
加入如下信息
1
2
|
vi
/
usr
/
local
/
nagios
/
etc
/
resource
.
cfg
$
USER7
$
=
mysqlpass
|
2.3、配置localhost.cfg
添加mysql监控项
1
2
3
4
5
6
7
8
9
|
vi
/
usr
/
local
/
nagios
/
etc
/
object
/
localhost
.
cfg
# 检查远程Linux主机的Mysql服务
define
service
{
use
generic
-
service
host_name
localhost
service_description
MySQL
check_command
check_mysql
notifications
_enabled
0
}
|
2.4、测试
1
|
service
nagios
restart
|
现在登录web查看mysql监控项
看到如下信息
ok,大功告成
Uptime: 949983 Threads: 3 Questions: 312804 Slow queries: 0 Opens: 154 Flush tables: 1 Open tables: 64 Queries per second avg: 0.329
3、总结
nagios是一款非常强大的监控工具,只要大家深入研究,多多尝试总会得到你想要的
日后如果安装插件,只需将插件下载到/usr/local/nagios/libexec目录下
然后采用上述步骤即可添加监控项,有些系统参数可能需要官方文档才知如何调用,大部分插件官方都给予足够的说明
收 藏
成长的对话版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!