2009-03-23 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/massive_edit_modules.php: The module selection is now done using cascade selects instead of having a confusing tree on the select. * godmode/alerts/alert_list.php: Fixed a bug when getting the latest module value. * godmode/alerts/alert_templates.php: Fixed an error that didn't allow deletion on some cases. Added an option to duplicate a template easily. * godmode/alerts/configure_alert_template.php: Added template duplication support. Fixed a mismatch on field1, field2 and field3 which required to have a default action to be updated. This values are not loaded anymore from default action. * godmode/db/db_purge.php: Many styles correction. Use pandora functions for the bottom table. * include/functions_alerts.php: Added duplicate_alert_template(). * include/functions_db.php: Added a parameter to get_agent_modules() to enable or disable the return of indexed values. * operation/agentes/sla_view.php: Style correction. * operation/agentes/ver_agente.php: Added support for indexed flag on get_agent_modules_json AJAX operation. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1553 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
a142d85ad2
commit
ff44352cfd
|
@ -1,3 +1,34 @@
|
|||
2009-03-23 Esteban Sanchez <estebans@artica.es>
|
||||
|
||||
* godmode/agentes/massive_edit_modules.php: The module selection is
|
||||
now done using cascade selects instead of having a confusing tree on
|
||||
the select.
|
||||
|
||||
* godmode/alerts/alert_list.php: Fixed a bug when getting the latest
|
||||
module value.
|
||||
|
||||
* godmode/alerts/alert_templates.php: Fixed an error that didn't allow
|
||||
deletion on some cases. Added an option to duplicate a template
|
||||
easily.
|
||||
|
||||
* godmode/alerts/configure_alert_template.php: Added template
|
||||
duplication support. Fixed a mismatch on field1, field2 and field3
|
||||
which required to have a default action to be updated. This values are
|
||||
not loaded anymore from default action.
|
||||
|
||||
* godmode/db/db_purge.php: Many styles correction. Use pandora
|
||||
functions for the bottom table.
|
||||
|
||||
* include/functions_alerts.php: Added duplicate_alert_template().
|
||||
|
||||
* include/functions_db.php: Added a parameter to get_agent_modules()
|
||||
to enable or disable the return of indexed values.
|
||||
|
||||
* operation/agentes/sla_view.php: Style correction.
|
||||
|
||||
* operation/agentes/ver_agente.php: Added support for indexed flag on
|
||||
get_agent_modules_json AJAX operation.
|
||||
|
||||
2009-03-20 Evi Vanoost <vanooste@rcbi.rochester.edu>
|
||||
|
||||
* include/functions_incidents.php: Style change
|
||||
|
|
|
@ -47,7 +47,6 @@ function process_manage_edit ($module_name) {
|
|||
$values[$field] = $value;
|
||||
}
|
||||
|
||||
|
||||
$modules = get_db_all_rows_filter ('tagente_modulo',
|
||||
array ('id_agente' => $agents,
|
||||
'nombre' => $module_name),
|
||||
|
@ -66,6 +65,7 @@ function process_manage_edit ($module_name) {
|
|||
process_sql ('SET AUTOCOMMIT = 1');
|
||||
}
|
||||
|
||||
$module_type = (int) get_parameter ('module_type');
|
||||
$module_name = (string) get_parameter ('module_name');
|
||||
|
||||
$update = (bool) get_parameter_post ('update');
|
||||
|
@ -74,7 +74,6 @@ if ($update) {
|
|||
process_manage_edit ($module_name);
|
||||
}
|
||||
|
||||
|
||||
$table->id = 'delete_table';
|
||||
$table->width = '95%';
|
||||
$table->data = array ();
|
||||
|
@ -82,45 +81,52 @@ $table->style = array ();
|
|||
$table->style[0] = 'font-weight: bold; vertical-align:top';
|
||||
$table->style[2] = 'font-weight: bold';
|
||||
$table->rowstyle = array ();
|
||||
$table->rowstyle['edit1'] = 'display: none';
|
||||
$table->rowstyle['edit2'] = 'display: none';
|
||||
$table->size = array ();
|
||||
$table->size[0] = '15%';
|
||||
$table->size[1] = '85%'; /* Fixed using javascript */
|
||||
$table->size[1] = '35%'; /* Fixed using javascript */
|
||||
$table->size[2] = '15%';
|
||||
$table->size[3] = '35%';
|
||||
$table->colspan = array ();
|
||||
$table->colspan[0][1] = '3';
|
||||
|
||||
if (! $module_type) {
|
||||
$table->rowstyle['edit1'] = 'display: none';
|
||||
$table->rowstyle['edit2'] = 'display: none';
|
||||
}
|
||||
$agents = get_group_agents (array_keys (get_user_groups ()), false, "none");
|
||||
$all_modules = get_db_all_rows_filter ('tagente_modulo',
|
||||
array ('id_agente' => array_keys ($agents),
|
||||
'group' => 'nombre',
|
||||
'order' => 'id_tipo_modulo,nombre'),
|
||||
array ('DISTINCT(nombre)', 'id_tipo_modulo'));
|
||||
$module_types = get_db_all_rows_filter ('tagente_modulo,ttipo_modulo',
|
||||
array ('tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo',
|
||||
'id_agente' => array_keys ($agents),
|
||||
'disabled' => 0,
|
||||
'order' => 'ttipo_modulo.nombre'),
|
||||
array ('DISTINCT(id_tipo)',
|
||||
'CONCAT(ttipo_modulo.descripcion," (",ttipo_modulo.nombre,")") AS description'));
|
||||
|
||||
if ($all_modules === false)
|
||||
$all_modules = array ();
|
||||
if ($module_types === false)
|
||||
$module_types = array ();
|
||||
|
||||
$modules = array ();
|
||||
$latest_type = -1;
|
||||
$i = -1;
|
||||
$prefix = str_repeat (' ', 3);
|
||||
foreach ($all_modules as $module) {
|
||||
if ($latest_type != $module['id_tipo_modulo']) {
|
||||
$modules[$i--] = get_moduletype_description ($module['id_tipo_modulo']);
|
||||
$latest_type = $module['id_tipo_modulo'];
|
||||
}
|
||||
$modules[$module['nombre']] = $prefix.$module['nombre'];
|
||||
$types = '';
|
||||
foreach ($module_types as $type) {
|
||||
$types[$type['id_tipo']] = $type['description'];
|
||||
}
|
||||
|
||||
$table->data = array ();
|
||||
$table->data[0][0] = __('Module');
|
||||
$table->data[0][0] .= '<span id="agent_loading" class="invisible">';
|
||||
$table->data[0][0] = __('Module type');
|
||||
$table->data[0][0] .= '<span id="module_loading" class="invisible">';
|
||||
$table->data[0][0] .= '<img src="images/spinner.gif" />';
|
||||
$table->data[0][0] .= '</span>';
|
||||
$table->data[0][1] = print_select ($modules,
|
||||
'module_name', 0, false, __('Select'), 0, true, false, false);
|
||||
$table->data[0][1] = print_select ($types,
|
||||
'module_type', $module_type, false, __('Select'), 0, true, false, false);
|
||||
|
||||
$modules = array ();
|
||||
if ($module_type != '') {
|
||||
$names = get_agent_modules (array_keys ($agents),
|
||||
'DISTINCT(nombre)',
|
||||
array ('id_tipo_modulo' => $module_type), false);
|
||||
foreach ($names as $name) {
|
||||
$modules[$name['nombre']] = $name['nombre'];
|
||||
}
|
||||
}
|
||||
$table->data[0][2] = __('Module name');
|
||||
$table->data[0][3] = print_select ($modules, 'module_name',
|
||||
$module_name, false, __('Select'), 0, true, false, false);
|
||||
|
||||
$table->data['edit1'][0] = __('Warning status');
|
||||
$table->data['edit1'][1] = '<em>'.__('Min.').'</em>';
|
||||
|
@ -156,6 +162,30 @@ require_jquery_file ('pandora.controls');
|
|||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
$(document).ready (function () {
|
||||
$("#module_type").change (function () {
|
||||
$("#module_loading").show ();
|
||||
$("tr#delete_table-edit1, tr#delete_table-edit2").hide ();
|
||||
$("#module_name").attr ("disabled", "disabled")
|
||||
$("#module_name option[value!=0]").remove ();
|
||||
jQuery.post ("ajax.php",
|
||||
{"page" : "operation/agentes/ver_agente",
|
||||
"get_agent_modules_json" : 1,
|
||||
"filter" : "id_tipo_modulo="+this.value,
|
||||
"fields" : "DISTINCT(nombre)",
|
||||
"indexed" : 0
|
||||
},
|
||||
function (data, status) {
|
||||
jQuery.each (data, function (id, value) {
|
||||
option = $("<option></option>").attr ("value", value["nombre"]).html (value["nombre"]);
|
||||
$("#module_name").append (option);
|
||||
});
|
||||
$("#module_loading").hide ();
|
||||
$("#module_name").removeAttr ("disabled");
|
||||
},
|
||||
"json"
|
||||
);
|
||||
});
|
||||
|
||||
$("#module_name").change (function () {
|
||||
if (this.value <= 0) {
|
||||
$("td#delete_table-0-1").css ("width", "85%");
|
||||
|
|
|
@ -504,7 +504,7 @@ $(document).ready (function () {
|
|||
jQuery.post ("ajax.php",
|
||||
{"page" : "operation/agentes/estado_agente",
|
||||
"get_agent_module_last_value" : 1,
|
||||
"id_agent_module" : 1
|
||||
"id_agent_module" : this.value
|
||||
},
|
||||
function (data, status) {
|
||||
if (data === false) {
|
||||
|
|
|
@ -124,13 +124,6 @@ if ($update_template) {
|
|||
|
||||
if ($delete_template) {
|
||||
$id = get_parameter ('id');
|
||||
// Templates below 4 are special and cannot be deleted
|
||||
if ($id < 4) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to access Alert Management");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = delete_alert_template ($id);
|
||||
|
||||
|
@ -144,12 +137,12 @@ $table->head = array ();
|
|||
$table->head[0] = __('Name');
|
||||
$table->head[1] = __('Description');
|
||||
$table->head[2] = __('Type');
|
||||
$table->head[3] = __('Delete');
|
||||
$table->head[3] = __('Op.');
|
||||
$table->style = array ();
|
||||
$table->style[0] = 'font-weight: bold';
|
||||
$table->size = array ();
|
||||
$table->size[2] = '10%';
|
||||
$table->size[3] = '40px';
|
||||
$table->size[3] = '50px';
|
||||
$table->align = array ();
|
||||
$table->align[3] = 'center';
|
||||
|
||||
|
@ -165,9 +158,17 @@ foreach ($templates as $template) {
|
|||
|
||||
$data[1] = $template['description'];
|
||||
$data[2] = get_alert_templates_type_name ($template['type']);
|
||||
$data[3] = '<a href="index.php?sec=gagente&sec2=godmode/alerts/alert_templates&delete_template=1&id='.$template['id'].'"
|
||||
onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.
|
||||
'<img src="images/cross.png"></a>';
|
||||
$data[3] = '<form method="post" action="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_template" style="display: inline; float: left">';
|
||||
$data[3] .= print_input_hidden ('duplicate_template', 1, true);
|
||||
$data[3] .= print_input_hidden ('source_id', $template['id'], true);
|
||||
$data[3] .= print_input_image ('dup', 'images/copy.png', 1, '', true, array ('title' => __('Duplicate')));
|
||||
$data[3] .= '</form> ';
|
||||
|
||||
$data[3] .= '<form method="post" style="display: inline; float: right" onsubmit="if (!confirm(\''.__('Are you sure?').'\')) return false;">';
|
||||
$data[3] .= print_input_hidden ('delete_template', 1, true);
|
||||
$data[3] .= print_input_hidden ('id', $template['id'], true);
|
||||
$data[3] .= print_input_image ('del', 'images/cross.png', 1, '', true, array ('title' => __('Delete')));
|
||||
$data[3] .= '</form> ';
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,19 @@ if (! give_acl ($config['id_user'], 0, "LM")) {
|
|||
exit;
|
||||
}
|
||||
|
||||
$duplicate_template = (bool) get_parameter ('duplicate_template');
|
||||
$id = (int) get_parameter ('id');
|
||||
|
||||
if ($duplicate_template) {
|
||||
$source_id = (int) get_parameter ('source_id');
|
||||
|
||||
$id = duplicate_alert_template ($source_id);
|
||||
print_error_message ($id,
|
||||
__('Successfully created from %s', get_alert_template_name ($source_id)),
|
||||
__('Could not be created'));
|
||||
}
|
||||
|
||||
|
||||
function print_alert_template_steps ($step, $id) {
|
||||
echo '<ol class="steps">';
|
||||
|
||||
|
@ -138,9 +151,6 @@ function update_template ($step) {
|
|||
$default_action = (int) get_parameter ('default_action');
|
||||
if (empty ($default_action)) {
|
||||
$default_action = NULL;
|
||||
$field1 = '';
|
||||
$field2 = '';
|
||||
$field3 = '';
|
||||
}
|
||||
|
||||
$values = array ('monday' => $monday,
|
||||
|
@ -163,9 +173,6 @@ function update_template ($step) {
|
|||
|
||||
if ($default_action) {
|
||||
$values['id_alert_action'] = $default_action;
|
||||
$values['field1'] = $field1;
|
||||
$values['field2'] = $field2;
|
||||
$values['field3'] = $field3;
|
||||
}
|
||||
|
||||
$result = update_alert_template ($id, $values);
|
||||
|
@ -173,7 +180,7 @@ function update_template ($step) {
|
|||
$recovery_notify = (bool) get_parameter ('recovery_notify');
|
||||
$field2_recovery = (string) get_parameter ('field2_recovery');
|
||||
$field3_recovery = (string) get_parameter ('field3_recovery');
|
||||
print_r ($_POST);
|
||||
|
||||
$result = update_alert_template ($id,
|
||||
array ('recovery_notify' => $recovery_notify,
|
||||
'field2_recovery' => $field2_recovery,
|
||||
|
@ -185,8 +192,6 @@ function update_template ($step) {
|
|||
return $result;
|
||||
}
|
||||
|
||||
$id = (int) get_parameter ('id');
|
||||
|
||||
/* We set here the number of steps */
|
||||
define ('LAST_STEP', 3);
|
||||
|
||||
|
@ -313,20 +318,12 @@ if ($step == 2) {
|
|||
$threshold_selected = -1;
|
||||
}
|
||||
|
||||
if ($default_action == 0) {
|
||||
$table->rowstyle = array ();
|
||||
$table->rowstyle['field1'] = 'display: none';
|
||||
$table->rowstyle['field2'] = 'display: none';
|
||||
$table->rowstyle['field3'] = 'display: none';
|
||||
$table->rowstyle['preview'] = 'display: none';
|
||||
}
|
||||
$table->colspan = array ();
|
||||
$table->colspan[0][1] = 3;
|
||||
$table->colspan[4][1] = 3;
|
||||
$table->colspan['field1'][1] = 3;
|
||||
$table->colspan['field2'][1] = 3;
|
||||
$table->colspan['field3'][1] = 3;
|
||||
$table->colspan['preview'][1] = 3;
|
||||
|
||||
$table->data[0][0] = __('Days of week');
|
||||
$table->data[0][1] = __('Mon');
|
||||
|
@ -366,11 +363,6 @@ if ($step == 2) {
|
|||
$table->data[3][3] = print_input_text ('max_alerts', $max_alerts, '',
|
||||
5, 7, true);
|
||||
|
||||
$table->data[4][0] = __('Default action');
|
||||
$table->data[4][1] = print_select_from_sql ('SELECT id, name FROM talert_actions ORDER BY name',
|
||||
'default_action', $default_action, '', __('None'), 0,
|
||||
true, false, false);
|
||||
|
||||
$table->data['field1'][0] = __('Field 1');
|
||||
$table->data['field1'][1] = print_input_text ('field1', $field1, '', 35, 255, true);
|
||||
|
||||
|
@ -380,9 +372,10 @@ if ($step == 2) {
|
|||
$table->data['field3'][0] = __('Field 3');
|
||||
$table->data['field3'][1] = print_textarea ('field3', 30, 30, $field3, '', true);
|
||||
|
||||
$table->data['preview'][0] = __('Command preview');
|
||||
$table->data['preview'][1] = print_textarea ('command_preview', 30, 30,
|
||||
'', 'disabled="disabled"', true);
|
||||
$table->data[4][0] = __('Default action');
|
||||
$table->data[4][1] = print_select_from_sql ('SELECT id, name FROM talert_actions ORDER BY name',
|
||||
'default_action', $default_action, '', __('None'), 0,
|
||||
true, false, false);
|
||||
} else if ($step == 3) {
|
||||
/* Alert recover */
|
||||
if (! $recovery_notify) {
|
||||
|
@ -659,38 +652,6 @@ $(document).ready (function () {
|
|||
$("#template-threshold-other_input").hide ();
|
||||
}
|
||||
});
|
||||
|
||||
$("#default_action").change (function () {
|
||||
if (this.value != 0) {
|
||||
values = Array ();
|
||||
values.push ({name: "page",
|
||||
value: "godmode/alerts/alert_actions"});
|
||||
values.push ({name: "get_alert_action",
|
||||
value: "1"});
|
||||
values.push ({name: "id",
|
||||
value: this.value});
|
||||
jQuery.get ("ajax.php",
|
||||
values,
|
||||
function (data) {
|
||||
$("#text-field1").attr ("value", data["field1"]);
|
||||
$("#text-field2").attr ("value", data["field2"]);
|
||||
$("#text-field3").attr ("value", data["field3"]);
|
||||
original_command = html_entity_decode (data["command"]["command"]);
|
||||
render_command_preview ();
|
||||
|
||||
$("#template-field1, #template-field2, #template-field3, #template-example")
|
||||
.show ();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
} else {
|
||||
$("#template-field1, #template-field2, #template-field3").hide ();
|
||||
}
|
||||
});
|
||||
|
||||
$("#text-field1").keyup (render_command_preview);
|
||||
$("#text-field2").keyup (render_command_preview);
|
||||
$("#text-field3").keyup (render_command_preview);
|
||||
<?php elseif ($step == 3): ?>
|
||||
$("#recovery_notify").change (function () {
|
||||
if (this.value == 1) {
|
||||
|
|
|
@ -30,11 +30,7 @@ if (! give_acl ($config['id_user'], 0, "DM")) {
|
|||
}
|
||||
|
||||
//id_agent = -1: None selected; id_agent = 0: All
|
||||
if (isset ($_POST["agent"])){
|
||||
$id_agent = (int) get_parameter_post ("agent", -1); //Default to none selected
|
||||
} else {
|
||||
$id_agent = -1;
|
||||
}
|
||||
$id_agent = (int) get_parameter_post ("agent", -1);
|
||||
|
||||
echo '<h2>'.__('Database Maintenance').' > '.__('Database purge').'</h2>
|
||||
<img src="reporting/fgraph.php?tipo=db_agente_purge&id='.$id_agent.'" />
|
||||
|
@ -48,19 +44,19 @@ $time["all"] = get_system_time ();
|
|||
$time["1day"] = $time["all"]-86400;
|
||||
|
||||
// 3 days ago
|
||||
$time["3day"] = $time["all"]-(86400*3);
|
||||
$time["3day"] = $time["all"] - 259200;
|
||||
|
||||
// 1 week ago
|
||||
$time["1week"] = $time["all"]-(86400*7);
|
||||
$time["1week"] = $time["all"] - 604800;
|
||||
|
||||
// 2 weeks ago
|
||||
$time["2week"] = $time["all"]-(86400*14);
|
||||
$time["2week"] = $time["all"] - 1209600;
|
||||
|
||||
// 1 month ago
|
||||
$time["1month"] = $time["all"]-(86400*30);
|
||||
$time["1month"] = $time["all"] - 2592000;
|
||||
|
||||
// Three months ago
|
||||
$time["3month"] = $time["all"]-(86400*90);
|
||||
$time["3month"] = $time["all"] - 7776000;
|
||||
|
||||
//Init data
|
||||
$data["1day"] = 0;
|
||||
|
@ -71,12 +67,10 @@ $data["1month"] = 0;
|
|||
$data["3month"] = 0;
|
||||
$data["total"] = 0;
|
||||
|
||||
# ADQUIRE DATA PASSED AS FORM PARAMETERS
|
||||
# ======================================
|
||||
|
||||
# Purge data using dates
|
||||
// Purge data using dates
|
||||
if (isset($_POST["purgedb"])) {
|
||||
$from_date = get_parameter_post ("date_purge", 0); //0: No time selected
|
||||
$from_date = get_parameter_post ("date_purge", 0);
|
||||
if ($id_agent > 0) {
|
||||
echo __('Purge task launched for agent')." ".get_agent_name ($id_agent)." :: ".__('Data older than')." ".human_time_description ($from_date);
|
||||
echo "<h3>".__('Please be patient. This operation can take a long time depending on the amount of modules.')."</h3>";
|
||||
|
@ -143,13 +137,15 @@ print_help_tip (__("Click here to get the data from the agent specified in the s
|
|||
echo '</noscript><br />';
|
||||
|
||||
if ($id_agent > 0) {
|
||||
$title = __('Information on agent').' '.get_agent_name ($id_agent).' '.__('in the database');
|
||||
$title = __('Information on agent %s in the database', get_agent_name ($id_agent));
|
||||
} else {
|
||||
$title = __('Information on all agents').' '.__('in the database');
|
||||
$title = __('Information on all agents in the database');
|
||||
}
|
||||
|
||||
echo "<h3>".$title."</h3>";
|
||||
flush (); //Flush before we do some SQL stuff
|
||||
echo '<h3>'.$title.'</h3>';
|
||||
//Flush before we do some SQL stuff
|
||||
flush ();
|
||||
|
||||
if ($id_agent > 0) { //If the agent is not All or Not selected
|
||||
$modules = get_agent_modules ($id_agent);
|
||||
$query = sprintf ("AND id_agente_modulo IN(%s)", implode (",", array_keys ($modules)));
|
||||
|
@ -181,43 +177,47 @@ $data["1month"] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_stri
|
|||
$data["3month"] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["3month"], $query));
|
||||
$data["total"] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE 1=1 %s", $query));
|
||||
|
||||
|
||||
if (isset ($table)) {
|
||||
unset ($table); //since $table is an object, we make sure it's gone first
|
||||
}
|
||||
|
||||
$table->width = 300;
|
||||
$table->width = '50%';
|
||||
$table->border = 0;
|
||||
$table->class = "databox";
|
||||
$table->cellspacing = 4;
|
||||
$table->cellpadding = 4;
|
||||
|
||||
$table->data[0] = array (__('Packets less than three months old'), $data["3month"]);
|
||||
$table->data[1] = array (__('Packets less than one month old'), $data["1month"]);
|
||||
$table->data[2] = array (__('Packets less than two weeks old'), $data["2week"]);
|
||||
$table->data[3] = array (__('Packets less than one week old'), $data["1week"]);
|
||||
$table->data[4] = array (__('Packets less than three days old'), $data["3day"]);
|
||||
$table->data[5] = array (__('Packets less than one day old'), $data["1day"]);
|
||||
$table->data[6] = array ('<b>'.__('Total number of packets').'</b>', '<b>'.$data["total"].'</b>');
|
||||
$table->data[0][0] = __('Packets less than three months old');
|
||||
$table->data[0][1] = $data["3month"];
|
||||
$table->data[1][0] = __('Packets less than one month old');
|
||||
$table->data[1][1] = $data["1month"];
|
||||
$table->data[2][0] = __('Packets less than two weeks old');
|
||||
$table->data[2][1] = $data["2week"];
|
||||
$table->data[3][0] = __('Packets less than one week old');
|
||||
$table->data[3][1] = $data["1week"];
|
||||
$table->data[4][0] = __('Packets less than three days old');
|
||||
$table->data[4][1] = $data["3day"];
|
||||
$table->data[5][0] = __('Packets less than one day old');
|
||||
$table->data[5][1] = $data["1day"];
|
||||
$table->data[6][0] = '<strong>'.__('Total number of packets').'</strong>';
|
||||
$table->data[6][1] = '<strong>'.$data["total"].'</strong>';
|
||||
|
||||
print_table ($table);
|
||||
|
||||
echo '<br />';
|
||||
echo '<h3>'.__('Purge data').'</h3>
|
||||
<table width="300" border="0" class="databox" cellspacing="4" cellpadding="4">
|
||||
<tr><td>
|
||||
<select name="date_purge" width="255px">
|
||||
<option value="'.$time["3month"].'">'.__('Purge data over 3 months').'</option>
|
||||
<option value="'.$time["1month"].'">'.__('Purge data over 1 month').'</option>
|
||||
<option value="'.$time["2week"].'">'.__('Purge data over 2 weeks').'</option>
|
||||
<option value="'.$time["1week"].'">'.__('Purge data over 1 week').'</option>
|
||||
<option value="'.$time["3day"].'">'.__('Purge data over 3 days').'</option>
|
||||
<option value="'.$time["1day"].'">'.__('Purge data over 1 day').'</option>
|
||||
<option value="'.$time["all"].'">'.__('All data until now').'</option>
|
||||
</select>
|
||||
</td><td>
|
||||
<input class="sub wand" type="submit" name="purgedb" value="'.__('Do it!').'" onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;" />
|
||||
</td></tr>
|
||||
</table>
|
||||
</form>';
|
||||
echo '<h3>'.__('Purge data').'</h3>';
|
||||
|
||||
$table->data = array ();
|
||||
|
||||
$times = array ();
|
||||
$times[$time["3month"]] = __('Purge data over 3 months');
|
||||
$times[$time["1month"]] = __('Purge data over 1 month');
|
||||
$times[$time["2week"]] = __('Purge data over 2 weeks');
|
||||
$times[$time["1week"]] = __('Purge data over 1 week');
|
||||
$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] = print_select ($times, 'date_purge', '', '', '', '',
|
||||
true, false, false);
|
||||
$table->data[0][1] = print_submit_button (__('Purge'), "purgedb", false,
|
||||
'class="sub wand"', true);
|
||||
|
||||
print_table ($table);
|
||||
|
||||
echo '</form>';
|
||||
?>
|
||||
|
|
|
@ -523,6 +523,24 @@ function get_alert_template_threshold_values () {
|
|||
return $times;
|
||||
}
|
||||
|
||||
function duplicate_alert_template ($id_alert_template) {
|
||||
$template = get_alert_template ($id_alert_template);
|
||||
if ($template === false)
|
||||
return false;
|
||||
$name = __('Copy of').' '.$template['name'];
|
||||
$type = $template['type'];
|
||||
|
||||
$size = count ($template) / 2;
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
unset ($template[$i]);
|
||||
}
|
||||
unset ($template['name']);
|
||||
unset ($template['id']);
|
||||
unset ($template['type']);
|
||||
|
||||
return create_alert_template ($name, $type, $template);
|
||||
}
|
||||
|
||||
function clean_alert_agent_module_values ($values, $set_empty = true) {
|
||||
$retvalues = array ();
|
||||
|
||||
|
|
|
@ -333,7 +333,10 @@ function get_agentmodule ($id_agentmodule) {
|
|||
* @param mixed Aditional filters to the modules. It can be an indexed array
|
||||
* (keys would be the field name and value the expected value, and would be
|
||||
* joined with an AND operator) or a string, including any SQL clause (without
|
||||
* the WHERE keyword). Example:
|
||||
* the WHERE keyword).
|
||||
* @param bool Wheter to return the modules indexed by the id_agente_modulo or
|
||||
* not. Default is indexed.
|
||||
* Example:
|
||||
<code>
|
||||
Both are similars:
|
||||
$modules = get_agent_modules ($id_agent, false, array ('disabled' => 0));
|
||||
|
@ -347,7 +350,7 @@ $modules = get_agent_modules ($id_agent, '*', 'disabled = 0 AND history_data = 0
|
|||
* @return array An array with all modules in the agent.
|
||||
* If multiple rows are selected, they will be in an array
|
||||
*/
|
||||
function get_agent_modules ($id_agent, $details = false, $filter = false) {
|
||||
function get_agent_modules ($id_agent, $details = false, $filter = false, $indexed = true) {
|
||||
$id_agent = safe_int ($id_agent, 1);
|
||||
|
||||
$where = '';
|
||||
|
@ -383,7 +386,7 @@ function get_agent_modules ($id_agent, $details = false, $filter = false) {
|
|||
FROM tagente_modulo
|
||||
%s
|
||||
ORDER BY nombre',
|
||||
$details != '*' ? 'id_agente_modulo,' : '',
|
||||
($details != '*' && $indexed) ? 'id_agente_modulo,' : '',
|
||||
implode (",", (array) $details),
|
||||
$where);
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
|
@ -392,13 +395,16 @@ function get_agent_modules ($id_agent, $details = false, $filter = false) {
|
|||
return array ();
|
||||
}
|
||||
|
||||
if (! $indexed)
|
||||
return $result;
|
||||
|
||||
$modules = array ();
|
||||
foreach ($result as $row) {
|
||||
foreach ($result as $module) {
|
||||
if (is_array ($details) || $details == '*') {
|
||||
//Just stack the information in array by ID
|
||||
$modules[$row['id_agente_modulo']] = $row;
|
||||
$modules[$module['id_agente_modulo']] = $module;
|
||||
} else {
|
||||
$modules[$row['id_agente_modulo']] = $row[$details];
|
||||
$modules[$module['id_agente_modulo']] = $module[$details];
|
||||
}
|
||||
}
|
||||
return $modules;
|
||||
|
@ -550,7 +556,7 @@ function dame_nombre_pluginid ($id_plugin) {
|
|||
*
|
||||
* @return string The name of the given type.
|
||||
*/
|
||||
function giveme_module_type ($id_type) {
|
||||
function get_module_type_name ($id_type) {
|
||||
return (string) get_db_value ('nombre', 'ttipo_modulo', 'id_tipo', (int) $id_type);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ if (! give_acl ($config['id_user'], 0, "AR") && ! give_acl ($config['id_user'],
|
|||
echo "<h2>".__('SLA view')."</h2>";
|
||||
$id_agent = get_parameter ("id_agente", 0);
|
||||
$interval = get_agent_interval ($id_agent);
|
||||
$modules = get_agent_modules ($id_agent, '*', array ('disabled' => 0, 'history_data' => 1, 'delete_pending' => 0));
|
||||
$modules = get_agent_modules ($id_agent, '*',
|
||||
array ('disabled' => 0, 'history_data' => 1, 'delete_pending' => 0));
|
||||
$offset = get_parameter ("offset", 0);
|
||||
|
||||
// Get all module from agent
|
||||
|
|
|
@ -41,10 +41,15 @@ if (is_ajax ()) {
|
|||
$id_agent = (int) get_parameter ('id_agent');
|
||||
$filter = (string) get_parameter ('filter');
|
||||
$fields = (string) get_parameter ('fields');
|
||||
$indexed = (bool) get_parameter ('indexed', true);
|
||||
|
||||
$agent_modules = get_agent_modules ($id_agent,
|
||||
/* Get all agents if no agent was given */
|
||||
if ($id_agent == 0)
|
||||
$id_agent = array_keys (get_group_agents (array_keys (get_user_groups ()), false, "none"));
|
||||
|
||||
$agent_modules = get_agent_modules ($id_agent,
|
||||
($fields != '' ? explode (',', $fields) : "*"),
|
||||
($filter != '' ? $filter : false));
|
||||
($filter != '' ? $filter : false), $indexed);
|
||||
|
||||
echo json_encode ($agent_modules);
|
||||
exit ();
|
||||
|
|
Loading…
Reference in New Issue