编写nagios插件的python库。
pynagios的Python项目详细描述
pynagios是一个简单的python库,用于编写 Nagios插件要容易得多。纳吉奥斯 插件有quite a few guidelines 为了坚持,pynagios提供了帮助 容易的。
安装
要安装,只需使用pip或easy_install:
pip install pynagios
文档
最新版本的文档可以在 http://kiip.github.com/pynagios/latest。
功能
pynagios支持的核心功能:
- 正在分析命令行参数,以便标准 接受参数(例如-H、-w、-c)。
- 返回基于状态的Posix POSIX退出代码。
- 分析Nagios范围格式(例如“@10:20”、“~:50”、“10”等)
- 输出状态和消息。
- 输出性能数据。
示例
所有这些特性产生的结果是简洁、简单和 基于指南的基于python的nagios插件:
from pynagios import Plugin class UserCheck(Plugin): """ Nagios plugin to check how many users are logged into this machine. """ def check(self): # Get the number of logged in users, for now we hardcode users = 27 # Build a response and exit. This `response_for_value` automatically # creates a response with the proper status given the value and the # warning/critical ranges passed in via the command line. response = self.response_for_value(users, "%d users" % users) response.set_perf_data("users", users) response.set_perf_data("another metric", 27, "MB") return response if __name__ == 'main': # Build the plugin instance and run it. This will also parse # command line arguments by default. UserCheck().check().exit()
虽然上面的示例子类Plugin,但是当然欢迎 直接调用plugin的方法并构建一个“响应” 你自己。