diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index a9a6d3938d..ff7682cad0 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.744-200319 +Version: 7.0NG.744-200324 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index ed7b218c92..c26d75c3d9 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.744-200319" +pandora_version="7.0NG.744-200324" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 44226ce0e5..1f805cb60b 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -55,7 +55,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.744'; -use constant AGENT_BUILD => '200319'; +use constant AGENT_BUILD => '200324'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 5467e321c4..6bfc78e0b1 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.744 -%define release 200319 +%define release 200324 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index f1bb0556d5..11643033d2 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.744 -%define release 200319 +%define release 200324 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 5ef15ed4fa..4cc67f8f26 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.744" -PI_BUILD="200319" +PI_BUILD="200324" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index b344d704fe..e4d431e67e 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{200319} +{200324} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 4c697a7073..84cf1a3a8b 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.744(Build 200319)") +#define PANDORA_VERSION ("7.0NG.744(Build 200324)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 7b8b9e9061..c5c323f618 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.744(Build 200319))" + VALUE "ProductVersion", "(7.0NG.744(Build 200324))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index fa39d49b93..560e7b251b 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.744-200319 +Version: 7.0NG.744-200324 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 6375f0d81c..4b021ef02a 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.744-200319" +pandora_version="7.0NG.744-200324" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/mr/37.sql b/pandora_console/extras/mr/37.sql index efd118bdd1..c53f5e3c09 100644 --- a/pandora_console/extras/mr/37.sql +++ b/pandora_console/extras/mr/37.sql @@ -4,5 +4,8 @@ ALTER TABLE `tagente_estado` ADD COLUMN `last_status_change` bigint(20) NOT NULL UPDATE `tconfig` SET `value`='policy,agent,data_type,module_name,server_type,interval,status,last_status_change,graph,warn,data,timestamp' WHERE `token` = 'status_monitor_fields'; +ALTER TABLE `talert_templates` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; +ALTER TABLE `tevent_alert` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; +ALTER TABLE `talert_snmp` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; -COMMIT; \ No newline at end of file +COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index bc08477b28..093258fe43 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -666,6 +666,7 @@ CREATE TABLE IF NOT EXISTS `tevent_alert` ( ALTER TABLE `tevent_alert` ADD COLUMN `special_days` tinyint(1) default 0; ALTER TABLE `tevent_alert` MODIFY COLUMN `time_threshold` int(10) NOT NULL default 86400; +ALTER TABLE `tevent_alert` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; -- ----------------------------------------------------- -- Table `tevent_alert_action` @@ -1239,6 +1240,7 @@ ALTER TABLE talert_templates ADD COLUMN `field12_recovery` TEXT NOT NULL DEFAULT ALTER TABLE talert_templates ADD COLUMN `field13_recovery` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_templates ADD COLUMN `field14_recovery` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_templates ADD COLUMN `field15_recovery` TEXT NOT NULL DEFAULT ""; +ALTER TABLE `talert_templates` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; -- --------------------------------------------------------------------- -- Table `talert_snmp` @@ -1248,6 +1250,7 @@ ALTER TABLE talert_snmp ADD COLUMN `al_field12` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_snmp ADD COLUMN `al_field13` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_snmp ADD COLUMN `al_field14` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_snmp ADD COLUMN `al_field15` TEXT NOT NULL DEFAULT ""; +ALTER TABLE `talert_snmp` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; ALTER TABLE `talert_snmp` MODIFY COLUMN `al_field11` text NOT NULL, MODIFY COLUMN `al_field12` text NOT NULL, MODIFY COLUMN `al_field13` text NOT NULL, diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index d4292bc465..e5a10f0a53 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -227,7 +227,9 @@ if (!$new_agent && $alias != '') { $agent_options_update = 'agent_options_update'; // Delete link from here. - $table_agent_name .= "".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).''; + if (!is_central_policies_on_node()) { + $table_agent_name .= "".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).''; + } // Remote configuration available. if (isset($filename)) { diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 3d2db9994a..244e1d8618 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -62,6 +62,10 @@ $onheader = ['view' => $viewtab]; // Header. ui_print_page_header(__('Agents defined in %s', get_product_name()), 'images/agent_mc.png', false, '', true, $onheader); +if (is_central_policies_on_node()) { + ui_print_warning_message(__('This node is configured with centralized mode. To delete an agent go to metaconsole.')); +} + // Perform actions. $agent_to_delete = (int) get_parameter('borrar_agente'); $enable_agent = (int) get_parameter('enable_agent'); @@ -694,7 +698,7 @@ if ($agents !== false) { echo html_print_image('images/lightbulb.png', true, ['alt' => __('Disable agent'), 'title' => __('Disable agent')]).''; } - if ($check_aw) { + if ($check_aw && !is_central_policies_on_node()) { echo " $max, 'min_value' => $min, 'matches_value' => $matches, + 'disable_event' => $disable_event, ]; // Different datetimes format for oracle @@ -532,6 +534,7 @@ if ($id && ! $create_template) { $max_alerts = $template['max_alerts']; $min_alerts = $template['min_alerts']; $min_alerts_reset_counter = $template['min_alerts_reset_counter']; + $disable_event = $template['disable_event']; $threshold = $template['time_threshold']; $fields = []; for ($i = 1; $i <= $config['max_macro_fields']; $i++) { @@ -578,8 +581,7 @@ if ($step == 2) { // Firing conditions and events $table->colspan = []; - $table->colspan[4][1] = 3; - + // $table->colspan[4][1] = 1; $table->data[0][0] = __('Days of week'); $table->data[0][1] = __('Mon'); $table->data[0][1] .= html_print_checkbox('monday', 1, $monday, true); @@ -653,6 +655,9 @@ if ($step == 2) { true ); + $table->data[4][2] = __('Disable event'); + $table->data[4][3] = html_print_checkbox('disable_event', 1, $disable_event, true); + $table->data[5][0] = __('Default action'); $usr_groups = implode(',', array_keys(users_get_groups($config['id_user'], 'LM', true))); switch ($config['dbtype']) { diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 8cb3c106c1..39fed17c8b 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -443,37 +443,140 @@ if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) { $usedGroup = groups_check_used($id_group); if (!$usedGroup['return']) { - $group = db_get_row_filter( - 'tgrupo', - ['id_grupo' => $id_group] - ); + $errors_meta = false; + if (is_metaconsole()) { + $group_name = groups_get_name($id_group); + $servers = metaconsole_get_servers(); - db_process_sql_update( - 'tgrupo', - ['parent' => $group['parent']], - ['parent' => $id_group] - ); + $error_counter = 0; + $success_counter = 0; + $success_nodes = []; + $error_nodes = []; + // Check if the group can be deleted or not. + foreach ($servers as $server) { + if (metaconsole_connect($server) == NOERR) { + $result_exist_group = db_get_row_filter('tgrupo', ['nombre' => $group_name, 'id_grupo' => $id_group]); + if ($result_exist_group !== false) { + $used_group = groups_check_used($id_group); + // Save the names of the nodes that are empty and can be deleted, and those that cannot. + if (!$used_group['return']) { + $success_nodes[] .= $server['server_name']; + $success_counter++; + } else { + $error_nodes[] .= $server['server_name']; + $error_counter++; + } + } + } - $result = db_process_sql_delete( - 'tgroup_stat', - ['id_group' => $id_group] - ); + metaconsole_restore_db(); + } - $result = db_process_sql_delete( - 'tgrupo', - ['id_grupo' => $id_group] - ); + if ($error_counter > 0) { + ui_print_error_message( + __('The group %s could not be deleted because it is not empty in the nodes', $group_name).': '.implode(', ', $error_nodes) + ); + $errors_meta = true; + } else { + if ($success_counter > 0) { + $error_deleting_counter = 0; + $success_deleting_counter = 0; + $error_deleting = []; + $success_deleting = []; + $error_connecting_node = []; + // Delete the group in the nodes. + foreach ($servers as $server) { + if (metaconsole_connect($server) == NOERR) { + $group = db_get_row_filter( + 'tgrupo', + ['id_grupo' => $id_group] + ); + + db_process_sql_update( + 'tgrupo', + ['parent' => $group['parent']], + ['parent' => $id_group] + ); + + db_process_sql_delete( + 'tgroup_stat', + ['id_group' => $id_group] + ); + + $result = db_process_sql_delete( + 'tgrupo', + ['id_grupo' => $id_group] + ); + + if ($result === false) { + $error_deleting[] .= $server['server_name']; + $error_deleting_counter++; + } else { + $success_deleting[] .= $server['server_name']; + $success_deleting_counter++; + } + } else { + $error_deleting_counter++; + $error_connecting_node[] .= $server['server_name']; + } + + metaconsole_restore_db(); + } + + // If the group could not be deleted in any node, do not delete it in meta. + if ($error_deleting_counter > 0) { + $errors_meta = true; + if (!empty($error_connecting_node)) { + ui_print_error_message(__('Error connecting to %s', implode(', ', $error_connecting_node).'. The group has not been deleted in the metaconsole.')); + } + + if (!empty($error_deleting)) { + ui_print_error_message( + __('The group has not been deleted in the metaconsole due to an error in the node database').': '.implode(', ', $error_deleting) + ); + } + } + + if ($success_deleting_counter > 0) { + ui_print_success_message(__('The group %s has been deleted in the nodes', $group_name).': '.implode(', ', $success_deleting)); + } + } + } + } + + if ($errors_meta === false) { + $group = db_get_row_filter( + 'tgrupo', + ['id_grupo' => $id_group] + ); + + db_process_sql_update( + 'tgrupo', + ['parent' => $group['parent']], + ['parent' => $id_group] + ); + + $result = db_process_sql_delete( + 'tgroup_stat', + ['id_group' => $id_group] + ); + + $result = db_process_sql_delete( + 'tgrupo', + ['id_grupo' => $id_group] + ); + + if ($result && (!$usedGroup['return'])) { + ui_print_success_message(__('Group successfully deleted')); + } else { + ui_print_error_message(__('There was a problem deleting group')); + } + } } else { ui_print_error_message( sprintf(__('The group is not empty. It is use in %s.'), implode(', ', $usedGroup['tables'])) ); } - - if ($result && (!$usedGroup['return'])) { - ui_print_success_message(__('Group successfully deleted')); - } else { - ui_print_error_message(__('There was a problem deleting group')); - } } @@ -636,7 +739,12 @@ if ($tab == 'tree') { ] ).''; - $confirm_message = __('Are you sure?'); + if (is_metaconsole()) { + $confirm_message = __('Are you sure? This group will also be deleted in all the nodes.'); + } else { + $confirm_message = __('Are you sure?'); + } + if ($group['has_child']) { $confirm_message = __('The child groups will be updated to use the parent id of the deleted group').'. '.$confirm_message; } diff --git a/pandora_console/godmode/massive/massive_delete_agents.php b/pandora_console/godmode/massive/massive_delete_agents.php index c886e11091..299d880336 100755 --- a/pandora_console/godmode/massive/massive_delete_agents.php +++ b/pandora_console/godmode/massive/massive_delete_agents.php @@ -186,11 +186,13 @@ $table->data[2][1] = html_print_select( echo '
'; html_print_table($table); +if (!is_central_policies_on_node()) { + echo '
'; + html_print_input_hidden('delete', 1); + html_print_submit_button(__('Delete'), 'go', false, 'class="sub delete"'); + echo '
'; +} -echo '
'; -html_print_input_hidden('delete', 1); -html_print_submit_button(__('Delete'), 'go', false, 'class="sub delete"'); -echo '
'; echo '
'; echo ''; diff --git a/pandora_console/godmode/massive/massive_delete_alerts.php b/pandora_console/godmode/massive/massive_delete_alerts.php index d7f316fd4d..c9bcda46ba 100755 --- a/pandora_console/godmode/massive/massive_delete_alerts.php +++ b/pandora_console/godmode/massive/massive_delete_alerts.php @@ -101,10 +101,17 @@ function process_manage_delete($id_alert_template, $id_agents, $module_names) $module_selection_mode = get_parameter('modules_selection_mode'); + $alert_list = db_get_all_rows_filter('talert_template_modules', ['id_alert_template' => $id_alert_template], 'id_agent_module'); + foreach ($module_names as $module) { foreach ($id_agents as $id_agent) { $module_id = modules_get_agentmodule_id($module, $id_agent); - $modules_id[] = $module_id['id_agente_modulo']; + // The module can exist in several of the selected agents, but we have to check if it has an alert. + foreach ($alert_list as $alert) { + if ($alert['id_agent_module'] == $module_id['id_agente_modulo']) { + $modules_id[] = $module_id['id_agente_modulo']; + } + } } } diff --git a/pandora_console/godmode/massive/massive_operations.php b/pandora_console/godmode/massive/massive_operations.php index 9e81bd3aaa..0fb08d0034 100755 --- a/pandora_console/godmode/massive/massive_operations.php +++ b/pandora_console/godmode/massive/massive_operations.php @@ -305,6 +305,10 @@ echo ''; '; echo '
'; echo ''; + echo ''; echo '
'; diff --git a/pandora_console/godmode/modules/manage_nc_groups.php b/pandora_console/godmode/modules/manage_nc_groups.php index 403a871622..e32644b9a8 100644 --- a/pandora_console/godmode/modules/manage_nc_groups.php +++ b/pandora_console/godmode/modules/manage_nc_groups.php @@ -283,7 +283,6 @@ html_print_input_hidden('new', 1); html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"'); echo ''; echo ''; -hd('entra o que ase'); enterprise_hook('close_meta_frame'); ?> diff --git a/pandora_console/godmode/snmpconsole/snmp_alert.php b/pandora_console/godmode/snmpconsole/snmp_alert.php index 66651d6522..7d0fc75876 100755 --- a/pandora_console/godmode/snmpconsole/snmp_alert.php +++ b/pandora_console/godmode/snmpconsole/snmp_alert.php @@ -170,6 +170,7 @@ if ($save_alert || $modify_alert) { $trap_type = (int) get_parameter('trap_type', -1); $single_value = (string) get_parameter('single_value'); $position = (int) get_parameter('position'); + $disable_event = (int) get_parameter('disable_event'); $group = (int) get_parameter('group'); if ($time_threshold == -1) { @@ -245,6 +246,7 @@ if ($save_alert || $modify_alert) { 'trap_type' => $trap_type, 'single_value' => $single_value, 'position' => $position, + 'disable_event' => $disable_event, 'id_group' => $group, ]; @@ -296,8 +298,8 @@ if ($save_alert || $modify_alert) { order_11 = '%d', order_12 = '%d', order_13 = '%d', order_14 = '%d', order_15 = '%d', order_16 = '%d', order_17 = '%d', order_18 = '%d', order_19 = '%d', - order_20 = '%d', trap_type = %d, - single_value = '%s', position = '%s', id_group ='%s' + order_20 = '%d', trap_type = %d, single_value = '%s', + position = '%s', disable_event = %d, id_group ='%s' WHERE id_as = %d", $priority, $alert_type, @@ -366,6 +368,7 @@ if ($save_alert || $modify_alert) { $trap_type, $single_value, $position, + $disable_event, $group, $id_as ); @@ -460,6 +463,7 @@ if ($update_alert || $duplicate_alert) { $trap_type = $alert['trap_type']; $single_value = $alert['single_value']; $position = $alert['position']; + $disable_event = $alert['disable_event']; $group = $alert['id_group']; } else if ($create_alert) { // Variable init @@ -532,6 +536,7 @@ if ($update_alert || $duplicate_alert) { $trap_type = -1; $single_value = ''; $position = 0; + $disable_event = 0; $group = 0; } @@ -566,7 +571,7 @@ if ($duplicate_alert) { '.db_escape_key_identifier('_snmp_f18_').', '.db_escape_key_identifier('_snmp_f19_').', '.db_escape_key_identifier('_snmp_f20_').", - trap_type, single_value, position, id_group, + trap_type, single_value, position, disable_event, id_group, order_1, order_2, order_3, order_4, order_5, order_6, order_7, order_8, order_9, order_10, order_11, order_12, order_13, order_14, order_15, order_16, order_17, order_18, order_19, order_20) @@ -574,7 +579,7 @@ if ($duplicate_alert) { (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', - '%s', '%s', '%s', '%s', %d, '%s', %d, %d, %d, %d, %d, %d, %d, %d, + '%s', '%s', '%s', '%s', %d, '%s', %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)", $id_alert, $al_field1, @@ -627,6 +632,7 @@ if ($duplicate_alert) { $trap_type, $single_value, $position, + $disable_event, $group, $order_1, $order_2, @@ -1080,6 +1086,10 @@ if ($create_alert || $update_alert) { html_print_input_text('position', $position, '', 3); echo '
'.__('Disable event').''; + + html_print_checkbox('disable_event', 1, $disable_event, false); + echo '
'; echo ""; diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 3f0600c08c..5b5641c616 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC200319'; +$build_version = 'PC200324'; $pandora_version = 'v7.0NG.744'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 4c09cde9ae..e18cfbd094 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -1868,6 +1868,12 @@ function api_set_delete_agent($id, $thrash1, $other, $thrash3) } } } else { + // Delete only if the centralised mode is disabled. + if (is_central_policies_on_node()) { + returnError('centralized'); + exit; + } + if ($agent_by_alias) { $idsAgents = agents_get_agent_id_by_alias(io_safe_input($id)); } else { diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 6b364e9bc8..9eebb7ac72 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -1083,6 +1083,19 @@ function events_get_all( $tag_without = base64_decode($filter['tag_without']); $tags = json_decode($tag_without, true); if (is_array($tags) && !in_array('0', $tags)) { + if (!$user_is_admin) { + $user_tags = array_flip(tags_get_tags_for_module_search()); + if ($user_tags != null) { + foreach ($tags as $key_tag => $id_tag) { + // User cannot filter with those tags. + if (!array_search($id_tag, $user_tags)) { + unset($tags[$key_tag]); + continue; + } + } + } + } + foreach ($tags as $id_tag) { if (!isset($tags_names[$id_tag])) { $tags_names[$id_tag] = tags_get_name($id_tag); diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index ce20278c15..103fa957d0 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -3809,7 +3809,7 @@ function graph_custom_sql_graph( * @param string homeurl * @param bool return or echo the result */ -function graph_graphic_agentevents($id_agent, $width, $height, $period=0, $homeurl, $return=false, $from_agent_view=false, $widgets=false) +function graph_graphic_agentevents($id_agent, $width, $height, $period=0, $homeurl, $return=false, $from_agent_view=false, $widgets=false, $server_id='') { global $config; global $graphic_type; @@ -3885,8 +3885,8 @@ function graph_graphic_agentevents($id_agent, $width, $height, $period=0, $homeu ]; // Draw slicebar graph - $out = flot_slicesbar_graph($data, $period, $width, $height, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl, '', '', false, $id_agent, $full_legend_date, 0, 1, $widgets); - + $out = flot_slicesbar_graph($data, $period, $width, $height, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl, '', '', false, $id_agent, $full_legend_date, 0, 1, $widgets, true, false, $server_id); + // id_server if ($return) { return $out; } else { diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 07ec0977ea..9a4ed439fa 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -3472,17 +3472,30 @@ function reporting_html_availability_graph($table, $item, $pdf=0) if (empty($item['data'][$k_chart]['failover']) === true) { $table1 = new stdClass(); $table1->width = '100%'; + $table1->autosize = 1; + $table1->styleTable = 'overflow: wrap; table-layout: fixed;'; $table1->data = []; $table1->size = []; $table1->size[0] = '10%'; $table1->size[1] = '80%'; - $table1->size[2] = '5%'; - $table1->size[3] = '5%'; + $table1->size[2] = '10%'; + $table1->style[0] = 'overflow-wrap: break-word'; + + // Align percentage and checks resume. + $table1->align[2] = 'center'; $table1->data[0][0] = $chart['agent'].'
'.$chart['module']; $table1->data[0][1] = $chart['chart']; - $table1->data[0][2] = "".$sla_value.''; - $table1->data[0][3] = "".$checks_resume.''; + $table1->data[0][2] = "".$sla_value.'
'; + + // Pdf sizes to avoid excesive overflow. + if ($pdf !== 0) { + $table1->size[0] = '15%'; + $table1->size[1] = '70%'; + $table1->size[2] = '15%'; + } + + $table1->data[0][2] .= "".$checks_resume.''; $tables_chart .= html_print_table( $table1, diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index b886e9be49..b7ef9cf8dd 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -774,7 +774,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false) } $events_graph = '
'; - $events_graph .= graph_graphic_agentevents($id_agente, 375, 45, SECONDS_1DAY, '', true, false, true); + $events_graph .= graph_graphic_agentevents($id_agente, 375, 45, SECONDS_1DAY, '', true, false, true, $server_id); $events_graph .= '

'; ui_toggle($events_graph, __('Events (24h)')); diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index bd721f57a6..be050beb4a 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -4782,9 +4782,7 @@ function ui_print_agent_autocomplete_input($parameters) inputs.push ("force_local_modules=1"); } - if ('.((int) $get_order_json).') { - inputs.push ("get_order_json=1"); - } + inputs.push ("get_order_json=1"); if ('.((int) $get_only_string_modules).') { inputs.push ("get_only_string_modules=1"); @@ -4819,6 +4817,14 @@ function ui_print_agent_autocomplete_input($parameters) url: action="'.$javascript_ajax_page.'", dataType: "json", success: function (data) { + if (Array.isArray(data) === true) { + data.sort(function(a, b) { + var textA = a.nombre.toUpperCase(); + var textB = b.nombre.toUpperCase(); + return (textA < textB) ? -1 : (textA > textB) ? 1 : 0; + }); + } + if ('.((int) $add_none_module).') { $("#'.$selectbox_id.'") .append($("") diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index aed866334d..ba4c971a7a 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -786,7 +786,8 @@ function pandoraFlotSlicebar( full_legend, not_interactive, show_date, - datelimit + datelimit, + server_id ) { values = values.split(separator2); legend = legend.split(separator); @@ -934,7 +935,9 @@ function pandoraFlotSlicebar( date_from: newdate, time_from: from + ":00", status: "-1", - group_rep: "1" + group_rep: "1", + from_event_graph: 1, + id_server_meta: server_id }; if (full_legend != "") { diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index 04560b6ce0..5445884a8a 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -740,7 +740,8 @@ function flot_slicesbar_graph( $ttl=1, $widgets=false, $show=true, - $date_to=false + $date_to=false, + $server_id='' ) { global $config; @@ -880,7 +881,7 @@ function flot_slicesbar_graph( // Javascript code. $return .= "'; diff --git a/pandora_console/install.php b/pandora_console/install.php index e94b64d749..b0a99b9396 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
{'disable_event'}) || (defined ($alert->{'disable_event'}) && $alert->{'disable_event'} == 0))) { #If we've spotted an alert recovered, we set the new event's severity to 2 (NORMAL), otherwise the original value is maintained. my ($text, $event, $severity) = ($alert_mode == RECOVERED_ALERT) ? ('recovered', 'alert_recovered', 2) : ('fired', 'alert_fired', $alert->{'priority'}); @@ -1426,8 +1425,9 @@ sub pandora_execute_action ($$$$$$$$$;$) { # Field 8 (comments); my $comment = $field8; - - pandora_event( + + if ((! defined($alert->{'disable_event'})) || (defined($alert->{'disable_event'}) && $alert->{'disable_event'} == 0)) { + pandora_event( $pa_config, $event_text, (defined ($agent) ? $agent->{'id_grupo'} : 0), @@ -1447,7 +1447,8 @@ sub pandora_execute_action ($$$$$$$$$;$) { $comment, $id_extra, $tags); - # Validate event (field1: agent name; field2: module name) + # Validate event (field1: agent name; field2: module name) + } } elsif ($clean_name eq "Validate Event") { my $agent_id = -1; my $module_id = -1; @@ -3883,6 +3884,7 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) { 'time_threshold' => 0, 'id' => $alert->{'id_alert'}, 'priority' => $alert->{'priority'}, + 'disable_event' => $alert->{'disable_event'} ); my %agent; @@ -3918,7 +3920,7 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) { pandora_execute_action ($pa_config, $trap_rcv_full, \%agent, \%alert, 1, $action, undef, $dbh, $timestamp, \%macros) if (defined ($action)); # Generate an event, ONLY if our alert action is different from generate an event. - if ($action->{'id_alert_command'} != 3){ + if ($action->{'id_alert_command'} != 3 && $alert->{'disable_event'} == 0){ pandora_event ($pa_config, "SNMP alert fired (" . safe_output($alert->{'description'}) . ")", 0, 0, $alert->{'priority'}, 0, 0, 'alert_fired', 0, $dbh); } @@ -3967,12 +3969,13 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) { 'time_threshold' => 0, 'id' => $other_alert->{'alert_type'}, 'priority' => $alert->{'priority'}, + 'disable_event' => $alert->{'disable_event'} ); pandora_execute_action ($pa_config, $trap_rcv_full, \%agent, \%alert_action, 1, $other_action, undef, $dbh, $timestamp, \%macros) if (defined ($other_action)); # Generate an event, ONLY if our alert action is different from generate an event. - if ($other_action->{'id_alert_command'} != 3){ + if ($other_action->{'id_alert_command'} != 3 && $alert->{'disable_event'} == 0){ pandora_event ($pa_config, "SNMP alert fired (" . safe_output($alert->{'description'}) . ")", 0, 0, $alert->{'priority'}, 0, 0, 'alert_fired', 0, $dbh); } diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 08ec22576c..1c96f24cf7 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -33,7 +33,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.744"; -my $pandora_build = "200319"; +my $pandora_build = "200324"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 0d4e69e4a3..d1cb16a7d3 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.744 -%define release 200319 +%define release 200324 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index b1641e6e07..4a102864bf 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.744 -%define release 200319 +%define release 200324 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index de93fb1f2e..48dbb24292 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.744" -PI_BUILD="200319" +PI_BUILD="200324" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 109eb5636c..de21b33baa 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -29,12 +29,13 @@ use Time::HiRes qw(usleep); # Default lib dir for RPM and DEB packages use lib '/usr/lib/perl5'; +use PandoraFMS::Core; use PandoraFMS::Tools; use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.744 PS200319"; +my $version = "7.0NG.744 PS200324"; # Pandora server configuration my %conf; @@ -1079,7 +1080,8 @@ my $history_dbh = undef; is_metaconsole(\%conf); if ($conf{'_history_db_enabled'} eq '1') { eval { - $history_dbh = db_connect ($conf{'dbengine'}, $conf{'_history_db_name'}, $conf{'_history_db_host'}, $conf{'_history_db_port'}, $conf{'_history_db_user'}, $conf{'_history_db_pass'}); + $conf{'encryption_key'} = enterprise_hook('pandora_get_encryption_key', [\%conf, $conf{'encryption_passphrase'}]); + $history_dbh = db_connect ($conf{'dbengine'}, $conf{'_history_db_name'}, $conf{'_history_db_host'}, $conf{'_history_db_port'}, $conf{'_history_db_user'}, pandora_output_password(\%conf, $conf{'_history_db_pass'})); }; if ($@) { if (is_offline(\%conf)) { diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 703a44238d..0ee3ea4bbc 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.744 PS200319"; +my $version = "7.0NG.744 PS200324"; # save program name for logging my $progname = basename($0); @@ -1143,6 +1143,11 @@ sub cli_delete_agent() { $agent_name = decode_entities($agent_name); + if(is_metaconsole($conf) != 1 and pandora_get_tconfig_token ($dbh, 'centralized_management', '')) { + print_log "[ERROR] This node is configured with centralized mode. To delete an agent go to metaconsole. \n\n"; + exit; + } + if (is_metaconsole($conf) == 1) { if (not defined $use_alias) { my $agents_groups = enterprise_hook('get_metaconsole_agent',[$dbh, $agent_name]); diff --git a/pandora_server/util/plugin/snmp_remote.pl b/pandora_server/util/plugin/snmp_remote.pl index ef37337556..62fa4cedc0 100755 --- a/pandora_server/util/plugin/snmp_remote.pl +++ b/pandora_server/util/plugin/snmp_remote.pl @@ -24,47 +24,65 @@ # # GPL License: http://www.gnu.org/licenses/gpl.txt #----------------------------------------------------------------------- +# Revised by Kevin Rojas 2020 kevin.rojas@pandorafms.com +# - Added check for Module options +# - Optimized SNMP v3 code +# - Improved Help +#----------------------------------------------------------------------- use strict; use Getopt::Std; -my $VERSION = 'v1r1'; + +my $VERSION = 'v1r2'; #----------------------------------------------------------------------- # HELP #----------------------------------------------------------------------- if ($#ARGV == -1 ) { + print "SNMP remote plugin ($VERSION). Retrieves information via SNMP for:\n"; + print "\t- Memory Usage (%)\n"; + print "\t- CPU Usage (%)\n"; + print "\t- Disk Usage (%)\n"; + print "\t- Whether a process is running (1) or not (0)\n"; + print "\n"; + + print "Arguments:\n\n"; + print "-H, --host=STRING\n"; print "\tHost IP\n"; print "-c, --community=STRING\n"; - print "\tSnmp Community\n"; + print "\tSNMP Community\n"; print "-m, --module=STRING\n"; print "\tDefine module (memuse|diskuse|process|cpuload) \n"; print "-d, --disk=STRING\n"; - print "\tDefine disk name (C:, D: in Windows) or mount point (Linux)(only in diskuse module)\n"; - + print "\t[Only for diskuse module] Define disk name (C:, D: in Windows) or mount point (Linux). Default: /\n"; + print "-p, --process=STRING\n"; - print "\tProcess or service name (only in process module)\n"; + print "\t[Only for process module] Process or service name\n\n"; + print "SNMP v3 options:\n"; + print "\n"; + print "-v, --version=STRING\n"; - print "\tVersion of protocol\n"; + print "\tSNMP version (Default 2c)\n"; print "-u, --user=STRING\n"; print "\tAuth user\n"; - - print "-A, --auth=STRING\n"; - print "\tAuth pass\n"; - + print "-l, --level=STRING\n"; print "\tSecurity level\n"; print "-a STRING\n"; print "\tAuth method\n"; + print "-A, --auth=STRING\n"; + print "\tAuth pass\n"; + print "-x STRING\n"; print "\tPrivacy method\n"; @@ -72,10 +90,12 @@ if ($#ARGV == -1 ) { print "\tPrivacy pass\n"; print "\n"; - print "Example of use \n"; - print "perl snmp_remoto.pl -H host -c community -m (memuse|diskuse|process|cpuload) [-p process -d disk] \n"; - print "\n"; - print "Version=$VERSION\n"; + print "Usage: \n"; + print "SNMP v1|2|2c:\n" ; + print "\tperl $0 -H host -c community -m (memuse|diskuse|process|cpuload) [-p process -d disk] \n" ; + print "SNMP v3:\n" ; + print "\tperl $0 -H host -v 3 -u user -l seclevel -a authMethod -A authPass -x privMethod -X privPass -m (memuse|diskuse|process|cpuload) [-p process -d disk] \n" ; + print "\n" ; exit; } @@ -151,104 +171,97 @@ sub options { $opts{"X"}); } -#----------------------------------------------------------------------- -# Module % Memory use -#----------------------------------------------------------------------- -if ($module eq "memuse") { - my $memuse = 0; - my $command_line_parammeters; - - if ($version == "3") { - if ($auth_method eq 'authNoPriv') { - $command_line_parammeters = "-v $version -u $user -a $auth_method -A $pass -l $security_level $host"; - } - elsif ($auth_method eq "noAuthNoPriv") { - $command_line_parammeters = "-v $version -u $user -l $security_level $host"; - } - else { - $command_line_parammeters = "-v $version -u $user -a $auth_method -A $pass -l $security_level -x $privacy_method -X $privacy_pass $host"; - } - } - else { - $command_line_parammeters = "-v $version -c $community $host"; - } - - my $memid = `snmpwalk -On $command_line_parammeters .1.3.6.1.2.1.25.2.3.1.3 | grep Physical | head -1 | gawk '{print \$1}' | gawk -F "." '{print \$13}' | tr -d "\r"`; - my $memtot = `snmpget $command_line_parammeters .1.3.6.1.2.1.25.2.3.1.5.$memid ` ; - my $memtot2 = `echo "$memtot" | gawk '{print \$4}'`; - my $memfree = `snmpget $command_line_parammeters .1.3.6.1.2.1.25.2.3.1.6.$memid` ; - my $memfree2 = `echo "$memfree" | gawk '{print \$4}'`; - - $memuse = ($memfree2) * 100 / $memtot2; - - printf("%.2f", $memuse); +unless ( $module ~~ ["memuse","cpuload","process","diskuse"] ){ + print "Error: Invalid or missing argument (-m).\n"; + print "Available options: memuse | diskuse | process | cpuload \n\n"; + exit; +} + +unless ($host){ + print "Error: missing host address.\n"; + exit; } #----------------------------------------------------------------------- -# Module % Disk use +# SNMP Version parameters +#----------------------------------------------------------------------- +my $command_line_parameters; +if ($version == "3") { + if ($security_level eq 'authNoPriv') { + $command_line_parameters = "-v $version -u $user -a $auth_method -A $pass -l $security_level $host"; + } + elsif ($security_level eq "AuthPriv") { + $command_line_parameters = "-v $version -u $user -a $auth_method -A $pass -l $security_level -x $privacy_method -X $privacy_pass $host"; + } + else { + $command_line_parameters = "-v $version -u $user -l $security_level $host"; + } + } +else { + $command_line_parameters = "-v $version -c $community $host"; +} + +#----------------------------------------------------------------------- +# Memory use % module +#----------------------------------------------------------------------- +if ($module eq "memuse") { + my $memuse = 0; + + my $memid = `snmpwalk -On $command_line_parameters .1.3.6.1.2.1.25.2.3.1.3 | grep Physical | head -1 | gawk '{print \$1}' | gawk -F "." '{print \$13}' | tr -d "\r"`; + my @memtot = split(/\s/, `snmpget $command_line_parameters .1.3.6.1.2.1.25.2.3.1.5.$memid `) ; + my @memfree = split(/\s/, `snmpget $command_line_parameters .1.3.6.1.2.1.25.2.3.1.6.$memid `) ; + + if ($memid){ + $memuse = ($memfree[-1]) * 100 / $memtot[-1]; + printf("%.2f", $memuse); + } + else { + print STDOUT "-1"; + print STDERR "Error: Memory OID not found"; + } +} + +#----------------------------------------------------------------------- +# Disk use % module #----------------------------------------------------------------------- if ($module eq "diskuse") { my $diskuse = 0; - my $command_line_parammeters; - if ($version == "3") { - if ($auth_method eq 'authNoPriv') { - $command_line_parammeters = "-v $version -u $user -a $auth_method -A $pass -l $security_level $host"; - } - elsif ($auth_method eq "noAuthNoPriv") { - $command_line_parammeters = "-v $version -u $user -l $security_level $host"; - } - else { - $command_line_parammeters = "-v $version -u $user -a $auth_method -A $pass -l $security_level -x $privacy_method -X $privacy_pass $host"; - } - } - else { - $command_line_parammeters = "-v $version -c $community $host"; + unless ($disk){ + print "Error: Invalid or missing argument (-d).\n"; + exit; } if ($disk =~ /\\ /) { $disk =~ s/\\/\\\\/g; } - my $diskid = `snmpwalk -r 2 -On $command_line_parammeters .1.3.6.1.2.1.25.2.3.1.3 | grep -F '$disk' | head -1 | gawk '{print \$1}' | gawk -F "." '{print \$13}' | tr -d "\r"`; - my $disktot = `snmpget -r 2 $command_line_parammeters .1.3.6.1.2.1.25.2.3.1.5.$diskid ` ; - my $disktot2 = `echo "$disktot" | gawk '{print \$4}'`; - - if ($disktot2 == 0) { + my $diskid = `snmpwalk -r 2 -On $command_line_parameters .1.3.6.1.2.1.25.2.3.1.3 | grep -F '$disk' | head -1 | gawk '{print \$1}' | gawk -F "." '{print \$13}' | tr -d "\r"`; + my @disktot= split /\s/, `snmpget -r 2 $command_line_parameters .1.3.6.1.2.1.25.2.3.1.5.$diskid` ; + + if ($diskid == ""){ + print STDOUT "-1"; + print STDERR "Error: Disk or partition not found\n"; + exit; + } + if ($disktot[-1] == 0) { $diskuse = 0; } else { - my $diskfree = `snmpget -r 2 $command_line_parammeters .1.3.6.1.2.1.25.2.3.1.6.$diskid` ; - my $diskfree2 = `echo "$diskfree" | gawk '{print \$4}'`; - - $diskuse = ($disktot2 - $diskfree2) * 100 / $disktot2; + my @diskfree = split (/\s/, `snmpget -r 2 $command_line_parameters .1.3.6.1.2.1.25.2.3.1.6.$diskid`) ; + + $diskuse = ($disktot[-1] - $diskfree[-1]) * 100 / $disktot[-1]; } printf("%.2f", $diskuse); } #----------------------------------------------------------------------- -# Module Process Status +# Process Status module #----------------------------------------------------------------------- if ($module eq "process") { my $status = 0; - my $command_line_parammeters; - if ($version == "3") { - if ($auth_method eq 'authNoPriv') { - $command_line_parammeters = "-v $version -u $user -a $auth_method -A $pass -l $security_level $host"; - } - elsif ($auth_method eq "noAuthNoPriv") { - $command_line_parammeters = "-v $version -u $user -l $security_level $host"; - } - else { - $command_line_parammeters = "-v $version -u $user -a $auth_method -A $pass -l $security_level -x $privacy_method -X $privacy_pass $host"; - } - } - else { - $command_line_parammeters = "-v $version -c $community $host"; - } - - $status = `snmpwalk $command_line_parammeters 1.3.6.1.2.1.25.4.2.1.2 2>/dev/null`; + $status = `snmpwalk $command_line_parameters .1.3.6.1.2.1.25.4.2.1.2 2>/dev/null`; if ($? == 0) { print (($status =~ m/$process/mi)?1:0); @@ -256,28 +269,12 @@ if ($module eq "process") { } #----------------------------------------------------------------------- -# Module % Cpu Load +# CPU Load % module #----------------------------------------------------------------------- if ($module eq "cpuload") { my $cputotal = 0; - my $command_line_parammeters; - if ($version == "3") { - if ($auth_method eq 'authNoPriv') { - $command_line_parammeters = "-v $version -u $user -a $auth_method -A $pass -l $security_level $host"; - } - elsif ($auth_method eq "noAuthNoPriv") { - $command_line_parammeters = "-v $version -u $user -l $security_level $host"; - } - else { - $command_line_parammeters = "-v $version -u $user -a $auth_method -A $pass -l $security_level -x $privacy_method -X $privacy_pass $host"; - } - } - else { - $command_line_parammeters = "-v $version -c $community $host"; - } - - my $cpuload = `snmpwalk $command_line_parammeters .1.3.6.1.2.1.25.3.3.1.2 | gawk '{print \$4}' `; + my $cpuload = `snmpwalk $command_line_parameters .1.3.6.1.2.1.25.3.3.1.2 | gawk '{print \$4}' `; my @cpuload = split(/\n/, $cpuload); my $sum; my $counter = 0;