2008-08-28 Evi Vanoost <vanooste@rcbi.rochester.edu>

* operation/events/events.php: Updated the queries and fixed some minor 
        bugs with the event selections. Style changes.

        * operation/agentes/networkmap.php: Style changes

        * pandora2ast: Removed hidden swapfile

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1048 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
guruevi 2008-08-29 16:05:08 +00:00
parent 253c57d7cf
commit b515149dbd
4 changed files with 86 additions and 92 deletions

View File

@ -1,3 +1,10 @@
2008-08-28 Evi Vanoost <vanooste@rcbi.rochester.edu>
* operation/events/events.php: Updated the queries and fixed some minor
bugs with the event selections. Style changes.
* operation/agentes/networkmap.php: Style changes
2008-08-28 Esteban Sanchez <estebans@artica.es> 2008-08-28 Esteban Sanchez <estebans@artica.es>
* extensions/update_manager.php: Added function to update Update * extensions/update_manager.php: Added function to update Update

View File

@ -1,5 +1,4 @@
<?php <?php
// Pandora FMS - the Flexible Monitoring System // Pandora FMS - the Flexible Monitoring System
// ============================================ // ============================================
// Copyright (c) 2008 Artica Soluciones Tecnologicas, http://www.artica.es // Copyright (c) 2008 Artica Soluciones Tecnologicas, http://www.artica.es
@ -21,7 +20,7 @@
// Load global vars // Load global vars
require("include/config.php"); require("include/config.php");
check_login(); check_login ();
if (! give_acl ($config['id_user'], 0, "AR")) { if (! give_acl ($config['id_user'], 0, "AR")) {
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
@ -43,23 +42,22 @@ function generate_dot ($simple = 0, $font_size) {
$orphans = array(); $orphans = array();
// Open Graph // Open Graph
$graph = open_graph(); $graph = open_graph ();
// Get agent data // Get agent data
$agents = mysql_query('SELECT id_grupo, nombre, id_os, id_parent, id_agente FROM tagente WHERE disabled = 0 ORDER BY id_grupo'); $agents = get_db_all_rows_sql ('SELECT id_grupo, nombre, id_os, id_parent, id_agente FROM tagente WHERE disabled = 0 ORDER BY id_grupo');
while ($agent = mysql_fetch_assoc($agents)) { foreach ($agents as $agent) {
if (give_acl($config["id_user"], $agent["id_grupo"], "AR") == 0) if (give_acl ($config["id_user"], $agent["id_grupo"], "AR") == 0)
continue; continue;
// Save node parent information to define edges later // Save node parent information to define edges later
if ($agent['id_parent'] != "0") { if ($agent['id_parent'] != "0") {
$parents[$agent['id_agente']] = $agent['id_parent']; $parents[$agent['id_agente']] = $agent['id_parent'];
} } else {
else {
$orphans[$agent['id_agente']] = 1; $orphans[$agent['id_agente']] = 1;
} }
// Add node // Add node
$graph .= create_node($agent , $simple, $font_size)."\n\t\t"; $graph .= create_node ($agent , $simple, $font_size)."\n\t\t";
} }
// Create a central node if orphan nodes exist // Create a central node if orphan nodes exist
@ -78,7 +76,7 @@ function generate_dot ($simple = 0, $font_size) {
} }
// Close graph // Close graph
$graph .= close_graph(); $graph .= close_graph ();
return $graph; return $graph;
} }
@ -306,19 +304,19 @@ if ($nooverlap == 1){
echo "<td>"; echo "<td>";
echo __('Distance between nodes') . ' &nbsp;'; echo __('Distance between nodes') . ' &nbsp;';
print_input_text ('ranksep', $ranksep, $alt = 'Separation between elements in the map (in Non-overlap mode)', 3, 4, 0); print_input_text ('ranksep', $ranksep, $alt = 'Separation between elements in the map (in Non-overlap mode)', 3, 4, 0);
echo "</td>";
} }
echo "<td>"; echo "<td>";
echo __('Font') . ' &nbsp;'; echo __('Font') . ' &nbsp;';
print_input_text ('font_size', $font_size, $alt = 'Font size (in pt)', 3, 4, 0); print_input_text ('font_size', $font_size, $alt = 'Font size (in pt)', 3, 4, 0);
echo "</td>";
//echo ' Display groups <input type="checkbox" name="group" value="group" class="chk"/>'; //echo ' Display groups <input type="checkbox" name="group" value="group" class="chk"/>';
echo '<td>'; echo '<td>';
echo '<input name="updbutton" type="submit" class="sub upd" value="'. __('Update'). '">'; echo '<input name="updbutton" type="submit" class="sub upd" value="'. __('Update'). '">';
echo '</td>'; echo '</td></tr>';
echo '</table>'; echo '</table></form>';
echo '</form>';
// Set filter // Set filter
$filter = set_filter(); $filter = set_filter();
@ -375,7 +373,7 @@ if ($result !== false) {
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
$(document).ready (function () { $(document).ready (function () {
$("area[title!='<?=$pandora_name?>']").cluetip ({ $("area[title!='<?php echo $pandora_name; ?>']").cluetip ({
arrows: true, arrows: true,
attribute: 'title', attribute: 'title',
cluetipClass: 'default', cluetipClass: 'default',

View File

@ -70,16 +70,22 @@ $accion = "";
// OPERATIONS // OPERATIONS
// Delete Event (only incident management access). // Delete Event (only incident management access).
if (isset ($_GET["delete"])) { if (isset ($_GET["delete"])) {
$id_evento = $_GET["delete"]; //safe input
$id_evento = get_parameter_get ("delete");
// Look for event_id following parameters: id_group. // Look for event_id following parameters: id_group.
$id_group = gime_idgroup_from_idevent($id_evento); $id_group = gime_idgroup_from_idevent ($id_evento);
if (give_acl ($config['id_user'], $id_group, "IM")) { if (give_acl ($config['id_user'], $id_group, "IM")) {
$sql2="DELETE FROM tevento WHERE id_evento =".$id_evento; $descr = return_event_description ($id_evento); //Get description before it gets deleted
$result2=mysql_query($sql2); $sql = "DELETE FROM tevento WHERE id_evento =".$id_evento;
if ($result) { $result = process_sql ($sql);
echo "<h3 class='suc'>".__('Event successfully deleted')."</h3>";
if ($result !== false) {
echo '<h3 class="suc">'.__('Event successfully deleted').'</h3>';
audit_db ($config['id_user'], $REMOTE_ADDR, audit_db ($config['id_user'], $REMOTE_ADDR,
"Event deleted","Deleted event: ".return_event_description ($id_evento)); "Event deleted","Deleted event: ".$descr);
} else {
echo '<h3 class="error">'.__('Error deleting event').'</h3>';
} }
} else { } else {
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
@ -89,17 +95,17 @@ if (isset ($_GET["delete"])) {
// Check Event (only incident write access). // Check Event (only incident write access).
if (isset ($_GET["check"])) { if (isset ($_GET["check"])) {
$id_evento = $_GET["check"]; $id_evento = get_parameter_get ("check");
// Look for event_id following parameters: id_group. // Look for event_id following parameters: id_group.
$id_group = gime_idgroup_from_idevent($id_evento); $id_group = gime_idgroup_from_idevent ($id_evento);
if (give_acl($config["id_user"], $id_group, "IW") ==1){ if (give_acl ($config["id_user"], $id_group, "IW") ==1){
$sql2="UPDATE tevento SET estado = 1, id_usuario = '".$config["id_user"]."' WHERE id_evento = ".$id_evento; $sql = "UPDATE tevento SET estado = 1, id_usuario = '".$config["id_user"]."' WHERE id_evento = ".$id_evento;
$result2=mysql_query($sql2); $result = process_sql ($sql);
if ($result2) { if ($result !== false) {
echo "<h3 class='suc'>".__('Event successfully validated')."</h3>"; echo '<h3 class="suc">'.__('Event successfully validated').'</h3>';
audit_db($config["id_user"],$REMOTE_ADDR, "Event validated","Validate event: ".return_event_description ($id_evento)); audit_db($config["id_user"],$REMOTE_ADDR, "Event validated","Validate event: ".return_event_description ($id_evento));
} else { } else {
echo "<h3 class='error'>".__('Event validation failed')."</h3>"; echo '<h3 class="error">'.__('Error validating event').'</h3>';
} }
} else { } else {
@ -111,11 +117,11 @@ if (isset ($_GET["check"])) {
// Mass-process DELETE // Mass-process DELETE
if (isset ($_POST["deletebt"])){ if (isset ($_POST["deletebt"])){
$count=0; $count=0;
while ($count <= $config["block_size"]){ while ($count <= $config["block_size"]) {
if (isset($_POST["eventid".$count])){ if (isset ($_POST["eventid".$count])) {
$event_id = $_POST["eventid".$count]; $event_id = get_parameter_post ("eventid".$count);
// Look for event_id following parameters: id_group. // Look for event_id following parameters: id_group.
$id_group = gime_idgroup_from_idevent($event_id); $id_group = gime_idgroup_from_idevent ($event_id);
if (give_acl ($config['id_user'], $id_group, "IM")) { if (give_acl ($config['id_user'], $id_group, "IM")) {
process_sql ("DELETE FROM tevento WHERE id_evento = ".$event_id); process_sql ("DELETE FROM tevento WHERE id_evento = ".$event_id);
audit_db ($config['id_user'], $REMOTE_ADDR, audit_db ($config['id_user'], $REMOTE_ADDR,
@ -134,7 +140,7 @@ if (isset ($_POST["updatebt"])) {
$count = 0; $count = 0;
while ($count <= $config["block_size"]) { while ($count <= $config["block_size"]) {
if (isset ($_POST["eventid".$count])) { if (isset ($_POST["eventid".$count])) {
$id_evento = $_POST["eventid".$count]; $id_evento = get_parameter_post ("eventid".$count);
$id_group = gime_idgroup_from_idevent($id_evento); $id_group = gime_idgroup_from_idevent($id_evento);
if (give_acl ($config['id_user'], $id_group, "IW")) { if (give_acl ($config['id_user'], $id_group, "IW")) {
$sql = "UPDATE tevento SET estado=1, id_usuario = '".$config['id_user']."' WHERE estado = 0 AND id_evento = ".$id_evento; $sql = "UPDATE tevento SET estado=1, id_usuario = '".$config['id_user']."' WHERE estado = 0 AND id_evento = ".$id_evento;
@ -195,11 +201,11 @@ echo "</h2>";
echo "<a href=\"javascript:;\" onmousedown=\"toggleDiv('event_control');\">"; echo "<a href=\"javascript:;\" onmousedown=\"toggleDiv('event_control');\">";
echo "<b>".__('Event control filter')." ".'<img src="images/wand.png"></A></b>'; echo "<b>".__('Event control filter')." ".'<img src="images/wand.png"></A></b>';
if ($config["pure"] == 1) if ($config["pure"] == 1) {
echo "<div id='event_control' style='display:none'>"; echo "<div id='event_control' style='display:none'>";
else } else {
echo "<div id='event_control' style='display:all'>"; echo "<div id='event_control' style='display:block'>"; //There is no value all to property display
}
// Table who separate control and graph // Table who separate control and graph
echo "<table width=99% cellpadding=0 cellspacing=2 border=0>"; echo "<table width=99% cellpadding=0 cellspacing=2 border=0>";
echo "<tr><td width=500>"; echo "<tr><td width=500>";
@ -214,90 +220,74 @@ echo "<td>".__('Group')."</td>";
echo "<td>"; echo "<td>";
echo "<select name='ev_group' onChange='javascript:this.form.submit();' class='w130'>"; echo "<select name='ev_group' onChange='javascript:this.form.submit();' class='w130'>";
if ( $ev_group > 1 ){ if ( $ev_group > 1 ){
echo "<option value='".$ev_group."'>".dame_nombre_grupo($ev_group)."</option>"; echo "<option value='".$ev_group."' selected>".dame_nombre_grupo ($ev_group)."</option>";
} }
echo "<option value=1>".dame_nombre_grupo(1)."</option>";
list_group ($config["id_user"]); list_group ($config["id_user"]);
echo "</select></td>"; echo "</select></td>";
// Event type // Event type
echo "<td>".__('Event type')."</td>"; echo "<td>".__('Event type')."</td>";
echo "<td>"; echo "<td>";
echo print_select (get_event_types (), 'event_type', $event_type, '', 'all', ""); print_select (get_event_types (), 'event_type', $event_type, '', 'All', '');
echo "<tr>"; echo "</td></tr><tr>";
// Severity // Severity
echo "<td>".__('Severity')."</td>"; echo "<td>".__('Severity')."</td>";
echo "<td>"; echo "<td>";
print_select (get_priorities (), "severity", $severity, '', 'All', '-1');
print_select (get_priorities (), "severity", $severity, '', 'all', '-1');
// Status // Status
echo "<td>".__('Event status')."</td>"; echo "</td><td>".__('Event status')."</td>";
echo "<td>"; echo "<td>";
echo "<select name='status' onChange='javascript:this.form.submit();'>"; $fields = array ( -1 => __('All event'),
if ($status == 1){ 1 => __('Only validated'),
echo "<option value=1>". __('Only validated'); 0 => __('Only pending')
echo "<option value=-1>". __('All event'); );
echo "<option value=0>". __('Only pending'); print_select ($fields, 'status', $status, 'javascript:this.form.submit();', '', '');
} elseif ($status == 0) { echo "</td></tr><tr>";
echo "<option value=0>". __('Only pending');
echo "<option value=1>". __('Only validated');
echo "<option value=-1>". __('All event');
} elseif ($status == -1) {
echo "<option value=-1>". __('All event');
echo "<option value=0>". __('Only pending');
echo "<option value=1>". __('Only validated');
}
echo "</select></td>";
echo "<tr>";
// Free search // Free search
echo "<td>".__('Free search')."</td>"; echo "<td>".__('Free search')."</td><td>";
echo "<td>"; print_input_text ('search', $search, '', 15);
echo "<input type='text' size=15 value='".$search."' name='search'>"; echo "</td><td colspan=2>";
echo "<td colspan=2>"; print_submit_button (__('Update'), '', false, $attributes = 'class="sub upd"');
echo "<input type=submit value='".__('Update')."' class='sub upd'>";
echo "&nbsp;&nbsp;&nbsp;";
// CSV // CSV
echo "<a href='operation/events/export_csv.php?ev_group=$ev_group&event_type=$event_type&search=$search&severity=$severity&status=$status&id_agent=$id_agent'>"; echo '&nbsp;&nbsp;&nbsp;
echo "<img src='images/disk.png' title='Export to CSV file'></A>"; <a href="operation/events/export_csv.php?ev_group='.$ev_group.'&event_type='.$event_type.'&search='.$search.'&severity='.$severity.'&status='.$status.'&id_agent='.$id_agent.'">
<img src="images/disk.png" title="Export to CSV file"></a>';
// Marquee // Marquee
echo "&nbsp;<a target='_top' href='operation/events/events_marquee.php'><img src='images/heart.png' title='".__('Marquee display')."'></a>"; echo "&nbsp;<a target='_top' href='operation/events/events_marquee.php'><img src='images/heart.png' title='".__('Marquee display')."'></a>";
// RSS // RSS
echo "&nbsp;<a target='_top' href='operation/events/events_rss.php'><img src='images/transmit.png' title='".__('RSS Events')."'></a>"; echo "&nbsp;<a target='_top' href='operation/events/events_rss.php'><img src='images/transmit.png' title='".__('RSS Events')."'></a>";
echo "</table>"; echo "</td></tr></table>";
echo "</form>"; echo "</form>";
echo "<td>"; echo "<td>";
echo '<img src="reporting/fgraph.php?tipo=group_events&width=250&height=180&url='.$sql_post.'" border=0>'; echo '<img src="reporting/fgraph.php?tipo=group_events&width=250&height=180&url='.rawurlencode($sql_post).'" border="0">'; //Don't rely on browsers to do this correctly
echo "</table>"; echo "</td></tr></table>";
echo "</div>"; echo "</div>";
$sql2 = "SELECT * FROM tevento WHERE 1=1 "; $sql = "SELECT * FROM tevento WHERE 1=1 ".$sql_post." ORDER BY timestamp DESC LIMIT ".$offset.",".$config["block_size"];
$sql2 .= $sql_post . " ORDER BY timestamp DESC LIMIT $offset, ".$config["block_size"]; $result = get_db_all_rows_sql ($sql);
$sql3 = "SELECT COUNT(id_evento) FROM tevento WHERE 1=1 "; $sql = "SELECT COUNT(id_evento) FROM tevento WHERE 1=1 ".$sql_post;
$sql3 .= $sql_post; $total_events = get_db_sql ($sql);
$result3=mysql_query($sql3);
$row3=mysql_fetch_array($result3);
$total_events = $row3[0];
// Show pagination header // Show pagination header
if ($total_events > 0){ if ($total_events > 0){
$offset = get_parameter ( "offset",0); $offset = get_parameter ("offset",0);
pagination ($total_events, $url."&pure=".$config["pure"], $offset); pagination ($total_events, $url."&pure=".$config["pure"], $offset);
// Show data. // Show data.
echo "<br>"; echo "<br>";
echo "<br>"; echo "<br>";
if ($config["pure"] == 0) if ($config["pure"] == 0) {
echo "<table cellpadding='4' cellspacing='4' width='765' class='databox'>"; echo "<table cellpadding='4' cellspacing='4' width='765' class='databox'>";
else } else {
echo "<table cellpadding='4' cellspacing='4' class='databox'>"; echo "<table cellpadding='4' cellspacing='4' class='databox'>";
}
echo "<tr>"; echo "<tr>";
echo "<th class=f9>".__('St')."</th>"; echo "<th class=f9>".__('St')."</th>";
echo "<th class=f9>".__('Type')."</th>"; echo "<th class=f9>".__('Type')."</th>";
@ -316,8 +306,7 @@ if ($total_events > 0){
$offset_counter=0; $offset_counter=0;
// Make query for data (all data, not only distinct). // Make query for data (all data, not only distinct).
$result2=mysql_query($sql2); foreach ($result as $row2) {
while ($row2=mysql_fetch_array($result2)){
$id_grupo = $row2["id_grupo"]; $id_grupo = $row2["id_grupo"];
if (give_acl($config["id_user"], $id_grupo, "AR") == 1){ // Only incident read access to view data ! if (give_acl($config["id_user"], $id_grupo, "AR") == 1){ // Only incident read access to view data !
$id_group = $row2["id_grupo"]; $id_group = $row2["id_grupo"];
@ -389,7 +378,7 @@ if ($total_events > 0){
echo ".."; echo "..";
if ($row2["id_agente"] > 0) { if ($row2["id_agente"] > 0) {
// Agent name // Agent name
$agent_name = dame_nombre_agente($row2["id_agente"]); $agent_name = dame_nombre_agente ($row2["id_agente"]);
echo "<td class='".$tdclass."f9' title='$agent_name'><a href='$url&pure=".$config["pure"]."&id_agent=".$row2["id_agente"]."'><b>"; echo "<td class='".$tdclass."f9' title='$agent_name'><a href='$url&pure=".$config["pure"]."&id_agent=".$row2["id_agente"]."'><b>";
echo substr($agent_name, 0, 14); echo substr($agent_name, 0, 14);
if (strlen($agent_name) > 14) if (strlen($agent_name) > 14)
@ -424,18 +413,18 @@ if ($total_events > 0){
// Timestamp // Timestamp
echo "<td class='".$tdclass."f9' title='".$row2["timestamp"]."'>"; echo "<td class='".$tdclass."f9' title='".$row2["timestamp"]."'>";
echo human_time_comparation($row2["timestamp"]); echo human_time_comparation ($row2["timestamp"]);
// Several options grouped here // Several options grouped here
echo "<td class='$tdclass' align='right'>"; echo "<td class='$tdclass' align='right'>";
// Validate event // Validate event
if (($row2["estado"] == 0) and (give_acl($config["id_user"], $id_group,"IW") ==1)) if (($row2["estado"] == 0) and (give_acl ($config["id_user"], $id_group,"IW") ==1))
echo "<a href='$url&check=".$row2["id_evento"]."&pure=".$config["pure"]."'><img src='images/ok.png' border='0'></a> "; echo "<a href='$url&check=".$row2["id_evento"]."&pure=".$config["pure"]."'><img src='images/ok.png' border='0'></a> ";
// Delete event // Delete event
if (give_acl($config["id_user"], $id_group,"IM") ==1) if (give_acl ($config["id_user"], $id_group,"IM") ==1)
echo "<a href='$url&delete=".$row2["id_evento"]."&pure=".$config["pure"]."'><img src='images/cross.png' border=0></a> "; echo "<a href='$url&delete=".$row2["id_evento"]."&pure=".$config["pure"]."'><img src='images/cross.png' border=0></a> ";
// Create incident from this event // Create incident from this event
if (give_acl($config["id_user"], $id_group,"IW") == 1) if (give_acl ($config["id_user"], $id_group,"IW") == 1)
echo "<a href='index.php?sec=incidencias&sec2=operation/incidents/incident_detail&insert_form&from_event=".$row2["id_evento"]."'><img src='images/page_lightning.png' border=0></a>"; echo "<a href='index.php?sec=incidencias&sec2=operation/incidents/incident_detail&insert_form&from_event=".$row2["id_evento"]."'><img src='images/page_lightning.png' border=0></a>";
// Checbox // Checbox
echo "<td class='$tdclass' align='center'>"; echo "<td class='$tdclass' align='center'>";
@ -448,7 +437,7 @@ if ($total_events > 0){
echo "<table width='750'><tr><td align='right'>"; echo "<table width='750'><tr><td align='right'>";
echo "<input class='sub ok' type='submit' name='updatebt' value='".__('Validate')."'> "; echo "<input class='sub ok' type='submit' name='updatebt' value='".__('Validate')."'> ";
if (give_acl($config["id_user"], 0,"IM") ==1){ if (give_acl ($config["id_user"], 0,"IM") ==1){
echo "<input class='sub delete' type='submit' name='deletebt' value='".__('Delete')."'>"; echo "<input class='sub delete' type='submit' name='deletebt' value='".__('Delete')."'>";
} }
echo "</form></table>"; echo "</form></table>";