-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7f3a631
Showing
18 changed files
with
711 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
bin/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
.tox/ | ||
.coverage | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
|
||
# Translations | ||
*.mo | ||
|
||
# Mr Developer | ||
.mr.developer.cfg | ||
.project | ||
.pydevproject | ||
|
||
# Rope | ||
.ropeproject | ||
|
||
# Django stuff: | ||
*.log | ||
*.pot | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
MANIFEST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.3.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
language: python | ||
|
||
python: | ||
- "2.6" | ||
- "2.7" | ||
- "3.2" | ||
- "3.3" | ||
|
||
install: | ||
- python setup.py install | ||
- pip install -r requirements_test.txt | ||
|
||
script: | ||
- pep8 sensu_plugin | ||
- pylint --rcfile=pylint.rc sensu_plugin | ||
- nosetests sensu_plugin/test/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
v0.2.0, 2014-01-06 -- Add support for Python3 | ||
v0.1.0, 2014-01-06 -- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
include *.txt *.md | ||
recursive-include docs *.txt *.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
![sensu](https://raw.github.com/sensu/sensu/master/sensu-logo.png) | ||
|
||
# Python Sensu Plugin | ||
|
||
This is a framework for writing your own [Sensu](https://github.com/sensu/sensu) plugins in Python. | ||
It's not required to write a plugin (most Nagios plugins will work | ||
without modification); it just makes it easier. | ||
|
||
[![Build Status](https://travis-ci.org/zsprackett/python_sensu_plugin.png?branch=master)](https://travis-ci.org/zsprackett/python_sensu_plugin) | ||
|
||
## Checks | ||
|
||
To implement your own check, subclass SensuPluginCheck, like | ||
this: | ||
|
||
from sensu_plugin import SensuPluginCheck | ||
|
||
class MyCheck(SensuPluginCheck): | ||
def setup(self): | ||
# Setup is called with self.parser set and is responsible for setting up | ||
# self.options before the run method is called | ||
|
||
self.parser.add_argument( | ||
'-w', | ||
'--warning', | ||
required=True, | ||
type=int, | ||
help='Integer warning level to output' | ||
) | ||
self.parser.add_argument( | ||
'-m', | ||
'--message', | ||
default=None, | ||
help='Message to print' | ||
) | ||
|
||
|
||
def run(self): | ||
# this method is called to perform the actual check | ||
|
||
self.check_name('my_awesome_check') # defaults to class name | ||
|
||
if self.options.warning == 0: | ||
self.ok(self.options.message) | ||
elif self.options.warning == 1: | ||
self.warning(self.options.message) | ||
elif self.options.warning == 2: | ||
self.critical(self.options.message) | ||
else: | ||
self.unknown(self.options.message) | ||
|
||
if __name__ == "__main__": | ||
f = MyCheck() | ||
|
||
## Metrics | ||
|
||
### JSON | ||
|
||
from sensu_plugin import SensuPluginMetricJSON | ||
|
||
class FooBarBazMetricJSON(SensuPluginMetricJSON): | ||
def run(self): | ||
self.ok({'foo': 1, 'bar': { 'baz': 'stuff' } }) | ||
|
||
if __name__ == "__main__": | ||
f = FooBarBazMetricJSON() | ||
|
||
### Graphite | ||
|
||
from sensu_plugin import SensuPluginMetricGraphite | ||
|
||
class FooBarBazMetricGraphite(SensuPluginMetricGraphite): | ||
def run(self): | ||
self.output('a', 1) | ||
self.output('b', 2) | ||
self.ok() | ||
|
||
if __name__ == "__main__": | ||
f = FooBarBazMetricGraphite() | ||
|
||
### StatsD | ||
|
||
from sensu_plugin import SensuPluginMetricStatsd | ||
|
||
class FooBarBazMetricStatsd(SensuPluginMetricStatsd): | ||
def run(self): | ||
self.output('a', 1, 'ms') | ||
self.output('b.c.d', 15) | ||
self.ok() | ||
|
||
if __name__ == "__main__": | ||
f = FooBarBazMetricStatsd() | ||
|
||
## License | ||
|
||
* Based heavily on [sensu-plugin](https://github.com/sensu/sensu-plugin) Copyright 2011 Decklin Foster | ||
* Python port Copyright 2014 S. Zachariah Sprackett | ||
|
||
Released under the same terms as Sensu (the MIT license); see LICENSE | ||
for details |
Oops, something went wrong.