manuales:nagios:capacitacion:mk_livestatus
Diferencias
Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
| manuales:nagios:capacitacion:mk_livestatus [2015/10/16 17:53] – cayu | manuales:nagios:capacitacion:mk_livestatus [2016/03/21 18:49] (actual) – [Compilación] cayu | ||
|---|---|---|---|
| Línea 35: | Línea 35: | ||
| ==== Compilación ==== | ==== Compilación ==== | ||
| < | < | ||
| - | root@linux# wget ' | + | root@linux# wget ' |
| - | root@linux# tar xzf mk-livestatus-1.1.2.tar.gz | + | root@linux# tar xzf mk-livestatus-1.2.6p16.tar.gz |
| - | root@linux# cd mk-livestatus-1.1.2 | + | root@linux# cd mk-livestatus-1.2.6p16 |
| root@linux# | root@linux# | ||
| - | root@linux# ./configure | + | root@linux# ./ |
| checking for a BSD-compatible install... / | checking for a BSD-compatible install... / | ||
| checking whether build environment is sane... yes | checking whether build environment is sane... yes | ||
| Línea 71: | Línea 71: | ||
| root@linux# make install | root@linux# make install | ||
| Making install in src | Making install in src | ||
| - | make[1]: Entering directory `/ | + | make[1]: Entering directory `/ |
| - | make[2]: Entering directory `/ | + | make[2]: Entering directory `/ |
| test -z "/ | test -z "/ | ||
| / | / | ||
| Línea 78: | Línea 78: | ||
| / | / | ||
| | | ||
| - | /bin/sh / | + | /bin/sh / |
| / | / | ||
| rm -f / | rm -f / | ||
| - | make[2]: Leaving directory `/ | + | make[2]: Leaving directory `/ |
| - | make[1]: Leaving directory `/ | + | make[1]: Leaving directory `/ |
| - | make[1]: Entering directory `/ | + | make[1]: Entering directory `/ |
| - | make[2]: Entering directory `/ | + | make[2]: Entering directory `/ |
| make[2]: Nothing to be done for `install-exec-am' | make[2]: Nothing to be done for `install-exec-am' | ||
| make[2]: Nothing to be done for `install-data-am' | make[2]: Nothing to be done for `install-data-am' | ||
| - | make[2]: Leaving directory `/ | + | make[2]: Leaving directory `/ |
| - | make[1]: Leaving directory `/ | + | make[1]: Leaving directory `/ |
| </ | </ | ||
| Despues tenemos que especificar que Nagios cargue el archivo objeto compilado // | Despues tenemos que especificar que Nagios cargue el archivo objeto compilado // | ||
| Línea 99: | Línea 99: | ||
| Y dentro del log de Nagios vamos a ver algo similar a esto | Y dentro del log de Nagios vamos a ver algo similar a esto | ||
| < | < | ||
| - | [1256144866] livestatus: Version | + | [1256144866] livestatus: Version 1.2.6p16 initializing. Socket path: '/ |
| / | / | ||
| [1256144866] livestatus: Created UNIX control socket at / | [1256144866] livestatus: Created UNIX control socket at / | ||
| Línea 157: | Línea 157: | ||
| </ | </ | ||
| ===== Ejemplos ===== | ===== Ejemplos ===== | ||
| + | ==== Python ==== | ||
| + | === livestatus === | ||
| <code python> | <code python> | ||
| # | # | ||
| - | # -*- encoding: utf-8; py-indent-offset: | ||
| - | # +------------------------------------------------------------------+ | ||
| - | # | ____ _ | ||
| - | # | / ___| |__ | ||
| - | # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | | ||
| - | # | | |___| | | | __/ (__| < | ||
| - | # | \____|_| |_|\___|\___|_|\_\___|_| | ||
| - | # | | | ||
| - | # | Copyright Mathias Kettner 2013 | ||
| - | # +------------------------------------------------------------------+ | ||
| - | # | ||
| - | # This file is part of Check_MK. | ||
| - | # The official homepage is at http:// | ||
| - | # | ||
| - | # check_mk is free software; | ||
| - | # under the terms of the GNU General Public License | ||
| - | # the Free Software Foundation in version 2. check_mk is distributed | ||
| - | # in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
| - | # out even the implied warranty of MERCHANTABILITY | ||
| - | # PARTICULAR PURPOSE. See the GNU General Public License for more de- | ||
| - | # ails. You should have received | ||
| - | # License along with GNU Make; see the file COPYING. | ||
| - | # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, | ||
| - | # Boston, MA 02110-1301 USA. | ||
| - | |||
| import os | import os | ||
| import livestatus | import livestatus | ||
| try: | try: | ||
| - | # omd_root = os.getenv(" | ||
| socket_path = " | socket_path = " | ||
| except: | except: | ||
| - | sys.stderr.write(" | ||
| - | sys.stderr.write(" | ||
| - | sys.stderr.write(" | ||
| sys.exit(1) | sys.exit(1) | ||
| Línea 228: | Línea 201: | ||
| except Exception, e: # livestatus.MKLivestatusException, | except Exception, e: # livestatus.MKLivestatusException, | ||
| print " | print " | ||
| + | </ | ||
| + | === Monitoring:: | ||
| + | API de Perl para acceder a datos Nagios e Icinga por medio de check_mk livestatus | ||
| + | <code perl> | ||
| + | use Monitoring:: | ||
| + | my $ml = Monitoring:: | ||
| + | socket => '/ | ||
| + | ); | ||
| + | my $hosts = $ml-> | ||
| + | </ | ||
| + | == new ([ARGS]) == | ||
| + | Creates an Monitoring:: | ||
| + | Crea el objeto Monitoring:: | ||
| + | ^Argumentos^^ | ||
| + | ^socket|Ruta al socket UNIX de check_mk livestatus| | ||
| + | ^server|Usar este servidor para una conexión TCP| | ||
| + | ^peer|Camino alternativo al socket o servidor, si se usa el valor ':' | ||
| + | ^name|Nombre para la conexión, default dirección socket/ | ||
| + | ^verbose|Modo verbose| | ||
| + | ^line_seperator|Código ascii separador de líneas default 10, (newline)| | ||
| + | ^column_seperator|Código ascii separador de columnas, defaults 0 (null byte)| | ||
| + | ^list_seperator|Código ascii separador de listas, default 44 (comma)| | ||
| + | ^host_service_seperator|Código ascii separador host/ | ||
| + | ^keepalive|keepalive. Default off| | ||
| + | ^errors_are_fatal|Errores con mensaje de caída. Default: on| | ||
| + | ^warnings|muestran advertencias en las consultas sin Columnas| | ||
| + | ^timeout|Tiempo de espera general. Usado para conexión y consultas| | ||
| + | ^query_timeout|set a query timeout. Used for retrieving querys, Default 60sec| | ||
| + | ^connect_timeout|Tiempo de espera de conexión inicial. Por defecto 5 s| | ||
| + | == Limit == | ||
| + | <code perl> | ||
| + | my $array_ref = $ml-> | ||
| + | " | ||
| + | { Limit => " | ||
| + | ); | ||
| + | </ | ||
| + | ==== Perl ==== | ||
| + | === Monitoring:: | ||
| + | <code perl> | ||
| + | # | ||
| + | use Monitoring:: | ||
| + | |||
| + | $filtergrp = ' | ||
| + | |||
| + | $ml = Monitoring:: | ||
| + | socket => '/ | ||
| + | ); | ||
| + | |||
| + | my $up = $ml-> | ||
| + | my $down = $ml-> | ||
| + | my $unknown = $ml-> | ||
| + | my $total = $up + $down + $unknown; | ||
| + | |||
| + | print " | ||
| </ | </ | ||
manuales/nagios/capacitacion/mk_livestatus.1445017981.txt.gz · Última modificación: 2015/10/16 17:53 por cayu
