Skip to main content

Helps to query MK livestatus and return results as dictionaries

Project description

Author:

Michael Fladischer

Version:
0.2

Access the data returned from MK Livestatus queries as Python lists or dictionaries. It does this by sending queries to the MK Livestatus UNIX socket and parses the returned rows. Read/write permission to the UNIX socket are required.

Usage

Here a simple example to fetch the name and hostgroups for all servers in the UP (0) state:

>>> from mk_livestatus import Socket
>>> s = Socket("/var/lib/icinga/rw/live")
>>> q = s.hosts.columns('name', 'groups').filter('state = 0')
>>> print q
GET hosts
Columns: name groups
Filter: state = 0
>>> q.call()
[{'name': 'example.com', 'groups': ['ssh', 'snmp', 'smtp-server', 'ping-server', 'http-server', 'debian-server', 'apache2']}]

s.hosts returns a Query to the hosts resources on Nagios. The columns and filter methods modify our query and return it, so we can chain the calls. The call to call method returns the rows as a list of dictionaries.

If you use xinetd to bind the Unix socket to a TCP socket (like explained here), you can create the socket like :

>>> s = Socket(('192.168.1.1', 6557))

For more information please visit the python-mk-livestatus website. Information about MK Livestatus and it’s query syntax is available at the mk-livestatus website.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-mk-livestatus-0.3.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file python-mk-livestatus-0.3.tar.gz.

File metadata

File hashes

Hashes for python-mk-livestatus-0.3.tar.gz
Algorithm Hash digest
SHA256 2edf8c1a01ec0fbcb923e523d28c55af07413096ff0cfa0115766f32ca504f85
MD5 3a53f102449307cdc97447f2b94d9311
BLAKE2b-256 7a541165cc6e9587654e2d6095de7b86f4f1a8e547b4433b29dbe01bb2c6f33a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page