manuales:nagios:capacitacion:desarrollo_de_plugins_de_nagios
Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anteriorRevisión previa | Próxima revisiónAmbos lados, revisión siguiente | ||
manuales:nagios:capacitacion:desarrollo_de_plugins_de_nagios [2015/10/16 14:55] – cayu | manuales:nagios:capacitacion:desarrollo_de_plugins_de_nagios [2015/10/22 14:51] – cayu | ||
---|---|---|---|
Línea 1: | Línea 1: | ||
====== Desarrollo de plugins de Nagios ====== | ====== Desarrollo de plugins de Nagios ====== | ||
- | |||
==== Ejemplo de plugins SNMP ==== | ==== Ejemplo de plugins SNMP ==== | ||
- | |||
snmpd.conf | snmpd.conf | ||
< | < | ||
Línea 61: | Línea 59: | ||
check_interval | check_interval | ||
notification_interval | notification_interval | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== Ejemplos de scripts generales ==== | ||
+ | == check_heartbeat == | ||
+ | |||
+ | Script simple para chequear el estado de HeartBeat y sus nodos, muy útil por cierto | ||
+ | |||
+ | <file bash check_heartbeat> | ||
+ | #!/bin/bash | ||
+ | # Author: Emmanuel Bretelle | ||
+ | # Date: 12/03/2010 | ||
+ | # Description: | ||
+ | # Based on http:// | ||
+ | # | ||
+ | # Autor: Stanila Constantin Adrian | ||
+ | # Date: 20/03/2009 | ||
+ | # Description: | ||
+ | # http:// | ||
+ | |||
+ | # Get program path | ||
+ | REVISION=1.3 | ||
+ | PROGNAME=`/ | ||
+ | PROGPATH=`echo $0 | /bin/sed -e ' | ||
+ | |||
+ | NODE_NAME=`uname -n` | ||
+ | CL_ST='/ | ||
+ | |||
+ | #nagios error codes | ||
+ | #. $PROGPATH/ | ||
+ | OK=0 | ||
+ | WARNING=1 | ||
+ | CRITICAL=2 | ||
+ | UNKNOWN=3 | ||
+ | |||
+ | usage () { | ||
+ | echo "\ | ||
+ | Nagios plugin to heartbeat. | ||
+ | |||
+ | Usage: | ||
+ | $PROGNAME | ||
+ | $PROGNAME [--help | -h] | ||
+ | $PROGNAME [--version | -v] | ||
+ | |||
+ | Options: | ||
+ | --help -l Print this help information | ||
+ | --version -v Print version of plugin | ||
+ | " | ||
+ | } | ||
+ | |||
+ | help () { | ||
+ | print_revision $PROGNAME $REVISION | ||
+ | echo; usage; echo; support | ||
+ | } | ||
+ | |||
+ | |||
+ | while test -n " | ||
+ | do | ||
+ | case " | ||
+ | --help | -h) | ||
+ | help | ||
+ | exit $STATE_OK;; | ||
+ | --version | -v) | ||
+ | print_revision $PROGNAME $REVISION | ||
+ | exit $STATE_OK;; | ||
+ | # -H) | ||
+ | # shift | ||
+ | # HOST=$1;; | ||
+ | # -C) | ||
+ | # shift | ||
+ | # COMMUNITY=$1;; | ||
+ | *) | ||
+ | echo " | ||
+ | esac | ||
+ | shift | ||
+ | done | ||
+ | |||
+ | $CL_ST hbstatus > /dev/null | ||
+ | res=$? | ||
+ | if [ $res -ne 0 ] | ||
+ | then | ||
+ | echo " | ||
+ | exit $CRITICAL | ||
+ | fi | ||
+ | |||
+ | declare -i I=0 | ||
+ | declare -i A=0 | ||
+ | NODES=`$CL_ST listnodes` | ||
+ | |||
+ | for node in $NODES | ||
+ | do | ||
+ | status=`$CL_ST nodestatus $node` | ||
+ | let I=$I+1 | ||
+ | if [ $status == " | ||
+ | then | ||
+ | let A=$A+1 | ||
+ | fi | ||
+ | done | ||
+ | |||
+ | if [ $A -eq 0 ] | ||
+ | then | ||
+ | echo " | ||
+ | exit $CRITICAL | ||
+ | elif [ $A -ne $I ] | ||
+ | then | ||
+ | echo " | ||
+ | exit $WARNING | ||
+ | else | ||
+ | echo " | ||
+ | exit $OK | ||
+ | fi | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | define command { | ||
+ | | ||
+ | | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | == check_systemimager == | ||
+ | |||
+ | Script para chequear que nuestras imágenes estén actualizadas a la fecha | ||
+ | |||
+ | <file php check_systemimager> | ||
+ | # | ||
+ | # Sergio Cayuqueo < | ||
+ | # http:// | ||
+ | <?php | ||
+ | $lista_imagenes = shell_exec(" | ||
+ | $lista_imagenes = preg_split("/ | ||
+ | $fecha_actual = date(' | ||
+ | foreach($lista_imagenes as $imagen) { | ||
+ | if(strlen($imagen)> | ||
+ | if(@!$i) { | ||
+ | $i=1; | ||
+ | } | ||
+ | $imagen = preg_split("/ | ||
+ | $imagenes[$i][' | ||
+ | $imagenes[$i][' | ||
+ | $imagenes[$i][' | ||
+ | if($imagen[4] == $fecha_actual) { | ||
+ | $imagenes[$i][' | ||
+ | } else { | ||
+ | $imagenes[$i][' | ||
+ | $critical=1; | ||
+ | } | ||
+ | $i++; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | if(@$critical) { | ||
+ | $head = " | ||
+ | $exit = 2; | ||
+ | } else { | ||
+ | $head = "OK - Todas las imagenes actualizadas a la fecha\n"; | ||
+ | $exit = 0; | ||
+ | } | ||
+ | print $head; | ||
+ | foreach($imagenes as $imagen) { | ||
+ | if(strlen($imagen[' | ||
+ | $tab = " | ||
+ | } else { | ||
+ | $tab = " | ||
+ | } | ||
+ | if($imagen[' | ||
+ | print "OK - " | ||
+ | } else { | ||
+ | print " | ||
+ | } | ||
+ | } | ||
+ | exit($exit); | ||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | |||
+ | < | ||
+ | define command { | ||
+ | | ||
+ | | ||
} | } | ||
</ | </ |
manuales/nagios/capacitacion/desarrollo_de_plugins_de_nagios.txt · Última modificación: 2016/07/27 15:12 por cayu