add cps for agent, module, policies and bulk opertaion
This commit is contained in:
parent
7dc60b65a2
commit
76cd718262
pandora_console/godmode
|
@ -515,9 +515,20 @@ $table->data[4][3] = html_print_input_text ('url_description',
|
|||
$url_description, '', 45, 255, true);
|
||||
|
||||
$table->data[5][2] = __('Quiet');
|
||||
$table->data[5][3] = ui_print_help_tip(
|
||||
__('The agent still runs but the alerts and events will be stop'), true);
|
||||
$table->data[5][3] .= html_print_checkbox('quiet', 1, $quiet, true);
|
||||
$table->data[5][3] .= ui_print_help_tip(__('The agent still runs but the alerts and events will be stop'), true);
|
||||
$table->data[5][3] = html_print_checkbox('quiet', 1, $quiet, true);
|
||||
|
||||
$cps_array[-1] = __('Disabled');
|
||||
if($cps > 0){
|
||||
$cps_array[$cps] = __('Enabled');
|
||||
}
|
||||
else{
|
||||
$cps_array[0] = __('Enabled');
|
||||
}
|
||||
|
||||
$table->data[6][0] = __('Cascade protection services');
|
||||
$table->data[6][0] .= ui_print_help_tip(__('Disable the alerts and events of the elements that belong to this service'), true);
|
||||
$table->data[6][1] = html_print_select($cps_array, 'cps', $cps, '', '', 0, true);
|
||||
|
||||
ui_toggle(html_print_table ($table, true), __('Advanced options'));
|
||||
unset($table);
|
||||
|
|
|
@ -84,6 +84,7 @@ $direccion_agente = io_safe_input($direccion_agente);
|
|||
$intervalo = SECONDS_5MINUTES;
|
||||
$ff_interval = 0;
|
||||
$quiet_module = 0;
|
||||
$cps_module = 0;
|
||||
$id_server = "";
|
||||
$max_alerts = 0;
|
||||
$modo = 1;
|
||||
|
@ -148,6 +149,7 @@ $tab_description = '';
|
|||
$url_description = '';
|
||||
$quiet = 0;
|
||||
$macros = '';
|
||||
$cps = 0;
|
||||
|
||||
$create_agent = (bool)get_parameter('create_agent');
|
||||
$module_macros = array ();
|
||||
|
@ -161,7 +163,7 @@ if ($create_agent) {
|
|||
|
||||
//safe_output only validate ip
|
||||
$direccion_agente = trim(io_safe_output($direccion_agente));
|
||||
|
||||
|
||||
if(!validate_address($direccion_agente)){
|
||||
$mssg_warning = 1;
|
||||
}
|
||||
|
@ -187,11 +189,12 @@ if ($create_agent) {
|
|||
$update_gis_data = (int) get_parameter_post("update_gis_data", 0);
|
||||
$url_description = (string) get_parameter("url_description");
|
||||
$quiet = (int) get_parameter("quiet", 0);
|
||||
|
||||
$cps = (int) get_parameter("cps", 0);
|
||||
|
||||
$fields = db_get_all_fields_in_table('tagent_custom_fields');
|
||||
|
||||
|
||||
if ($fields === false) $fields = array();
|
||||
|
||||
|
||||
$field_values = array();
|
||||
|
||||
foreach ($fields as $field) {
|
||||
|
@ -216,8 +219,10 @@ if ($create_agent) {
|
|||
}
|
||||
|
||||
if(!$exists_alias){
|
||||
$id_agente = db_process_sql_insert ('tagente',
|
||||
array ('nombre' => $nombre_agente,
|
||||
$id_agente = db_process_sql_insert (
|
||||
'tagente',
|
||||
array (
|
||||
'nombre' => $nombre_agente,
|
||||
'alias' => $alias,
|
||||
'alias_as_name' => $alias_as_name,
|
||||
'direccion' => $direccion_agente,
|
||||
|
@ -235,7 +240,10 @@ if ($create_agent) {
|
|||
'icon_path' => $icon_path,
|
||||
'update_gis_data' => $update_gis_data,
|
||||
'url_address' => $url_description,
|
||||
'quiet' => $quiet));
|
||||
'quiet' => $quiet,
|
||||
'cps' => $cps
|
||||
)
|
||||
);
|
||||
enterprise_hook ('update_agent', array ($id_agente));
|
||||
}
|
||||
else{
|
||||
|
@ -253,19 +261,19 @@ if ($create_agent) {
|
|||
if ( $direccion_agente != '') {
|
||||
agents_add_address ($id_agente, $direccion_agente);
|
||||
}
|
||||
|
||||
|
||||
$agent_created_ok = true;
|
||||
|
||||
|
||||
$tpolicy_group_old = db_get_all_rows_sql("SELECT id_policy FROM tpolicy_groups
|
||||
WHERE id_group = ".$grupo);
|
||||
|
||||
|
||||
if($tpolicy_group_old){
|
||||
foreach ($tpolicy_group_old as $key => $old_group) {
|
||||
db_process_sql_insert ('tpolicy_agents',
|
||||
array('id_policy' => $old_group['id_policy'], 'id_agent' => $id_agente));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$info = '{"Name":"' . $nombre_agente .'",
|
||||
"IP":"' . $direccion_agente .'",
|
||||
"Group":"' . $grupo .'",
|
||||
|
@ -282,8 +290,9 @@ if ($create_agent) {
|
|||
"Icon path":"' . $icon_path .'",
|
||||
"Update GIS data":"' . $update_gis_data .'",
|
||||
"Url description":"' . $url_description .'",
|
||||
"Quiet":"' . (int)$quiet.'"}';
|
||||
|
||||
"Quiet":"' . (int)$quiet.'",
|
||||
"Cps":"' . (int)$cps.'"}';
|
||||
|
||||
$unsafe_alias = io_safe_output($alias);
|
||||
db_pandora_audit("Agent management",
|
||||
"Created agent $unsafe_alias", false, true, $info);
|
||||
|
@ -743,6 +752,7 @@ if ($update_agent) { // if modified some agent paramenter
|
|||
$update_gis_data = (int) get_parameter_post("update_gis_data", 0);
|
||||
$url_description = (string) get_parameter("url_description");
|
||||
$quiet = (int) get_parameter("quiet", 0);
|
||||
$cps = (int) get_parameter("cps", 0);
|
||||
|
||||
$old_interval = db_get_value('intervalo', 'tagente', 'id_agente', $id_agente);
|
||||
$fields = db_get_all_fields_in_table('tagent_custom_fields');
|
||||
|
@ -794,47 +804,49 @@ if ($update_agent) { // if modified some agent paramenter
|
|||
$direccion_agente != agents_get_address ($id_agente)) {
|
||||
agents_add_address ($id_agente, $direccion_agente);
|
||||
}
|
||||
|
||||
|
||||
$action_delete_ip = (bool)get_parameter('delete_ip', false);
|
||||
//If IP is set for deletion, delete first
|
||||
if ($action_delete_ip) {
|
||||
$delete_ip = get_parameter_post ("address_list");
|
||||
|
||||
|
||||
$direccion_agente = agents_delete_address($id_agente, $delete_ip);
|
||||
}
|
||||
|
||||
$values = array ('disabled' => $disabled,
|
||||
'id_parent' => $id_parent,
|
||||
'id_os' => $id_os,
|
||||
'modo' => $modo,
|
||||
'alias' => $alias,
|
||||
'alias_as_name' => $alias_as_name,
|
||||
'direccion' => $direccion_agente,
|
||||
'id_grupo' => $grupo,
|
||||
'intervalo' => $intervalo,
|
||||
'comentarios' => $comentarios,
|
||||
'cascade_protection' => $cascade_protection,
|
||||
'cascade_protection_module' => $cascade_protection_module,
|
||||
'server_name' => $server_name,
|
||||
'custom_id' => $custom_id,
|
||||
'icon_path' => $icon_path,
|
||||
'update_gis_data' => $update_gis_data,
|
||||
'url_address' => $url_description,
|
||||
'url_address' => $url_description,
|
||||
'quiet' => $quiet,
|
||||
'safe_mode_module' => $safe_mode_module);
|
||||
|
||||
|
||||
$values = array (
|
||||
'disabled' => $disabled,
|
||||
'id_parent' => $id_parent,
|
||||
'id_os' => $id_os,
|
||||
'modo' => $modo,
|
||||
'alias' => $alias,
|
||||
'alias_as_name' => $alias_as_name,
|
||||
'direccion' => $direccion_agente,
|
||||
'id_grupo' => $grupo,
|
||||
'intervalo' => $intervalo,
|
||||
'comentarios' => $comentarios,
|
||||
'cascade_protection' => $cascade_protection,
|
||||
'cascade_protection_module' => $cascade_protection_module,
|
||||
'server_name' => $server_name,
|
||||
'custom_id' => $custom_id,
|
||||
'icon_path' => $icon_path,
|
||||
'update_gis_data' => $update_gis_data,
|
||||
'url_address' => $url_description,
|
||||
'url_address' => $url_description,
|
||||
'quiet' => $quiet,
|
||||
'cps' => $cps,
|
||||
'safe_mode_module' => $safe_mode_module
|
||||
);
|
||||
|
||||
if ($config['metaconsole_agent_cache'] == 1) {
|
||||
$values['update_module_count'] = 1; // Force an update of the agent cache.
|
||||
}
|
||||
|
||||
|
||||
$group_old = db_get_sql("SELECT id_grupo FROM tagente WHERE id_agente =" .$id_agente);
|
||||
$tpolicy_group_old = db_get_all_rows_sql("SELECT id_policy FROM tpolicy_groups
|
||||
WHERE id_group = ".$group_old);
|
||||
|
||||
|
||||
$result = db_process_sql_update ('tagente', $values, array ('id_agente' => $id_agente));
|
||||
|
||||
|
||||
|
||||
if ($result == false && $update_custom_result == false) {
|
||||
ui_print_error_message(
|
||||
__('There was a problem updating the agent'));
|
||||
|
@ -868,7 +880,7 @@ if ($update_agent) { // if modified some agent paramenter
|
|||
foreach ($tpolicy_group as $key => $value) {
|
||||
$tpolicy_agents= db_get_sql("SELECT * FROM tpolicy_agents
|
||||
WHERE id_policy = ".$value['id_policy'] . " AND id_agent =" .$id_agente);
|
||||
|
||||
|
||||
if(!$tpolicy_agents){
|
||||
db_process_sql_insert ('tpolicy_agents',
|
||||
array('id_policy' => $value['id_policy'], 'id_agent' => $id_agente));
|
||||
|
@ -879,7 +891,7 @@ if ($update_agent) { // if modified some agent paramenter
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$info = '{
|
||||
"id_agente":"' . $id_agente . '",
|
||||
"alias":"' . $alias . '",
|
||||
|
@ -897,8 +909,9 @@ if ($update_agent) { // if modified some agent paramenter
|
|||
"Icon Path":"' . $icon_path . '",
|
||||
"Update GIS data":"' .$update_gis_data .'",
|
||||
"Url description":"' . $url_description .'",
|
||||
"Quiet":"' . (int)$quiet.'"}';
|
||||
|
||||
"Quiet":"' . (int)$quiet.'",
|
||||
"Cps":"' . (int)$cps.'"}';
|
||||
|
||||
enterprise_hook ('update_agent', array ($id_agente));
|
||||
ui_print_success_message (__('Successfully updated'));
|
||||
db_pandora_audit("Agent management",
|
||||
|
@ -918,14 +931,14 @@ if ($id_agente) {
|
|||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$agent = db_get_row ('tagente', 'id_agente', $id_agente);
|
||||
if (empty ($agent)) {
|
||||
//Close out the page
|
||||
ui_print_error_message (__('There was a problem loading the agent'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$intervalo = $agent["intervalo"]; // Define interval in seconds
|
||||
$nombre_agente = $agent["nombre"];
|
||||
if(empty($alias)){
|
||||
|
@ -951,6 +964,7 @@ if ($id_agente) {
|
|||
$update_gis_data = $agent["update_gis_data"];
|
||||
$url_description = $agent["url_address"];
|
||||
$quiet = $agent["quiet"];
|
||||
$cps = $agent["cps"];
|
||||
$safe_mode_module = $agent["safe_mode_module"];
|
||||
$safe_mode = ($safe_mode_module) ? 1 : 0;
|
||||
}
|
||||
|
@ -967,7 +981,7 @@ $edit_module = (bool) get_parameter ('edit_module');
|
|||
// GET DATA for MODULE UPDATE OR MODULE INSERT
|
||||
if ($update_module || $create_module) {
|
||||
$id_grupo = agents_get_agent_group ($id_agente);
|
||||
|
||||
|
||||
$id_agent_module = (int) get_parameter ('id_agent_module');
|
||||
|
||||
if (!check_acl ($config["id_user"], $id_grupo, "AW")) {
|
||||
|
@ -1001,6 +1015,7 @@ if ($update_module || $create_module) {
|
|||
$interval = (int) get_parameter ('module_interval', $intervalo);
|
||||
$ff_interval = (int) get_parameter ('module_ff_interval');
|
||||
$quiet_module = (int) get_parameter ('quiet_module');
|
||||
$cps_module = (int) get_parameter ('cps_module');
|
||||
$id_plugin = (int) get_parameter ('id_plugin');
|
||||
$id_export = (int) get_parameter ('id_export');
|
||||
$disabled = (bool) get_parameter ('disabled');
|
||||
|
@ -1318,6 +1333,7 @@ if ($update_module) {
|
|||
'unit' => io_safe_output($unit),
|
||||
'macros' => $macros,
|
||||
'quiet' => $quiet_module,
|
||||
'cps' => $cps_module,
|
||||
'critical_instructions' => $critical_instructions,
|
||||
'warning_instructions' => $warning_instructions,
|
||||
'unknown_instructions' => $unknown_instructions,
|
||||
|
@ -1362,8 +1378,8 @@ if ($update_module) {
|
|||
}
|
||||
else {
|
||||
$check_dynamic =
|
||||
db_get_row_sql('SELECT dynamic_interval, dynamic_max, dynamic_min, dynamic_two_tailed
|
||||
FROM tagente_modulo WHERE id_agente_modulo =' . $id_agent_module);
|
||||
db_get_row_sql('SELECT dynamic_interval, dynamic_max, dynamic_min, dynamic_two_tailed
|
||||
FROM tagente_modulo WHERE id_agente_modulo =' . $id_agent_module);
|
||||
|
||||
if( ($check_dynamic['dynamic_interval'] == $dynamic_interval) &&
|
||||
($check_dynamic['dynamic_max'] == $dynamic_max) &&
|
||||
|
@ -1500,6 +1516,7 @@ if ($create_module) {
|
|||
'unit' => io_safe_output($unit),
|
||||
'macros' => $macros,
|
||||
'quiet' => $quiet_module,
|
||||
'cps' => $cps_module,
|
||||
'critical_instructions' => $critical_instructions,
|
||||
'warning_instructions' => $warning_instructions,
|
||||
'unknown_instructions' => $unknown_instructions,
|
||||
|
|
|
@ -162,6 +162,7 @@ if ($id_agent_module) {
|
|||
}
|
||||
$ff_interval = $module['module_ff_interval'];
|
||||
$quiet_module = $module['quiet'];
|
||||
$cps_module = $module['cps'];
|
||||
$unit = $module['unit'];
|
||||
$tcp_port = $module['tcp_port'];
|
||||
$tcp_send = $module['tcp_send'];
|
||||
|
@ -302,6 +303,7 @@ else {
|
|||
$max = '';
|
||||
$interval = '';
|
||||
$quiet_module = 0;
|
||||
$cps_module = 0;
|
||||
$unit = '';
|
||||
$prediction_module = '';
|
||||
$custom_integer_1 = 0;
|
||||
|
|
|
@ -566,11 +566,20 @@ if ($__code_from == 'modules') {
|
|||
}
|
||||
|
||||
$table_advanced->data[7][0] = __('Quiet');
|
||||
$table_advanced->data[7][0] .= ui_print_help_tip(
|
||||
__('The module still stores data but the alerts and events will be stop'), true);
|
||||
$table_advanced->colspan[7][1] = 7;
|
||||
$table_advanced->data[7][1] = html_print_checkbox('quiet_module', 1,
|
||||
$quiet_module, true, $disabledBecauseInPolicy);
|
||||
$table_advanced->data[7][0] .= ui_print_help_tip(__('The module still stores data but the alerts and events will be stop'), true);
|
||||
$table_advanced->data[7][1] = html_print_checkbox('quiet_module', 1, $quiet_module, true, $disabledBecauseInPolicy);
|
||||
|
||||
$cps_array[-1] = __('Disabled');
|
||||
if($cps > 0){
|
||||
$cps_array[$cps_module] = __('Enabled');
|
||||
}
|
||||
else{
|
||||
$cps_array[0] = __('Enabled');
|
||||
}
|
||||
$table_advanced->data[7][2] = __('Cascade Protection Services');
|
||||
$table_advanced->data[7][2] .= ui_print_help_tip(__('Disable the alerts and events of the elements that belong to this service'), true);
|
||||
$table_advanced->colspan[7][3] = 5;
|
||||
$table_advanced->data[7][3] = html_print_select($cps_array, 'cps_module', $cps_module, '', '', 0, true, false, true, "", $disabledBecauseInPolicy);
|
||||
|
||||
$table_advanced->data[8][0] = __('Critical instructions') .
|
||||
ui_print_help_tip(__("Instructions when the status is critical"), true);
|
||||
|
|
|
@ -82,6 +82,8 @@ if ($update_agents) {
|
|||
$values['delete_conf'] = get_parameter('delete_conf');
|
||||
if (get_parameter('quiet_select', -1) != -1)
|
||||
$values['quiet'] = get_parameter('quiet_select');
|
||||
if (get_parameter('cps_select', -2) != -2)
|
||||
$values['cps'] = get_parameter('cps_select');
|
||||
|
||||
$fields = db_get_all_fields_in_table('tagent_custom_fields');
|
||||
|
||||
|
@ -392,6 +394,7 @@ $update_gis_data = -1;
|
|||
$cascade_protection = -1;
|
||||
$cascade_protection_module = -1;
|
||||
$quiet_select = -1;
|
||||
$cps_select = -2;
|
||||
|
||||
$table = new StdClass();
|
||||
$table->width = '100%';
|
||||
|
@ -479,6 +482,19 @@ $table->data[6][1] = html_print_select(array(-1 => __('No change'),
|
|||
1 => __('Yes'), 0 => __('No')),
|
||||
"quiet_select", $quiet_select, "", '', 0, true);
|
||||
|
||||
$cps_array[-2] = __('No change');
|
||||
$cps_array[-1] = __('Disabled');
|
||||
if($cps > 0){
|
||||
$cps_array[$cps_select] = __('Enabled');
|
||||
}
|
||||
else{
|
||||
$cps_array[0] = __('Enabled');
|
||||
}
|
||||
|
||||
$table->data[7][0] = __('Cascade Protection Service');
|
||||
$table->data[7][0] .= ui_print_help_tip(__('Disable the alerts and events of the elements that belong to this service'), true);
|
||||
$table->data[7][1] = html_print_select($cps_array, "cps_select", $cps_select, "", '', 0, true);
|
||||
|
||||
ui_toggle(html_print_table ($table, true), __('Advanced options'));
|
||||
unset($table);
|
||||
|
||||
|
|
|
@ -635,21 +635,34 @@ $table->data['edit11'][0] .= ui_print_help_tip(__('The module still store data b
|
|||
$table->data['edit11'][1] = html_print_select(array(-1 => __('No change'),
|
||||
1 => __('Yes'), 0 => __('No')),
|
||||
"quiet_select", -1, "", '', 0, true);
|
||||
$table->data['edit11'][2] = __('Timeout');
|
||||
$table->data['edit11'][3] = html_print_input_text(
|
||||
|
||||
$cps_array[-2] = __('No change');
|
||||
$cps_array[-1] = __('Disabled');
|
||||
if($cps > 0){
|
||||
$cps_array[$cps_select] = __('Enabled');
|
||||
}
|
||||
else{
|
||||
$cps_array[0] = __('Enabled');
|
||||
}
|
||||
|
||||
$table->data['edit11'][2] = __('Cascade Protection Service');
|
||||
$table->data['edit11'][2] .= ui_print_help_tip(__('Disable the alerts and events of the elements that belong to this service'), true);
|
||||
$table->data['edit11'][3] .= html_print_select($cps_array, "cps_select", -1, "", '', 0, true);
|
||||
|
||||
$table->data['edit16'][0] = __('Timeout');
|
||||
$table->data['edit16'][1] .= html_print_input_text(
|
||||
'max_timeout', '', '', 5, 10, true) . ' ' .
|
||||
ui_print_help_tip (
|
||||
__('Seconds that agent will wait for the execution of the module.'), true);
|
||||
|
||||
$table->data['edit16'][0] = __('Retries');
|
||||
$table->data['edit16'][1] = html_print_input_text ('max_retries', '', '', 5, 10, true) . ' ' .
|
||||
|
||||
$table->data['edit16'][1] .= __('Retries');
|
||||
$table->data['edit16'][1] .= html_print_input_text ('max_retries', '', '', 5, 10, true) . ' ' .
|
||||
ui_print_help_tip (
|
||||
__('Number of retries that the module will attempt to run.'), true);
|
||||
|
||||
|
||||
$table->data['edit22'][0] = __('Web checks').ui_print_help_icon ("web_checks", true);;
|
||||
$table->data['edit22'][1] = '<textarea id="textarea_plugin_parameter" name="plugin_parameter" cols="65" rows="15"></textarea>';
|
||||
|
||||
|
||||
$table->data['edit22'][0] = __('Web checks').ui_print_help_icon ("web_checks", true);;
|
||||
$table->data['edit22'][1] = '<textarea id="textarea_plugin_parameter" name="plugin_parameter" cols="65" rows="15"></textarea>';
|
||||
|
||||
$table->data['edit16'][2] = __('Port');
|
||||
$table->data['edit16'][3] = html_print_input_text ('tcp_port', '', '', 5, 20, true);
|
||||
|
||||
|
@ -1491,7 +1504,7 @@ function process_manage_edit ($module_name, $agents_select = null, $module_statu
|
|||
$values['custom_string_2'] = io_input_password($snmp3_privacy_pass);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$throw_unknown_events = get_parameter('throw_unknown_events', '');
|
||||
if ($throw_unknown_events !== '') {
|
||||
//Set the event type that can show.
|
||||
|
@ -1499,24 +1512,27 @@ function process_manage_edit ($module_name, $agents_select = null, $module_statu
|
|||
EVENTS_GOING_UNKNOWN => (int)$throw_unknown_events);
|
||||
$values['disabled_types_event'] = json_encode($disabled_types_event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (strlen(get_parameter('history_data')) > 0) {
|
||||
$values['history_data'] = get_parameter('history_data');
|
||||
}
|
||||
|
||||
|
||||
if (get_parameter('quiet_select', -1) != -1) {
|
||||
$values['quiet'] = get_parameter('quiet_select');
|
||||
}
|
||||
|
||||
|
||||
if (get_parameter('cps_select', -2) != -2) {
|
||||
$values['cps'] = get_parameter('cps_select');
|
||||
}
|
||||
|
||||
$filter_modules = false;
|
||||
|
||||
|
||||
if (!is_numeric($module_name) or ($module_name != 0))
|
||||
$filter_modules['nombre'] = $module_name;
|
||||
|
||||
|
||||
// Whether to update module tag info
|
||||
$update_tags = get_parameter('id_tag', false);
|
||||
|
||||
|
||||
if (array_search(0, $agents_select) !== false) {
|
||||
//Apply at All agents.
|
||||
$modules = db_get_all_rows_filter ('tagente_modulo',
|
||||
|
|
Loading…
Reference in New Issue