Nagios maneja eventos no traps,
Lo unico que se me ocurre que puedas hacer para armarte una "trapera" es tomar el nagios.log y mostrarlo a traves de un frontend,
Algo asi,
Creas un archivo logtail.php,
Donde dice tail -"10" puedes poner el numero que quieras para hacer una trapera a gusto
<?
// logtail.php
$cmd = "tail -10 /usr/local/nagios/var/nagios.log";
exec("$cmd 2>&1", $output);
foreach($output as $outputline) {
$palabra=preg_quote('CRITICAL');
$palabra2=preg_quote('OK');
$palabra3=preg_quote('WARNING');
if(eregi(".$palabra.",$outputline)) {
$image="critical.png";
} elseif(eregi(".$palabra2.",$outputline)) {
$image="recovery.png";
} elseif(eregi(".$palabra3.",$outputline)) {
$image="warning.png";
} else {
$image="info.png";
}
echo '<img src="'.$image.'" width="16" height="16">',("$outputline\n");
}
?>
Creas un archivo viewer.html
<html>
<head>
<script type="text/javascript" src="js/ajax.js"> </script>
<script type="text/javascript" src="js/logtail.js"> </script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
body {
background-color: #666;
}
</style>
</head>
<body onLoad="getLog('start');">
<table align="center" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><img src="barra_log.png" width="900" height="60"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<div id="log" style="border:solid 1px #ccc; margin-left:5px; font-size:9px;
padding-left:5px; padding-right:5px; padding-top:5px; padding-bottom:5px;
margin-top:5px; margin-bottom:5px; width:96%; text-align:left; color: #fff; font-size: 16px;"></div>
</tr>
</table>
</body>
Creas un directorio llamado js,
Creas un archivo llamado ajax.js
cat ajax.js
function createRequest() {
var request = null;
try {
request = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = null;
}
}
}
if (request == null) {
alert("Error creating request object!");
} else {
return request;
}
}
Creas un archivo llamado logtail.js
/* logtail.js
an ajax log file tailer / viewer
copyright 2007 john minnihan.
Released under these terms
1. This script, associated functions and HTML code ("the code") may be used by you ("the recipient") for any purpose.
2. This code may be modified in any way deemed useful by the recipient.
3. This code may be used in derivative works of any kind, anywhere, by the recipient.
4. Your use of the code indicates your acceptance of these terms.
5. This notice must be kept intact with any use of the code to provide attribution.
*/
function getLog(timer) {
var url = "logtail.php";
request.open("POST", url, true);
request.onreadystatechange = updatePage;
request.send(null);
startTail(timer);
}
function startTail(timer) {
if (timer == "stop") {
stopTail();
} else {
t= setTimeout("getLog()",4000);
}
}
function stopTail() {
t= setTimeout("getLog()",4000);
}
function updatePage() {
if (request.readyState == 4) {
if (request.status == 200) {
var currentLogValue = request.responseText.split("\n");
eval(currentLogValue);
logDiv = document.getElementById("log");
var logLine = ' ';
for (i=0; i < currentLogValue.length - 1; i++) {
logLine += currentLogValue[i] + '<br/>\n';
}
logDiv.innerHTML=logLine;
} else
alert("Error! Request status is " + request.status);
}
Creas otro archivo viewer.html
<html>
<head>
<script type="text/javascript" src="js/ajax.js"> </script>
<script type="text/javascript" src="js/logtail.js"> </script>
</head>
<body onLoad="getLog('start');">
<div id="log" style="border:solid 1px #dddddd; margin-left:25px; font-size:9px;
padding-left:5px; padding-right:10px; padding-top:10px; padding-bottom:20px;
margin-top:10px; margin-bottom:10px; width:90%; text-align:left; color: #036; font-size: 12px;"></div>
</body>