diff --git a/doc/2.4-setting-up-livestatus.md b/doc/2.4-setting-up-livestatus.md index 86c6dad6d..8e1b24e76 100644 --- a/doc/2.4-setting-up-livestatus.md +++ b/doc/2.4-setting-up-livestatus.md @@ -15,6 +15,9 @@ The Livestatus component that is distributed as part of Icinga 2 is a re-implementation of the Livestatus protocol which is compatible with MK Livestatus. +Details on the available tables and attributes with Icinga 2 can be found +in the [Livestatus Schema](#schema-livestatus) section. + You can enable Livestatus using icinga2-enable-feature: # icinga2-enable-feature livestatus diff --git a/doc/6.12-schemas.md b/doc/6.12-schemas.md index 1516d25ee..fc91e1bbb 100644 --- a/doc/6.12-schemas.md +++ b/doc/6.12-schemas.md @@ -1,16 +1,179 @@ -### Schemas +## Schemas -#### DB IDO +### DB IDO -New tables: endpoints, endpointstatus -name, identity, node, is_connected +There is a detailed documentation for the Icinga IDOUtils 1.x +database schema available on [http://docs.icinga.org/latest/en/db_model.html] -New columns: endpoint_object_id, check_source_object_id +#### DB IDO Schema Extensions -#### Livestatus +Icinga 2 specific extensions are shown below: -New table: endpoints -name, identity, node, is_connected +New tables: `endpoints`, `endpointstatus` -New columns: check_source, endpoint + Table | Column | Type | Default | Description + --------------------|--------------------|----------|---------|------------- + endpoints | endpoint_object_id | bigint | NULL | FK: objects table + endpoints | identity | TEXT | NULL | endpoint name + endpoints | node | TEXT | NULL | local node name + + Table | Column | Type | Default | Description + --------------------|--------------------|----------|---------|------------- + endpointstatus | endpoint_object_id | bigint | NULL | FK: objects table + endpointstatus | identity | TEXT | NULL | endpoint name + endpointstatus | node | TEXT | NULL | local node name + endpointstatus | is_connected | smallint | 0 | update on endpoint connect/disconnect + +New columns: + + Table | Column | Type | Default | Description + --------------------|--------------------|----------|---------|------------- + all status/history | endpoint_object_id | bigint | NULL | FK: objects table + servicestatus | check_source | TEXT | NULL | node name where check was executed + hoststatus | check_source | TEXT | NULL | node name where check was executed + statehistory | check_source | TEXT | NULL | node name where check was executed + logentries | object_id | bigint | NULL | FK: objects table (service associated with column) + + + +### Livestatus + + +#### Livestatus Tables + + Table | Join |Description + --------------|-----------|---------------------------- + hosts | | host config and status attributes, services counter + hostgroups | | hostgroup config, status attributes and host/service counters + services | hosts | service config and status attributes + servicegroups | | servicegroup config, status attributes and service counters + contacts | | contact config and status attributes + contactgroups | | contact config, members + commands | | command name and line + status | | programstatus, config and stats + comments | services | status attributes + downtimes | services | status attributes + timeperiods | | name and is inside flag + endpoints | | config and status attributes + log | services, hosts, contacts, commands | parses [compatlog](#objecttype-compatlogger) and shows log attributes + statehist | hosts, services | parses [compatlog](#objecttype-compatlogger) and aggregates state change attributes + +> **Note** +> +> The `commands` table is populated with `CheckCommand`, `EventCommand` and `NotificationCommand` objects. + + +#### Livestatus Table Attributes + +A detailed list which table attributes are supported can be found here: [https://wiki.icinga.org/display/icinga2/Livestatus#Livestatus-Attributes] + + +#### Livestatus GET Queries + + $ echo -e 'GET services' | netcat 127.0.0.1 6558 + + $ cat servicegroups < Livestatus COMMAND Queries + + $ echo -e 'COMMAND ' | netcat 127.0.0.1 6558 + + +#### Livestatus Filters + +and, or, negate + + Operator | Negate | Description + ----------|------------------------ + = | != | Euqality + ~ | !~ | Regex match + =~ | !=~ | Euqality ignoring case + ~~ | !~~ | Regex ignoring case + > | | Less than + < | | Greater than + >= | | Less than or equal + <= | | Greater than or equal + + +#### Livestatus Stats + +Schema: "Stats: aggregatefunction aggregateattribute" + + Aggregate Function | Description + -------------------|-------------- + sum | + min | + max | + avg | sum / count + std | standard deviation + suminv | sum (1 / value) + avginv | suminv / count + count | ordinary default for any stats query if not aggregate function defined + +Example: + + GET hosts + Filter: has_been_checked = 1 + Filter: check_type = 0 + Stats: sum execution_time + Stats: sum latency + Stats: sum percent_state_change + Stats: min execution_time + Stats: min latency + Stats: min percent_state_change + Stats: max execution_time + Stats: max latency + Stats: max percent_state_change + OutputFormat: json + ResponseHeader: fixed16 + +#### Livestatus Output + +* CSV + +CSV Output uses two levels of array seperators: The members array separator +is a comma (1st level) while extra info and host|service relation separator +is a pipe (2nd level). + +Seperators can be set using ASCII codes like: + + Separators: 10 59 44 124 + +* JSON + +Default separators. + +#### Livestatus Error Codes + + Code | Description + ----------|-------------- + 200 | OK + 404 | Table does not exist + 452 | Exception on query + +#### Livestatus Schema Extensions + +Icinga 2 specific extensions are shown below: + +New table: `endpoints` + + Table | Column + ----------|-------------- + endpoints | name + endpoints | identity + endpoints | node + endpoints | is_connected + +New columns: + + Table | Column + ----------|-------------- + services | check_source + downtimes | triggers + downtimes | trigger_time