Nomit
Nomit is a small library that can be used to process HTTP/XML POST requests from Monit instances. While it is a relatively trivial adaption of Python’s BaseHTTPRequestHandler, it may be useful to multiple other projects. For this reason Nomit is registered as its own little project.
Monit is a free utility for managing Unix systems. Multiple Monit instances can be centrally managed by its sister project MMonit. Monit communicates with MMonit through HTTP/XML POST request.
Requirements
Nomit uses the lxml.objectify module from the lxml project. Many Linux distributions provide lxml in their native package format.
The MonitHandler class
Nomit provides a single class MonitHandler which is a sub-class of BaseHTTPRequestHandler. MonitHandler is meant to be sub-classed itself.
It provides two methods:
handle_unparsed() is called with the raw XML of the HTTP/XML POST request.
handle_parsed() is called after the XML has been parsed by lxml.objectify.fromstring().
The default implementation of these methods does nothing. Any derived class must implement these methods as necessary.
Example
The example below implements handle_unparsed() to print the raw XML as POSTed by the Monit agent and uses handle_parsed() to display the data structure returned by lxml.objectify.fromstring():
import BaseHTTPServer
import xml.dom.minidom
import lxml.objectify
import nomit
class ExampleHandler(nomit.MonitXmlHandler):
def handle_unparsed(self, s):
print xml.dom.minidom.parseString(s).toprettyxml()
def handle_parsed(self, o):
print lxml.objectify.dump(o)
server = BaseHTTPServer.HTTPServer(("127.0.0.1", 2811), ExampleHandler)
server.serve_forever()
Monit configuration
The Monit agent must be told to POST status information to the Python script above. From the agent’s point of view the script is simply (another[1]_) MMonit server.
monit.conf:
set mmonit http://monit:monit@mmonit.example.com:8080/collector
http://localhost:2811/
_[1] The set mmonit directive accepts multiple URLs.
Metadata
Release files for nomit 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nomit-1.0.tar.gz | 3.7 kB | Without provenance | Details for nomit-1.0.tar.gz |
Release files / nomit-1.0.tar.gz
| Download URL | nomit-1.0.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61724841c602cd6e5aa327fa768824d5d5f1bbb127247383b32d67cfbb67c8fe
|
|
BLAKE2b-256 checksum How to use checksums |
da46a9a940d47d56a820974db7f2b6f9bc702c5826b42560f9e59c4a21fdae85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for nomit 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.