共计 22883 个字符,预计需要花费 58 分钟才能阅读完成。
1,监控插件下载
Mongodb 插件下载地址为:git clone git://github.com/mzupan/nagios-plugin-mongodb.git,刚开始本人这里没有安装 gitpub 环境,找网友帮忙下载的,之后上传到了 Linux 公社资源网站,新的下载地址为:
—————————————— 分割线 ——————————————
免费下载地址在 http://linux.linuxidc.com/
用户名与密码都是www.linuxidc.com
具体下载目录在 /2014 年资料 /10 月 /10 日 /Nagios 监控 MongoDB 分片集群服务实战
下载方法见 http://www.linuxidc.com/Linux/2013-07/87684.htm
—————————————— 分割线 ——————————————
网络监控器 Nagios 全攻略 http://www.linuxidc.com/Linux/2013-07/87067.htm
Nagios 搭建与配置详解 http://www.linuxidc.com/Linux/2013-05/84848.htm
Nginx 环境下构建 Nagios 监控平台 http://www.linuxidc.com/Linux/2011-07/38112.htm
在 RHEL5.3 上配置基本的 Nagios 系统(使用 Nagios-3.1.2) http://www.linuxidc.com/Linux/2011-07/38129.htm
CentOS 5.5+Nginx+Nagios 监控端和被控端安装配置指南 http://www.linuxidc.com/Linux/2011-09/44018.htm
Ubuntu 13.10 Server 安装 Nagios Core 网络监控运用 http://www.linuxidc.com/Linux/2013-11/93047.htm
2,添加新的 mongodb 监控命令
因为 mongodb 服务是和 mysql 从库公用一台物理机,之前已经做了基础 nagios 以及 mysql 服务监控,所以这里只需要在原来的基础上添加 mongodb 命令和服务即可。Nagios 监控 mysql 请参考:http://www.linuxidc.com/Linux/2014-10/107809.htm 以及 http://www.linuxidc.com/Linux/2014-07/104241.htm。所以这里需要添加的 mongodb 监控命令如下所示:
[root@wgq objects]# cd /usr/local/nagios/etc/objects
[root@wgq objects]# vim commands.cfg
define command {
command_name check_mongodb
command_line $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$
}
define command {
command_name check_mongodb_database
command_line $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -d $ARG5$
}
define command {
command_name check_mongodb_collection
command_line $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -d $ARG5$ -c $ARG6$
}
define command {
command_name check_mongodb_replicaset
command_line $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -r $ARG5$
}
define command {
command_name check_mongodb_query
command_line $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -q $ARG5$
}
3,添加 mongodb 监控服务
mongodb 的服务也需要单独重新添加,如下所示:
# 检测 mongodb 服务的连接时间,超过 2 秒就普通报警,5 秒就严重报警
define service{
host_name dbm1slave1
service_description Mongo Connect Check
check_command check_mongodb!connect!30000!2!5
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# 检查 mongodb 的连接数,超过 150 普通报警,200 严重报警
define service{
host_name dbm1slave1
service_description Mongo Free Connections
check_command check_mongodb!connections!27017!70!80
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# 检查 mongodb 复制完成的百分比率,确保 primary 和 standby 的 time 是一致的。
define service{
host_name dbm1slave1
service_description Mongo Replication Lag
check_command check_mongodb!replication_lag!27017!15!30
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# 检查 mongodb 内存使用率,阀值与 mongodb 所在机器的总内存数相关
define service{
host_name dbm1slave1
service_description Mongo Memory Usage
check_command check_mongodb!memory!27017!20!28
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# 检查 mongodb Mapped 的内存使用率,阀值与 mongodb 所在机器的总内存数相关
define service{
host_name dbm1slave1
service_description Mongo Mapped Memory Usage
check_command check_mongodb!memory_mapped!27017!20!28
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# 检查 Lock Time 的百分率,如果 lock time 占据 mongo 运行时间的 5% 就普通报警,如果超过 10% 就严重报警
define service{
host_name dbm1slave1
service_description Mongo Lock Percentage
check_command check_mongodb!lock!27017!5!10
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check Average Flush Time,检查 mongo 服务器的平均 flush 时间,
define service{
host_name dbm1slave1
service_description Mongo Flush Average
check_command check_mongodb!flushing!27017!100!200
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check Last Flush Time,检查最新的 flush 时间,如果超过 200ms 就普通报警,超过 400ms 就严重报警
define service{
host_name dbm1slave1
service_description Mongo Last Flush Time
check_command check_mongodb!last_flush_time!27017!200!400
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check status of mongodb replicaset,检查 mongo 复制的状态
define service{
host_name dbm1slave1
service_description MongoDB state
check_command check_mongodb!replset_state!27017!0!0
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check status of index miss ratio,检查索引命中率,
define service{
host_name dbm1slave1
service_description MongoDB Index Miss Ratio
check_command check_mongodb!index_miss_ratio!27017!.005!.01
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check number of databases and number of collections
define service{
host_name dbm1slave1
service_description MongoDB Number of databases
check_command check_mongodb!databases!27017!300!500
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
define service{
host_name dbm1slave1
service_description MongoDB Number of collections
check_command check_mongodb!collections!27017!300!500
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check size of a database,检查库的大小
define service{
host_name dbm1slave1
service_description MongoDB Database size your-database
check_command check_mongodb_database!database_size!27017!300!500!your-database
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check index size of a database,检查库索引的大小
define service{
host_name dbm1slave1
service_description MongoDB Database index size your-database
check_command check_mongodb_database!database_indexes!27017!50!100!your-database
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check index size of a collection,检查集合 collection 的索引大小
define service{
host_name dbm1slave1
service_description MongoDB Database index size your-database
check_command check_mongodb_collection!collection_indexes!27017!50!100!your-database!your-collection
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check the primary server of replicaset,检查复制的 primary 服务
define service{
host_name dbm1slave1
service_description MongoDB Replicaset Master Monitor: your-replicaset
check_command check_mongodb_replicaset!replica_primary!27017!0!1!your-replicaset
#示例:check_command check_mongodb_replicaset!replica_primary!27017!0!1!shard2
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check the number of queries per second,检查每一秒的查询数量
define service{
host_name dbm1slave1
service_description MongoDB Updates per Second
check_command check_mongodb_query!queries_per_second!27017!200!150!update
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check Primary Connection,检查复制中与 primary 库的连接时间,超过 2 秒就普通报警,超过 4 秒就严重报警
define service{
host_name dbm1slave1
service_description Mongo Connect Check
check_command check_mongodb!connect_primary!27017!2!4
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check Collection State,检查 collection 状态,检查 mongo 服务组列表的每一个主机,可以检查重要 collection 的高可用性(锁、超时、服务配置的可用性),如果发现一个查询失败就会报警。
define service{
host_name dbm1slave1
service_description Mongo Collection State
check_command check_mongodb!collection_state!27017!your-database!your-collection
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
更多详情见请继续阅读下一页的精彩内容:http://www.linuxidc.com/Linux/2014-10/107826p2.htm
4,查看部分监控项效果
配置完 nagios 端服务,重启下 service nagios restart; 等上几分钟,nagios 监控界面就会出现完整的 mongo 服务信息,如下所示:
5,从 ps 中确定 mongodb 的架构
[root@db-m1-slave-1 ~]# ps -eaf|grep mongo
mongodb 2457 1 0 2013 ? 2-03:39:08 ./mongod –configsvr –dbpath /home/data/mongodb/config –port 20000 –logpath /home/data/mongodb/config.log –logappend –fork
mongodb 2804 1 0 2013 ? 1-10:02:33 mongos –configdb 192.168.12.62:20000,192.168.12.63:20000,192.168.12.72:20000 –port 30000 –chunkSize 64 –logpath /home/data/mongodb/mongos.log –logappend –fork
mongodb 3072 1 0 2013 ? 1-10:17:20 mongod –shardsvr –replSet shard1 –port 27017 –dbpath /home/data/mongodb/shard11 –oplogSize 2048 –logpath /home/data/mongodb/shard11.log –logappend –fork
root 11179 9391 0 11:14 pts/1 00:00:00 grep mongo
mongodb 30414 1 0 Feb14 ? 1-06:20:50 mongod –shardsvr –replSet shard2 –port 27018 –dbpath /home/data/mongodb/shard21 –oplogSize 2048 –logpath /home/data/mongodb/shard21.log –logappend –fork
[root@db-m1-slave-1 ~]#
看到有 4 个 mongo 进程,
a) 启动参数有“–configdb”的就是集群入口进程;
b) Shard Server,启动参数带“–shardsvr –replSet”的是集群分片的一个片组启动进程,用户存储实际的数据块,也就是 27017 端口和 27018 端口的 mongodb 服务实例。至于如何判断 27017 端口中哪个是 primary 哪个是 secondary 需要去登录 27107 端口执行 rs.status(); 去查看一下。
c) Config Server:启动参数带“–configsvr”的进程,存储了整个 Cluster Metadata,其中包括 chunk 信息,也就是 20000 端口的 mongodb 服务实例。
d) Route Server:启动参数带“mongos –configdb”的进程,前端路由,客户端由此接入,且让整个集群看上去像单一数据库,前端应用可以透明使用,也就是 30000 端口的 mongodb 实例。
6,调试中出现过的错误
错误 1:
[root@wgq nagios ~]# tail -f /usr/local/nagios/var/nagios.log
[1412819956] Warning: Return code of 13 for check of service ‘Mongo Memory Usage’ on host ‘dbm1slave1’ was out of bounds.
[1412819956] SERVICE ALERT: dbm1slave1;Mongo Memory Usage;CRITICAL;SOFT;1;(Return code of 13 is out of bounds)
[1412819975] Warning: Return code of 13 for check of service ‘Mongodb Connect Check’ on host ‘dbm1slave1’ was out of bounds.
[1412819975] SERVICE ALERT: dbm1slave1;Mongodb Connect Check;CRITICAL;SOFT;1;(Return code of 13 is out of bounds)
[1412820058] Warning: Return code of 13 for check of service ‘Mongo Free Connections’ on host ‘dbm1slave1’ was out of bounds.
需要赋值 nagios 用户所有权限以及 r 执行权限
chmod 770 /usr/lib/nagios/plugins/check_mongodb.py
chown -R nagios.nagios /usr/lib/nagios/plugins/check_mongodb.py
错误 2:
监控界面 Status Information 一栏出现 No module named pymongo 报错提示信息:
出现这个提示是因为需要安装 pymongo 模块,执行 easy_install pymongo 命令安装即可,如下所示:
[root@wgq objects]# easy_install pymongo
Searching for pymongo
Reading http://pypi.python.org/simple/pymongo/
Best match: pymongo 2.7.2
……
zip_safe flag not set; analyzing archive contents…
Adding pymongo 2.7.2 to easy-install.pth file
Installed /usr/lib/python2.6/site-packages/pymongo-2.7.2-py2.6-linux-x86_64.egg
Processing dependencies for pymongo
Finished processing dependencies for pymongo
1,监控插件下载
Mongodb 插件下载地址为:git clone git://github.com/mzupan/nagios-plugin-mongodb.git,刚开始本人这里没有安装 gitpub 环境,找网友帮忙下载的,之后上传到了 Linux 公社资源网站,新的下载地址为:
—————————————— 分割线 ——————————————
免费下载地址在 http://linux.linuxidc.com/
用户名与密码都是www.linuxidc.com
具体下载目录在 /2014 年资料 /10 月 /10 日 /Nagios 监控 MongoDB 分片集群服务实战
下载方法见 http://www.linuxidc.com/Linux/2013-07/87684.htm
—————————————— 分割线 ——————————————
网络监控器 Nagios 全攻略 http://www.linuxidc.com/Linux/2013-07/87067.htm
Nagios 搭建与配置详解 http://www.linuxidc.com/Linux/2013-05/84848.htm
Nginx 环境下构建 Nagios 监控平台 http://www.linuxidc.com/Linux/2011-07/38112.htm
在 RHEL5.3 上配置基本的 Nagios 系统(使用 Nagios-3.1.2) http://www.linuxidc.com/Linux/2011-07/38129.htm
CentOS 5.5+Nginx+Nagios 监控端和被控端安装配置指南 http://www.linuxidc.com/Linux/2011-09/44018.htm
Ubuntu 13.10 Server 安装 Nagios Core 网络监控运用 http://www.linuxidc.com/Linux/2013-11/93047.htm
2,添加新的 mongodb 监控命令
因为 mongodb 服务是和 mysql 从库公用一台物理机,之前已经做了基础 nagios 以及 mysql 服务监控,所以这里只需要在原来的基础上添加 mongodb 命令和服务即可。Nagios 监控 mysql 请参考:http://www.linuxidc.com/Linux/2014-10/107809.htm 以及 http://www.linuxidc.com/Linux/2014-07/104241.htm。所以这里需要添加的 mongodb 监控命令如下所示:
[root@wgq objects]# cd /usr/local/nagios/etc/objects
[root@wgq objects]# vim commands.cfg
define command {
command_name check_mongodb
command_line $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$
}
define command {
command_name check_mongodb_database
command_line $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -d $ARG5$
}
define command {
command_name check_mongodb_collection
command_line $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -d $ARG5$ -c $ARG6$
}
define command {
command_name check_mongodb_replicaset
command_line $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -r $ARG5$
}
define command {
command_name check_mongodb_query
command_line $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -q $ARG5$
}
3,添加 mongodb 监控服务
mongodb 的服务也需要单独重新添加,如下所示:
# 检测 mongodb 服务的连接时间,超过 2 秒就普通报警,5 秒就严重报警
define service{
host_name dbm1slave1
service_description Mongo Connect Check
check_command check_mongodb!connect!30000!2!5
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# 检查 mongodb 的连接数,超过 150 普通报警,200 严重报警
define service{
host_name dbm1slave1
service_description Mongo Free Connections
check_command check_mongodb!connections!27017!70!80
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# 检查 mongodb 复制完成的百分比率,确保 primary 和 standby 的 time 是一致的。
define service{
host_name dbm1slave1
service_description Mongo Replication Lag
check_command check_mongodb!replication_lag!27017!15!30
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# 检查 mongodb 内存使用率,阀值与 mongodb 所在机器的总内存数相关
define service{
host_name dbm1slave1
service_description Mongo Memory Usage
check_command check_mongodb!memory!27017!20!28
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# 检查 mongodb Mapped 的内存使用率,阀值与 mongodb 所在机器的总内存数相关
define service{
host_name dbm1slave1
service_description Mongo Mapped Memory Usage
check_command check_mongodb!memory_mapped!27017!20!28
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# 检查 Lock Time 的百分率,如果 lock time 占据 mongo 运行时间的 5% 就普通报警,如果超过 10% 就严重报警
define service{
host_name dbm1slave1
service_description Mongo Lock Percentage
check_command check_mongodb!lock!27017!5!10
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check Average Flush Time,检查 mongo 服务器的平均 flush 时间,
define service{
host_name dbm1slave1
service_description Mongo Flush Average
check_command check_mongodb!flushing!27017!100!200
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check Last Flush Time,检查最新的 flush 时间,如果超过 200ms 就普通报警,超过 400ms 就严重报警
define service{
host_name dbm1slave1
service_description Mongo Last Flush Time
check_command check_mongodb!last_flush_time!27017!200!400
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check status of mongodb replicaset,检查 mongo 复制的状态
define service{
host_name dbm1slave1
service_description MongoDB state
check_command check_mongodb!replset_state!27017!0!0
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check status of index miss ratio,检查索引命中率,
define service{
host_name dbm1slave1
service_description MongoDB Index Miss Ratio
check_command check_mongodb!index_miss_ratio!27017!.005!.01
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check number of databases and number of collections
define service{
host_name dbm1slave1
service_description MongoDB Number of databases
check_command check_mongodb!databases!27017!300!500
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
define service{
host_name dbm1slave1
service_description MongoDB Number of collections
check_command check_mongodb!collections!27017!300!500
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check size of a database,检查库的大小
define service{
host_name dbm1slave1
service_description MongoDB Database size your-database
check_command check_mongodb_database!database_size!27017!300!500!your-database
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check index size of a database,检查库索引的大小
define service{
host_name dbm1slave1
service_description MongoDB Database index size your-database
check_command check_mongodb_database!database_indexes!27017!50!100!your-database
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check index size of a collection,检查集合 collection 的索引大小
define service{
host_name dbm1slave1
service_description MongoDB Database index size your-database
check_command check_mongodb_collection!collection_indexes!27017!50!100!your-database!your-collection
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check the primary server of replicaset,检查复制的 primary 服务
define service{
host_name dbm1slave1
service_description MongoDB Replicaset Master Monitor: your-replicaset
check_command check_mongodb_replicaset!replica_primary!27017!0!1!your-replicaset
#示例:check_command check_mongodb_replicaset!replica_primary!27017!0!1!shard2
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check the number of queries per second,检查每一秒的查询数量
define service{
host_name dbm1slave1
service_description MongoDB Updates per Second
check_command check_mongodb_query!queries_per_second!27017!200!150!update
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check Primary Connection,检查复制中与 primary 库的连接时间,超过 2 秒就普通报警,超过 4 秒就严重报警
define service{
host_name dbm1slave1
service_description Mongo Connect Check
check_command check_mongodb!connect_primary!27017!2!4
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
# Check Collection State,检查 collection 状态,检查 mongo 服务组列表的每一个主机,可以检查重要 collection 的高可用性(锁、超时、服务配置的可用性),如果发现一个查询失败就会报警。
define service{
host_name dbm1slave1
service_description Mongo Collection State
check_command check_mongodb!collection_state!27017!your-database!your-collection
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c,r
contact_groups ops
}
更多详情见请继续阅读下一页的精彩内容:http://www.linuxidc.com/Linux/2014-10/107826p2.htm