手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Nagios监控MongoDB分片集群服务实战

[日期:2014-10-10] 来源:Linux社区  作者:黄杉 [字体: ]

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 24x7 
        notification_interval 10 
        notification_period 24x7 
        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 24x7 
        notification_interval 10 
        notification_period 24x7 
        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 24x7 
        notification_interval 10 
        notification_period 24x7 
        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 24x7 
        notification_interval 10 
        notification_period 24x7 
        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 24x7 
        notification_interval 10 
        notification_period 24x7 
        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 24x7 
        notification_interval 10 
        notification_period 24x7 
        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 24x7 
        notification_interval 10 
        notification_period 24x7 
        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 24x7 
        notification_interval 10 
        notification_period 24x7 
        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 24x7 
        notification_interval 10 
        notification_period 24x7 
        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 24x7 
        notification_interval 10 
        notification_period 24x7 
        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 24x7 
        notification_interval 10 
        notification_period 24x7 
        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 24x7 
        notification_interval 10 
        notification_period 24x7 
        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 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 
        } 

更多详情见请继续阅读下一页的精彩内容http://www.linuxidc.com/Linux/2014-10/107826p2.htm

linux
相关资讯       Nagios监控  Nagios监控MongoDB 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间���导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款