Profundizando nagios.pdf


Vista previa del archivo PDF profundizando-nagios.pdf


Página 1...78 79 808182111

Vista previa de texto


* @author
*/

Joerg Linge <pitchfork@ederdrom.de>

$host=str_replace(' ', '_',strtolower($_GET['host']));
$srv=str_replace(' ', '_',strtolower($_GET['srv']));

if ($host!="" && $srv!="") {
header("Location: doku.php?id=nagios:".$host.":".$srv);
exit;
} elseif($host!="") {
header("Location: doku.php?id=nagios:".$host.":host");
exit;
} else {
header("Location: doku.php?id=nagios:index");
exit;
}
?>

Con lo cual deberemos agregar algunas directivas a la configuración de Nagios.
Ejemplo de un serviceextinfo, aunque tambien lo podemos aplicar dentro de la
plantilla inicial del servicio.
define serviceextinfo {
host_name router
service_description ping
notes_url /wiki/nagios.php?host=$HOSTNAME$&srv=$SERVICEDESC$
icon_image help.png
}

Desde Dokuwiki haciendo uso de la extension PHP, podemos embeber los datos
actuales de los objetos de Nagios, gracias a MK Live Status
<php>
$lista_servidores = shell_exec("/bin/echo -e \"GET hosts\nColumns: name address
alias state\n\" | /usr/local/bin/unixcat /usr/local/nagios/var/rw/live");
$lista_hosts = str_getcsv($lista_servidores, "\n");
echo "<div class='level2'>
<div class='table sectionedit3'>
<table class='inline'>
<th>Host</th><th>IP</th><th>Descripcion</th><th>Estado Actual</th><th>Metricas /
Informes</th>
";
foreach ($lista_hosts as $host) {
$host = explode(";", $host);
print "<tr><td>";
print "<a href='doku.php?id=nagios:servidores:".$host['0']."'>".
$host['0']."</a>";
print "</td><td>";