tons协议的公共接口,用于监视工具,如nagios/icinga…
argusp的Python项目详细描述
arguspy
[已弃用]由于nagios太旧,此项目已弃用。
请转到另一个项目[super-devops]。
Arguspy是纯python代码
它是一个用于监视插件的api包,比如nagios、icinga、naemon、shinken、centreon、opsview和sensu。
如何安装
使用PIP安装:
$ pip install super_devops $ pip install arguspy
如何使用
只需导入您需要的协议:
from arguspy.ftp_ftplib import Ftp from arguspy.http_requests import Http from arguspy.mssql_pymssql import Mssql from arguspy.mysql_pymysql import Mysql from arguspy.ssh_paramiko import Ssh from arguspy.winrm_pywinrm import WinRM from arguspy.wmi_sh import Wmi from arguspy.wmi_subprocess import Wmi
然后编写自己的函数监视类:
class YourClass(Ftp/Mssql/Ssh/WinRM/Wmi/Http/Snmp/...): def __init__(self): super(YourClass, self).__init__() self.logger.debug("Init YourClass.") def define_sub_options(self): super(YourClass, self).define_sub_options() self.your_parser = self.subparsers.add_parser(...) self.your_parser.add_argument(...) ... def your_handle(self): """Put your function monitoring code here.""" # Default status is ok. status = self.ok # Call the API and get the monitoring data. # Read the document or check the API on python/ipython Interactive console. # help(Ftp/...) # dir(Ftp/...) ... # Compare with the warning and critical value and change the status. ... self.shortoutput = "..." self.longoutput.append(...) self.perfdata.append(...) self.logger.debug("Return status and output.") status(self.output())
如果在一个文件中放置多个函数监视类(不推荐):
class Register(YourClass1, YourClass2, ...): def __init__(self): super(Register, self).__init__()
最后一步:
def main(): plugin = Register() if plugin.args.option == 'action': plugin.action_handle() elif ...: ... else: plugin.unknown("Unknown actions.") if __name__ == "__main__": main()
如何扩展
检查todo列表,可以给出测试示例或文档。
你也可以请求你的代码。
待办事项
- 在测试中编写单元测试/
- 在文档中写入文档/
- 在示例中编写示例/
- 与python3兼容
- vSphere监视
- LDAP监视
- SNMP监视