温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何使用zabbix监控mongod

发布时间:2021-09-26 14:20:53 来源:亿速云 阅读:118 作者:柒染 栏目:MongoDB数据库

如何使用zabbix监控mongod,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

1 被监控端写mongodb.sh

注意:里面的路径和你的端口要看自己的实际情况

case $# in
  1)
    output=$(/bin/echo "db.serverStatus().$1" |/usr/local/mongodb/bin/mongo admin --port 27017|sed -n '3p')
    ;;
  2)
    output=$(/bin/echo "db.serverStatus().$1.$2" |/usr/local/mongodb/bin/mongo admin --port 27017|sed -n '3p')
    ;;
  3)
    output=$(/bin/echo "db.serverStatus().$1.$2.$3" |/usr/local/mongodb/bin/mongo admin --port 27017|sed -n '3p')
    ;;
esac
 
#check if the output contains "NumberLong"
if [[ "$output" =~ "NumberLong"   ]];then
  echo $output|sed -n 's/NumberLong(//p'|sed -n 's/)//p'
else 
  echo $output
fi

2 编辑zabbix_agentd.conf配置文件

添加如下内容

UserParameter=MongoDB.Status[*],/usr/local/zabbix/script/mongodb.sh $1 $2 $3

3 导入模板并重启zabbix_agentd服务

见附件

4 服务端测试 

/home/usr/local/zabbix/bin/zabbix_get -s ip -kMongoDB.Status[network,bytesIn]

40667759

#######################################################################################

mongodb 监控项
MongoDB.Status[opcounters,delete]
MongoDB.Status[opcounters,getmore]##自实例启动以来,在游标执行getMore次数
MongoDB.Status[opcounters,insert] ##自实例启动以来,执行insert次数
MongoDB.Status[opcounters,query] ##自实例启动以来,执行query次数
MongoDB.Status[opcounters,command]##自实例启动以来,执行其他操作的次数
MongoDB.Status[network,numRequests]
MongoDB.Status[mem,virtual]
MongoDB.Status[backgroundFlushing,average_ms]##平均每次刷新执行时间
MongoDB.Status[network,bytesOut]
MongoDB.Status[opcounters,update]
MongoDB.Status[opcountersRepl,command]
MongoDB.Status[process] ##当前实例是mongod,还是mongos
MongoDB.Status[uptime]##实例连续正常运行时间,单位秒
used_connections_percentage
used_memory_percentage
MongoDB.Status[opcountersRepl,update]
MongoDB.Status[opcountersRepl,query]
MongoDB.Status[opcountersRepl,delete]
MongoDB.Status[opcountersRepl,getmore]
MongoDB.Status[opcountersRepl,insert]
MongoDB.Status[mem,resident]
MongoDB.Status[network,bytesIn]
MongoDB.Status[extra_info,heap_usage_bytes]##当前实例堆大小,单位bytes
MongoDB.Status[extra_info,page_faults]##加载磁盘内容时发生页错误的次数
MongoDB.Status[mem,mapped]
MongoDB.Status[globalLock,activeClients,total] 当前活动的连接数
MongoDB.Status[cursors,totalOpen]
MongoDB.Status[cursors,timedOut]
MongoDB.Status[connections,available]##剩余多少可供连接
MongoDB.Status[connections,current] ##当前连接到本机处于活动状态的连接数
MongoDB.Status[connections,totalCreated]
MongoDB.Status[globalLock,activeClients,writers] 当前活动的写连接数
MongoDB.Status[globalLock,activeClients,readers] 当前活动的读连接数
MongoDB.Status[indexCounters,mi***atio]
MongoDB.Status[globalLock,currentQueue,readers]  #当前等待获取读锁的队列
MongoDB.Status[mem,bits]
MongoDB.Status[indexCounters,misses] 访问索引时,索引不是在内存中被命中的次数
MongoDB.Status[indexCounters,resets] 索引计数器被重置的次数
MongoDB.Status[indexCounters,hits] 访问索引时,索引在内存中被命中的次数
MongoDB.Status[indexCounters,accesses]
MongoDB.Status[globalLock,currentQueue,total] #当前等待获取锁的队列
MongoDB.Status[globalLock,currentQueue,writers]#当前等待获取写锁的队列

关于如何使用zabbix监控mongod问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI