2009-11-06 Miguel de Dios <miguel.dedios@artica.es>
* operation/snmpconsole/snmp_view.php: fix and optimize the query to traps in DB, because the old style didn't run with paginator and it was slow with much traps registers. * operation/agentes/status_monitor.php, godmode/alerts/configure_alert_compound.php: little fix arround the code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2089 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
a6e3552ee8
commit
b117cae535
|
@ -1,4 +1,13 @@
|
|||
2009-11-04 Ramon Novoa <rnovoa@artica.es>
|
||||
2009-11-06 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* operation/snmpconsole/snmp_view.php: fix and optimize the query to traps
|
||||
in DB, because the old style didn't run with paginator and it was slow with
|
||||
much traps registers.
|
||||
* operation/agentes/status_monitor.php,
|
||||
godmode/alerts/configure_alert_compound.php: little fix arround the code
|
||||
style.
|
||||
|
||||
2009-11-04 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* DEBIAN/control: fix dependencies, not necesary mysql-server, because the
|
||||
mysql can install in another machine.
|
||||
|
|
|
@ -118,11 +118,14 @@ if ($ag_freestring != "") {
|
|||
// Status selector
|
||||
if ($status == 0) { //Up
|
||||
$sql .= " AND tagente_estado.estado = 0 AND (UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2)";
|
||||
} elseif ($status == 2) { //Critical
|
||||
}
|
||||
elseif ($status == 2) { //Critical
|
||||
$sql .= " AND tagente_estado.estado = 1 AND (UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2)";
|
||||
} elseif ($status == 1) { //warning
|
||||
}
|
||||
elseif ($status == 1) { //warning
|
||||
$sql .= " AND tagente_estado.estado = 2 AND (UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval * 2)";
|
||||
} elseif ($status == 4) { //not normal
|
||||
}
|
||||
elseif ($status == 4) { //not normal
|
||||
$sql .= " AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) >= (tagente_estado.current_interval * 2) OR tagente_estado.estado = 2 OR tagente_estado.estado = 1) ";
|
||||
} elseif ($status == 3) { //Unknown
|
||||
$sql .= " AND utimestamp > 0 AND tagente_modulo.id_tipo_modulo < 21 AND (UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) >= (tagente_estado.current_interval * 2)";
|
||||
|
@ -246,7 +249,8 @@ foreach ($result as $row) {
|
|||
|
||||
if ($seconds >= ($row["module_interval"] * 2)) {
|
||||
$option = array ("html_attr" => 'class="redb"');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$option = array ();
|
||||
}
|
||||
|
||||
|
|
|
@ -142,10 +142,48 @@ foreach ($traps as $trap) {
|
|||
$oids[$oid] = $oid;
|
||||
}
|
||||
|
||||
//Make query to extract traps of DB.
|
||||
$sql = "SELECT * FROM ttrap %s ORDER BY timestamp DESC LIMIT %d,%d";
|
||||
$whereSubquery = 'WHERE 1=1';
|
||||
if ($filter_agent != '')
|
||||
$whereSubquery .= ' AND source LIKE "' . $filter_agent . "'";
|
||||
|
||||
if ($filter_oid != '') {
|
||||
//Test if install the enterprise to search oid in text or oid field in ttrap.
|
||||
if ($config['enterprise_installed'])
|
||||
$whereSubquery .= ' AND (text LIKE "' . $filter_oid . '" OR oid LIKE "' . $filter_oid . '")';
|
||||
else
|
||||
$whereSubquery .= ' AND oid LIKE "' . $filter_oid . '"';
|
||||
}
|
||||
if ($filter_fired != -1)
|
||||
$whereSubquery .= ' AND alerted = ' . $filter_fired;
|
||||
if ($search_string != '')
|
||||
$whereSubquery .= ' AND value LIKE "%' . $search_string . '%"';
|
||||
|
||||
if ($filter_severity != -1) {
|
||||
//Test if install the enterprise to search oid in text or oid field in ttrap.
|
||||
if ($config['enterprise_installed'])
|
||||
$whereSubquery .= ' AND (
|
||||
(alerted = 0 AND severity = ' . $filter_severity . ') OR
|
||||
(alerted = 1 AND priority = ' . $filter_severity . '))';
|
||||
else
|
||||
$whereSubquery .= ' AND (
|
||||
(alerted = 0 AND 1 = ' . $filter_severity . ') OR
|
||||
(alerted = 1 AND priority = ' . $filter_severity . '))';
|
||||
}
|
||||
if ($filter_status != -1)
|
||||
$whereSubquery .= ' AND status = ' . $filter_status;
|
||||
|
||||
|
||||
$sql = sprintf($sql, $whereSubquery, $offset, $config['block_size']);
|
||||
|
||||
$traps = get_db_all_rows_sql($sql);
|
||||
|
||||
if ($config["pure"] == 1) {
|
||||
echo '<div id="filters" style="display:none;">';
|
||||
} else {
|
||||
echo '<div id="filters" style="display:block;">'; //There is no value all to property display
|
||||
}
|
||||
else {
|
||||
echo '<div id="filters" style="display: none;">';
|
||||
}
|
||||
|
||||
// Agent select
|
||||
|
@ -193,8 +231,13 @@ echo '</div>';
|
|||
echo '<br />';
|
||||
|
||||
// Prepare index for pagination
|
||||
$trapcount = get_db_sql ("SELECT COUNT(*) FROM ttrap");
|
||||
pagination ($trapcount, "index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&filter_agent=".$filter_agent."&filter_oid=".$filter_oid."&pagination=".$pagination."&offset=".$offset."&refr=".$config["refr"]."&pure=".$config["pure"], $offset, $pagination);
|
||||
$trapcount = get_db_sql ("SELECT COUNT(*) FROM ttrap " . $whereSubquery);
|
||||
|
||||
$urlPagination = "index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&filter_agent=" . $filter_agent
|
||||
. "&filter_oid=" . $filter_oid . "&filter_severity=" . $filter_severity
|
||||
. "&filter_fired=" . $filter_fired . "&filter_status=" . $filter_status
|
||||
. "&search_string=" . $search_string . "&pagination=".$pagination."&offset=".$offset."&refr=".$config["refr"]."&pure=".$config["pure"];
|
||||
pagination ($trapcount, $urlPagination, $offset, $pagination);
|
||||
|
||||
echo '<form name="eventtable" method="POST" action="index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&pagination='.$pagination.'&offset='.$offset.'">';
|
||||
|
||||
|
@ -240,44 +283,45 @@ $table->align[9] = "center";
|
|||
|
||||
// Skip offset records
|
||||
$idx = 0;
|
||||
foreach ($traps as $trap) {
|
||||
if ($traps !== false) {
|
||||
foreach ($traps as $trap) {
|
||||
$data = array ();
|
||||
|
||||
// Apply filters
|
||||
if ($filter_agent != '' && $trap["source"] != $filter_agent) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$oid = enterprise_hook ('get_oid', array ($trap));
|
||||
if ($oid === ENTERPRISE_NOT_HOOK) {
|
||||
$oid = $trap["oid"];
|
||||
}
|
||||
|
||||
if ($filter_oid != '' && $oid != $filter_oid) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($filter_fired != -1 && $trap["alerted"] != $filter_fired) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($filter_status != -1 && $trap["status"] != $filter_status) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// // Apply filters
|
||||
// if ($filter_agent != '' && $trap["source"] != $filter_agent) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// $oid = enterprise_hook ('get_oid', array ($trap));
|
||||
// if ($oid === ENTERPRISE_NOT_HOOK) {
|
||||
// $oid = $trap["oid"];
|
||||
// }
|
||||
//
|
||||
// if ($filter_oid != '' && $oid != $filter_oid) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if ($filter_fired != -1 && $trap["alerted"] != $filter_fired) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if ($filter_status != -1 && $trap["status"] != $filter_status) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
$severity = enterprise_hook ('get_severity', array ($trap));
|
||||
if ($severity === ENTERPRISE_NOT_HOOK) {
|
||||
$severity = $trap["alerted"] == 1 ? $trap["priority"] : 1;
|
||||
}
|
||||
|
||||
if ($filter_severity != -1 && $severity != $filter_severity) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($search_string != '' && ereg ($search_string, $trap["value"]) == 0 &&
|
||||
ereg ($search_string, $trap["value_custom"]) == 0) {
|
||||
continue;
|
||||
}
|
||||
//
|
||||
// if ($filter_severity != -1 && $severity != $filter_severity) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if ($search_string != '' && ereg ($search_string, $trap["value"]) == 0 &&
|
||||
// ereg ($search_string, $trap["value_custom"]) == 0) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
//Status
|
||||
if ($trap["status"] == 0) {
|
||||
|
@ -365,6 +409,7 @@ foreach ($traps as $trap) {
|
|||
|
||||
array_push ($table->data, $data);
|
||||
$idx++;
|
||||
}
|
||||
}
|
||||
|
||||
// No matching traps
|
||||
|
|
Loading…
Reference in New Issue