Livestatus

letzte Änderung: 9. Jan 2015, 18:51 Veröffentlicht: 18. Nov 2010, 19:23

Inhaltsverzeichnis

Das Broker-Modul mk_livestatus bietet einen direkten Zugriff auf die aktuellen Statusdaten von Nagios-Objekten als Alternative zu NDO oder zur Abfrage der Dateien status.dat und nagios.log.

Vorteile:

  • hochperformante Abfrage
  • aktuelle Daten
  • flexible Abfragesprache

 

Implementierung in shinken

Shinken enthält eine eigene Implementierung von Livestatus:

define broker {
    broker_name     broker-1
    address         localhost
    port            7772
    spare           0
.
.
.
    modules     Livestatus, Simple-log, WebUI, NPCDMOD, PickleRetentionBroker
.
.
.
}

 

define module {
    module_name     Livestatus
    module_type     livestatus
    host            172.24.42.11	; * = listen on all configured IP addresses
    port            50000

    modules         logsqlite
}

 

define module {
    module_name     logsqlite
    module_type     logstore_sqlite
    database_file   /usr/local/shinken/var/livelogs.db
    max_logs_age    3m  ; d = days, w = weeks, m = months, y = years
}

 

Abfrage Beispiele

 

Liste aller Informationen eines Host

echo -e "GET hosts\nFilter: host_name = win-ts-01" | unixcat /usr/local/nagios/var/rw/live

oder

echo -e "GET hosts\nFilter: host_name = win-ts-01" | netcat 172.24.42.11 50000

 

srv-mon-01:/usr/local/shinken # echo -e "GET hosts\nFilter: host_name = win-ts-01" | netcat 172.24.42.11 50000
accept_passive_checks;acknowledged;acknowledgement_type;action_url;action_url_expanded;active_checks_enabled;address;alias;business_impact;check_command;check_flapping_recovery_notification;check_freshness;check_interval;check_options;check_period;check_type;checks_enabled;child_dependencies;childs;comments;comments_with_info;contact_groups;contacts;criticity;current_attempt;current_notification_number;custom_variable_names;custom_variable_values;custom_variables;display_name;downtimes;downtimes_with_info;event_handler;event_handler_enabled;execution_time;filename;first_notification_delay;flap_detection_enabled;got_business_rule;groups;hard_state;has_been_checked;high_flap_threshold;icon_image;icon_image_alt;icon_image_expanded;impacts;in_check_period;in_notification_period;initial_state;is_executing;is_flapping;is_impact;is_problem;last_check;last_hard_state;last_hard_state_change;last_notification;last_state;last_state_change;last_time_down;last_time_unreachable;last_time_up;latency;long_plugin_output;low_flap_threshold;max_check_attempts;modified_attributes;modified_attributes_list;name;next_check;next_notification;no_more_notifications;notes;notes_expanded;notes_url;notes_url_expanded;notification_interval;notification_period;notifications_enabled;num_services;num_services_crit;num_services_hard_crit;num_services_hard_ok;num_services_hard_unknown;num_services_hard_warn;num_services_ok;num_services_pending;num_services_unknown;num_services_warn;obsess_over_host;parent_dependencies;parents;pending_flex_downtime;percent_state_change;perf_data;plugin_output;pnpgraph_present;poller_tag;process_performance_data;realm;retry_interval;scheduled_downtime_depth;services;services_with_info;services_with_state;source_problems;state;state_type;statusmap_image;total_services;worst_service_hard_state;worst_service_state;x_3d;y_3d;z_3d
1;0;1;/pnp4nagios/graph?host=$HOSTNAME$&srv=_HOST_;/pnp4nagios/graph?host=win-ts-01&srv=_HOST_;1;172.16.42.111;win-ts-01;2;check_host_alive;1;0;1;;24x7;0;1;win-ts-01/Info-Client-Version,win-ts-01/System_SWAP,win-ts-01/Remote_Service_ICA,win-ts-01/System_Services_Citrix,win-ts-01/Remote_Service_RDP,win-ts-01/System_Uptime,win-ts-01/System_Services_Windows,win-ts-01/System_CPU,win-ts-01/System_MEM,win-ts-01/System_Drive,win-ts-01/Terminaldienste_Sitzungen_insgesamt,win-ts-01/System_Timesync;;;;admins;admin,dagmar,waltraut,herbert;2;1;0;;;;win-ts-01;;;;0;0.0100150108337;;0;1;0;citrix,windows;;1;50;;;;;1;1;u;0;0;0;0;1419344165;UP;1419292972;1411719380;UP;1419292972;1419292965;0;1419344165;2.05769205093;;25;2;0;;win-ts-01;1419344223;0;0;;;;;1440;24x7;1;12;0;0;12;0;0;12;0;0;0;0;;;0;0.0;pkt=1;;0;5 rta=0.365;1000.000;2000.000;;;OK - 172.16.42.111 responds to ICMP. Packet 1, rta 0.365ms;0;;1;All;0;0;System_Services_Windows,Info-Client-Version,System_Drive,System_MEM,System_CPU,Remote_Service_RDP,System_Timesync,System_Uptime,System_SWAP,Remote_Service_ICA,System_Services_Citrix,Terminaldienste_Sitzungen_insgesamt;;System_Services_Windows|0|1,Info-Client-Version|0|1,System_Drive|0|1,System_MEM|0|1,System_CPU|0|1,Remote_Service_RDP|0|1,System_Timesync|0|1,System_Uptime|0|1,System_SWAP|0|1,Remote_Service_ICA|0|1,System_Services_Citrix|0|1,Terminaldienste_Sitzungen_insgesamt|0|1;;0;1;;;0;0;;;

 

Liste aller Services eines Hosts

Da die ungefilterte Ausgabe extrem viel Daten enthält wird die Ausgabe durch den Einsatz von Filter auf die benötigeten Daten reduziert:

 

echo -e "GET hosts\nColumns: host_name services\nFilter: host_name = win-ts-01" | netcat 172.24.42.11 50000

 

srv-mon-01:/usr/local/shinken # echo -e "GET hosts\nColumns: host_name services\nFilter: host_name = win-ts-01" | netcat 172.24.42.11 50000
win-ts-01;System_Services_Windows,Info-Client-Version,System_Drive,System_MEM,System_CPU,Remote_Service_RDP,System_Timesync,System_Uptime,System_SWAP,Remote_Service_ICA,System_Services_Citrix,Terminaldienste_Sitzungen_insgesamt

 

Liste mit allen Services

Ausgabe einer Liste mit allen Services nach Hosts sortiert unter angabe von <HOST_NAME>;<SERVICE_DESCRIPTION>;<NOTIFICATION_PERIOD>

echo -e "GET services\nColumns: host_name description notification_period\n" | netcat 172.16.42.11 50000

 

srv-mon-01:/usr/local/shinken # echo -e "GET services\nColumns: host_name description notification_period\n" | netcat 172.16.42.11 50000
win-ts-01;Info-Client-Version;24x7
win-ts-01;Remote_Service_ICA;24x7
win-ts-01;Remote_Service_RDP;24x7
win-ts-01;System_CPU;24x7
win-ts-01;System_Drive;24x7
win-ts-01;System_MEM;24x7
win-ts-01;System_SWAP;24x7
win-ts-01;System_Services_Citrix;24x7
win-ts-01;System_Services_Windows;24x7
win-ts-01;System_Timesync;24x7
win-ts-01;System_Uptime;24x7
win-ts-01;Terminaldienste_Sitzungen_insgesamt;24x7
www-01;Info-Client-Version;24x7
www-01;Info-OS-Version;24x7
www-01;System_CPU;24x7
www-01;System_Disk_IO;24x7
www-01;System_Disk_Inode;24x7
www-01;System_Disk_Space;24x7
www-01;System_Load;24x7
www-01;System_LocalUserMailbox_root;24x7
www-01;System_LogFile_Sizes;24x7
www-01;System_MEM;24x7
www-01;System_Open_Files;24x7
www-01;System_Process_NTPD;24x7
www-01;System_Process_Total;24x7
www-01;System_Process_Zombie;24x7
www-01;System_Timesync;24x7
www-01;System_Uptime;24x7

 

Einzelnen Konfigurationsparameter anzeigen

Anzeige des Wertes notification_period des Services System_CPU auf dem Host win-ts-01

echo -e "GET services\nColumns: host_name description notification_period\nFilter: host_name = win-ts-01\nFilter: description = System_CPU" | netcat 172.24.42.11 50000

 

srv-mon-01:/usr/local/shinken # echo -e "GET services\nColumns: host_name description notification_period\nFilter: host_name = win-ts-01\nFilter: description = System_CPU" | netcat 172.24.42.11 50000
win-ts-01;System_CPU;24x7

 

Hostobjekte einer Hostgruppe

alle Hostnamen der Gruppe „linux“

echo -e "GET hosts\n Columns: host_name\nFilter: host_state = 0\nFilter: groups >= linux" | netcat 172.24.42.11 50000

 

srv-mon-01:/usr/local/shinken # echo -e "GET hosts\n Columns: host_name\nFilter: host_state = 0\nFilter: groups >= linux" | netcat 172.24.42.11 50000
www-01
www-02
www-03
dns-01
dns-02
px-01
db-01
db-02

 

Hostobjekte einer Hostgruppe mit Status und Gruppenzugehörigkeit

alle Host-Objekte der Gruppe „citrix“ mit Status und Gruppenzugehörigkeit

echo -e "GET hosts\n Columns: host_name host_state groups\nFilter: host_state = 0\nFilter: groups >= citrix" | netcat 172.24.42.11 50000

 

srv-mon-01:/usr/local/shinken # echo -e "GET hosts\n Columns: host_name host_state groups\nFilter: host_state = 0\nFilter: groups >= citrix" | netcat 172.24.42.11 50000
win-ts-01;0;citrix,windows,L2-Support,Zone7
win-ts-02;0;citrix,windows,L2-Support,Zone7
win-ts-03;0;citrix,windows,L2-Support,Zone7
win-ts-04;0;citrix,windows,L2-Support,Zone7