Livestatus: Command reference


This article is just a draft and not yet finished!

1. Available tables

The following tables are available for use in Livestatus. Some of them additionally function over the columns of another table. These columns will be identified by the table's name as a prefix:

Table Comments
hosts Contains all information for the configured hosts.
services Contains all information for the configured services, and additionally the columns from hosts.
hostgroups Information for the host groups.
servicegroups Information for the service groups.
contactgroups Information for the contact groups.
servicesbygroup As for services, but additionally with the columns from servicegroups.
servicesbyhostgroup Like services, but additionally with the columns from hostgroups.
hostsbygroup Like hosts, but additionally with the columns from hostgroups.
contacts Information for the contacts.
commands All configured Check-Commands, as found for a service under Service check command.
timeperiods All information for the configured Time Periods.
downtimes As for timeperiods, but for scheduled maintenance times.
comments Contains all information for comments, and in addition the columns from hosts and services.
log All information for logged events. These should be filtered by class and time stamp/time period.
status Information for the core's status and performance.
columns All available tables will be listed here. Additionally,a description of all of a table's columns is also provided.
statehist The past-statuses for a host/service can be comprehensively searched with this table.
eventconsoleevents Lists all of the Event Console's events. This table additionally has all columns from hosts.
eventconsolehistory Like eventconsoleevents, but also with additional columns for an event's history.
eventconsolestatus Lists statistics from the performance of the Event Console.
eventconsolerules Statistics for how often the rule-matching for an incoming event was successful.

Should you wish to know which columns a table uses, these can be easily shown with the following command:

OMD[mysite]:~$ lq "GET columns\nColumns: name\nFilter: table = columns"
description
name
table
type

Other tables can also be selected by using filters. All of the columns available for searching by column and table can be seen in the output from the example shown.

2. Available headers

Header Argument Function
Columns Column name Restricts the output to the specified columns
Filter Column name, operator and object name Restricts the output to the defined object. See also [livestatus_references#filter]
OR Integer Links the last n filter(s) with a logical OR
AND Ganzzahl Links the last n filter(s) with a logical AND
NEGATE Integer Inverts the last n Filter(s)
Separators ASCII-values Defines the characters for separating elements
OutputFormat Name Defines an alternative output format for the data. Possible formats are json, python, python3, CSV and csv (the standard format)
Stats Operator and column names Generates statistics for specified columns
StatsOr Integer Provides the OR-header's functions in the statistics
StatsAnd Integer Provides the AND-header's functions in the statistics
StatsNegate Integer Provides the NEGATE-header's functions in the statistics
Limit Integer Limits the output to n lines
Timelimit Integer Restricts the time allowed for processing the query to n seconds
ColumnHeaders - The first line of the output contains the name of the column used. If the header ResponseHeader has additionally been set, the column name will be output in the second line
AuthUser User Name Restricts the output to the lines that the specified user is authorised to see
WaitObject Object Name The object for which a specified behaviour is expected. This is the object's name, or respectively in the case of the services table, the host's name followed by a blank character, followed in turn by the service description. If the host name itself contains blank characters the two elements can also be separated by a semicolon. This header is only supported by the hosts, services hostgroups servicegroups contacts and contactgroups tables
WaitCondition FilterCondition The condition that must be satisfied for the defined object. Any desired number of conditions can be defined – these are linked together with a logical and
WaitConditionOr Integer Provides the OR-header function in the Wait-conditions
WaitConditionAnd Integer Provides the AND-header function in the Wait-conditions
WaitConditionNegate Integer Provides the NEGATE-header function in the Wait-conditions
WaitTrigger Keyword* Keywords work like a normal condition if they are set by themselves. In combination with the WaitCondition this simplifies the locating of relevant log entries and reduces the overhead in Livestatus
WaitTimeout Integer Sets a time limit in milliseconds. Following, for example, 5000 Milliseconds (5 seconds), the query will be executed even if the condition has not been satisfied
Localtime Unix Time By using a specified reference time it is attempted to compensate for differing local time stamps in a distributed environment
ResponseHeader fixed16/off Returns a status line in the first line of the response. The output itself remains in the first line if the header ColumnHeaders has additionally been set
KeepAlive on Prevents the Livestatus-channel being closed following a query

* The following keywords are available for the WaitTrigger:

  • check
  • state
  • log
  • downtime
  • comment
  • command
  • program
  • all

3. Operators for filters

3.1. General operators

Operator* For numbers For character strings
= Equality Equality
~ Superset** Contains a character string as a regular expression.
=~ Subset** Case-insensitive equality
~~ Contains at least one of the values** Contains a case-insensitive character string as a regular expression
< Smaller than Lexicographically smaller than
> Larger than Lexicographically larger than
<= Smaller or equal Lexicographically smaller or equal
>= Larger or equal Lexicographically larger or equal

* All operators can be negated with an exclamation mark (!).

** These operators are useful when working with lists. Livestatus then interprets the specified values as a quantity.

3.2. Operators for lists

You can check whether an element is included in a list using the following operators:

Operator Type of check
= Checks for empty lists*
>= Equality
< Disparity
<= Case-insensitive equality
> Case-insensitive disparity
~ The character string for a regular expression*
~~ The case-insensitive character string for a regular expression*

* These operators can be negated with an exclamation mark (!).

4. Operators for statistics

Operator Description
sum Generates a sum from the values
min Searches for the smallest value
max Searches for the highest value
avg Calculates an average value (mean value)
std Outputs the standard deviation
suminv Inverts the sum of the values according to 1/sum
avginv Inverts the mean value of the values according to 1/avg

5. Status codes from the ResponseHeader

Status code Description
200 The query was successful and the response contains the requested data
400 The query contains a faulty header
404 The table could not be found
413 The time limit for the query has been exceeded
451 The query was incompletely transferred
452 The query is completely invalid

6. Commands

The following commands are available in the CMC with the  Check_MK Enterprise Edition:

Command Description
ACKNOWLEDGE_HOST_PROBLEM
ACKNOWLEDGE_SVC_PROBLEM
ADD_HOST_COMMENT
ADD_SVC_COMMENT
CHANGE_HOST_MODATTR
CHANGE_SVC_MODATTR
DEL_HOST_COMMENT
DEL_HOST_DOWNTIME
DEL_SVC_COMMENT
DEL_SVC_DOWNTIME
DISABLE_EVENT_HANDLERS
DISABLE_FLAP_DETECTION
DISABLE_HOST_CHECK
DISABLE_HOST_NOTIFICATIONS
DISABLE_HOST_SVC_NOTIFICATIONS
DISABLE_NOTIFICATIONS
DISABLE_PASSIVE_HOST_CHECKS
DISABLE_PASSIVE_SVC_CHECKS
DISABLE_PERFORMANCE_DATA
DISABLE_SVC_CHECK
DISABLE_SVC_NOTIFICATIONS
ENABLE_EVENT_HANDLERS
ENABLE_FLAP_DETECTION
ENABLE_HOST_CHECK
ENABLE_HOST_NOTIFICATIONS
ENABLE_HOST_SVC_NOTIFICATIONS
ENABLE_NOTIFICATIONS
ENABLE_PASSIVE_HOST_CHECKS
ENABLE_PASSIVE_SVC_CHECKS
ENABLE_PERFORMANCE_DATA
ENABLE_SVC_CHECK
ENABLE_SVC_NOTIFICATIONS
LOG
MK_LOGWATCH_ACKNOWLEDGE
MODIFY_HOST_DOWNTIME
MODIFY_SVC_DOWNTIME
PROCESS_HOST_CHECK_RESULT
PROCESS_HOST_PERFDATA
PROCESS_SERVICE_CHECK_RESULT
PROCESS_SVC_PERFDATA
RELOAD_CONFIG
REMOVE_HOST_ACKNOWLEDGEMENT
REMOVE_SVC_ACKNOWLEDGEMENT
REOPEN_DAEMONLOG
ROTATE_LOGFILE
SAVE_STATE_INFORMATION
SCHEDULE_FORCED_HOST_CHECK
SCHEDULE_FORCED_SVC_CHECK
SCHEDULE_HOST_DOWNTIME
SCHEDULE_SVC_DOWNTIME
SEGFAULT
SEND_CUSTOM_HOST_NOTIFICATION
SEND_CUSTOM_SVC_NOTIFICATION
START_EXECUTING_HOST_CHECKS
START_EXECUTING_SVC_CHECKS
STOP_EXECUTING_HOST_CHECKS
STOP_EXECUTING_SVC_CHECKS
UPDATE_SHADOW_HOST_STATE
UPDATE_SHADOW_SERVICE_STATE