diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index c572e8ac0f..f0d77205c6 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,23 @@ +2008-10-10 Sancho Lerena + + * pandoradb_data.sql: Added support for autoupdate and trap2agent + forward in tconfig. + + * update_manager.php: Automatically in logon function hook detect + if is defined. If not, try to connect the first time and automatically + set autoupdate to 0 in tconfig. + + * db_audit.php: Now works, before don't. + + * setup.php: Added new items: trap2agent forward and autoupdate. + + * snmp_view.php: Now display properly OID, Value and Custom Value. Need + changes in snmptconsole server to work and render all data. Better layout. + + * config_process.php: Detect if trap2agent is not configured, and if not, + create record in tconfig (this should not be necessary but there is a lot + of people using beta1 yet and will have problems if not have this). + 2008-10-08 Evi Vanoost * operation/agentes/estado_grupo.php: Fixed bug #2155213 and rewrote diff --git a/pandora_console/extensions/update_manager.php b/pandora_console/extensions/update_manager.php index 9bd89c4c1c..76c3adad14 100644 --- a/pandora_console/extensions/update_manager.php +++ b/pandora_console/extensions/update_manager.php @@ -82,6 +82,15 @@ function pandora_update_manager_login () { global $config; global $db; + // If first time, make the first autoupdate and disable it in DB + if (!isset($config["autoupdate"])){ + $config["autoupdate"] = 1; + process_sql ("INSERT INTO tconfig (token,value) VALUES ('autoupdate', 0)"); + } + + if ($config["autoupdate"] == 0) + return; + load_update_manager_lib (); $db =& um_db_connect ('mysql', $config['dbhost'], $config['dbuser'], diff --git a/pandora_console/godmode/db/db_audit.php b/pandora_console/godmode/db/db_audit.php index 1c94c0f1d7..a63715e969 100644 --- a/pandora_console/godmode/db/db_audit.php +++ b/pandora_console/godmode/db/db_audit.php @@ -28,6 +28,27 @@ if (! give_acl ($config['id_user'], 0, "DM")) { return; } +// All data (now) +$time["all"] = time (); + +// 1 day ago +$time["1day"] = $time["all"]-86400; + +// 3 days ago +$time["3day"] = $time["all"]-(86400*3); + +// 1 week ago +$time["1week"] = $time["all"]-(86400*7); + +// 2 weeks ago +$time["2week"] = $time["all"]-(86400*14); + +// 1 month ago +$time["1month"] = $time["all"]-(86400*30); + +// Three months ago +$time["3month"] = $time["all"]-(86400*90); + // Todo for a good DB maintenance /* - Delete too on datos_string and and datos_inc tables @@ -43,7 +64,7 @@ if (! give_acl ($config['id_user'], 0, "DM")) { # Purge data using dates if (isset($_POST["purgedb"])){ # Fixed 2005-1-13, nil $from_date = get_parameter_post("date_purge"); - $query = sprintf("DELETE FROM `tsesion` WHERE `fecha` < '%s';",$from_date); + $query = sprintf("DELETE FROM `tsesion` WHERE `utimestamp` < '%s';",$from_date); (int) $deleted = process_sql($query); } # End of get parameters block @@ -72,13 +93,13 @@ echo "";
diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 97380347ec..46c7235333 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -45,6 +45,9 @@ if ($update_settings) { $config["graph_color3"] = (string) get_parameter ('graph_color3'); $config["sla_period"] = (int) get_parameter ("sla_period"); $config["date_format"] = (string) get_parameter ("date_format"); + $config["trap2agent"] = (string) get_parameter ("trap2agent"); + $config["autoupdate"] = (string) get_parameter ("autoupdate"); + $config["style"] = substr ($config["style"], 0, strlen ($config["style"]) - 4); process_sql ("UPDATE tconfig SET VALUE='".$config["remote_config"]."' WHERE token = 'remote_config'"); @@ -62,6 +65,8 @@ if ($update_settings) { process_sql ("UPDATE tconfig SET VALUE='".$config["graph_color3"]."' WHERE token = 'graph_color3'"); process_sql ("UPDATE tconfig SET VALUE='".$config["sla_period"]."' WHERE token = 'sla_period'"); process_sql ("UPDATE tconfig SET VALUE='".$config["date_format"]."' WHERE token = 'date_format'"); + process_sql ("UPDATE tconfig SET VALUE='".$config["trap2agent"]."' WHERE token = 'trap2agent'"); + process_sql ("UPDATE tconfig SET VALUE='".$config["autoupdate"]."' WHERE token = 'autoupdate'"); } echo "

".__('Pandora Setup')." > "; @@ -116,6 +121,12 @@ $table->data[13][1] = print_select ($file_styles, 'style', $config["style"], '', $table->data[14][0] = __('Block size for pagination'); $table->data[14][1] = print_input_text ('block_size', $config["block_size"], '', 5, 5, true); +$table->data[15][0] = __('Forward SNMP traps to agent (if exist)'); +$table->data[15][1] = print_checkbox ('trap2agent', 1, $config["trap2agent"], true); + +$table->data[16][0] = __('Automatic update check'); +$table->data[16][1] = print_checkbox ('autoupdate', 1, $config["autoupdate"], true); + echo '
'; print_input_hidden ('update_settings', 1); print_table ($table); diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 83a9a061ee..73849f67db 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -119,6 +119,13 @@ if (isset ($config['homeurl']) && $config['homeurl'][0] != '/') { $config['homeurl'] = '/'.$config['homeurl']; } + +// If first time, make the trap2agent disable in DB +if (!isset($config["trap2agent"])){ + $config["trap2agent"] = 0; + process_sql ("INSERT INTO tconfig (token,value) VALUES ('trap2agent', 0)"); +} + if (!isset ($config["sla_period"]) || empty ($config["sla_period"])) { // Default period (in secs) for auto SLA calculation (for monitors) $config["sla_period"] = 604800; diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index f534a0f8ee..64cdc816b5 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -171,6 +171,7 @@ div#container { border-right: solid 2px #000; border-top: solid 2px #000; margin-top: 5px; + background: #fff; } div#page { width: 960px; diff --git a/pandora_console/operation/snmpconsole/snmp_view.php b/pandora_console/operation/snmpconsole/snmp_view.php index e5e7b20970..2777d469b2 100644 --- a/pandora_console/operation/snmpconsole/snmp_view.php +++ b/pandora_console/operation/snmpconsole/snmp_view.php @@ -127,54 +127,50 @@ if (isset($_POST["updatebt"])){ echo "

Pandora SNMP > "; echo __('SNMP console')."

"; -if (isset($_GET["offset"])) - $offset=$_GET["offset"]; -else - $offset=0; +$offset = get_parameter ('offset'); $sql2="SELECT * FROM ttrap ORDER BY timestamp DESC"; $result2=mysql_query($sql2); -if (mysql_num_rows($result2)){ - echo ""; - echo ""; - echo ""; - echo "
"; - echo " - ".__('Validated event'); - echo "
"; - echo " - ".__('Not validated event'); - //echo "
"; - //echo " - ".__('Alert'); - echo "
"; - echo " - ".__('Validate event'); - echo "
"; - echo " - ".__('Delete event'); - echo "
"; - echo "
"; - - // Prepare index for pagination - $trap_list[]=""; - - while ($row2=mysql_fetch_array($result2)){ // Jump offset records - $trap_list[]=$row2["id_trap"]; - } - -$total_traps = count($trap_list); -pagination($total_traps, "index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view", $offset); - - -if (isset($_GET["offset"])){ - $offset=entrada_limpia($_GET["offset"]); -} else { - $offset=0; +if (mysql_num_rows ($result2) == 0) { + echo "
".__('There are no SNMP traps in database')."
"; + return; } + +echo ""; +echo ""; +echo ""; +echo "
"; +echo " - ".__('Validated event'); +echo "
"; +echo " - ".__('Not validated event'); +//echo "
"; +//echo " - ".__('Alert'); +echo "
"; +echo " - ".__('Validate event'); +echo "
"; +echo " - ".__('Delete event'); +echo "
"; +echo "
"; + +// Prepare index for pagination +$trap_list[]=""; + +while ($row2=mysql_fetch_array($result2)){ // Jump offset records + $trap_list[]=$row2["id_trap"]; +} + +$total_traps = count ($trap_list); +pagination ($total_traps, "index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view", $offset); + echo "
"; echo ""; echo ""; echo ""; -echo ""; echo ""; -echo ""; +echo ""; +echo ""; +echo ""; echo ""; echo ""; echo ""; @@ -187,8 +183,8 @@ echo ""; - if ($row["status"] == 0){ + if ($trap["status"] == 0){ echo ""; } else { @@ -217,44 +213,58 @@ for ($a=$offset_limit;$a < ($config["block_size"] + $offset + 1);$a++){ } echo ""; - echo ""; - } - else { - echo ""; + + ".$agent['nombre'].""; + } else { + echo ""; } + + // OID + echo ""; - $custom = substr($row["value_custom"],0,15); - if (strlen ($row["value_custom"]) > 15) + // CUSTOM + $custom = substr ($trap["value_custom"], 0, 15); + if (strlen ($trap["value_custom"]) > 15) $custom .= "..."; - echo ""; + echo ""; + // User echo ""; - echo ""; + // Timestamp + echo ""; + // Alerted ? echo ""; + // Delete and ACK echo ""; echo ""; } } @@ -268,9 +278,4 @@ if (give_acl ($config['id_user'], 0, "IM")) { echo ""; } echo "
".__('Status')."".__('OID')."".__('SNMP Agent')."".__('Custom value')."".__('OID')."".__('Value')."".__('Custom')."".__('User ID')."".__('Timestamp')."".__('Alert')."".$row["oid"]; - $sql="SELECT * FROM tagente WHERE direccion = '".$row["source"]."'"; - $result2=mysql_query($sql); // If there's any agent with this IP we show name and link to agent - if ($row2=mysql_fetch_array($result2)){ + + // Agent ID + $agent = get_db_row ('tagente', 'direccion', $trap['source']); + if ($agent) { echo " - - ".dame_nombre_agente($row2["id_agente"])."".$row["source"]."".$trap["source"]."".$trap["oid"]; + + + // Value + $value = substr ($trap["value"], 0, 15); + if (strlen ($trap["value"]) > 15) + $value .= "..."; + echo "".$value."".$custom."".$custom.""; - if ($row["status"] <> 0) - echo " ".dame_nombre_real($row["id_usuario"])."".substr($row["id_usuario"],0,8).""; + if ($trap["status"]) + echo " ".dame_nombre_real($trap["id_usuario"])."".substr($trap["id_usuario"],0,8).""; echo "".$row["timestamp"]."".$trap["timestamp"].""; - if ($row["alerted"] != 0 ) - echo ""; + if ($trap["alerted"]) + echo ""; echo ""; - if ($row["status"] == 0 && give_acl ($config['id_user'],"0","IW")) - echo ""; + if ($trap["status"] == 0 && give_acl ($config['id_user'],"0","IW")) + echo ""; if (give_acl ($config['id_user'], "0", "IM")) - echo ""; + echo ""; echo ""; - echo ""; + echo ""; echo "
"; - -} else { - echo "
".__('There are no SNMP traps in database')."
"; -} - ?> diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 68b227e8ab..63eb1e5759 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -60,6 +60,7 @@ INSERT INTO `tconfig` VALUES (18, 'graph_color2', '#42D100'), (19, 'graph_color3', '#89FF09'), (20, 'sla_period', '604800'), +(21, 'trap2agent', '0'), (22, 'date_format', 'F j, Y, g:i a'); UNLOCK TABLES;