From 95e4d51e55f52fc35b21282a5f78db1ed323f2e5 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Wed, 19 Oct 2016 13:48:25 +0200 Subject: [PATCH] Added new functions and parameters to pandora cli --- pandora_server/util/pandora_manage.pl | 86 ++++++++++++++++++--------- 1 file changed, 58 insertions(+), 28 deletions(-) diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 46923d5657..ca9e1341d8 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -126,10 +126,11 @@ sub help_screen{ help_screen_line('--get_bad_conf_files', '', 'Get the files bad configured (without essential tokens)'); help_screen_line('--locate_agent', '', 'Search a agent into of nodes of metaconsole. Only Enterprise.'); print "\nMODULES:\n\n" unless $param ne ''; - help_screen_line('--create_data_module', " [ \n\t \n\t \n\t \n\t ]", 'Add data server module to agent'); - help_screen_line('--create_network_module', " \n\t [ \n\t \n\t \n\t ]", 'Add not snmp network module to agent'); - help_screen_line('--create_snmp_module', " \n\t [ \n\t \n\t \n\t \n\t \n\t ]", 'Add snmp network module to agent'); - help_screen_line('--create_plugin_module', " \n\t [ \n\t \n\t \n\t \n\t ]", 'Add plug-in module to agent'); + help_screen_line('--create_data_module', " [ \n\t \n\t \n\t \n\t \n\t ]", 'Add data server module to agent'); + help_screen_line('--create_network_module', " \n\t [ \n\t \n\t \n\t \n\t ]", 'Add not snmp network module to agent'); + help_screen_line('--create_snmp_module', " \n\t [ \n\t \n\t \n\t \n\t \n\t + \n\t ]", 'Add snmp network module to agent'); + help_screen_line('--create_plugin_module', " \n\t [ \n\t \n\t \n\t \n\t \n\t ]", 'Add plug-in module to agent'); help_screen_line('--create_module_group', ''); help_screen_line('--delete_module', 'Delete module from agent', ' '); help_screen_line('--data_module', " \n\t []", 'Insert data to module'); @@ -184,10 +185,11 @@ sub help_screen{ help_screen_line('--delete_not_policy_modules', '', 'Delete all modules without policy from configuration file'); help_screen_line('--disable_policy_alerts', '', 'Disable all the alerts of a policy'); help_screen_line('--create_policy', ' '); - help_screen_line('--create_policy_data_module', " [ \n\t \n\t \n\t \n\t \n\t ]", 'Add data server module to policy'); - help_screen_line('--create_policy_network_module', " [ \n\t \n\t \n\t \n\t ]", "Add not snmp network module to policy"); - help_screen_line('--create_policy_snmp_module', " \n\t [ \n\t \n\t \n\t \n\t \n\t ]", 'Add snmp network module to policy'); - help_screen_line('--create_policy_plugin_module', " \n\t [ \n\t \n\t \n\t \n\t ]", 'Add plug-in module to policy'); + help_screen_line('--create_policy_data_module', " [ \n\t \n\t \n\t \n\t \n\t ]", 'Add data server module to policy'); + help_screen_line('--create_policy_network_module', " [ \n\t \n\t \n\t \n\t \n\t ]", "Add not snmp network module to policy"); + help_screen_line('--create_policy_snmp_module', " \n\t [ \n\t \n\t \n\t \n\t \n\t \n\t + ]", 'Add snmp network module to policy'); + help_screen_line('--create_policy_plugin_module', " \n\t [ \n\t \n\t \n\t \n\t \n\t ]", 'Add plug-in module to policy'); help_screen_line('--create_policy_data_module_from_local_component', ' '); help_screen_line('--add_collection_to_policy', " "); help_screen_line('--validate_policy_alerts', '', 'Validate the alerts of a given policy'); @@ -1149,21 +1151,21 @@ sub cli_create_data_module($) { $min,$max,$post_process, $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $definition_file, $configuration_data, $warning_str, $critical_str, $enable_unknown_events, $ff_threshold, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $ff_timeout, - $warning_inverse, $critical_inverse); + $warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions); if ($in_policy == 0) { ($module_name, $module_type, $agent_name, $description, $module_group, $min,$max,$post_process, $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $definition_file, $warning_str, $critical_str, $enable_unknown_events, $ff_threshold, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $ff_timeout, - $warning_inverse, $critical_inverse) = @ARGV[2..27]; + $warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions) = @ARGV[2..30]; } else { ($policy_name, $module_name, $module_type, $description, $module_group, $min,$max,$post_process, $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $configuration_data, $warning_str, $critical_str, $enable_unknown_events, $ff_threshold, $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $ff_timeout, - $warning_inverse, $critical_inverse) = @ARGV[2..28]; + $warning_inverse, $critical_inverse, $critical_instructions, $warning_instructions, $unknown_instructions) = @ARGV[2..31]; } my $module_name_def; @@ -1307,6 +1309,9 @@ sub cli_create_data_module($) { $parameters{'ff_timeout'} = $ff_timeout unless !defined ($ff_timeout); $parameters{'critical_inverse'} = $critical_inverse unless !defined ($critical_inverse); $parameters{'warning_inverse'} = $warning_inverse unless !defined ($warning_inverse); + $parameters{'critical_instructions'} = $critical_instructions unless !defined ($critical_instructions); + $parameters{'warning_instructions'} = $warning_instructions unless !defined ($warning_instructions); + $parameters{'unknown_instructions'} = $unknown_instructions unless !defined ($unknown_instructions); if ($in_policy == 0) { pandora_create_module_from_hash ($conf, \%parameters, $dbh); @@ -1382,21 +1387,22 @@ sub cli_create_network_module($) { my ($policy_name, $module_name, $module_type, $agent_name, $module_address, $module_port, $description, $module_group, $min, $max, $post_process, $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, $each_ff, - $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, $retries); + $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, $retries, $critical_instructions, + $warning_instructions, $unknown_instructions); if ($in_policy == 0) { ($module_name, $module_type, $agent_name, $module_address, $module_port, $description, $module_group, $min, $max, $post_process, $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, $each_ff, $ff_threshold_normal, $ff_threshold_warning, - $ff_threshold_critical, $timeout, $retries) = @ARGV[2..27]; + $ff_threshold_critical, $timeout, $retries,$critical_instructions, $warning_instructions, $unknown_instructions) = @ARGV[2..30]; } else { ($policy_name, $module_name, $module_type, $module_port, $description, $module_group, $min, $max, $post_process, $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, $each_ff, $ff_threshold_normal, $ff_threshold_warning, - $ff_threshold_critical, $timeout, $retries) = @ARGV[2..26]; + $ff_threshold_critical, $timeout, $retries, $critical_instructions, $warning_instructions, $unknown_instructions) = @ARGV[2..29]; } my $module_name_def; @@ -1508,6 +1514,9 @@ sub cli_create_network_module($) { $parameters{'min_ff_event_critical'} = $ff_threshold_critical unless !defined ($ff_threshold_critical); $parameters{'max_timeout'} = $timeout unless !defined ($timeout); $parameters{'max_retries'} = $retries unless !defined ($retries); + $parameters{'critical_instructions'} = $critical_instructions unless !defined ($critical_instructions); + $parameters{'warning_instructions'} = $warning_instructions unless !defined ($warning_instructions); + $parameters{'unknown_instructions'} = $unknown_instructions unless !defined ($unknown_instructions); if ($in_policy == 0) { pandora_create_module_from_hash ($conf, \%parameters, $dbh); @@ -1528,21 +1537,24 @@ sub cli_create_snmp_module($) { $oid, $description, $module_group, $min, $max, $post_process, $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $snmp3_priv_method, $snmp3_priv_pass, $snmp3_sec_level, $snmp3_auth_method, $snmp3_auth_user, $snmp3_auth_pass, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, - $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, $retries); + $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, $retries, + $critical_instructions, $warning_instructions, $unknown_instructions); if ($in_policy == 0) { ($module_name, $module_type, $agent_name, $module_address, $module_port, $version, $community, $oid, $description, $module_group, $min, $max, $post_process, $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $snmp3_priv_method, $snmp3_priv_pass, $snmp3_sec_level, $snmp3_auth_method, $snmp3_auth_user, $snmp3_auth_pass, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, - $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, $retries) = @ARGV[2..36]; + $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, $retries, + $critical_instructions, $warning_instructions, $unknown_instructions) = @ARGV[2..39]; } else { ($policy_name, $module_name, $module_type, $module_port, $version, $community, $oid, $description, $module_group, $min, $max, $post_process, $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $snmp3_priv_method, $snmp3_priv_pass, $snmp3_sec_level, $snmp3_auth_method, $snmp3_auth_user, $snmp3_auth_pass, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, - $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, $retries) = @ARGV[2..35]; + $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, $retries, + $critical_instructions, $warning_instructions, $unknown_instructions) = @ARGV[2..38]; } my $module_name_def; @@ -1659,6 +1671,9 @@ sub cli_create_snmp_module($) { $parameters{'min_ff_event_critical'} = $ff_threshold_critical unless !defined ($ff_threshold_critical); $parameters{'max_timeout'} = $timeout unless !defined ($timeout); $parameters{'max_retries'} = $retries unless !defined ($retries); + $parameters{'critical_instructions'} = $critical_instructions unless !defined ($critical_instructions); + $parameters{'warning_instructions'} = $warning_instructions unless !defined ($warning_instructions); + $parameters{'unknown_instructions'} = $unknown_instructions unless !defined ($unknown_instructions); if ($in_policy == 0) { pandora_create_module_from_hash ($conf, \%parameters, $dbh); @@ -1679,21 +1694,24 @@ sub cli_create_plugin_module($) { $user, $password, $params, $description, $module_group, $min, $max, $post_process, $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, - $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout); + $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, + $critical_instructions, $warning_instructions, $unknown_instructions); if ($in_policy == 0) { ($module_name, $module_type, $agent_name, $module_address, $module_port, $plugin_name, $user, $password, $params, $description, $module_group, $min, $max, $post_process, $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, - $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout) = @ARGV[2..30]; + $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, + $critical_instructions, $warning_instructions, $unknown_instructions) = @ARGV[2..33]; } else { ($policy_name, $module_name, $module_type, $module_port, $plugin_name, $user, $password, $params, $description, $module_group, $min, $max, $post_process, $interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data, $ff_threshold, $warning_str, $critical_str, $enable_unknown_events, - $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout) = @ARGV[2..29]; + $each_ff, $ff_threshold_normal, $ff_threshold_warning, $ff_threshold_critical, $timeout, + $critical_instructions, $warning_instructions, $unknown_instructions) = @ARGV[2..32]; } my $module_name_def; @@ -1825,6 +1843,9 @@ sub cli_create_plugin_module($) { $parameters{'min_ff_event_warning'} = $ff_threshold_warning unless !defined ($ff_threshold_warning); $parameters{'min_ff_event_critical'} = $ff_threshold_critical unless !defined ($ff_threshold_critical); $parameters{'max_timeout'} = $timeout unless !defined ($timeout); + $parameters{'critical_instructions'} = $critical_instructions unless !defined ($critical_instructions); + $parameters{'warning_instructions'} = $warning_instructions unless !defined ($warning_instructions); + $parameters{'unknown_instructions'} = $unknown_instructions unless !defined ($unknown_instructions); if ($in_policy == 0) { pandora_create_module_from_hash ($conf, \%parameters, $dbh); @@ -2524,6 +2545,15 @@ sub cli_module_update() { elsif ($field eq 'ff_threshold_critical') { $field = 'min_ff_event_critical'; } + elsif ($field eq 'critical_instructions') { + $field = 'critical_instructions'; + } + elsif ($field eq 'warning_instructions') { + $field = 'warning_instructions'; + } + elsif ($field eq 'unknown_instructions') { + $field = 'unknown_instructions'; + } else { # If is not a common value, check type and call type update funtion my $type = pandora_get_module_type($dbh,$id_agent_module); @@ -4520,7 +4550,7 @@ sub pandora_manage_main ($$$) { cli_delete_agent(); } elsif ($param eq '--create_data_module') { - param_check($ltotal, 27, 24); + param_check($ltotal, 30, 24); cli_create_data_module(0); } elsif ($param eq '--create_module_group') { @@ -4528,15 +4558,15 @@ sub pandora_manage_main ($$$) { cli_create_module_group(); } elsif ($param eq '--create_network_module') { - param_check($ltotal, 24, 20); + param_check($ltotal, 30, 20); cli_create_network_module(0); } elsif ($param eq '--create_snmp_module') { - param_check($ltotal, 35, 28); + param_check($ltotal, 38, 28); cli_create_snmp_module(0); } elsif ($param eq '--create_plugin_module') { - param_check($ltotal, 29, 19); + param_check($ltotal, 32, 19); cli_create_plugin_module(0); } elsif ($param eq '--delete_module') { @@ -4672,19 +4702,19 @@ sub pandora_manage_main ($$$) { cli_create_policy(); } elsif ($param eq '--create_policy_data_module') { - param_check($ltotal, 23, 20); + param_check($ltotal, 26, 20); cli_create_data_module(1); } elsif ($param eq '--create_policy_network_module') { - param_check($ltotal, 23, 20); + param_check($ltotal, 26, 20); cli_create_network_module(1); } elsif ($param eq '--create_policy_snmp_module') { - param_check($ltotal, 32, 27); + param_check($ltotal, 35, 27); cli_create_snmp_module(1); } elsif ($param eq '--create_policy_plugin_module') { - param_check($ltotal, 27, 19); + param_check($ltotal, 30, 19); cli_create_plugin_module(1); } elsif ($param eq '--create_alert_template') {