Skip to main content

access MK livestatus query results either as lists or dictionaries

Project description

Author:

Michael Fladischer

Version:
0.1

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.query(
... """GET hosts
... Columns: name groups
... Filter: state = 0
... Limit: 1
... """)
>>> q.get_list()
[{'name': 'example.com', 'groups': ['ssh', 'snmp', 'smtp-server', 'ping-server', 'http-server', 'debian-server', 'apache2']}]
>>> q.get_dict('name')
{'example.com': {'name': 'example.com', 'groups': ['ssh', 'snmp', 'smtp-server', 'ping-server', 'http-server', 'debian-server', 'apache2']}}

The call to get_list returns the rows as a list of dictionaries while get_dict requires one argument which specifies the column name which is to be used as the key for the entries in the dictionaries.

TODO

  • Implement get_column_list to fetch a single column as a list.

  • Test with INET sockets.

For more information please visit the python-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.1.tar.gz (3.0 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for python-mk-livestatus-0.1.tar.gz
Algorithm Hash digest
SHA256 32dcdde623d4104ddb9f56a1cf479d8b6a54e4fe23f54a5d64606e8177d540b3
MD5 fa23a01670970555b51a3fb55fb64ba1
BLAKE2b-256 525faa203e94e888c8a275cbc5081addcd81d4ac3b0b3a7af8629e09b9209c57

See more details on using hashes here.

Supported by

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