2008-10-10 Sancho Lerena <slerena@artica.es>
* 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 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1136 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
a920a0cc75
commit
273f4d1b54
|
@ -1,3 +1,23 @@
|
|||
2008-10-10 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* 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 <vanooste@rcbi.rochester.edu>
|
||||
|
||||
* operation/agentes/estado_grupo.php: Fixed bug #2155213 and rewrote
|
||||
|
|
|
@ -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'],
|
||||
|
|
|
@ -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 "</tr></table>";
|
|||
<table width='300' cellpadding='4' cellspacing='4' class='databox'>
|
||||
<tr><td class='datos'>
|
||||
<select name="date_purge" width="255px">
|
||||
<option value="<?php echo $month3 ?>"><?php echo __('Purge audit data over 90 days') ?>
|
||||
<option value="<?php echo $month ?>"><?php echo __('Purge audit data over 30 days') ?>
|
||||
<option value="<?php echo $week2 ?>"><?php echo __('Purge audit data over 14 days') ?>
|
||||
<option value="<?php echo $week ?>"><?php echo __('Purge audit data over 7 days') ?>
|
||||
<option value="<?php echo $d3 ?>"><?php echo __('Purge audit data over 3 days') ?>
|
||||
<option value="<?php echo $d1 ?>"><?php echo __('Purge audit data over 1 day') ?>
|
||||
<option value="<?php echo $all_data ?>"><?php echo __('Purge all audit data') ?>
|
||||
<option value="<?php echo $time["3month"] ?>"><?php echo __('Purge audit data over 90 days') ?>
|
||||
<option value="<?php echo $time["1month"] ?>"><?php echo __('Purge audit data over 30 days') ?>
|
||||
<option value="<?php echo $time["2week"] ?>"><?php echo __('Purge audit data over 14 days') ?>
|
||||
<option value="<?php echo $time["1week"] ?>"><?php echo __('Purge audit data over 7 days') ?>
|
||||
<option value="<?php echo $time["3day"] ?>"><?php echo __('Purge audit data over 3 days') ?>
|
||||
<option value="<?php echo $time["1day"] ?>"><?php echo __('Purge audit data over 1 day') ?>
|
||||
<option value="<?php echo $time["all"] ?>"><?php echo __('Purge all audit data') ?>
|
||||
</select>
|
||||
|
||||
<td class="datos">
|
||||
|
|
|
@ -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 "<h2>".__('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 '<form id="form_setup" method="POST" action="index.php?sec=gsetup&sec2=godmode/setup/setup">';
|
||||
print_input_hidden ('update_settings', 1);
|
||||
print_table ($table);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -127,54 +127,50 @@ if (isset($_POST["updatebt"])){
|
|||
echo "<h2>Pandora SNMP > ";
|
||||
echo __('SNMP console')."</h2>";
|
||||
|
||||
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 "<table border=0 width=600><tr>";
|
||||
echo "<td class='f9' style='padding-left: 30px;'>";
|
||||
echo "<img src='images/pixel_green.png' width=20 height=20> - ".__('Validated event');
|
||||
echo "<br>";
|
||||
echo "<img src='images/pixel_red.png' width=20 height=20> - ".__('Not validated event');
|
||||
//echo "<br>";
|
||||
//echo "<img src='images/pixel_yellow.png' width=20 height=35> - ".__('Alert');
|
||||
echo "</td>";
|
||||
echo "<td class='f9' style='padding-left: 20px;'>";
|
||||
echo "<img src='images/ok.png'> - ".__('Validate event');
|
||||
echo "<br>";
|
||||
echo "<img src='images/cross.png '> - ".__('Delete event');
|
||||
echo "</td>";
|
||||
echo "</tr></table>";
|
||||
echo "<br>";
|
||||
|
||||
// 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 "<div class='nf'>".__('There are no SNMP traps in database')."</div>";
|
||||
return;
|
||||
}
|
||||
|
||||
echo "<table border=0 width=600><tr>";
|
||||
echo "<td class='f9' style='padding-left: 30px;'>";
|
||||
echo "<img src='images/pixel_green.png' width=20 height=20> - ".__('Validated event');
|
||||
echo "<br>";
|
||||
echo "<img src='images/pixel_red.png' width=20 height=20> - ".__('Not validated event');
|
||||
//echo "<br>";
|
||||
//echo "<img src='images/pixel_yellow.png' width=20 height=35> - ".__('Alert');
|
||||
echo "</td>";
|
||||
echo "<td class='f9' style='padding-left: 20px;'>";
|
||||
echo "<img src='images/ok.png'> - ".__('Validate event');
|
||||
echo "<br>";
|
||||
echo "<img src='images/cross.png '> - ".__('Delete event');
|
||||
echo "</td>";
|
||||
echo "</tr></table>";
|
||||
echo "<br>";
|
||||
|
||||
// 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 "<br>";
|
||||
echo "<table cellpadding='4' cellspacing='4' width='735' class='databox'>";
|
||||
echo "<tr>";
|
||||
echo "<th>".__('Status')."</th>";
|
||||
echo "<th>".__('OID')."</th>";
|
||||
echo "<th>".__('SNMP Agent')."</th>";
|
||||
echo "<th>".__('Custom value')."</th>";
|
||||
echo "<th>".__('OID')."</th>";
|
||||
echo "<th>".__('Value')."</th>";
|
||||
echo "<th>".__('Custom')."</th>";
|
||||
echo "<th>".__('User ID')."</th>";
|
||||
echo "<th width ='130px'>".__('Timestamp')."</th>";
|
||||
echo "<th>".__('Alert')."</th>";
|
||||
|
@ -187,8 +183,8 @@ echo "<form name='eventtable' method='POST' action='index.php?sec=snmpconsole&se
|
|||
|
||||
$id_trap = 0;
|
||||
$color = 0;
|
||||
if ($offset !=0)
|
||||
$offset_limit = $offset +1;
|
||||
if ($offset != 0)
|
||||
$offset_limit = $offset + 1;
|
||||
else
|
||||
$offset_limit = $offset;
|
||||
// Skip offset records
|
||||
|
@ -197,7 +193,7 @@ for ($a=$offset_limit;$a < ($config["block_size"] + $offset + 1);$a++){
|
|||
$id_trap = $trap_list[$a];
|
||||
$sql="SELECT * FROM ttrap WHERE id_trap = $id_trap";
|
||||
if ($result=mysql_query($sql)){
|
||||
$row=mysql_fetch_array($result);
|
||||
$trap=mysql_fetch_array($result);
|
||||
if ($color == 1){
|
||||
$tdcolor = "datos";
|
||||
$color = 0;
|
||||
|
@ -209,7 +205,7 @@ for ($a=$offset_limit;$a < ($config["block_size"] + $offset + 1);$a++){
|
|||
$offset_counter++;
|
||||
echo "<tr>";
|
||||
echo "<td class='$tdcolor' align='center'>";
|
||||
if ($row["status"] == 0){
|
||||
if ($trap["status"] == 0){
|
||||
echo "<img src='images/pixel_red.png' width=20 height=20>";
|
||||
}
|
||||
else {
|
||||
|
@ -217,44 +213,58 @@ for ($a=$offset_limit;$a < ($config["block_size"] + $offset + 1);$a++){
|
|||
}
|
||||
echo "</td>";
|
||||
|
||||
echo "<td class='$tdcolor'>".$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 "<td class='$tdcolor'>
|
||||
<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$row2["id_agente"]."'>
|
||||
<b>".dame_nombre_agente($row2["id_agente"])."</b></a></td>";
|
||||
}
|
||||
else {
|
||||
echo "<td class='$tdcolor'>".$row["source"]."</td>";
|
||||
<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$agent["id_agente"]."'>
|
||||
<strong>".$agent['nombre']."</strong></a></td>";
|
||||
} else {
|
||||
echo "<td class='$tdcolor'>".$trap["source"]."</td>";
|
||||
}
|
||||
|
||||
// OID
|
||||
echo "<td class='$tdcolor'>".$trap["oid"];
|
||||
|
||||
|
||||
// Value
|
||||
$value = substr ($trap["value"], 0, 15);
|
||||
if (strlen ($trap["value"]) > 15)
|
||||
$value .= "...";
|
||||
echo "<td title='".$trap["value"]."' class='$tdcolor'>".$value."</td>";
|
||||
|
||||
$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 "<td title='".$row["value_custom"]."' class='$tdcolor'>".$custom."</td>";
|
||||
echo "<td title='".$trap["value_custom"]."' class='$tdcolor'>".$custom."</td>";
|
||||
|
||||
// User
|
||||
echo "<td class='$tdcolor'>";
|
||||
if ($row["status"] <> 0)
|
||||
echo "<a href='index.php?sec=usuario&sec2=operation/users/user_edit&ver=".$row["id_usuario"]."'><a href='#' class='tip'> <span>".dame_nombre_real($row["id_usuario"])."</span></a>".substr($row["id_usuario"],0,8)."</a>";
|
||||
if ($trap["status"])
|
||||
echo "<a href='index.php?sec=usuario&sec2=operation/users/user_edit&ver=".$trap["id_usuario"]."'><a href='#' class='tip'> <span>".dame_nombre_real($trap["id_usuario"])."</span></a>".substr($trap["id_usuario"],0,8)."</a>";
|
||||
echo "</td>";
|
||||
|
||||
echo "<td class='$tdcolor'>".$row["timestamp"]."</td>";
|
||||
// Timestamp
|
||||
echo "<td class='$tdcolor'>".$trap["timestamp"]."</td>";
|
||||
|
||||
// Alerted ?
|
||||
echo "<td class='$tdcolor' align='center'>";
|
||||
if ($row["alerted"] != 0 )
|
||||
echo "<img src='images/dot_yellow.png' border=0>";
|
||||
if ($trap["alerted"])
|
||||
echo "<img src='images/pixel_yellow.png' width=40 height=18 border=0>";
|
||||
echo "</td>";
|
||||
|
||||
// Delete and ACK
|
||||
echo "<td class='$tdcolor' align='center'>";
|
||||
if ($row["status"] == 0 && give_acl ($config['id_user'],"0","IW"))
|
||||
echo "<a href='index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&check=".$row["id_trap"]."'><img src='images/ok.png' border='0'></a>";
|
||||
if ($trap["status"] == 0 && give_acl ($config['id_user'],"0","IW"))
|
||||
echo "<a href='index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&check=".$trap["id_trap"]."'><img src='images/ok.png' border='0'></a>";
|
||||
if (give_acl ($config['id_user'], "0", "IM"))
|
||||
echo "<a href='index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&delete=".$row["id_trap"]."&refr=60&offset=".$offset."'><img src='images/cross.png' border=0></a>";
|
||||
echo "<a href='index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&delete=".$trap["id_trap"]."&refr=60&offset=".$offset."'><img src='images/cross.png' border=0></a>";
|
||||
echo "</td>";
|
||||
|
||||
echo "<td class='$tdcolor' align='center'>";
|
||||
echo "<input type='checkbox' class='chk' name='snmptrapid".$offset_counter."' value='".$row["id_trap"]."'>";
|
||||
echo "<input type='checkbox' class='chk' name='snmptrapid".$offset_counter."' value='".$trap["id_trap"]."'>";
|
||||
echo "</td></tr>";
|
||||
}
|
||||
}
|
||||
|
@ -268,9 +278,4 @@ if (give_acl ($config['id_user'], 0, "IM")) {
|
|||
echo "<input class='sub delete' type='submit' name='deletebt' value='".__('Delete')."'>";
|
||||
}
|
||||
echo "</form></td></tr></table>";
|
||||
|
||||
} else {
|
||||
echo "<div class='nf'>".__('There are no SNMP traps in database')."</div>";
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue