val 2
check_period 24x7
notification_interval 10
notification_period 24x7
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 24x7
notification_interval 10
notification_period 24x7
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 24x7
notification_interval 10
notification_period 24x7
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 24x7
notification_interval 10
notification_period 24x7
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 24x7
notification_interval 10
notification_period 24x7
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 24x7
notification_interval 10
notification_period 24x7
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 24x7
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
contact_groups ops
}
4,查看部分监控项效果
配置完nagios端服务,重启下service nagios restart; 等上几分钟,nagios监控界面就会出现完整的mongo服务信息,如下所示:
,从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 280 |