2013-05-14 Miguel de Dios <miguel.dedios@artica.es>
* godmode/modules/manage_network_components.php, godmode/modules/manage_nc_groups.php, godmode/modules/manage_network_templates.php, godmode/reporting/reporting_builder.php, godmode/reporting/graphs.php, godmode/db/db_purge.php, godmode/agentes/module_manager.php, godmode/events/event_filter.php, godmode/massive/massive_delete_modules.php, godmode/massive/massive_delete_agents.php, godmode/massive/massive_edit_modules.php, godmode/netflow/nf_edit.php, godmode/netflow/nf_item_list.php, include/functions_agents.php, include/functions_tags.php, include/functions_messages.php, include/functions_events.php: erased deprecated SQL transaction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8130 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
9d2e9c5161
commit
5d7dd5567d
|
@ -1,3 +1,19 @@
|
|||
2013-05-14 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* godmode/modules/manage_network_components.php,
|
||||
godmode/modules/manage_nc_groups.php,
|
||||
godmode/modules/manage_network_templates.php,
|
||||
godmode/reporting/reporting_builder.php,
|
||||
godmode/reporting/graphs.php, godmode/db/db_purge.php,
|
||||
godmode/agentes/module_manager.php, godmode/events/event_filter.php,
|
||||
godmode/massive/massive_delete_modules.php,
|
||||
godmode/massive/massive_delete_agents.php,
|
||||
godmode/massive/massive_edit_modules.php,
|
||||
godmode/netflow/nf_edit.php, godmode/netflow/nf_item_list.php,
|
||||
include/functions_agents.php, include/functions_tags.php,
|
||||
include/functions_messages.php, include/functions_events.php:
|
||||
erased deprecated SQL transaction.
|
||||
|
||||
2013-05-14 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/constants.php: added constant "ITEMS_TO_SHOW_IN_MAIN_TAB".
|
||||
|
|
|
@ -156,15 +156,16 @@ if ($multiple_delete) {
|
|||
enterprise_include_once('include/functions_config_agents.php');
|
||||
enterprise_hook('config_agents_delete_module_in_conf', array(modules_get_agentmodule_agent($id_agent_module_del), modules_get_agentmodule_name($id_agent_module_del)));
|
||||
|
||||
//Init transaction
|
||||
$error = 0;
|
||||
db_process_sql_begin ();
|
||||
|
||||
// First delete from tagente_modulo -> if not successful, increment
|
||||
// error. NOTICE that we don't delete all data here, just marking for deletion
|
||||
// and delete some simple data.
|
||||
$status = '';
|
||||
$module = db_get_row_sql ('SELECT * FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.id_agente_modulo=' . (int)$id_agent_module_del);
|
||||
$module = db_get_row_sql ('SELECT *
|
||||
FROM tagente_modulo, tagente_estado
|
||||
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
AND tagente_modulo.id_agente_modulo=' . (int)$id_agent_module_del);
|
||||
if (db_process_sql("UPDATE tagente_modulo
|
||||
SET nombre = 'pendingdelete', disabled = 1, delete_pending = 1 WHERE id_agente_modulo = ".$id_agent_module_del, "affected_rows", '', true, $status, false) === false) {
|
||||
$error++;
|
||||
|
@ -173,22 +174,34 @@ if ($multiple_delete) {
|
|||
// Update module status count
|
||||
if ($module !== false) {
|
||||
if ($module['estado'] == 0) {
|
||||
db_process_sql ('UPDATE tagente SET normal_count=normal_count-1 WHERE id_agente=' . $module['id_agente']);
|
||||
db_process_sql ('UPDATE tagente
|
||||
SET normal_count=normal_count-1
|
||||
WHERE id_agente=' . $module['id_agente']);
|
||||
}
|
||||
else if ($module['estado'] == 1) {
|
||||
db_process_sql ('UPDATE tagente SET critical_count=critical_count-1 WHERE id_agente=' . $module['id_agente']);
|
||||
db_process_sql ('UPDATE tagente
|
||||
SET critical_count=critical_count-1
|
||||
WHERE id_agente=' . $module['id_agente']);
|
||||
}
|
||||
else if ($module['estado'] == 2) {
|
||||
db_process_sql ('UPDATE tagente SET warning_count=warning_count-1 WHERE id_agente=' . $module['id_agente']);
|
||||
db_process_sql ('UPDATE tagente
|
||||
SET warning_count=warning_count-1
|
||||
WHERE id_agente=' . $module['id_agente']);
|
||||
}
|
||||
else if ($module['estado'] == 3) {
|
||||
db_process_sql ('UPDATE tagente SET unknown_count=unknown_count-1 WHERE id_agente=' . $module['id_agente']);
|
||||
db_process_sql ('UPDATE tagente
|
||||
SET unknown_count=unknown_count-1
|
||||
WHERE id_agente=' . $module['id_agente']);
|
||||
}
|
||||
else if ($module['estado'] == 4) {
|
||||
db_process_sql ('UPDATE tagente SET notinit_count=notinit_count-1 WHERE id_agente=' . $module['id_agente']);
|
||||
db_process_sql ('UPDATE tagente
|
||||
SET notinit_count=notinit_count-1
|
||||
WHERE id_agente=' . $module['id_agente']);
|
||||
}
|
||||
|
||||
db_process_sql ('UPDATE tagente SET total_count=total_count-1 WHERE id_agente=' . $module['id_agente']);
|
||||
db_process_sql ('UPDATE tagente
|
||||
SET total_count=total_count-1
|
||||
WHERE id_agente=' . $module['id_agente']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,10 +260,8 @@ if ($multiple_delete) {
|
|||
|
||||
//Check for errors
|
||||
if ($error != 0) {
|
||||
db_process_sql_rollback ();
|
||||
}
|
||||
else {
|
||||
db_process_sql_commit ();
|
||||
$count_correct_delete_modules++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,12 +34,13 @@ if (! check_acl ($config['id_user'], 0, "DM")) {
|
|||
//id_agent = -1: None selected; id_agent = 0: All
|
||||
$id_agent = (int) get_parameter_post ("agent", -1);
|
||||
|
||||
ui_print_page_header (__('Database maintenance').' » '.__('Database purge'), "images/gm_db.png", false, "", true);
|
||||
ui_print_page_header (__('Database maintenance') . ' » ' .
|
||||
__('Database purge'), "images/gm_db.png", false, "", true);
|
||||
|
||||
echo grafico_db_agentes_purge($id_agent);
|
||||
|
||||
echo '<br /><br />';
|
||||
echo '<h4>'.__('Get data from agent').'</h4>';
|
||||
echo '<h4>' . __('Get data from agent') . '</h4>';
|
||||
|
||||
// All data (now)
|
||||
$time["all"] = get_system_time ();
|
||||
|
@ -70,27 +71,33 @@ $data["total"] = 0;
|
|||
if (isset($_POST["purgedb"])) {
|
||||
$from_date = get_parameter_post ("date_purge", 0);
|
||||
if ($id_agent > 0) {
|
||||
echo __('Purge task launched for agent')." ".agents_get_name ($id_agent)." :: ".__('Data older than')." ".human_time_description_raw ($from_date);
|
||||
echo "<h3>".__('Please be patient. This operation can take a long time depending on the amount of modules.')."</h3>";
|
||||
echo sprintf(
|
||||
__("Purge task launched for agent %s :: Data older than %s"),
|
||||
agents_get_name ($id_agent), human_time_description_raw ($from_date));
|
||||
echo "<h3>" .
|
||||
__('Please be patient. This operation can take a long time depending on the amount of modules.') .
|
||||
"</h3>";
|
||||
|
||||
$sql = sprintf ("SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = %d", $id_agent);
|
||||
$sql = sprintf ("SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente = %d", $id_agent);
|
||||
$result = db_get_all_rows_sql ($sql);
|
||||
if (empty ($result)) {
|
||||
$result = array ();
|
||||
}
|
||||
|
||||
//Made it in a transaction so it gets done all at once.
|
||||
db_process_sql_begin ();
|
||||
|
||||
$errors = 0;
|
||||
$affected = 0;
|
||||
foreach ($result as $row) {
|
||||
echo __('Deleting records for module')." ".modules_get_agentmodule_name ($row["id_agente_modulo"]);
|
||||
echo sprintf(__('Deleting records for module %s'),
|
||||
modules_get_agentmodule_name ($row["id_agente_modulo"]));
|
||||
echo "<br />";
|
||||
flush (); //Flush here in case there are errors and the script dies, at least we know where we ended
|
||||
set_time_limit (); //Reset the time limit just in case
|
||||
|
||||
$result = db_process_sql_delete('tagente_datos', array('id_agente_modulo' => $row["id_agente_modulo"], 'utimestamp' => '< ' . $from_date));
|
||||
$result = db_process_sql_delete('tagente_datos',
|
||||
array('id_agente_modulo' => $row["id_agente_modulo"],
|
||||
'utimestamp' => '< ' . $from_date));
|
||||
|
||||
if ($result === false)
|
||||
$errors++;
|
||||
|
@ -98,7 +105,9 @@ if (isset($_POST["purgedb"])) {
|
|||
$affected += $result;
|
||||
|
||||
if ($errors == 0) {
|
||||
$result = db_process_sql_delete('tagente_datos_inc', array('id_agente_modulo' => $row["id_agente_modulo"], 'utimestamp' => '< ' . $from_date));
|
||||
$result = db_process_sql_delete('tagente_datos_inc',
|
||||
array('id_agente_modulo' => $row["id_agente_modulo"],
|
||||
'utimestamp' => '< ' . $from_date));
|
||||
|
||||
if ($result === false)
|
||||
$errors++;
|
||||
|
@ -106,7 +115,9 @@ if (isset($_POST["purgedb"])) {
|
|||
$affected += $result;
|
||||
}
|
||||
if ($errors == 0) {
|
||||
$result = db_process_sql_delete('tagente_datos_string', array('id_agente_modulo' => $row["id_agente_modulo"], 'utimestamp' => '< ' . $from_date));
|
||||
$result = db_process_sql_delete('tagente_datos_string',
|
||||
array('id_agente_modulo' => $row["id_agente_modulo"],
|
||||
'utimestamp' => '< ' . $from_date));
|
||||
|
||||
if ($result === false)
|
||||
$errors++;
|
||||
|
@ -114,7 +125,9 @@ if (isset($_POST["purgedb"])) {
|
|||
$affected += $result;
|
||||
}
|
||||
if ($errors == 0) {
|
||||
$result = db_process_sql_delete('tagente_datos_log4x', array('id_agente_modulo' => $row["id_agente_modulo"], 'utimestamp' => '< ' . $from_date));
|
||||
$result = db_process_sql_delete('tagente_datos_log4x',
|
||||
array('id_agente_modulo' => $row["id_agente_modulo"],
|
||||
'utimestamp' => '< ' . $from_date));
|
||||
|
||||
if ($result === false)
|
||||
$errors++;
|
||||
|
@ -124,12 +137,11 @@ if (isset($_POST["purgedb"])) {
|
|||
}
|
||||
|
||||
if ($errors > 0) {
|
||||
db_process_sql_rollback ();
|
||||
echo sprintf(__('Total errors: %s'), $errors);
|
||||
echo sprintf(__('Total records deleted: %s'), $affected);
|
||||
}
|
||||
else {
|
||||
db_process_sql_commit ();
|
||||
|
||||
echo __('Total records deleted: ') . $affected;
|
||||
echo sprintf(__('Total records deleted: %s'), $affected);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -137,10 +149,14 @@ if (isset($_POST["purgedb"])) {
|
|||
echo __('Deleting records for all agents');
|
||||
flush ();
|
||||
|
||||
db_process_sql_delete('tagente_datos', array('utimestamp' => '< ' . $from_date));
|
||||
db_process_sql_delete('tagente_datos_inc', array('utimestamp' => '< ' . $from_date));
|
||||
db_process_sql_delete('tagente_datos_string', array('utimestamp' => '< ' . $from_date));
|
||||
db_process_sql_delete('tagente_datos_log4x', array('utimestamp' => '< ' . $from_date));
|
||||
db_process_sql_delete('tagente_datos',
|
||||
array('utimestamp' => '< ' . $from_date));
|
||||
db_process_sql_delete('tagente_datos_inc',
|
||||
array('utimestamp' => '< ' . $from_date));
|
||||
db_process_sql_delete('tagente_datos_string',
|
||||
array('utimestamp' => '< ' . $from_date));
|
||||
db_process_sql_delete('tagente_datos_log4x',
|
||||
array('utimestamp' => '< ' . $from_date));
|
||||
}
|
||||
echo "<br /><br />";
|
||||
}
|
||||
|
@ -166,7 +182,7 @@ else {
|
|||
$title = __('Information on all agents in the database');
|
||||
}
|
||||
|
||||
echo '<h4>'.$title.'</h4>';
|
||||
echo '<h4>' . $title . '</h4>';
|
||||
//Flush before we do some SQL stuff
|
||||
flush ();
|
||||
|
||||
|
@ -178,91 +194,119 @@ else {
|
|||
$query = "";
|
||||
}
|
||||
|
||||
$data["1day"] = db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["1day"] = db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos
|
||||
WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||
$data["3day"] = db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["3day"] = db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos
|
||||
WHERE utimestamp > %d %s", $time["3day"], $query));
|
||||
$data["1week"] = db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["1week"] = db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos
|
||||
WHERE utimestamp > %d %s", $time["1week"], $query));
|
||||
$data["2week"] = db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["2week"] = db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos
|
||||
WHERE utimestamp > %d %s", $time["2week"], $query));
|
||||
$data["1month"] = db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["1month"] = db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos
|
||||
WHERE utimestamp > %d %s", $time["1month"], $query));
|
||||
$data["3month"] = db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["3month"] = db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos
|
||||
WHERE utimestamp > %d %s", $time["3month"], $query));
|
||||
$data["total"] = db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["total"] = db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos
|
||||
WHERE 1=1 %s", $query));
|
||||
|
||||
$data["1day"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["1day"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_inc
|
||||
WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||
$data["3day"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["3day"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_inc
|
||||
WHERE utimestamp > %d %s", $time["3day"], $query));
|
||||
$data["1week"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["1week"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_inc
|
||||
WHERE utimestamp > %d %s", $time["1week"], $query));
|
||||
$data["2week"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["2week"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_inc
|
||||
WHERE utimestamp > %d %s", $time["2week"], $query));
|
||||
$data["1month"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["1month"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_inc
|
||||
WHERE utimestamp > %d %s", $time["1month"], $query));
|
||||
$data["3month"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["3month"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_inc
|
||||
WHERE utimestamp > %d %s", $time["3month"], $query));
|
||||
$data["total"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["total"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_inc
|
||||
WHERE 1=1 %s", $query));
|
||||
|
||||
$data["1day"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["1day"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_string
|
||||
WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||
$data["3day"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["3day"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_string
|
||||
WHERE utimestamp > %d %s", $time["3day"], $query));
|
||||
$data["1week"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["1week"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_string
|
||||
WHERE utimestamp > %d %s", $time["1week"], $query));
|
||||
$data["2week"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["2week"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_string
|
||||
WHERE utimestamp > %d %s", $time["2week"], $query));
|
||||
$data["1month"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["1month"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_string
|
||||
WHERE utimestamp > %d %s", $time["1month"], $query));
|
||||
$data["3month"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["3month"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_string
|
||||
WHERE utimestamp > %d %s", $time["3month"], $query));
|
||||
$data["total"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["total"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_string
|
||||
WHERE 1=1 %s", $query));
|
||||
|
||||
$data["1day"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["1day"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_log4x
|
||||
WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||
$data["3day"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["3day"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_log4x
|
||||
WHERE utimestamp > %d %s", $time["3day"], $query));
|
||||
$data["1week"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["1week"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_log4x
|
||||
WHERE utimestamp > %d %s", $time["1week"], $query));
|
||||
$data["2week"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["2week"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_log4x
|
||||
WHERE utimestamp > %d %s", $time["2week"], $query));
|
||||
$data["1month"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["1month"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_log4x
|
||||
WHERE utimestamp > %d %s", $time["1month"], $query));
|
||||
$data["3month"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["3month"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_log4x
|
||||
WHERE utimestamp > %d %s", $time["3month"], $query));
|
||||
$data["total"] += db_get_sql (sprintf ("SELECT COUNT(*)
|
||||
$data["total"] += db_get_sql (sprintf ("
|
||||
SELECT COUNT(*)
|
||||
FROM tagente_datos_log4x
|
||||
WHERE 1=1 %s", $query));
|
||||
|
||||
|
@ -288,7 +332,7 @@ $table->data[6][1] = '<strong>'.format_numeric($data["total"]).'</strong>';
|
|||
html_print_table ($table);
|
||||
|
||||
echo '<br />';
|
||||
echo '<h4>'.__('Purge data').'</h4>';
|
||||
echo '<h4>' . __('Purge data') . '</h4>';
|
||||
|
||||
$table->data = array ();
|
||||
|
||||
|
@ -301,10 +345,10 @@ $times[$time["3day"]] = __('Purge data over 3 days');
|
|||
$times[$time["1day"]] = __('Purge data over 1 day');
|
||||
$times[$time["all"]] = __('All data until now');
|
||||
|
||||
$table->data[0][0] = html_print_select ($times, 'date_purge', '', '', '', '',
|
||||
true, false, false);
|
||||
$table->data[0][1] = html_print_submit_button (__('Purge'), "purgedb", false,
|
||||
'class="sub wand"', true);
|
||||
$table->data[0][0] = html_print_select ($times, 'date_purge', '', '',
|
||||
'', '', true, false, false);
|
||||
$table->data[0][1] = html_print_submit_button (__('Purge'), "purgedb",
|
||||
false, 'class="sub wand"', true);
|
||||
|
||||
html_print_table ($table);
|
||||
|
||||
|
|
|
@ -57,22 +57,15 @@ if ($delete){
|
|||
if ($multiple_delete) {
|
||||
$ids = (array)get_parameter('delete_multiple', array());
|
||||
|
||||
db_process_sql_begin();
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$result = db_process_sql_delete ('tevent_filter',
|
||||
array ('id_filter' => $id));
|
||||
|
||||
if ($result === false) {
|
||||
db_process_sql_rollback();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
db_process_sql_commit();
|
||||
}
|
||||
|
||||
if ($result !== false) $result = true;
|
||||
else $result = false;
|
||||
|
||||
|
@ -148,7 +141,8 @@ if (isset($data)) {
|
|||
echo "</form>";
|
||||
}
|
||||
else {
|
||||
echo "<div class='nf'>".__('There are no defined filters')."</div>";
|
||||
echo "<div class='nf'>" .
|
||||
__('There are no defined filters') . "</div>";
|
||||
}
|
||||
|
||||
echo '<form method="post" action="index.php?sec=geventos&sec2=godmode/events/events§ion=edit_filter&pure='.$config['pure'].'">';
|
||||
|
@ -160,12 +154,12 @@ echo '<form method="post" action="index.php?sec=geventos&sec2=godmode/events/eve
|
|||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
function check_all_checkboxes() {
|
||||
if ($("input[name=all_delete]").attr('checked')) {
|
||||
$(".check_delete").attr('checked', true);
|
||||
function check_all_checkboxes() {
|
||||
if ($("input[name=all_delete]").attr('checked')) {
|
||||
$(".check_delete").attr('checked', true);
|
||||
}
|
||||
else {
|
||||
$(".check_delete").attr('checked', false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$(".check_delete").attr('checked', false);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -39,8 +39,6 @@ function process_manage_delete ($id_agents) {
|
|||
$copy_modules = (bool) get_parameter ('copy_modules');
|
||||
$copy_alerts = (bool) get_parameter ('copy_alerts');
|
||||
|
||||
db_process_sql_begin ();
|
||||
|
||||
$error = false;
|
||||
$count_deleted = 0;
|
||||
$agent_id_restore = 0;
|
||||
|
@ -54,17 +52,16 @@ function process_manage_delete ($id_agents) {
|
|||
}
|
||||
|
||||
if (! $success) {
|
||||
ui_print_error_message(__('There was an error deleting the agent, the operation has been cancelled') . '. ' . __('Could not delete agent').' '.agents_get_name ($agent_id_restore));
|
||||
|
||||
//echo '<h3 class="error">'.__('There was an error deleting the agent, the operation has been cancelled').'</h3>';
|
||||
//echo '<h4>'.__('Could not delete agent').' '.agents_get_name ($id_agent).'</h4>';
|
||||
db_process_sql_rollback ();
|
||||
ui_print_error_message(
|
||||
sprintf(
|
||||
__('There was an error deleting the agent, the operation has been cancelled Could not delete agent %s'),
|
||||
agents_get_name ($agent_id_restore)));
|
||||
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
ui_print_success_message(__('Successfully deleted') . ' (' . $count_deleted . ')');
|
||||
db_process_sql_commit ();
|
||||
ui_print_success_message(sprintf(__('Successfully deleted (%s)',
|
||||
$count_deleted)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -59,8 +59,6 @@ function process_manage_delete ($module_name, $id_agents) {
|
|||
return false;
|
||||
}
|
||||
|
||||
db_process_sql_begin ();
|
||||
|
||||
$module_name = (array)$module_name;
|
||||
|
||||
// We are selecting "any" agent for the selected modules
|
||||
|
@ -91,13 +89,11 @@ function process_manage_delete ($module_name, $id_agents) {
|
|||
$success = modules_delete_agent_module ($modules);
|
||||
if (! $success) {
|
||||
ui_print_error_message(__('There was an error deleting the modules, the operation has been cancelled'));
|
||||
db_process_sql_rollback ();
|
||||
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
ui_print_success_message(__('Successfully deleted') . ' (' . $count_deleted_modules . ')');
|
||||
db_process_sql_commit ();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -729,8 +729,6 @@ function process_manage_edit ($module_name, $agents_select = null) {
|
|||
}
|
||||
}
|
||||
|
||||
db_process_sql_begin ();
|
||||
|
||||
if ($modules === false)
|
||||
return false;
|
||||
|
||||
|
@ -739,14 +737,11 @@ function process_manage_edit ($module_name, $agents_select = null) {
|
|||
$module['id_agente_modulo'], $values, true, $update_tags);
|
||||
|
||||
if (is_error($result)) {
|
||||
db_process_sql_rollback ();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
db_process_sql_commit ();
|
||||
|
||||
return true;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -123,8 +123,6 @@ if ($delete) {
|
|||
if ($multiple_delete) {
|
||||
$ids = (array)get_parameter('delete_multiple', array());
|
||||
|
||||
db_process_sql_begin();
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$result = db_process_sql_delete ('tnetwork_component_group',
|
||||
array ('id_sg' => $id));
|
||||
|
@ -132,24 +130,22 @@ if ($multiple_delete) {
|
|||
$result1 = db_process_sql_update('tnetwork_component_group', array('parent' => 0), array('parent' => $id));
|
||||
|
||||
if (($result === false) or ($result1 === false)) {
|
||||
db_process_sql_rollback();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
db_process_sql_commit();
|
||||
}
|
||||
|
||||
if ($result !== false) $result = true;
|
||||
else $result = false;
|
||||
|
||||
$str_ids = implode (',', $ids);
|
||||
if ($result) {
|
||||
db_pandora_audit( "Module management", "Multiple delete component group: $str_ids");
|
||||
db_pandora_audit( "Module management",
|
||||
"Multiple delete component group: $str_ids");
|
||||
}
|
||||
else {
|
||||
db_pandora_audit( "Module management", "Fail try to delete component group: $str_ids");
|
||||
db_pandora_audit( "Module management",
|
||||
"Fail try to delete component group: $str_ids");
|
||||
}
|
||||
ui_print_result_message ($result,
|
||||
__('Successfully multiple deleted'),
|
||||
|
@ -244,12 +240,12 @@ echo '</div>';
|
|||
echo '</form>';
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
function check_all_checkboxes() {
|
||||
if ($("input[name=all_delete]").attr('checked')) {
|
||||
$(".check_delete").attr('checked', true);
|
||||
function check_all_checkboxes() {
|
||||
if ($("input[name=all_delete]").attr('checked')) {
|
||||
$(".check_delete").attr('checked', true);
|
||||
}
|
||||
else {
|
||||
$(".check_delete").attr('checked', false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$(".check_delete").attr('checked', false);
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -320,13 +320,10 @@ if ($delete_component) {
|
|||
if ($multiple_delete) {
|
||||
$ids = (array)get_parameter('delete_multiple', array());
|
||||
|
||||
db_process_sql_begin();
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$result = network_components_delete_network_component ($id);
|
||||
|
||||
if ($result === false) {
|
||||
db_process_sql_rollback();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -339,10 +336,6 @@ if ($multiple_delete) {
|
|||
db_pandora_audit( "Module management", "Fail try to delete network component: $str_ids");
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
db_process_sql_commit();
|
||||
}
|
||||
|
||||
ui_print_result_message ($result,
|
||||
__('Successfully multiple deleted'),
|
||||
__('Not deleted. Error deleting multiple data'));
|
||||
|
|
|
@ -56,21 +56,14 @@ if ($delete_profile) { // if delete
|
|||
if ($multiple_delete) {
|
||||
$ids = (array)get_parameter('delete_multiple', array());
|
||||
|
||||
db_process_sql_begin();
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$result = network_profiles_delete_network_profile ($id);
|
||||
|
||||
if ($result === false) {
|
||||
db_process_sql_rollback();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
db_process_sql_commit();
|
||||
}
|
||||
|
||||
$str_ids = implode (',', $ids);
|
||||
if ($result) {
|
||||
db_pandora_audit("Module management", "Multiple delete module template: $str_ids");
|
||||
|
|
|
@ -73,8 +73,6 @@ if ($delete) {
|
|||
if ($multiple_delete) {
|
||||
$ids = (array)get_parameter('delete_multiple', array());
|
||||
|
||||
db_process_sql_begin();
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$id_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id);
|
||||
$result = db_process_sql_delete ('tnetflow_filter',
|
||||
|
@ -84,15 +82,10 @@ if ($multiple_delete) {
|
|||
array ('id_filter' => $id_filter));
|
||||
|
||||
if ($result === false) {
|
||||
db_process_sql_rollback();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
db_process_sql_commit();
|
||||
}
|
||||
|
||||
if ($result !== false) $result = true;
|
||||
else $result = false;
|
||||
|
||||
|
|
|
@ -36,19 +36,19 @@ $id = (int)get_parameter('id');
|
|||
|
||||
$buttons['report_list']['active'] = false;
|
||||
$buttons['report_list'] = '<a href="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_report">'
|
||||
. html_print_image ("images/edit.png", true, array ("title" => __('Report list')))
|
||||
. '</a>';
|
||||
|
||||
. html_print_image ("images/edit.png", true, array ("title" => __('Report list')))
|
||||
. '</a>';
|
||||
|
||||
$buttons['report_items']['active'] = true;
|
||||
$buttons['report_items']['text'] = '<a href="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_item_list&id='.$id.'">'
|
||||
. html_print_image ("images/god6.png", true, array ("title" => __('Report items')))
|
||||
. '</a>';
|
||||
|
||||
. html_print_image ("images/god6.png", true, array ("title" => __('Report items')))
|
||||
. '</a>';
|
||||
|
||||
$buttons['edit_report']['active'] = false;
|
||||
$buttons['edit_report']['text'] = '<a href="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_report_form&id='.$id.'">'
|
||||
. html_print_image ("images/config.png", true, array ("title" => __('Edit report')))
|
||||
. '</a>';
|
||||
|
||||
. html_print_image ("images/config.png", true, array ("title" => __('Edit report')))
|
||||
. '</a>';
|
||||
|
||||
//Header
|
||||
if (! defined ('METACONSOLE')) {
|
||||
ui_print_page_header (__('Report items'), "images/gm_netflow.png", false, "", true, $buttons);
|
||||
|
@ -69,7 +69,10 @@ $id_rc = (int) get_parameter ('id_rc');
|
|||
|
||||
if ($order) {
|
||||
$dir = get_parameter ('dir');
|
||||
$old_order = db_get_value_sql('SELECT `order` FROM tnetflow_report_content WHERE id_rc = ' . $id_rc);
|
||||
$old_order = db_get_value_sql('
|
||||
SELECT `order`
|
||||
FROM tnetflow_report_content
|
||||
WHERE id_rc = ' . $id_rc);
|
||||
switch ($dir) {
|
||||
case 'up':
|
||||
$new_order = $old_order-1;
|
||||
|
@ -78,20 +81,26 @@ if ($order) {
|
|||
$new_order = $old_order + 1;
|
||||
break;
|
||||
}
|
||||
$sql = "select id_rc from tnetflow_report_content where id_report=$id and `order`=$new_order";
|
||||
|
||||
$sql = "SELECT id_rc
|
||||
FROM tnetflow_report_content
|
||||
WHERE id_report=$id AND `order`=$new_order";
|
||||
|
||||
$item_cont = db_get_row_sql($sql);
|
||||
$id_item_mod = $item_cont['id_rc'];
|
||||
$result = db_process_sql_update('tnetflow_report_content', array('`order`' => $new_order), array('id_rc' => $id_rc));
|
||||
$result2 = db_process_sql_update('tnetflow_report_content', array('`order`' => $old_order), array('id_rc' => $id_item_mod));
|
||||
$result = db_process_sql_update('tnetflow_report_content',
|
||||
array('`order`' => $new_order), array('id_rc' => $id_rc));
|
||||
$result2 = db_process_sql_update('tnetflow_report_content',
|
||||
array('`order`' => $old_order), array('id_rc' => $id_item_mod));
|
||||
}
|
||||
|
||||
if ($delete) {
|
||||
$result = db_process_sql_delete ('tnetflow_report_content',
|
||||
array ('id_rc' => $id_rc));
|
||||
|
||||
|
||||
if ($result !== false) $result = true;
|
||||
else $result = false;
|
||||
|
||||
|
||||
ui_print_result_message ($result,
|
||||
__('Successfully deleted'),
|
||||
__('Not deleted. Error deleting data'));
|
||||
|
@ -100,23 +109,16 @@ if ($delete) {
|
|||
|
||||
if ($multiple_delete) {
|
||||
$ids = (array)get_parameter('delete_multiple', array());
|
||||
|
||||
db_process_sql_begin();
|
||||
|
||||
foreach ($ids as $id_delete) {
|
||||
$result = db_process_sql_delete ('tnetflow_report_content',
|
||||
array ('id_rc' => $id_delete));
|
||||
|
||||
if ($result === false) {
|
||||
db_process_sql_rollback();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
db_process_sql_commit();
|
||||
}
|
||||
|
||||
if ($result !== false) $result = true;
|
||||
else $result = false;
|
||||
|
||||
|
@ -133,9 +135,9 @@ $filter['limit'] = (int) $config['block_size'];
|
|||
$reports_item = db_get_all_rows_filter ('tnetflow_report_content', $filter);
|
||||
|
||||
$reports_item = db_get_all_rows_sql("
|
||||
SELECT *
|
||||
FROM tnetflow_report_content
|
||||
WHERE id_report=$id ORDER BY `order`");
|
||||
SELECT *
|
||||
FROM tnetflow_report_content
|
||||
WHERE id_report=$id ORDER BY `order`");
|
||||
|
||||
if ($reports_item === false)
|
||||
$reports_item = array ();
|
||||
|
@ -148,7 +150,7 @@ $table->head[2] = __('Description');
|
|||
$table->head[3] = __('Max. values');
|
||||
$table->head[4] = __('Chart type');
|
||||
$table->head[5] = __('Action') . html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();');
|
||||
|
||||
|
||||
$table->style = array ();
|
||||
$table->style[1] = 'font-weight: bold';
|
||||
$table->align = array ();
|
||||
|
@ -253,26 +255,25 @@ else {
|
|||
echo "<div class='nf'>".__('There are no defined items')."</div>";
|
||||
}
|
||||
|
||||
echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_report_item&id='.$id.'">';
|
||||
echo "<div style='padding-bottom: 20px; text-align: right; width:" . $table->width . "'>";
|
||||
html_print_submit_button (__('Create item'), 'crt', false, 'class="sub wand"');
|
||||
echo "</div>";
|
||||
echo "</form>";
|
||||
echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_report_item&id='.$id.'">';
|
||||
echo "<div style='padding-bottom: 20px; text-align: right; width:" . $table->width . "'>";
|
||||
html_print_submit_button (__('Create item'), 'crt', false, 'class="sub wand"');
|
||||
echo "</div>";
|
||||
echo "</form>";
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready (function () {
|
||||
$("textarea").TextAreaResizer ();
|
||||
});
|
||||
|
||||
function check_all_checkboxes() {
|
||||
if ($("input[name=all_delete]").attr('checked')) {
|
||||
$(".check_delete").attr('checked', true);
|
||||
$(document).ready (function () {
|
||||
$("textarea").TextAreaResizer ();
|
||||
});
|
||||
|
||||
function check_all_checkboxes() {
|
||||
if ($("input[name=all_delete]").attr('checked')) {
|
||||
$(".check_delete").attr('checked', true);
|
||||
}
|
||||
else {
|
||||
$(".check_delete").attr('checked', false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$(".check_delete").attr('checked', false);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -103,22 +103,15 @@ if ($delete_graph) {
|
|||
if ($multiple_delete) {
|
||||
$ids = (array)get_parameter('delete_multiple', array());
|
||||
|
||||
db_process_sql_begin();
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$result = db_process_sql_delete ('tgraph',
|
||||
array('id_graph' => $id));
|
||||
|
||||
if ($result === false) {
|
||||
db_process_sql_rollback();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
db_process_sql_commit();
|
||||
}
|
||||
|
||||
if ($result !== false)
|
||||
$result = true;
|
||||
else
|
||||
|
|
|
@ -1297,8 +1297,6 @@ switch ($action) {
|
|||
break;
|
||||
}
|
||||
|
||||
db_process_sql_begin();
|
||||
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$resultOperationDB = db_process_sql_update('treport_content',
|
||||
|
@ -1313,31 +1311,31 @@ switch ($action) {
|
|||
case "oracle":
|
||||
$resultOperationDB = db_process_sql_update('treport_content',
|
||||
array('"order"' => $oldOrder),
|
||||
array('"order"' => $newOrder, 'id_report' => $idReport), 'AND', false);
|
||||
array('"order"' => $newOrder, 'id_report' => $idReport),
|
||||
'AND', false);
|
||||
break;
|
||||
}
|
||||
if ($resultOperationDB !== false) {
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$resultOperationDB = db_process_sql_update('treport_content', array('`order`' => $newOrder), array('id_rc' => $idItem));
|
||||
$resultOperationDB = db_process_sql_update(
|
||||
'treport_content',
|
||||
array('`order`' => $newOrder), array('id_rc' => $idItem));
|
||||
break;
|
||||
case "postgresql":
|
||||
$resultOperationDB = db_process_sql_update('treport_content', array('"order"' => $newOrder), array('id_rc' => $idItem));
|
||||
$resultOperationDB = db_process_sql_update(
|
||||
'treport_content',
|
||||
array('"order"' => $newOrder), array('id_rc' => $idItem));
|
||||
break;
|
||||
case "oracle":
|
||||
$resultOperationDB = db_process_sql_update('treport_content', array('"order"' => $newOrder), array('id_rc' => $idItem), 'AND', false);
|
||||
$resultOperationDB = db_process_sql_update(
|
||||
'treport_content',
|
||||
array('"order"' => $newOrder), array('id_rc' => $idItem),
|
||||
'AND', false);
|
||||
break;
|
||||
}
|
||||
if ($resultOperationDB !== false) {
|
||||
db_process_sql_commit();
|
||||
}
|
||||
else {
|
||||
db_process_sql_rollback();
|
||||
}
|
||||
}
|
||||
else {
|
||||
db_process_sql_rollback();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -67,15 +67,19 @@ function agents_get_agent_id_by_module_id ($id_agente_modulo) {
|
|||
function agents_create_agent ($name, $id_group, $interval, $ip_address, $values = false) {
|
||||
if (empty ($name))
|
||||
return false;
|
||||
|
||||
if (empty ($id_group))
|
||||
return false;
|
||||
|
||||
if (empty ($ip_address))
|
||||
return false;
|
||||
|
||||
// Check interval greater than zero
|
||||
if ($interval < 0)
|
||||
$interval = false;
|
||||
if (empty ($interval))
|
||||
return false;
|
||||
|
||||
if (! is_array ($values))
|
||||
$values = array ();
|
||||
$values['nombre'] = $name;
|
||||
|
@ -85,7 +89,6 @@ function agents_create_agent ($name, $id_group, $interval, $ip_address, $values
|
|||
|
||||
$id_agent = db_process_sql_insert ('tagente', $values);
|
||||
if ($id_agent === false) {
|
||||
db_process_sql_rollback ();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -93,16 +96,17 @@ function agents_create_agent ($name, $id_group, $interval, $ip_address, $values
|
|||
agents_add_address ($id_agent, $ip_address);
|
||||
|
||||
// Create special module agent_keepalive
|
||||
$values_modules = array ('id_tipo_modulo' => 100,
|
||||
'descripcion' => __('Agent keepalive monitor'),
|
||||
'id_modulo' => 1,
|
||||
'min_warning' => 0,
|
||||
'max_warning' => 1);
|
||||
|
||||
$id_agent_module = modules_create_agent_module($id_agent, 'agent_keepalive', $values_modules);
|
||||
$values_modules = array(
|
||||
'id_tipo_modulo' => 100,
|
||||
'descripcion' => __('Agent keepalive monitor'),
|
||||
'id_modulo' => 1,
|
||||
'min_warning' => 0,
|
||||
'max_warning' => 1);
|
||||
|
||||
$id_agent_module = modules_create_agent_module($id_agent,
|
||||
'agent_keepalive', $values_modules);
|
||||
|
||||
if ($id_agent_module === false) {
|
||||
db_process_sql_rollback ();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -725,14 +729,14 @@ function agents_common_modules_with_alerts ($id_agent, $filter = false, $indexed
|
|||
|
||||
foreach ($result_tmp as $module_template) {
|
||||
|
||||
$sql_modules = sprintf ('SELECT t1.id_agente_modulo
|
||||
FROM tagente_modulo t1, talert_template_modules t2
|
||||
WHERE t1.id_agente_modulo = t2.id_agent_module
|
||||
AND delete_pending = 0
|
||||
AND t1.nombre = \'%s\' AND t2.id_alert_template = %s'
|
||||
, $module_template['nombre']
|
||||
, $module_template['id_alert_template']);
|
||||
|
||||
$sql_modules = sprintf ('
|
||||
SELECT t1.id_agente_modulo
|
||||
FROM tagente_modulo t1, talert_template_modules t2
|
||||
WHERE t1.id_agente_modulo = t2.id_agent_module
|
||||
AND delete_pending = 0
|
||||
AND t1.nombre = \'%s\' AND t2.id_alert_template = %s',
|
||||
$module_template['nombre'], $module_template['id_alert_template']);
|
||||
|
||||
$id_modules_template = db_get_all_rows_sql ($sql_modules);
|
||||
|
||||
if ($id_modules_template != false)
|
||||
|
@ -763,7 +767,7 @@ function agents_common_modules_with_alerts ($id_agent, $filter = false, $indexed
|
|||
|
||||
$modules = array ();
|
||||
foreach ($result as $module) {
|
||||
if($get_not_init_modules || modules_get_agentmodule_is_init($module['id_agente_modulo'])) {
|
||||
if ($get_not_init_modules || modules_get_agentmodule_is_init($module['id_agente_modulo'])) {
|
||||
$modules[$module['id_agente_modulo']] = $module['id_agente_modulo'];
|
||||
}
|
||||
}
|
||||
|
@ -830,7 +834,7 @@ function agents_common_modules ($id_agent, $filter = false, $indexed = true, $ge
|
|||
ORDER BY nombre',
|
||||
$where);
|
||||
$result = db_get_all_rows_sql ($sql);
|
||||
|
||||
|
||||
if (empty ($result)) {
|
||||
return array ();
|
||||
}
|
||||
|
@ -840,7 +844,7 @@ function agents_common_modules ($id_agent, $filter = false, $indexed = true, $ge
|
|||
|
||||
$modules = array ();
|
||||
foreach ($result as $module) {
|
||||
if($get_not_init_modules || modules_get_agentmodule_is_init($module['id_agente_modulo'])) {
|
||||
if ($get_not_init_modules || modules_get_agentmodule_is_init($module['id_agente_modulo'])) {
|
||||
$modules[$module['id_agente_modulo']] = $module['id_agente_modulo'];
|
||||
}
|
||||
}
|
||||
|
@ -1202,8 +1206,9 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
|
|||
case "mysql":
|
||||
case "postgresql":
|
||||
$sql = sprintf ('SELECT %s%s
|
||||
FROM tagente_modulo WHERE
|
||||
%s
|
||||
FROM tagente_modulo
|
||||
WHERE
|
||||
%s
|
||||
ORDER BY nombre',
|
||||
($details != '*' && $indexed) ? 'id_agente_modulo,' : '',
|
||||
io_safe_output(implode (",", (array) $details)),
|
||||
|
@ -1211,8 +1216,9 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
|
|||
break;
|
||||
case "oracle":
|
||||
$sql = sprintf ('SELECT %s%s
|
||||
FROM tagente_modulo WHERE
|
||||
%s
|
||||
FROM tagente_modulo
|
||||
WHERE
|
||||
%s
|
||||
ORDER BY dbms_lob.substr(nombre, 4000, 1)',
|
||||
($details != '*' && $indexed) ? 'id_agente_modulo,' : '',
|
||||
io_safe_output(implode (",", (array) $details)),
|
||||
|
@ -1329,9 +1335,10 @@ function agents_get_modules_data_count ($id_agent = 0) {
|
|||
$modules = array_keys (agents_get_modules ($agent_id));
|
||||
foreach ($query as $sql) {
|
||||
//Add up each table's data
|
||||
//Avoid the count over empty array
|
||||
//Avoid the count over empty array
|
||||
if (!empty($modules))
|
||||
$count[$agent_id] += (int) db_get_sql ($sql." WHERE id_agente_modulo IN (".implode (",", $modules).")", 0, true);
|
||||
$count[$agent_id] += (int) db_get_sql ($sql .
|
||||
" WHERE id_agente_modulo IN (".implode (",", $modules).")", 0, true);
|
||||
}
|
||||
//Add total agent count to total count
|
||||
$count["total"] += $count[$agent_id];
|
||||
|
@ -1412,15 +1419,17 @@ function agents_add_address ($id_agent, $ip_address) {
|
|||
// Check if already is attached to agent
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$sql = sprintf ("SELECT COUNT(`ip`) FROM taddress_agent, taddress
|
||||
$sql = sprintf ("SELECT COUNT(`ip`)
|
||||
FROM taddress_agent, taddress
|
||||
WHERE taddress_agent.id_a = taddress.id_a
|
||||
AND ip = '%s' AND id_agent = %d",$ip_address,$id_agent);
|
||||
AND ip = '%s' AND id_agent = %d",$ip_address,$id_agent);
|
||||
break;
|
||||
case "postgresql":
|
||||
case "oracle":
|
||||
$sql = sprintf ("SELECT COUNT(ip) FROM taddress_agent, taddress
|
||||
$sql = sprintf ("SELECT COUNT(ip)
|
||||
FROM taddress_agent, taddress
|
||||
WHERE taddress_agent.id_a = taddress.id_a
|
||||
AND ip = '%s' AND id_agent = %d", $ip_address, $id_agent);
|
||||
AND ip = '%s' AND id_agent = %d", $ip_address, $id_agent);
|
||||
break;
|
||||
}
|
||||
$current_address = db_get_sql ($sql);
|
||||
|
@ -1431,7 +1440,7 @@ function agents_add_address ($id_agent, $ip_address) {
|
|||
$id_address = (int) db_get_value ('id_a', 'taddress', 'ip', $ip_address);
|
||||
|
||||
if ($id_address === 0) {
|
||||
// Create IP address in tadress table
|
||||
// Create IP address in tadress table
|
||||
$id_address = db_process_sql_insert('taddress', array('ip' => $ip_address));
|
||||
}
|
||||
|
||||
|
@ -1559,16 +1568,16 @@ function agents_get_status_from_counts($agent) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if($agent['critical_count'] > 0) {
|
||||
if ($agent['critical_count'] > 0) {
|
||||
return AGENT_MODULE_STATUS_CRITICAL_BAD;
|
||||
}
|
||||
else if($agent['warning_count'] > 0) {
|
||||
else if ($agent['warning_count'] > 0) {
|
||||
return AGENT_MODULE_STATUS_WARNING;
|
||||
}
|
||||
else if($agent['unknown_count'] > 0) {
|
||||
else if ($agent['unknown_count'] > 0) {
|
||||
return AGENT_MODULE_STATUS_UNKNOW;
|
||||
}
|
||||
else if($agent['normal_count'] == $agent['total_count']) {
|
||||
else if ($agent['normal_count'] == $agent['total_count']) {
|
||||
return AGENT_MODULE_STATUS_NORMAL;
|
||||
}
|
||||
//~ else if($agent['notinit_count'] == $agent['total_count']) {
|
||||
|
@ -1591,7 +1600,8 @@ function agents_get_status($id_agent = 0, $noACLs = false) {
|
|||
global $config;
|
||||
|
||||
if (!$noACLs) {
|
||||
$modules = agents_get_modules ($id_agent, 'id_agente_modulo', array('disabled' => 0), true, false);
|
||||
$modules = agents_get_modules ($id_agent, 'id_agente_modulo',
|
||||
array('disabled' => 0), true, false);
|
||||
}
|
||||
else {
|
||||
$filter_modules['id_agente'] = $id_agent;
|
||||
|
@ -1699,7 +1709,6 @@ function agents_delete_agent ($id_agents, $disableACL = false) {
|
|||
/* Check for deletion permissions */
|
||||
$id_group = agents_get_agent_group ($id_agent);
|
||||
if ((! check_acl ($config['id_user'], $id_group, "AW")) && !$disableACL) {
|
||||
db_process_sql_rollback ();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1960,9 +1969,8 @@ function agents_monitor_total ($id_agent, $filter = '', $disabled = false) {
|
|||
}
|
||||
|
||||
$sql = "SELECT COUNT( DISTINCT tagente_modulo.id_agente_modulo)
|
||||
FROM tagente_estado, tagente, tagente_modulo
|
||||
WHERE " . //tagente_estado.utimestamp != 0 AND
|
||||
"tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
FROM tagente_estado, tagente, tagente_modulo
|
||||
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
AND tagente_estado.id_agente = tagente.id_agente
|
||||
AND tagente.id_agente = $id_agent".$filter;
|
||||
|
||||
|
@ -1984,7 +1992,9 @@ function agents_get_alerts_fired ($id_agent, $filter="") {
|
|||
|
||||
$mod_clause = "(".implode(",", $modules_agent).")";
|
||||
|
||||
return db_get_sql ("SELECT COUNT(times_fired) FROM talert_template_modules WHERE times_fired != 0 AND id_agent_module IN ".$mod_clause);
|
||||
return db_get_sql ("SELECT COUNT(times_fired)
|
||||
FROM talert_template_modules
|
||||
WHERE times_fired != 0 AND id_agent_module IN ".$mod_clause);
|
||||
}
|
||||
|
||||
//Returns the alert image to display tree view
|
||||
|
@ -2003,13 +2013,16 @@ function agents_tree_view_alert_img ($alert_fired) {
|
|||
|
||||
function agents_tree_view_status_img ($critical, $warning, $unknown) {
|
||||
if ($critical > 0) {
|
||||
return ui_print_status_image (STATUS_AGENT_CRITICAL, __('At least one module in CRITICAL status'), true);
|
||||
return ui_print_status_image (STATUS_AGENT_CRITICAL,
|
||||
__('At least one module in CRITICAL status'), true);
|
||||
}
|
||||
else if ($warning > 0) {
|
||||
return ui_print_status_image (STATUS_AGENT_WARNING, __('At least one module in WARNING status'), true);
|
||||
return ui_print_status_image (STATUS_AGENT_WARNING,
|
||||
__('At least one module in WARNING status'), true);
|
||||
}
|
||||
else if ($unknown > 0) {
|
||||
return ui_print_status_image (STATUS_AGENT_DOWN, __('At least one module is in UKNOWN status'), true);
|
||||
return ui_print_status_image (STATUS_AGENT_DOWN,
|
||||
__('At least one module is in UKNOWN status'), true);
|
||||
}
|
||||
else {
|
||||
return ui_print_status_image (STATUS_AGENT_OK, __('All Monitors OK'), true);
|
||||
|
@ -2020,16 +2033,20 @@ function agents_tree_view_status_img ($critical, $warning, $unknown) {
|
|||
|
||||
function agents_detail_view_status_img ($critical, $warning, $unknown) {
|
||||
if ($critical > 0) {
|
||||
return ui_print_status_image (STATUS_AGENT_CRITICAL, __('At least one module in CRITICAL status'), true, false, 'images');
|
||||
return ui_print_status_image (STATUS_AGENT_CRITICAL,
|
||||
__('At least one module in CRITICAL status'), true, false, 'images');
|
||||
}
|
||||
else if ($warning > 0) {
|
||||
return ui_print_status_image (STATUS_AGENT_WARNING, __('At least one module in WARNING status'), true, false, 'images');
|
||||
return ui_print_status_image (STATUS_AGENT_WARNING,
|
||||
__('At least one module in WARNING status'), true, false, 'images');
|
||||
}
|
||||
else if ($unknown > 0) {
|
||||
return ui_print_status_image (STATUS_AGENT_UNKNOWN, __('At least one module is in UKNOWN status'), true, false, 'images');
|
||||
return ui_print_status_image (STATUS_AGENT_UNKNOWN,
|
||||
__('At least one module is in UKNOWN status'), true, false, 'images');
|
||||
}
|
||||
else {
|
||||
return ui_print_status_image (STATUS_AGENT_OK, __('All Monitors OK'), true, false, 'images');
|
||||
return ui_print_status_image (STATUS_AGENT_OK,
|
||||
__('All Monitors OK'), true, false, 'images');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -363,8 +363,6 @@ function events_validate_event ($id_event, $similars = true, $new_status = 1, $m
|
|||
|
||||
events_comment($id_event, '', "Change status to $status_string", $meta, $history);
|
||||
|
||||
db_process_sql_begin ();
|
||||
|
||||
$alerts = array();
|
||||
|
||||
foreach ($id_event as $event) {
|
||||
|
@ -397,13 +395,10 @@ function events_validate_event ($id_event, $similars = true, $new_status = 1, $m
|
|||
array('id_evento' => $event), 'AND', false);
|
||||
|
||||
if (($ret === false) || ($ret === 0)) {
|
||||
db_process_sql_rollback ();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
db_process_sql_commit ();
|
||||
|
||||
if ($meta && !empty($alerts)) {
|
||||
$server = metaconsole_get_connection_by_id ($server_id);
|
||||
metaconsole_connect($server);
|
||||
|
|
|
@ -81,9 +81,6 @@ function messages_create_group ($usuario_origen, $dest_group, $subject, $mensaje
|
|||
return true;
|
||||
}
|
||||
|
||||
//Start transaction so that if it fails somewhere along the way, we roll back
|
||||
db_process_sql_begin ();
|
||||
|
||||
// array unique
|
||||
foreach ($group_users as $user) {
|
||||
foreach ($user as $key=>$us) {
|
||||
|
@ -96,15 +93,11 @@ function messages_create_group ($usuario_origen, $dest_group, $subject, $mensaje
|
|||
foreach ($group_user as $user) {
|
||||
$return = messages_create_message ($usuario_origen, get_user_id ($user), $subject, $mensaje);
|
||||
if ($return === false) {
|
||||
//Error sending message, rollback and return false
|
||||
db_process_sql_rollback ();
|
||||
//Error sending message
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//We got here, so we can commit - if this function gets extended, make sure to do SQL above these lines
|
||||
db_process_sql_commit ();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -351,11 +351,9 @@ function tags_delete_tag ($id_tag) {
|
|||
$errn++;
|
||||
|
||||
if ($errn == 0) {
|
||||
db_process_sql_commit();
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
db_process_sql_rollback();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -398,15 +396,6 @@ function tags_insert_module_tag ($id_agent_module, $tags) {
|
|||
if ($result_tag === false)
|
||||
$errn++;
|
||||
}
|
||||
|
||||
/* if ($errn > 0) {
|
||||
db_process_sql_rollback();
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
db_process_sql_commit();
|
||||
return true;
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue