编写icinga插件的python库。
pycinga的Python项目详细描述
pycinga是一个简单的python库,用于编写 Icinga插件要容易得多。伊辛加 插件有quite a few guidelines 为了坚持,pycinga提供了帮助 容易的。
安装
要安装,只需使用pip或easy_install:
pip install pycinga
文档
最新版本的文档可以在 http://pycinga.readthedocs.io/en/latest。
功能
pycinga支持的核心功能:
- 正在分析命令行参数,以便标准 接受参数(例如-H、-w、-c)。
- 返回基于状态的Posix POSIX退出代码。
- 正在分析ICinga范围格式(例如“@10:20”、“~:50”、“10”等)
- 输出状态和消息。
- 输出性能数据。
示例
所有这些特性产生的结果是简洁、简单和 符合指南的基于python的icinga插件:
from pycinga import Plugin class UserCheck(Plugin): """ Icinga 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的方法并构建一个“响应” 你自己。