Linux Nagios检查问题:MongoDB检查_云数据库.py

2024-10-01 16:28:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我在amazon linux上运行mongodb版本3。我想检查一下mongodb,即锁表百分比

我把这一行加进去了自然资源配置在

/usr/lib64/nagios/plugins/check_云数据库.py-A锁-W 9-C 10

这在mongoversion2中运行良好,但在3中却显示了这个错误

无法从mongo获取globalLock lockTime信息,你确定你没有使用版本3吗?请参见-M选项。 严重-一般MongoDB错误:“锁定时间”

我怎样才能解决这个问题? 有人用支票付账吗_云数据库.py? 在


Tags: py版本数据库amazonlinuxmongodbusrcheck
1条回答
网友
1楼 · 发布于 2024-10-01 16:28:35

它没有记录在nagios-plugin-mongodb project's README.md上,但是您应该在中修改命令定义自然资源配置传入一个附加参数-M "3"。 例如:

/usr/lib64/nagios/plugins/check_mongodb.py -A lock -W 9 -C 10 -M "3"

这将告诉检查_云数据库.py您使用的是mongodb版本3而不是版本2。这也会导致您得到一条更有用的错误消息:

^{bq}$

。。。这会让您知道MongoDB版本3不支持此操作。在

现在,从代码来看,他们放入这个异常的原因是因为他们从MongoDB版本2获取锁时间信息的方式在MongoDB版本3中已经不存在了。在

节选自check_mongodby.py

检查锁

^{pr2}$

获取服务器状态

def get_server_status(con):
    try:
        set_read_preference(con.admin)
        data = con.admin.command(pymongo.son_manipulator.SON([('serverStatus', 1)]))
    except:
        data = con.admin.command(son.SON([('serverStatus', 1)]))
    return data

如果您检查MongoDBdocumentation for version 2.6,您将看到serverStatus.globalLock.lockTime存在,用于检查_云数据库.pynagios插件。在

serverStatus.globalLock.lockTime The value of lockTime represents the time, in microseconds, since the database last started, that the globalLock has been held.

但是,serverStatus.globalLock.lockTime在MongoDB版本3中不存在。根据MongoDB version 3 documentation

locks For an example of the locks output, see the locks section of the Server Status Output page.

serverStatus.locks Changed in version 3.0.

The locks document contains embedded documents that provides a granular report for each lock type and mode. The possible lock types are as follows:

serverStatus.locks

Global represents global lock. MMAPV1Journal represents MMAPv1 storage engine specific lock to synchronize journal writes; for non-MMAPv1 storage engines, the mode for MMAPV1Journal is empty. Database represents database lock. Collection represents collection lock. Metadata represents metadata lock. oplog represents lock on the oplog.

globalLock

globalLock For an example of the globalLock output, see the globalLock section of the Server Status Output page.

serverStatus.globalLock The globalLock data structure contains information regarding the database’s current lock state, historical lock status, current operation queue, and the number of active clients.

serverStatus.globalLock.totalTime The value of totalTime represents the time, in microseconds, since the database last started and created the globalLock. This is roughly equivalent to total server uptime.

因为全球锁定时间不再表示,它不能用于计算MongoDB版本3所需的度量。在

相关问题 更多 >

    热门问题