-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.rst
143 lines (103 loc) · 3.9 KB
/
README.rst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
.. image:: https://img.shields.io/pypi/v/pymonitoringplugins.svg
:target: https://pypi.python.org/pypi/pymonitoringplugins/
.. image:: https://img.shields.io/pypi/dm/pymonitoringplugins.svg
:target: https://pypi.python.org/pypi/pymonitoringplugins/
.. image:: https://travis-ci.org/crazy-canux/pymonitoringplugins.svg?branch=master
:target: https://travis-ci.org/crazy-canux/pymonitoringplugins
.. image:: https://coveralls.io/repos/github/crazy-canux/pymonitoringplugins/badge.svg?branch=master
:target: https://coveralls.io/github/crazy-canux/pymonitoringplugins?branch=master
===================
pymonitoringplugins
===================
pymonitoringplugins is pure python code.
It's a API packge for monitoring plugins, like Nagios, Icinga, Naemon, Shinken, Centreon, Opsview and Sensu.
`[awesome-monitoring] <https://github.com/crazy-canux/awesome-monitoring>`_.
--------------
How to install
--------------
Use pip to install::
pip install pymonitoringplugins
----------
How to use
----------
Just import what protocol you need::
from pymonitoringplugins.ftp_ftplib import Ftp
from pymonitoringplugins.http_requests import Http
from pymonitoringplugins.mssql_pymssql import Mssql
from pymonitoringplugins.mysql_pymysql import Mysql
from pymonitoringplugins.ssh_paramiko import Ssh
from pymonitoringplugins.winrm_pywinrm import WinRM
from pymonitoringplugins.wmi_sh import Wmi
from pymonitoringplugins.wmi_subprocess import Wmi
Then write your own function monitoring class::
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())
If you put more than one function monitoring class in one file(Not recommend)::
class Register(YourClass1, YourClass2, ...):
def __init__(self):
super(Register, self).__init__()
Last step::
def main():
# For multiple inherit
# plugin = Register()
plugin = YourClass()
arguments = sys.argv[1:]
if 'your' in arguments:
plugin.your_handle()
elif 'your2' in arguments:
plugin.your2_handle()
else:
plugin.unknown("Unknown actions.")
if __name__ == "__main__":
main()
--------------
How to extends
--------------
Check the TODO list, you can give test examples or documents.
Also you can pull request for your code.
-----
TODO
-----
* Compatible with Python3(2.0.0)
* vSphere monitoring(1.6.0)
* LDAP monitoring(1.5.0)
* SNMP monitoring(1.4.0)
=============
Documentation
=============
`[Documentation] <http://pymonitoringplugins.readthedocs.io/en/latest/>`_
============
Contribution
============
`[Contribution] <https://github.com/crazy-canux/pymonitoringplugins/blob/master/CONTRIBUTING.rst>`_
=======
Authors
=======
`[Authors] <https://github.com/crazy-canux/pymonitoringplugins/blob/master/AUTHORS.rst>`_
=======
License
=======
`[License] <https://github.com/crazy-canux/pymonitoringplugins/blob/master/LICENSE>`_