Depuis la version 1.1.0rc1 check_mk embarque un nouvel élément qui mérite à lui seul le détour. Cet élément se nomme livestatus et vient combler à lui seul les derniers manques de Nagios, pouvoir enfin dialoguer avec nagios sans middleware type ndo ou merlin. L’avantage de cette méthode est un accès aux données (comme celles du status.dat) immédiat et sans IO disque ! La performance est au rendez vous : 50000 services récupérés en moins de 2 secondes !!!. Autre avantage, l’installation de livestatus est enfantine et se limite à configurer un broker d’événement dans le fichier de configuration principal de nagios.
Au démarrage de Nagios livestatus créé un socket unix et se met en écoute de celui ci. Il suffit alors d’écrire des requêtes dans ce socket pour obtenir les informations de nagios (services, hôtes, groupes, contact, downtime …). Les requêtes sont formatées selon un langage spécifiquement créé pour l’occasion : LQL. Il présente une philosophie assez proche de SQL (accés aux données dans des “tables”, filtre correspondant aux clauses where, possibilité de regroupement….).
Nous aurons besoins des outils de compilation pour réaliser cette opération :
yum install gcc gcc-c++ make automake autoconf libtool m4
: A rédiger
tar zxvf mk-livestatus-1.1.12p7.tar.gz
cd mk-livestatus-1.1.12p7 ./configure make
cp src/livestatus.o /usr/local/nagios/bin/
cp src/unixcat /usr/local/nagios/bin/
broker_module=/usr/local/nagios/bin/livestatus.o /usr/local/nagios/var/rw/live event_broker_options=-1
/etc/init.d/nagios restart
De par sa conception livestatus ne peut être interrogé que localement. Il existe une possibilité de le rendre accéssible via le réseau au travers de xinetd. Xinetd n’est pas installé par défaut :
yum install xinetd
: à rédiger
Créer un fichier /etc/xinetd.d/livestatus et copier le contenu suivant :
service livestatus { type = UNLISTED port = 6557 socket_type = stream protocol = tcp wait = no # limit to 100 connections per second. Disable 3 secs if above. cps = 100 3 # Disable TCP delay, makes connection more responsive flags = NODELAY user = nagios server = /usr/local/nagios/bin/unixcat server_args = /usr/local/nagios/var/rw/live # configure the IP address(es) of your Nagios server here: # only_from = localhost 192.168.0.254 disable = no }
# echo "GET hosts" | /usr/local/nagios/bin/unixcat /usr/local/nagios/var/rw/live accept_passive_checks;acknowledged;acknowledgement_type;action_url;action_url_expanded;active_checks_enabled;address;alias;check_command;check_flapping_recovery_notification;check_freshness;check_interval;check_options;check_period;check_type;checks_enabled;childs;comments;comments_with_info;contact_groups;contacts;current_attempt;current_notification_number;custom_variable_names;custom_variable_values;custom_variables;display_name;downtimes;downtimes_with_info;event_handler_enabled;execution_time;filename;first_notification_delay;flap_detection_enabled;groups;hard_state;has_been_checked;high_flap_threshold;icon_image;icon_image_alt;icon_image_expanded;in_check_period;in_notification_period;initial_state;is_executing;is_flapping;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;parents;pending_flex_downtime;percent_state_change;perf_data;plugin_output;pnpgraph_present;process_performance_data;retry_interval;scheduled_downtime_depth;services;services_with_info;services_with_state;state;state_type;statusmap_image;total_services;worst_service_hard_state;worst_service_state;x_3d;y_3d;z_3d 1;0;0;;;1;127.0.0.1;localhost;check-host-alive;0;0;5.0000000000e+00;0;24x7;0;1;;;;admins;nagiosadmin;5;0;;;;localhost;;;1;1.2804000000e-02;;0.0000000000e+00;1;linux-servers;0;1;0.0000000000e+00;;;;1;1;0;1;0;1338285655;0;1338284997;0;1;1338285665;1338285665;0;0;1.6000000000e-02;;0.0000000000e+00;10;0;;localhost;1338285725;0;0;;;;;1.2000000000e+02;workhours;1;8;8;8;0;0;0;0;0;0;0;1;;0;4.9342105263e+00;;(Return code of 127 is out of bounds - plugin may be missing);-1;1;1.0000000000e+00;0;Total Processes,Swap Usage,SSH,Root Partition,PING,HTTP,Current Users,Current Load;Total Processes|2|1|(Return code of 127 is out of bounds - plugin may be missing),Swap Usage|2|1|(Return code of 127 is out of bounds - plugin may be missing),SSH|2|1|(Return code of 127 is out of bounds - plugin may be missing),Root Partition|2|1|(Return code of 127 is out of bounds - plugin may be missing),PING|2|1|(Return code of 127 is out of bounds - plugin may be missing),HTTP|2|1|(Return code of 127 is out of bounds - plugin may be missing),Current Users|2|1|(Return code of 127 is out of bounds - plugin may be missing),Current Load|2|1|(Return code of 127 is out of bounds - plugin may be missing);Total Processes|2|1,Swap Usage|2|1,SSH|2|1,Root Partition|2|1,PING|2|1,HTTP|2|1,Current Users|2|1,Current Load|2|1;1;0;;8;2;2;0.0000000000e+00;0.0000000000e+00;0.0000000000e+00
echo "GET hosts" > hosts.lql nc 127.0.0.1 6557 < hosts.lql
Multisite est la console de supervision du projet check_mk. Elle permet d’agréger plusieurs collecteurs nagios/shinken indépendant en son sein grâce à livestatus. Cette agrégation peut être configurée dans le fichier multisite.mk de multisite. Vous pourrez trouver ce fichier dans /usr/local/check_mk/etc/
La déclaration d’un nouveau collecteur se fait de la manière suivante :
sites = { "nagios1" : { "alias" : "nagios1", "socket" : "tcp:192.168.122.128:6557" } }
Si nous voulons rajouter le collecteur local à la machine exécutant multisite, cela se fait en rajoutant une entrée de la manière suivante :
sites = { "nagios1" : { "alias" : "nagios1", "socket" : "tcp:192.168.122.128:6557" }, "local" : { "alias" : "local", } }