6.自定义Nagios监控项

1、流程简介 nagios带有大量的插件,一般常见的服务均可在nagios官网下载到插件,也会有些自带的插件,却未直接被定义的,所以需要大家手动定义下 简单点说就是在commands.cfg中定义命令,如果需要变量可以在resource.cfg中定义(如数据库密码等),最后在需要监控的服务器配置文件中(如localhost.cfg)添加相应的服务即可 2、配置check_mysql服务 2.1、配置commands.cfg 在commands.cfg最后加入如下命令
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 加入如下信息
vi /usr/local/nagios/etc/resource.cfg
$USER7$=mysqlpass
2.3、配置localhost.cfg 添加mysql监控项
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、测试
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目录下 然后采用上述步骤即可添加监控项,有些系统参数可能需要官方文档才知如何调用,大部分插件官方都给予足够的说明

转载于:https://my.oschina.net/766/blog/210968

猜你喜欢

转载自blog.csdn.net/weixin_34085658/article/details/91546398
今日推荐