Merge branch 'develop' into 'ent-5530-Mostrar-el-tiempo-en-que-un-elemento-se-ha-mantenido-en-un-estado'

# Conflicts:
#   pandora_console/extras/mr/37.sql
This commit is contained in:
Alejandro Campos 2020-03-24 13:55:57 +01:00
commit b56076044b
48 changed files with 395 additions and 193 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.744-200319 Version: 7.0NG.744-200324
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # 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." echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -55,7 +55,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.744'; 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 # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.744 %define version 7.0NG.744
%define release 200319 %define release 200324
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.744 %define version 7.0NG.744
%define release 200319 %define release 200324
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.744" PI_VERSION="7.0NG.744"
PI_BUILD="200319" PI_BUILD="200324"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{200319} {200324}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #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_path;
string pandora_dir; string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" 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" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.744-200319 Version: 7.0NG.744-200324
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.744-200319" pandora_version="7.0NG.744-200324"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -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'; 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; COMMIT;

View File

@ -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` 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` 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` -- 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 `field13_recovery` TEXT NOT NULL DEFAULT "";
ALTER TABLE talert_templates ADD COLUMN `field14_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 `field15_recovery` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_templates` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0;
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `talert_snmp` -- 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_field13` TEXT NOT NULL DEFAULT "";
ALTER TABLE talert_snmp ADD COLUMN `al_field14` 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 `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, ALTER TABLE `talert_snmp` MODIFY COLUMN `al_field11` text NOT NULL,
MODIFY COLUMN `al_field12` text NOT NULL, MODIFY COLUMN `al_field12` text NOT NULL,
MODIFY COLUMN `al_field13` text NOT NULL, MODIFY COLUMN `al_field13` text NOT NULL,

View File

@ -227,7 +227,9 @@ if (!$new_agent && $alias != '') {
$agent_options_update = 'agent_options_update'; $agent_options_update = 'agent_options_update';
// Delete link from here. // Delete link from here.
$table_agent_name .= "<a onClick=\"if (!confirm('".__('Are you sure?')."')) return false;\" href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=".$id_agente."&search=&offset=0&sort_field=&sort=none'>".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).'</a>'; if (!is_central_policies_on_node()) {
$table_agent_name .= "<a onClick=\"if (!confirm('".__('Are you sure?')."')) return false;\" href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=".$id_agente."&search=&offset=0&sort_field=&sort=none'>".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).'</a>';
}
// Remote configuration available. // Remote configuration available.
if (isset($filename)) { if (isset($filename)) {

View File

@ -62,6 +62,10 @@ $onheader = ['view' => $viewtab];
// Header. // Header.
ui_print_page_header(__('Agents defined in %s', get_product_name()), 'images/agent_mc.png', false, '', true, $onheader); 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. // Perform actions.
$agent_to_delete = (int) get_parameter('borrar_agente'); $agent_to_delete = (int) get_parameter('borrar_agente');
$enable_agent = (int) get_parameter('enable_agent'); $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')]).'</a>'; echo html_print_image('images/lightbulb.png', true, ['alt' => __('Disable agent'), 'title' => __('Disable agent')]).'</a>';
} }
if ($check_aw) { if ($check_aw && !is_central_policies_on_node()) {
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente& echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
borrar_agente=".$agent['id_agente']."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled'"; borrar_agente=".$agent['id_agente']."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled'";

View File

@ -290,6 +290,7 @@ function update_template($step)
$max_alerts = (int) get_parameter('max_alerts'); $max_alerts = (int) get_parameter('max_alerts');
$min_alerts = (int) get_parameter('min_alerts'); $min_alerts = (int) get_parameter('min_alerts');
$min_alerts_reset_counter = (int) get_parameter('min_alerts_reset_counter'); $min_alerts_reset_counter = (int) get_parameter('min_alerts_reset_counter');
$disable_event = (int) get_parameter('disable_event');
$type = (string) get_parameter('type'); $type = (string) get_parameter('type');
$value = (string) html_entity_decode(get_parameter('value')); $value = (string) html_entity_decode(get_parameter('value'));
$max = (float) get_parameter('max'); $max = (float) get_parameter('max');
@ -320,6 +321,7 @@ function update_template($step)
'max_value' => $max, 'max_value' => $max,
'min_value' => $min, 'min_value' => $min,
'matches_value' => $matches, 'matches_value' => $matches,
'disable_event' => $disable_event,
]; ];
// Different datetimes format for oracle // Different datetimes format for oracle
@ -532,6 +534,7 @@ if ($id && ! $create_template) {
$max_alerts = $template['max_alerts']; $max_alerts = $template['max_alerts'];
$min_alerts = $template['min_alerts']; $min_alerts = $template['min_alerts'];
$min_alerts_reset_counter = $template['min_alerts_reset_counter']; $min_alerts_reset_counter = $template['min_alerts_reset_counter'];
$disable_event = $template['disable_event'];
$threshold = $template['time_threshold']; $threshold = $template['time_threshold'];
$fields = []; $fields = [];
for ($i = 1; $i <= $config['max_macro_fields']; $i++) { for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
@ -578,8 +581,7 @@ if ($step == 2) {
// Firing conditions and events // Firing conditions and events
$table->colspan = []; $table->colspan = [];
$table->colspan[4][1] = 3; // $table->colspan[4][1] = 1;
$table->data[0][0] = __('Days of week'); $table->data[0][0] = __('Days of week');
$table->data[0][1] = __('Mon'); $table->data[0][1] = __('Mon');
$table->data[0][1] .= html_print_checkbox('monday', 1, $monday, true); $table->data[0][1] .= html_print_checkbox('monday', 1, $monday, true);
@ -653,6 +655,9 @@ if ($step == 2) {
true 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'); $table->data[5][0] = __('Default action');
$usr_groups = implode(',', array_keys(users_get_groups($config['id_user'], 'LM', true))); $usr_groups = implode(',', array_keys(users_get_groups($config['id_user'], 'LM', true)));
switch ($config['dbtype']) { switch ($config['dbtype']) {

View File

@ -443,37 +443,140 @@ if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) {
$usedGroup = groups_check_used($id_group); $usedGroup = groups_check_used($id_group);
if (!$usedGroup['return']) { if (!$usedGroup['return']) {
$group = db_get_row_filter( $errors_meta = false;
'tgrupo', if (is_metaconsole()) {
['id_grupo' => $id_group] $group_name = groups_get_name($id_group);
); $servers = metaconsole_get_servers();
db_process_sql_update( $error_counter = 0;
'tgrupo', $success_counter = 0;
['parent' => $group['parent']], $success_nodes = [];
['parent' => $id_group] $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( metaconsole_restore_db();
'tgroup_stat', }
['id_group' => $id_group]
);
$result = db_process_sql_delete( if ($error_counter > 0) {
'tgrupo', ui_print_error_message(
['id_grupo' => $id_group] __('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 { } else {
ui_print_error_message( ui_print_error_message(
sprintf(__('The group is not empty. It is use in %s.'), implode(', ', $usedGroup['tables'])) 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') {
] ]
).'</a>'; ).'</a>';
$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']) { if ($group['has_child']) {
$confirm_message = __('The child groups will be updated to use the parent id of the deleted group').'. '.$confirm_message; $confirm_message = __('The child groups will be updated to use the parent id of the deleted group').'. '.$confirm_message;
} }

View File

@ -186,11 +186,13 @@ $table->data[2][1] = html_print_select(
echo '<form method="post" id="form_agents" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_agents">'; echo '<form method="post" id="form_agents" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_agents">';
html_print_table($table); html_print_table($table);
if (!is_central_policies_on_node()) {
echo '<div class="action-buttons" style="width: '.$table->width.'" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
html_print_input_hidden('delete', 1);
html_print_submit_button(__('Delete'), 'go', false, 'class="sub delete"');
echo '</div>';
}
echo '<div class="action-buttons" style="width: '.$table->width.'" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
html_print_input_hidden('delete', 1);
html_print_submit_button(__('Delete'), 'go', false, 'class="sub delete"');
echo '</div>';
echo '</form>'; echo '</form>';
echo '<h3 class="error invisible" id="message"> </h3>'; echo '<h3 class="error invisible" id="message"> </h3>';

View File

@ -101,10 +101,17 @@ function process_manage_delete($id_alert_template, $id_agents, $module_names)
$module_selection_mode = get_parameter('modules_selection_mode'); $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 ($module_names as $module) {
foreach ($id_agents as $id_agent) { foreach ($id_agents as $id_agent) {
$module_id = modules_get_agentmodule_id($module, $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'];
}
}
} }
} }

View File

@ -305,6 +305,10 @@ echo '</div>';
</script> </script>
<?php <?php
if (is_central_policies_on_node() && $option == 'delete_agents') {
ui_print_warning_message(__('This node is configured with centralized mode. To delete an agent go to metaconsole.'));
}
echo '<br />'; echo '<br />';
echo '<form method="post" id="form_options" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations">'; echo '<form method="post" id="form_options" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations">';
echo '<table border="0"><tr><td>'; echo '<table border="0"><tr><td>';

View File

@ -283,7 +283,6 @@ html_print_input_hidden('new', 1);
html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"'); html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"');
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
hd('entra o que ase');
enterprise_hook('close_meta_frame'); enterprise_hook('close_meta_frame');
?> ?>

View File

@ -170,6 +170,7 @@ if ($save_alert || $modify_alert) {
$trap_type = (int) get_parameter('trap_type', -1); $trap_type = (int) get_parameter('trap_type', -1);
$single_value = (string) get_parameter('single_value'); $single_value = (string) get_parameter('single_value');
$position = (int) get_parameter('position'); $position = (int) get_parameter('position');
$disable_event = (int) get_parameter('disable_event');
$group = (int) get_parameter('group'); $group = (int) get_parameter('group');
if ($time_threshold == -1) { if ($time_threshold == -1) {
@ -245,6 +246,7 @@ if ($save_alert || $modify_alert) {
'trap_type' => $trap_type, 'trap_type' => $trap_type,
'single_value' => $single_value, 'single_value' => $single_value,
'position' => $position, 'position' => $position,
'disable_event' => $disable_event,
'id_group' => $group, 'id_group' => $group,
]; ];
@ -296,8 +298,8 @@ if ($save_alert || $modify_alert) {
order_11 = '%d', order_12 = '%d', order_13 = '%d', order_11 = '%d', order_12 = '%d', order_13 = '%d',
order_14 = '%d', order_15 = '%d', order_16 = '%d', order_14 = '%d', order_15 = '%d', order_16 = '%d',
order_17 = '%d', order_18 = '%d', order_19 = '%d', order_17 = '%d', order_18 = '%d', order_19 = '%d',
order_20 = '%d', trap_type = %d, order_20 = '%d', trap_type = %d, single_value = '%s',
single_value = '%s', position = '%s', id_group ='%s' position = '%s', disable_event = %d, id_group ='%s'
WHERE id_as = %d", WHERE id_as = %d",
$priority, $priority,
$alert_type, $alert_type,
@ -366,6 +368,7 @@ if ($save_alert || $modify_alert) {
$trap_type, $trap_type,
$single_value, $single_value,
$position, $position,
$disable_event,
$group, $group,
$id_as $id_as
); );
@ -460,6 +463,7 @@ if ($update_alert || $duplicate_alert) {
$trap_type = $alert['trap_type']; $trap_type = $alert['trap_type'];
$single_value = $alert['single_value']; $single_value = $alert['single_value'];
$position = $alert['position']; $position = $alert['position'];
$disable_event = $alert['disable_event'];
$group = $alert['id_group']; $group = $alert['id_group'];
} else if ($create_alert) { } else if ($create_alert) {
// Variable init // Variable init
@ -532,6 +536,7 @@ if ($update_alert || $duplicate_alert) {
$trap_type = -1; $trap_type = -1;
$single_value = ''; $single_value = '';
$position = 0; $position = 0;
$disable_event = 0;
$group = 0; $group = 0;
} }
@ -566,7 +571,7 @@ if ($duplicate_alert) {
'.db_escape_key_identifier('_snmp_f18_').', '.db_escape_key_identifier('_snmp_f18_').',
'.db_escape_key_identifier('_snmp_f19_').', '.db_escape_key_identifier('_snmp_f19_').',
'.db_escape_key_identifier('_snmp_f20_').", '.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_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_9, order_10, order_11, order_12, order_13, order_14, order_15,
order_16, order_17, order_18, order_19, order_20) 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', (%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', %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', '%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)", %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)",
$id_alert, $id_alert,
$al_field1, $al_field1,
@ -627,6 +632,7 @@ if ($duplicate_alert) {
$trap_type, $trap_type,
$single_value, $single_value,
$position, $position,
$disable_event,
$group, $group,
$order_1, $order_1,
$order_2, $order_2,
@ -1080,6 +1086,10 @@ if ($create_alert || $update_alert) {
html_print_input_text('position', $position, '', 3); html_print_input_text('position', $position, '', 3);
echo '</td></tr>'; echo '</td></tr>';
echo '<tr><td class="datos">'.__('Disable event').'</td><td class="datos">';
html_print_checkbox('disable_event', 1, $disable_event, false);
echo '</td></tr>';
echo '</table>'; echo '</table>';
echo "<table style='width:100%'>"; echo "<table style='width:100%'>";

View File

@ -20,7 +20,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC200319'; $build_version = 'PC200324';
$pandora_version = 'v7.0NG.744'; $pandora_version = 'v7.0NG.744';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -1868,6 +1868,12 @@ function api_set_delete_agent($id, $thrash1, $other, $thrash3)
} }
} }
} else { } else {
// Delete only if the centralised mode is disabled.
if (is_central_policies_on_node()) {
returnError('centralized');
exit;
}
if ($agent_by_alias) { if ($agent_by_alias) {
$idsAgents = agents_get_agent_id_by_alias(io_safe_input($id)); $idsAgents = agents_get_agent_id_by_alias(io_safe_input($id));
} else { } else {

View File

@ -1083,6 +1083,19 @@ function events_get_all(
$tag_without = base64_decode($filter['tag_without']); $tag_without = base64_decode($filter['tag_without']);
$tags = json_decode($tag_without, true); $tags = json_decode($tag_without, true);
if (is_array($tags) && !in_array('0', $tags)) { 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) { foreach ($tags as $id_tag) {
if (!isset($tags_names[$id_tag])) { if (!isset($tags_names[$id_tag])) {
$tags_names[$id_tag] = tags_get_name($id_tag); $tags_names[$id_tag] = tags_get_name($id_tag);

View File

@ -3809,7 +3809,7 @@ function graph_custom_sql_graph(
* @param string homeurl * @param string homeurl
* @param bool return or echo the result * @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 $config;
global $graphic_type; global $graphic_type;
@ -3885,8 +3885,8 @@ function graph_graphic_agentevents($id_agent, $width, $height, $period=0, $homeu
]; ];
// Draw slicebar graph // 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) { if ($return) {
return $out; return $out;
} else { } else {

View File

@ -3472,17 +3472,30 @@ function reporting_html_availability_graph($table, $item, $pdf=0)
if (empty($item['data'][$k_chart]['failover']) === true) { if (empty($item['data'][$k_chart]['failover']) === true) {
$table1 = new stdClass(); $table1 = new stdClass();
$table1->width = '100%'; $table1->width = '100%';
$table1->autosize = 1;
$table1->styleTable = 'overflow: wrap; table-layout: fixed;';
$table1->data = []; $table1->data = [];
$table1->size = []; $table1->size = [];
$table1->size[0] = '10%'; $table1->size[0] = '10%';
$table1->size[1] = '80%'; $table1->size[1] = '80%';
$table1->size[2] = '5%'; $table1->size[2] = '10%';
$table1->size[3] = '5%';
$table1->style[0] = 'overflow-wrap: break-word';
// Align percentage and checks resume.
$table1->align[2] = 'center';
$table1->data[0][0] = $chart['agent'].'<br />'.$chart['module']; $table1->data[0][0] = $chart['agent'].'<br />'.$chart['module'];
$table1->data[0][1] = $chart['chart']; $table1->data[0][1] = $chart['chart'];
$table1->data[0][2] = "<span style = 'font-weight: bold; font-size: ".$font_size.'; color: '.$color."'>".$sla_value.'</span>'; $table1->data[0][2] = "<span style = 'font-weight: bold; font-size: ".$font_size.'; color: '.$color."'>".$sla_value.'</span><br/>';
$table1->data[0][3] = "<span style = 'font-size: ".$font_mini.";'>".$checks_resume.'</span>';
// 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] .= "<span style = 'font-size: ".$font_mini.";'>".$checks_resume.'</span>';
$tables_chart .= html_print_table( $tables_chart .= html_print_table(
$table1, $table1,

View File

@ -774,7 +774,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
} }
$events_graph = '<div style="margin-left:10px; width:100%;">'; $events_graph = '<div style="margin-left:10px; width:100%;">';
$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 .= '</div><br>'; $events_graph .= '</div><br>';
ui_toggle($events_graph, __('Events (24h)')); ui_toggle($events_graph, __('Events (24h)'));

View File

@ -4782,9 +4782,7 @@ function ui_print_agent_autocomplete_input($parameters)
inputs.push ("force_local_modules=1"); 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).') { if ('.((int) $get_only_string_modules).') {
inputs.push ("get_only_string_modules=1"); inputs.push ("get_only_string_modules=1");
@ -4819,6 +4817,14 @@ function ui_print_agent_autocomplete_input($parameters)
url: action="'.$javascript_ajax_page.'", url: action="'.$javascript_ajax_page.'",
dataType: "json", dataType: "json",
success: function (data) { 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).') { if ('.((int) $add_none_module).') {
$("#'.$selectbox_id.'") $("#'.$selectbox_id.'")
.append($("<option></option>") .append($("<option></option>")

View File

@ -786,7 +786,8 @@ function pandoraFlotSlicebar(
full_legend, full_legend,
not_interactive, not_interactive,
show_date, show_date,
datelimit datelimit,
server_id
) { ) {
values = values.split(separator2); values = values.split(separator2);
legend = legend.split(separator); legend = legend.split(separator);
@ -934,7 +935,9 @@ function pandoraFlotSlicebar(
date_from: newdate, date_from: newdate,
time_from: from + ":00", time_from: from + ":00",
status: "-1", status: "-1",
group_rep: "1" group_rep: "1",
from_event_graph: 1,
id_server_meta: server_id
}; };
if (full_legend != "") { if (full_legend != "") {

View File

@ -740,7 +740,8 @@ function flot_slicesbar_graph(
$ttl=1, $ttl=1,
$widgets=false, $widgets=false,
$show=true, $show=true,
$date_to=false $date_to=false,
$server_id=''
) { ) {
global $config; global $config;
@ -880,7 +881,7 @@ function flot_slicesbar_graph(
// Javascript code. // Javascript code.
$return .= "<script type='text/javascript'>"; $return .= "<script type='text/javascript'>";
$return .= "//<![CDATA[\n"; $return .= "//<![CDATA[\n";
$return .= "pandoraFlotSlicebar('$graph_id','$values','$datacolor','$legend',$intervaltick,'$fontpath',$fontsize,'$separator','$separator2',$id_agent,'$full_legend_date',$not_interactive, '$show', $datelimit)"; $return .= "pandoraFlotSlicebar('$graph_id','$values','$datacolor','$legend',$intervaltick,'$fontpath',$fontsize,'$separator','$separator2',$id_agent,'$full_legend_date',$not_interactive, '$show', $datelimit, $server_id)";
$return .= "\n//]]>"; $return .= "\n//]]>";
$return .= '</script>'; $return .= '</script>';

View File

@ -129,7 +129,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0NG.744'; $version = '7.0NG.744';
$build = '200319'; $build = '200324';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -417,7 +417,10 @@ $user_filter = db_get_row_sql(
$config['id_user'] $config['id_user']
) )
); );
if ($user_filter !== false) {
// Do not load the user filter if we come from the 24h event graph
$from_event_graph = get_parameter('filter[from_event_graph]', $filter['from_event_graph']);
if ($user_filter !== false && $from_event_graph != 1) {
$filter = events_get_event_filter($user_filter['id_filter']); $filter = events_get_event_filter($user_filter['id_filter']);
if ($filter !== false) { if ($filter !== false) {
$id_group = $filter['id_group']; $id_group = $filter['id_group'];

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.744 %define version 7.0NG.744
%define release 200319 %define release 200324
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.744 %define version 7.0NG.744
%define release 200319 %define release 200324
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.744 %define version 7.0NG.744
%define release 200319 %define release 200324
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -343,6 +343,7 @@ CREATE TABLE IF NOT EXISTS `talert_snmp` (
`trap_type` int(11) NOT NULL default '-1', `trap_type` int(11) NOT NULL default '-1',
`single_value` varchar(255) default '', `single_value` varchar(255) default '',
`position` int(10) unsigned NOT NULL default '0', `position` int(10) unsigned NOT NULL default '0',
`disable_event` tinyint(1) default 0,
`id_group` int(10) unsigned NOT NULL default '0', `id_group` int(10) unsigned NOT NULL default '0',
`order_1` int(10) unsigned NOT NULL default 1, `order_1` int(10) unsigned NOT NULL default 1,
`order_2` int(10) unsigned NOT NULL default 2, `order_2` int(10) unsigned NOT NULL default 2,
@ -488,6 +489,7 @@ CREATE TABLE IF NOT EXISTS `talert_templates` (
`special_day` tinyint(1) default 0, `special_day` tinyint(1) default 0,
`wizard_level` enum('basic','advanced','nowizard') default 'nowizard', `wizard_level` enum('basic','advanced','nowizard') default 'nowizard',
`min_alerts_reset_counter` tinyint(1) default 0, `min_alerts_reset_counter` tinyint(1) default 0,
`disable_event` tinyint(1) default 0,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `idx_template_action` (`id_alert_action`), KEY `idx_template_action` (`id_alert_action`),
FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`) FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`)
@ -2858,6 +2860,7 @@ CREATE TABLE IF NOT EXISTS `tevent_alert` (
`force_execution` tinyint(1) default '0', `force_execution` tinyint(1) default '0',
`group_by` enum ('','id_agente','id_agentmodule','id_alert_am','id_grupo') default '', `group_by` enum ('','id_agente','id_agentmodule','id_alert_am','id_grupo') default '',
`special_days` tinyint(1) default 0, `special_days` tinyint(1) default 0,
`disable_event` tinyint(1) default 0,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.744-200319 Version: 7.0NG.744-200324
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.744-200319" pandora_version="7.0NG.744-200324"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -45,7 +45,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.744"; my $pandora_version = "7.0NG.744";
my $pandora_build = "200319"; my $pandora_build = "200324";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash

View File

@ -916,8 +916,7 @@ sub pandora_execute_alert ($$$$$$$$$;$) {
} }
# Generate an event only if an event has not already been generated by an alert action # Generate an event only if an event has not already been generated by an alert action
if ($event_generated == 0) { if ($event_generated == 0 && (! defined ($alert->{'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. #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'}); my ($text, $event, $severity) = ($alert_mode == RECOVERED_ALERT) ? ('recovered', 'alert_recovered', 2) : ('fired', 'alert_fired', $alert->{'priority'});
@ -1427,7 +1426,8 @@ sub pandora_execute_action ($$$$$$$$$;$) {
# Field 8 (comments); # Field 8 (comments);
my $comment = $field8; my $comment = $field8;
pandora_event( if ((! defined($alert->{'disable_event'})) || (defined($alert->{'disable_event'}) && $alert->{'disable_event'} == 0)) {
pandora_event(
$pa_config, $pa_config,
$event_text, $event_text,
(defined ($agent) ? $agent->{'id_grupo'} : 0), (defined ($agent) ? $agent->{'id_grupo'} : 0),
@ -1447,7 +1447,8 @@ sub pandora_execute_action ($$$$$$$$$;$) {
$comment, $comment,
$id_extra, $id_extra,
$tags); $tags);
# Validate event (field1: agent name; field2: module name) # Validate event (field1: agent name; field2: module name)
}
} elsif ($clean_name eq "Validate Event") { } elsif ($clean_name eq "Validate Event") {
my $agent_id = -1; my $agent_id = -1;
my $module_id = -1; my $module_id = -1;
@ -3883,6 +3884,7 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
'time_threshold' => 0, 'time_threshold' => 0,
'id' => $alert->{'id_alert'}, 'id' => $alert->{'id_alert'},
'priority' => $alert->{'priority'}, 'priority' => $alert->{'priority'},
'disable_event' => $alert->{'disable_event'}
); );
my %agent; 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)); 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. # 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'}) . ")", pandora_event ($pa_config, "SNMP alert fired (" . safe_output($alert->{'description'}) . ")",
0, 0, $alert->{'priority'}, 0, 0, 'alert_fired', 0, $dbh); 0, 0, $alert->{'priority'}, 0, 0, 'alert_fired', 0, $dbh);
} }
@ -3967,12 +3969,13 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
'time_threshold' => 0, 'time_threshold' => 0,
'id' => $other_alert->{'alert_type'}, 'id' => $other_alert->{'alert_type'},
'priority' => $alert->{'priority'}, '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)); 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. # 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'}) . ")", pandora_event ($pa_config, "SNMP alert fired (" . safe_output($alert->{'description'}) . ")",
0, 0, $alert->{'priority'}, 0, 0, 'alert_fired', 0, $dbh); 0, 0, $alert->{'priority'}, 0, 0, 'alert_fired', 0, $dbh);
} }

View File

@ -33,7 +33,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.744"; my $pandora_version = "7.0NG.744";
my $pandora_build = "200319"; my $pandora_build = "200324";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.744 %define version 7.0NG.744
%define release 200319 %define release 200324
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.744 %define version 7.0NG.744
%define release 200319 %define release 200324
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -9,7 +9,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.744" PI_VERSION="7.0NG.744"
PI_BUILD="200319" PI_BUILD="200324"
MODE=$1 MODE=$1
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then

View File

@ -29,12 +29,13 @@ use Time::HiRes qw(usleep);
# Default lib dir for RPM and DEB packages # Default lib dir for RPM and DEB packages
use lib '/usr/lib/perl5'; use lib '/usr/lib/perl5';
use PandoraFMS::Core;
use PandoraFMS::Tools; use PandoraFMS::Tools;
use PandoraFMS::Config; use PandoraFMS::Config;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0NG.744 PS200319"; my $version = "7.0NG.744 PS200324";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;
@ -1079,7 +1080,8 @@ my $history_dbh = undef;
is_metaconsole(\%conf); is_metaconsole(\%conf);
if ($conf{'_history_db_enabled'} eq '1') { if ($conf{'_history_db_enabled'} eq '1') {
eval { 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 ($@) {
if (is_offline(\%conf)) { if (is_offline(\%conf)) {

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "7.0NG.744 PS200319"; my $version = "7.0NG.744 PS200324";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);
@ -1143,6 +1143,11 @@ sub cli_delete_agent() {
$agent_name = decode_entities($agent_name); $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 (is_metaconsole($conf) == 1) {
if (not defined $use_alias) { if (not defined $use_alias) {
my $agents_groups = enterprise_hook('get_metaconsole_agent',[$dbh, $agent_name]); my $agents_groups = enterprise_hook('get_metaconsole_agent',[$dbh, $agent_name]);

View File

@ -24,47 +24,65 @@
# #
# GPL License: http://www.gnu.org/licenses/gpl.txt # 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 strict;
use Getopt::Std; use Getopt::Std;
my $VERSION = 'v1r1';
my $VERSION = 'v1r2';
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
# HELP # HELP
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
if ($#ARGV == -1 ) { 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 "-H, --host=STRING\n";
print "\tHost IP\n"; print "\tHost IP\n";
print "-c, --community=STRING\n"; print "-c, --community=STRING\n";
print "\tSnmp Community\n"; print "\tSNMP Community\n";
print "-m, --module=STRING\n"; print "-m, --module=STRING\n";
print "\tDefine module (memuse|diskuse|process|cpuload) \n"; print "\tDefine module (memuse|diskuse|process|cpuload) \n";
print "-d, --disk=STRING\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 "-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 "-v, --version=STRING\n";
print "\tVersion of protocol\n"; print "\tSNMP version (Default 2c)\n";
print "-u, --user=STRING\n"; print "-u, --user=STRING\n";
print "\tAuth user\n"; print "\tAuth user\n";
print "-A, --auth=STRING\n";
print "\tAuth pass\n";
print "-l, --level=STRING\n"; print "-l, --level=STRING\n";
print "\tSecurity level\n"; print "\tSecurity level\n";
print "-a STRING\n"; print "-a STRING\n";
print "\tAuth method\n"; print "\tAuth method\n";
print "-A, --auth=STRING\n";
print "\tAuth pass\n";
print "-x STRING\n"; print "-x STRING\n";
print "\tPrivacy method\n"; print "\tPrivacy method\n";
@ -72,10 +90,12 @@ if ($#ARGV == -1 ) {
print "\tPrivacy pass\n"; print "\tPrivacy pass\n";
print "\n"; print "\n";
print "Example of use \n"; print "Usage: \n";
print "perl snmp_remoto.pl -H host -c community -m (memuse|diskuse|process|cpuload) [-p process -d disk] \n"; print "SNMP v1|2|2c:\n" ;
print "\n"; print "\tperl $0 -H host -c community -m (memuse|diskuse|process|cpuload) [-p process -d disk] \n" ;
print "Version=$VERSION\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; exit;
} }
@ -151,104 +171,97 @@ sub options {
$opts{"X"}); $opts{"X"});
} }
#----------------------------------------------------------------------- unless ( $module ~~ ["memuse","cpuload","process","diskuse"] ){
# Module % Memory use print "Error: Invalid or missing argument (-m).\n";
#----------------------------------------------------------------------- print "Available options: memuse | diskuse | process | cpuload \n\n";
if ($module eq "memuse") { exit;
my $memuse = 0; }
my $command_line_parammeters;
if ($version == "3") { unless ($host){
if ($auth_method eq 'authNoPriv') { print "Error: missing host address.\n";
$command_line_parammeters = "-v $version -u $user -a $auth_method -A $pass -l $security_level $host"; exit;
}
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);
} }
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
# 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") { if ($module eq "diskuse") {
my $diskuse = 0; my $diskuse = 0;
my $command_line_parammeters;
if ($version == "3") { unless ($disk){
if ($auth_method eq 'authNoPriv') { print "Error: Invalid or missing argument (-d).\n";
$command_line_parammeters = "-v $version -u $user -a $auth_method -A $pass -l $security_level $host"; exit;
}
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";
} }
if ($disk =~ /\\ /) { if ($disk =~ /\\ /) {
$disk =~ s/\\/\\\\/g; $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 $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 = `snmpget -r 2 $command_line_parammeters .1.3.6.1.2.1.25.2.3.1.5.$diskid ` ; my @disktot= split /\s/, `snmpget -r 2 $command_line_parameters .1.3.6.1.2.1.25.2.3.1.5.$diskid` ;
my $disktot2 = `echo "$disktot" | gawk '{print \$4}'`;
if ($disktot2 == 0) { if ($diskid == ""){
print STDOUT "-1";
print STDERR "Error: Disk or partition not found\n";
exit;
}
if ($disktot[-1] == 0) {
$diskuse = 0; $diskuse = 0;
} }
else { else {
my $diskfree = `snmpget -r 2 $command_line_parammeters .1.3.6.1.2.1.25.2.3.1.6.$diskid` ; my @diskfree = split (/\s/, `snmpget -r 2 $command_line_parameters .1.3.6.1.2.1.25.2.3.1.6.$diskid`) ;
my $diskfree2 = `echo "$diskfree" | gawk '{print \$4}'`;
$diskuse = ($disktot2 - $diskfree2) * 100 / $disktot2; $diskuse = ($disktot[-1] - $diskfree[-1]) * 100 / $disktot[-1];
} }
printf("%.2f", $diskuse); printf("%.2f", $diskuse);
} }
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
# Module Process Status # Process Status module
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
if ($module eq "process") { if ($module eq "process") {
my $status = 0; my $status = 0;
my $command_line_parammeters;
if ($version == "3") { $status = `snmpwalk $command_line_parameters .1.3.6.1.2.1.25.4.2.1.2 2>/dev/null`;
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`;
if ($? == 0) { if ($? == 0) {
print (($status =~ m/$process/mi)?1: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") { if ($module eq "cpuload") {
my $cputotal = 0; my $cputotal = 0;
my $command_line_parammeters;
if ($version == "3") { my $cpuload = `snmpwalk $command_line_parameters .1.3.6.1.2.1.25.3.3.1.2 | gawk '{print \$4}' `;
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 = split(/\n/, $cpuload); my @cpuload = split(/\n/, $cpuload);
my $sum; my $sum;
my $counter = 0; my $counter = 0;