Class library for writing Nagios (Icinga) plugins
The nagiosplugin library
nagiosplugin is a Python class library which helps writing Nagios (or Icinga) compatible plugins easily in Python. It cares for much of the boilerplate code and default logic commonly found in Nagios checks, including:
- Nagios 3 Plugin API compliant parameters and output formatting
- Full Nagios range syntax support
- Automatic threshold checking
- Multiple independend measures
- Custom status line to communicate the main point quickly
- Long output and performance data
- Timeout handling
- Persistent “cookies” to retain state information between check runs
- Resume log file processing at the point where the last run left
- No dependencies beyond the Python standard library (except for Python 2.6).
nagiosplugin runs on POSIX and Windows systems. It is compatible with Python 2.7, and Python 3.4 through 3.7.
Feedback and Suggestions
nagiosplugin is currently maintained by Matt Pounsett <email@example.com>. A public issue tracker can be found at <https://github.com/mpounsett/nagiosplugin/issues> for bugs, suggestions, and patches.
The nagiosplugin package is released under the Zope Public License 2.1 (ZPL), a BSD-style Open Source license.
nagiosplugin was originally written and maintained by Christian Kauhaus <firstname.lastname@example.org>. Additional contributions from the community are acknowledged in the file CONTRIBUTORS.txt
Getting the source
The source can be obtained via git from https://github.com/mpounsett/nagiosplugin.git:
git clone https://github.com/mpounsett/nagiosplugin.git
This package supports installation in a virtualenv:
python3 -m venv . pip install -e .
Once you have pyenv set up, make sure you have each of the supported versions of python specified by the envlist in tox.ini. This will likely look something like:
pyenv install 2.7.16 pyenv install 3.4.10 pyenv install 3.5.7 pyenv install 3.6.9 pyenv install 3.7.4 pyenv global 3.7.4 3.6.9 3.5.7 3.4.10 2.7.16
Install test dependencies:
pip install -r requirements_test.txt
After doing so, run the unit tests:
To limit tests to a particular python environment:
tox -e py37
Run only linting tests:
tox -e lint
nagiosplugin also includes support for test coverage reports. Coverage reports are updated automatically by tox. Open htmlcov/index.html to see coverage reports.
You may run the supplied examples with the local interpreter:
The documentation depends on Sphinx. Install the necessary dependencies, and then build the documentation:
pip install -r requirements_docs.txt make docs
HTML documentation will be built and installed in doc/_build/html/. You can read the documentation by opening doc/_build/html/index.html.
How to release
Begin by making sure you have the build prerequisites installed:
pip install -r requirements_build.txt
Update the version number in nagiosplugin/version.py, update the version release date in the HISTORY.txt file, and tag the release. Make sure both of the file changes are in the same commit. For a new version 0.1.2:
sed -i '' -e 's/\(__VERSION__ =\).*/\1 "0.1.2"/' nagiosplugin/version.py sed -i '' -e 's/0.1.2 (unreleased)/0.1.2 (2019-11-07)/' HISTORY.txt git stage HISTORY.txt nagiosplugin/version.py git commit -m "Preparing release 0.1.2" git tag 0.1.2 git push git push --tags
Build the nagiosplugin distribution for PyPi:
python3 setup.py sdist bdist_wheel
Check the contents of the packages in dist/ to ensure they contain all of the expected files.
Test your package upload with TestPyPi:
twine upload --repository-url https://test.pypi.org/legacy dist/*
Check on https://test.pypi.org/nagiosplugin that the package metadata looks correct. If everything is fine, upload the release:
twine upload dist/*
After updating PyPi, advance the version number again to the next patch version plus a .dev0 suffix.
Go to https://readthedocs.io/ and ensure the new stable and dev releases are available.
nagiosplugin has become what it is now with the help of many contributors from the community. We want to thank everyone who has invested time and energy to make nagiosplugin better:
- Christian Kauhaus <email@example.com>, the original author and maintainer.
- Wolfgang Schnerring <firstname.lastname@example.org> for thoughts on the design.
- Thomas Lotze <email@example.com> for improving the test infrastructure.
- Christian Theune <firstname.lastname@example.org> for comments and general feedback.
- Michael Howitz <email@example.com> and Andrei Chirila <firstname.lastname@example.org> for the Python 3 port.
- Birger Schmidt <email@example.com> for bug reports.
- Florian Lagg <LaggAt@lagg-asus1.lan> for Windows compatibility fixes
- Jeff Goldschrafe <firstname.lastname@example.org> for the Python 2.6 backport.
- José Manuel Fardello <email@example.com> for a logging fix.
- Jordan Metzmeier <firstname.lastname@example.org> for build fixes and Debian packaging.
- Andrey Panfilov <email@example.com> for a perfdata fix.
- Mihai Limbășan <firstname.lastname@example.org> for various output formatting fixes.
- Include doc and tests directories in source distribution to support Gentoo package building tests (#22)
- Update official python support to 2.7, 3.4+ in README
- Fixed a packaging bug
- New maintainer/contributor information and project home
- Updated tests and package metadata for recent Python 3 versions
- Newer tooling for tests/documentation
- Add optional keyword parameter verbose to Runtime.guarded(). This parameter allows to set verbose level in the early execution phase (#13).
- Allow Context.evaluate() return either a Result or ServiceState object. In case the latter is returned, it gets automatically wrapped in a Result object (#6).
- Fix bug that caused a UnicodeDecodeError when using non-ASCII characters in fmt_metric (#12).
- Print perfdata always on a single line (even in multi-line mode) to improve compatibility with various monitoring systems (#11).
- Mention that nagiosplugin also runs with Python 3.4 (no code changes necessary).
- Make name prefix in status output optional by allowing to assign None to Check.name.
- Accept bare metric as return value from Resource.probe().
- Fix bug where Context.describe() was not used to obtain metric description (#13162).
- Fix build failures with LANG=C (#13140).
- Remove length limitation of perfdata labels (#13214).
- Fix formatting of large integers as Metric values (#13287).
- Range: allow simple numerals as argument to Range() (#12658).
- Cookie: allow for empty state file specification (#12788).
- New Summary.empty method is called if there are no results present (#11593).
- Improve range violation wording (#11597).
- Ensure that nagiosplugin install correctly with current setuptools (#12660).
- Behave and do not attach anything to the root logger.
- Add debugging topic guide. Explain how to disable the timeout when using pdb (#11592).
- Identical to 1.1b1.
- Made compatible with Python 2.6 (#12297).
- Tutorial #3: check_users (#11539).
- Minor documentation improvements.
- LogTail returns lines as byte strings in Python 3 to avoid codec issues (#11564).
- LogTail gives a line-based iterator instead of a file object (#11564).
- Basic API docs for the most important classes (#11612).
- Made compatible with Python 2.7 (#11533).
- Made compatible with Python 3.3.
- Improve error reporting for missing contexts.
- Exit with code 3 if no metrics have been generated.
- Improve default Summary.verbose() to list all threshold violations.
- Move main source repository to https://bitbucket.org/gocept/nagiosplugin/ (#11561).
- API docs for the most important classes (#7939).
- Added two tutorials (#9425).
- Fix packaging issues.
- Completely reworked API. The new API is not compatible with the old 0.4 API so you must update your plugins.
- Python 3 support.
- The Cookie class is now basically a persistent dict and accepts key/value pairs. Cookie are stored as JSON files by default so they can be inspected by the system administrator (#9400).
- New LogTail class which provides convenient access to constantly growing log files which are eventually rotated.
- Windows port. nagiosplugin code now runs under pywin32 (#10899).
- Include examples in egg release (#9901).
Bugfix release to fix issues reported by users.
- Improve Mac OS X compatibility (#8755).
- Include examples in distribution (#8555).
- Change __str__ representation of large numbers to avoid scientific notation.
- Packaging issues.
- Fix distribution to install correctly.
- Documentation: tutorial and topic guides.
- Initial public release.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size nagiosplugin-1.3.2-py3-none-any.whl (35.2 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size nagiosplugin-1.3.2.tar.gz (54.3 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for nagiosplugin-1.3.2-py3-none-any.whl