2007-10-12 18:27:50 +02:00
|
|
|
<?php
|
|
|
|
// Pandora FMS - the Free monitoring system
|
|
|
|
// ========================================
|
2008-04-24 01:29:50 +02:00
|
|
|
// Copyright (c) 2004-2008 Sancho Lerena, slerena@openideas.info
|
2007-10-12 18:27:50 +02:00
|
|
|
// Copyright (c) 2005-2007 Artica Soluciones Tecnologicas
|
2006-03-27 05:37:27 +02:00
|
|
|
|
2007-10-12 18:27:50 +02:00
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation version 2
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, U
|
2006-03-27 05:37:27 +02:00
|
|
|
|
|
|
|
// Load global vars
|
2008-04-24 01:29:50 +02:00
|
|
|
global $config;
|
2008-07-16 23:04:31 +02:00
|
|
|
check_login ();
|
2008-04-24 01:29:50 +02:00
|
|
|
|
2008-07-16 23:04:31 +02:00
|
|
|
$id_usuario= $_SESSION["id_usuario"];
|
|
|
|
|
2008-07-21 14:23:28 +02:00
|
|
|
if (give_acl ($id_usuario, 0, "DM")==1){
|
2008-04-24 01:29:50 +02:00
|
|
|
|
2008-07-21 14:23:28 +02:00
|
|
|
if (isset ($_POST["agent"])){
|
|
|
|
$id_agent = get_parameter_post ("agent");
|
2007-06-22 14:00:04 +02:00
|
|
|
} else
|
|
|
|
$id_agent = -1;
|
|
|
|
|
2007-10-12 18:27:50 +02:00
|
|
|
echo '<h2>'.$lang_label["dbmain_title"].' >'.$lang_label["db_purge"]."</h2>";
|
2007-06-22 14:00:04 +02:00
|
|
|
echo "<img src='reporting/fgraph.php?tipo=db_agente_purge&id=$id_agent'>";
|
|
|
|
echo "<br><br>";
|
|
|
|
echo '<h3>'.$lang_label["get_data_agent"].'</h3>';
|
|
|
|
|
2006-03-27 05:37:27 +02:00
|
|
|
// All data (now)
|
|
|
|
$purge_all=date("Y-m-d H:i:s",time());
|
|
|
|
|
2008-07-16 23:04:31 +02:00
|
|
|
require("godmode/db/times_incl.php");
|
2006-03-27 05:37:27 +02:00
|
|
|
|
2008-07-21 14:23:28 +02:00
|
|
|
$datos_rango3=0;
|
|
|
|
$datos_rango2=0;
|
|
|
|
$datos_rango1=0;
|
|
|
|
$datos_rango0=0;
|
|
|
|
$datos_rango00=0;
|
|
|
|
$datos_rango11=0;
|
|
|
|
$datos_total=0;
|
2006-03-27 05:37:27 +02:00
|
|
|
|
|
|
|
# ADQUIRE DATA PASSED AS FORM PARAMETERS
|
|
|
|
# ======================================
|
|
|
|
# Purge data using dates
|
|
|
|
|
2007-06-22 14:00:04 +02:00
|
|
|
|
2006-03-27 05:37:27 +02:00
|
|
|
# Purge data using dates
|
|
|
|
if (isset($_POST["purgedb"])){
|
2008-07-21 14:23:28 +02:00
|
|
|
$from_date = get_parameter_post ("date_purge");
|
2006-03-27 05:37:27 +02:00
|
|
|
if (isset($id_agent)){
|
|
|
|
if ($id_agent != -1) {
|
2008-07-21 14:23:28 +02:00
|
|
|
echo $lang_label["purge_task"].$id_agent." / ".$from_date;
|
2006-03-27 05:37:27 +02:00
|
|
|
echo "<h3>".$lang_label["please_wait"]."<br>",$lang_label["while_delete_data"].$lang_label["agent"]."</h3>";
|
2008-07-21 14:23:28 +02:00
|
|
|
if ($id_agent == 0) {
|
|
|
|
$sql_2='SELECT * FROM tagente_modulo';
|
|
|
|
} else {
|
|
|
|
$sql_2='SELECT * FROM tagente_modulo WHERE id_agente = '.$id_agent;
|
|
|
|
}
|
2006-03-27 05:37:27 +02:00
|
|
|
$result_t=mysql_query($sql_2);
|
2008-07-21 14:23:28 +02:00
|
|
|
while ($row=mysql_fetch_array($result_t)) {
|
2006-03-27 05:37:27 +02:00
|
|
|
echo $lang_label["deleting_records"].dame_nombre_modulo_agentemodulo($row["id_agente_modulo"]);
|
|
|
|
flush();
|
2007-07-23 13:02:31 +02:00
|
|
|
//ob_flush();
|
2006-03-27 05:37:27 +02:00
|
|
|
echo "<br>";
|
2008-07-21 14:23:28 +02:00
|
|
|
$query = sprintf("DELETE FROM `tagente_datos` WHERE `id_agente_modulo` = '%d' AND `timestamp` < '%s'",$row["id_agente_modulo"],$from_date);
|
|
|
|
process_sql ($query);
|
|
|
|
$query = sprintf("DELETE FROM `tagente_datos_inc` WHERE `id_agente_modulo` = '%d' AND `timestamp` < '%s'",$row["id_agente_modulo"],$from_date);
|
|
|
|
process_sql ($query);
|
|
|
|
$query = sprintf("DELETE FROM `tagente_datos_string` WHERE `id_agente_modulo` = '%d' AND `timestamp` < '%s'",$row["id_agente_modulo"],$from_date);
|
|
|
|
process_sql ($query);
|
2006-03-27 05:37:27 +02:00
|
|
|
}
|
2008-07-21 14:23:28 +02:00
|
|
|
} else {
|
2006-06-29 16:33:34 +02:00
|
|
|
echo $lang_label["deleting_records"].$lang_label["all_agents"];
|
2006-03-27 05:37:27 +02:00
|
|
|
flush();
|
|
|
|
ob_flush();
|
2008-07-21 14:23:28 +02:00
|
|
|
$query = "DELETE FROM tagente_datos,tagente_datos_inc,tagente_datos_string WHERE timestamp < '".$from_date."'";
|
|
|
|
process_sql ($query);
|
2006-03-27 05:37:27 +02:00
|
|
|
}
|
2008-07-21 14:23:28 +02:00
|
|
|
echo "<br><br>";
|
2006-03-27 05:37:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Select Agent for further operations.
|
2006-06-29 16:33:34 +02:00
|
|
|
?>
|
|
|
|
<form action='index.php?sec=gdbman&sec2=godmode/db/db_purge' method='post'>
|
2007-06-06 18:23:24 +02:00
|
|
|
<table class='databox'>
|
|
|
|
<tr><td class='datos'>
|
2006-06-29 16:33:34 +02:00
|
|
|
<select name='agent' class='w130'>
|
|
|
|
|
|
|
|
<?php
|
2008-04-24 01:29:50 +02:00
|
|
|
if (isset($_POST["agent"]) and ($id_agent > 0))
|
2006-03-27 05:37:27 +02:00
|
|
|
echo "<option value='".$_POST["agent"]."'>".dame_nombre_agente($_POST["agent"]);
|
2008-04-24 01:29:50 +02:00
|
|
|
if (isset($_POST["agent"]) and ($id_agent == 0)){
|
|
|
|
echo "<option value=0>".$lang_label["all_agents"];
|
|
|
|
echo "<option value=-1>".$lang_label["choose_agent"];
|
|
|
|
} else {
|
|
|
|
echo "<option value=-1>".$lang_label["choose_agent"];
|
|
|
|
echo "<option value=0>".$lang_label["all_agents"];
|
|
|
|
}
|
2006-03-27 05:37:27 +02:00
|
|
|
$result_t=mysql_query("SELECT * FROM tagente");
|
|
|
|
while ($row=mysql_fetch_array($result_t)){
|
|
|
|
echo "<option value='".$row["id_agente"]."'>".$row["nombre"];
|
2006-06-29 16:33:34 +02:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
</select>
|
|
|
|
<a href="#" class="tip"> <span><?php echo $help_label["db_purge0"] ?></span></a>
|
2007-06-06 18:23:24 +02:00
|
|
|
<td><input class='sub upd' type='submit' name='purgedb_ag' value='<?php echo $lang_label["get_data"] ?>'>
|
2006-06-29 16:33:34 +02:00
|
|
|
<a href="#" class="tip"> <span><?php echo $help_label["db_purge1"] ?></span></a>
|
|
|
|
</table><br>
|
|
|
|
|
|
|
|
<?php
|
2006-03-27 05:37:27 +02:00
|
|
|
# End of get parameters block
|
|
|
|
|
|
|
|
if (isset($_POST["agent"]) and ($id_agent !=-1)){
|
|
|
|
echo "<h3>".$lang_label["db_agent_bra"].dame_nombre_agente($id_agent).$lang_label["db_agent_ket"]."</h3>";
|
2008-07-21 14:23:28 +02:00
|
|
|
|
|
|
|
$sql = "SELECT id_agente_modulo FROM tagente_modulo";
|
|
|
|
if ($id_agent != 0) {
|
|
|
|
$sql .= sprintf(" WHERE id_agente = '%d'",$id_agent);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
flush();
|
|
|
|
ob_flush();
|
|
|
|
*/
|
|
|
|
$datos_rango00 += get_db_sql (sprintf("SELECT COUNT(*) FROM `tagente_datos` WHERE `id_agente_modulo` = ANY(%s) AND `timestamp` > '%s'",$sql,$d1));
|
|
|
|
$datos_rango0 += get_db_sql (sprintf("SELECT COUNT(*) FROM `tagente_datos` WHERE `id_agente_modulo` = ANY(%s) AND `timestamp` > '%s'",$sql,$d3));
|
|
|
|
$datos_rango1 += get_db_sql (sprintf("SELECT COUNT(*) FROM `tagente_datos` WHERE `id_agente_modulo` = ANY(%s) AND `timestamp` > '%s'",$sql,$week));
|
|
|
|
$datos_rango11 += get_db_sql (sprintf("SELECT COUNT(*) FROM `tagente_datos` WHERE `id_agente_modulo` = ANY(%s) AND `timestamp` > '%s'",$sql,$week2));
|
|
|
|
$datos_rango2 += get_db_sql (sprintf("SELECT COUNT(*) FROM `tagente_datos` WHERE `id_agente_modulo` = ANY(%s) AND `timestamp` > '%s'",$sql,$month));
|
|
|
|
$datos_rango3 += get_db_sql (sprintf("SELECT COUNT(*) FROM `tagente_datos` WHERE `id_agente_modulo` = ANY(%s) AND `timestamp` > '%s'",$sql,$month3));
|
|
|
|
$datos_total += get_db_sql (sprintf("SELECT COUNT(*) FROM `tagente_datos` WHERE `id_agente_modulo` = ANY(%s)",$sql));
|
|
|
|
|
2006-03-27 05:37:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
2007-06-06 18:23:24 +02:00
|
|
|
<table width='300' border='0' class='databox' cellspacing='4' cellpadding='4'>
|
2006-03-27 05:37:27 +02:00
|
|
|
<tr><td class=datos>
|
|
|
|
<?php echo $lang_label["rango3"]?>
|
2006-07-03 12:49:42 +02:00
|
|
|
</td>
|
2006-03-27 05:37:27 +02:00
|
|
|
<td class=datos>
|
2008-07-21 14:23:28 +02:00
|
|
|
<?php echo $datos_rango3; ?>
|
2006-07-03 12:49:42 +02:00
|
|
|
</td>
|
2006-03-27 05:37:27 +02:00
|
|
|
|
2006-07-03 12:49:42 +02:00
|
|
|
<tr><td class=datos2>
|
2006-03-27 05:37:27 +02:00
|
|
|
<?php echo $lang_label["rango2"]?>
|
2006-07-03 12:49:42 +02:00
|
|
|
</td>
|
|
|
|
<td class=datos2>
|
2008-07-21 14:23:28 +02:00
|
|
|
<?php echo $datos_rango2; ?>
|
2006-07-03 12:49:42 +02:00
|
|
|
</td>
|
|
|
|
|
2006-06-29 16:33:34 +02:00
|
|
|
<tr><td class=datos>
|
|
|
|
<?php echo $lang_label["rango11"]?>
|
2006-07-03 12:49:42 +02:00
|
|
|
</td>
|
2006-06-29 16:33:34 +02:00
|
|
|
<td class=datos>
|
2008-07-21 14:23:28 +02:00
|
|
|
<?php echo $datos_rango11; ?>
|
2006-07-03 12:49:42 +02:00
|
|
|
</td>
|
2006-03-27 05:37:27 +02:00
|
|
|
|
2006-07-03 12:49:42 +02:00
|
|
|
<tr><td class=datos2>
|
2006-03-27 05:37:27 +02:00
|
|
|
<?php echo $lang_label["rango1"]?>
|
2006-07-03 12:49:42 +02:00
|
|
|
</td>
|
|
|
|
<td class=datos2>
|
2008-07-21 14:23:28 +02:00
|
|
|
<?php echo $datos_rango1; ?>
|
2006-07-03 12:49:42 +02:00
|
|
|
</td>
|
2006-03-27 05:37:27 +02:00
|
|
|
|
|
|
|
<tr><td class=datos>
|
|
|
|
<?php echo $lang_label["rango0"]?>
|
2006-07-03 12:49:42 +02:00
|
|
|
</td>
|
2006-03-27 05:37:27 +02:00
|
|
|
<td class=datos>
|
2008-07-21 14:23:28 +02:00
|
|
|
<?php echo $datos_rango0; ?>
|
2006-07-03 12:49:42 +02:00
|
|
|
</td>
|
2006-03-27 05:37:27 +02:00
|
|
|
|
2006-07-03 12:49:42 +02:00
|
|
|
<tr><td class=datos2>
|
2006-03-27 05:37:27 +02:00
|
|
|
<?php echo $lang_label["rango00"]?>
|
2006-07-03 12:49:42 +02:00
|
|
|
</td>
|
|
|
|
<td class=datos2>
|
2008-07-21 14:23:28 +02:00
|
|
|
<?php echo $datos_rango00; ?>
|
2006-07-03 12:49:42 +02:00
|
|
|
</td>
|
|
|
|
<tr><td class=datos>
|
|
|
|
<b><?php echo $lang_label["total_packets"]?></b>
|
|
|
|
</td>
|
|
|
|
<td class=datos>
|
2008-07-21 14:23:28 +02:00
|
|
|
<b><?php echo $datos_total; ?></b>
|
2006-07-03 12:49:42 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
2006-03-27 05:37:27 +02:00
|
|
|
</table>
|
2006-06-29 16:33:34 +02:00
|
|
|
<br>
|
2006-03-27 05:37:27 +02:00
|
|
|
<h3><?php echo $lang_label["purge_data"] ?></h3>
|
2007-06-06 18:23:24 +02:00
|
|
|
<table width='300' border='0' class='databox' cellspacing='4' cellpadding='4'>
|
2006-03-27 05:37:27 +02:00
|
|
|
<tr><td>
|
2007-04-18 23:45:03 +02:00
|
|
|
<select name="date_purge" width="255px">
|
2006-06-29 16:33:34 +02:00
|
|
|
<option value="<?php echo $month3 ?>"><?php echo $lang_label["purge_90day"] ?>
|
2006-03-27 05:37:27 +02:00
|
|
|
<option value="<?php echo $month ?>"><?php echo $lang_label["purge_30day"] ?>
|
|
|
|
<option value="<?php echo $week2 ?>"><?php echo $lang_label["purge_14day"] ?>
|
|
|
|
<option value="<?php echo $week ?>"><?php echo $lang_label["purge_7day"] ?>
|
|
|
|
<option value="<?php echo $d3 ?>"><?php echo $lang_label["purge_3day"] ?>
|
|
|
|
<option value="<?php echo $d1 ?>"><?php echo $lang_label["purge_1day"] ?>
|
|
|
|
</select>
|
|
|
|
|
2007-06-06 18:23:24 +02:00
|
|
|
<td><input class="sub wand" type="submit" name="purgedb" value="<?php echo $lang_label["doit"] ?>" onClick="if (!confirm('<?php echo $lang_label["are_you_sure"] ?>')) return false;">
|
2006-03-27 05:37:27 +02:00
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<?php
|
2008-07-16 23:04:31 +02:00
|
|
|
} else {
|
2006-03-27 05:37:27 +02:00
|
|
|
audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to access to Database Purge Section");
|
|
|
|
include ("general/noaccess.php");
|
2008-07-16 23:04:31 +02:00
|
|
|
}
|
2007-07-23 13:02:31 +02:00
|
|
|
?>
|