From c12a6c1e3a2fd3345c3046c5c226c5dfd81bc871 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 5 Jan 2016 13:17:35 +0100 Subject: [PATCH] Added documentation for locale_agent call. TICKET: #3119 (cherry picked from commit aceb7ac34fafd26efb7a47ff6b1f23a5376db89c) Conflicts: pandora_server/util/pandora_manage.pl --- pandora_server/util/pandora_manage.pl | 86 ++++++++++++++------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 299b5b289d..c6ad6ad80f 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -84,15 +84,15 @@ db_disconnect ($history_dbh) if defined ($history_dbh); db_disconnect ($dbh); exit; -############################################################################### -############################################################################### +######################################################################## +######################################################################## # GENERAL FUNCTIONS -############################################################################### -############################################################################### +######################################################################## +######################################################################## -############################################################################## +######################################################################## # Print a help screen and exit. -############################################################################## +######################################################################## sub help_screen{ print "\nPandora FMS CLI $version Copyright (c) 2013-2015 Artica ST\n"; print "This program is Free Software, licensed under the terms of GPL License v2\n"; @@ -102,12 +102,12 @@ sub help_screen{ print "Available options by category:\n\n" unless $param ne ''; print "Available options for $param:\n\n" unless $param eq ''; print "AGENTS:\n\n" unless $param ne ''; - help_screen_line('--create_agent', " \n\t [
]", 'Create agent'); - help_screen_line('--update_agent', ' ', "Update an agent field. The fields can be \n\t the following: agent_name, address, description, group_name, interval, os_name, disabled (0-1), \n\t parent_name, cascade_protection (0-1), icon_path, update_gis_data (0-1), custom_id"); + help_screen_line('--create_agent', " \n\t [
]", 'Create agent'); + help_screen_line('--update_agent', ' ', "Update an agent field. The fields can be \n\t the following: agent_name, address, description, group_name, interval, os_name, disabled (0-1), \n\t parent_name, cascade_protection (0-1), icon_path, update_gis_data (0-1), custom_id"); help_screen_line('--delete_agent', '', 'Delete agent'); help_screen_line('--disable_group', '', 'Disable agents from an entire group'); - help_screen_line('--enable_group', '', 'Enable agents from an entire group'); - help_screen_line('--create_group', ' [ ]', 'Create an agent group'); + help_screen_line('--enable_group', '', 'Enable agents from an entire group'); + help_screen_line('--create_group', ' [ ]', 'Create an agent group'); help_screen_line('--stop_downtime', '', 'Stop a planned downtime'); help_screen_line('--create_downtime', " \n\t \n\t ", 'Create a planned downtime'); help_screen_line('--add_item_planned_downtime', " ", 'Add a items planned downtime'); @@ -121,6 +121,7 @@ sub help_screen{ help_screen_line('--delete_conf_file', '', 'Delete a local conf of a given agent'); help_screen_line('--clean_conf_file', '', "Clean a local conf of a given agent deleting all modules, \n\t policies, file collections and comments"); 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'); @@ -150,33 +151,33 @@ sub help_screen{ help_screen_line('--update_special_day', " ", 'Update a field of a special day'); help_screen_line('--create_data_module_from_local_component', ' ', "Create a new data \n\t module from a local component"); help_screen_line('--create_local_component', " [ \n\t \n\t \n\t \n\t \n\t \n\t \n\t \n\t ]", 'Create local component'); - + print "\nUSERS:\n\n" unless $param ne ''; - help_screen_line('--create_user', ' []', 'Create user'); - help_screen_line('--delete_user', '', 'Delete user'); - help_screen_line('--update_user', ' ', "Update a user field. The fields\n\t can be the following: email, phone, is_admin (0-1), language, id_skin, flash_chart (0-1)\n\t , comments, fullname, password"); - help_screen_line('--enable_user', '', 'Enable a given user'); - help_screen_line('--disable_user', '', 'Disable a given user'); - help_screen_line('--create_profile', ' ', 'Add perfil to user'); - help_screen_line('--delete_profile', ' ', 'Delete perfil from user'); - help_screen_line('--add_profile_to_user', ' []', 'Add a profile in group to a user'); + help_screen_line('--create_user', ' []', 'Create user'); + help_screen_line('--delete_user', '', 'Delete user'); + help_screen_line('--update_user', ' ', "Update a user field. The fields\n\t can be the following: email, phone, is_admin (0-1), language, id_skin, flash_chart (0-1)\n\t , comments, fullname, password"); + help_screen_line('--enable_user', '', 'Enable a given user'); + help_screen_line('--disable_user', '', 'Disable a given user'); + help_screen_line('--create_profile', ' ', 'Add perfil to user'); + help_screen_line('--delete_profile', ' ', 'Delete perfil from user'); + help_screen_line('--add_profile_to_user', ' []', 'Add a profile in group to a user'); help_screen_line('--disable_eacl', '', 'Disable enterprise ACL system'); help_screen_line('--enable_eacl', '', 'Enable enterprise ACL system'); help_screen_line('--disable_double_auth', '', 'Disable the double authentication for the specified user'); print "\nEVENTS:\n\n" unless $param ne ''; help_screen_line('--create_event', " [ \n\t \n\t ]", 'Add event'); - help_screen_line('--validate_event', " \n\t ", 'Validate events'); - help_screen_line('--validate_event_id', '', 'Validate event given a event id'); - help_screen_line('--get_event_info', '[]', 'Show info about a event given a event id'); + help_screen_line('--validate_event', " \n\t ", 'Validate events'); + help_screen_line('--validate_event_id', '', 'Validate event given a event id'); + help_screen_line('--get_event_info', '[]', 'Show info about a event given a event id'); help_screen_line('--add_event_comment', ' ', 'Add event\'s comment'); print "\nINCIDENTS:\n\n" unless $param ne ''; - help_screen_line('--create_incident', " <description> <origin> <status> <priority 0 for Informative, \n\t 1 for Low, 2 for Medium, 3 for Serious, 4 for Very serious or 5 for Maintenance>\n\t <group> [<owner>]", 'Create incidents'); + help_screen_line('--create_incident', "<title> <description> <origin> <status> <priority 0 for Informative, \n\t 1 for Low, 2 for Medium, 3 for Serious, 4 for Very serious or 5 for Maintenance>\n\t <group> [<owner>]", 'Create incidents'); print "\nPOLICIES:\n\n" unless $param ne ''; - help_screen_line('--apply_policy', '<policy_name>', 'Force apply a policy'); - help_screen_line('--apply_all_policies', '', 'Force apply to all the policies'); - help_screen_line('--add_agent_to_policy', '<agent_name> <policy_name>', 'Add an agent to a policy'); - help_screen_line('--delete_not_policy_modules', '', 'Delete all modules without policy from configuration file'); - help_screen_line('--disable_policy_alerts', '<policy_name>', 'Disable all the alerts of a policy'); + help_screen_line('--apply_policy', '<policy_name>', 'Force apply a policy'); + help_screen_line('--apply_all_policies', '', 'Force apply to all the policies'); + help_screen_line('--add_agent_to_policy', '<agent_name> <policy_name>', 'Add an agent to a policy'); + help_screen_line('--delete_not_policy_modules', '', 'Delete all modules without policy from configuration file'); + help_screen_line('--disable_policy_alerts', '<policy_name>', 'Disable all the alerts of a policy'); help_screen_line('--create_policy_data_module', "<policy_name> <module_name> <module_type> [<description> \n\t <module_group> <min> <max> <post_process> <interval> <warning_min> <warning_max> \n\t <critical_min> <critical_max> <history_data> <data_configuration> <warning_str> \n\t <critical_str> <unknown_events> <ff_threshold> <each_ff>\n\t <ff_threshold_normal> <ff_threshold_warning> <ff_threshold_critical>\n\t <ff_timeout>]", 'Add data server module to policy'); help_screen_line('--create_policy_network_module', "<policy_name> <module_name> <module_type> [<module_port> \n\t <description> <module_group> <min> <max> <post_process> <interval> \n\t <warning_min> <warning_max> <critical_min> <critical_max> <history_data> <ff_threshold> \n\t <warning_str> <critical_str> <unknown_events> <each_ff>\n\t <ff_threshold_normal> <ff_threshold_warning> <ff_threshold_critical>]", "Add not snmp network module to policy"); help_screen_line('--create_policy_snmp_module', "<policy_name> <module_name> <module_type> <module_port> \n\t <version> [<community> <oid> <description> <module_group> <min> <max> \n\t <post_process> <interval> <warning_min> <warning_max> <critical_min> <critical_max> <history_data>\n\t <snmp3_priv_method> <snmp3_priv_pass> <snmp3_sec_level> <snmp3_auth_method> <snmp3_auth_user> \n\t <snmp3_priv_pass> <ff_threshold> <warning_str> <critical_str>\n\t <unknown_events> <each_ff> <ff_threshold_normal>\n\t <ff_threshold_warning> <ff_threshold_critical>]", 'Add snmp network module to policy'); @@ -185,12 +186,12 @@ sub help_screen{ help_screen_line('--get_policy_modules', '<policy_name>', 'Get the modules of a policy'); help_screen_line('--get_policies', '[<agent_name>]', "Get all the policies (without parameters) or \n\tthe policies of a given agent (agent name as parameter)"); help_screen_line('--recreate_collection', '<collection_id>', 'Recreate the files of a collection'); - + print "\nNETFLOW:\n\n" unless $param ne ''; help_screen_line('--create_netflow_filter', "<filter_name> <group_name> <filter> \n\t <aggregate_by dstip|dstport|none|proto|srcip|srcport> <output_format kilobytes|kilobytespersecond|\n\t megabytes|megabytespersecond>", "Create a new netflow filter"); print "\nTOOLS:\n\n" unless $param ne ''; help_screen_line('--exec_from_file', '<file_path> <option_to_execute> <option_params>', "Execute any CLI option \n\t with macros from CSV file"); - help_screen_line('--create_snmp_trap', '<name> <oid> <description> <severity>', "Create a new trap definition. \n\tSeverity 0 (Maintenance), 1(Info) , 2 (Normal), 3 (Warning), 4 (Critical), 5 (Minor) and 6 (Major)"); + help_screen_line('--create_snmp_trap', '<name> <oid> <description> <severity>', "Create a new trap definition. \n\tSeverity 0 (Maintenance), 1(Info) , 2 (Normal), 3 (Warning), 4 (Critical), 5 (Minor) and 6 (Major)"); print "\nSETUP:\n\n" unless $param ne ''; help_screen_line('--set_event_storm_protection', '<value>', "Enable (1) or disable (0) event \n\t storm protection"); @@ -198,18 +199,18 @@ sub help_screen{ help_screen_line('--create_tag', '<tag_name> <tag_description> [<tag_url>] [<tag_email>]', 'Create a new tag'); help_screen_line('--add_tag_to_user_profile', '<user_id> <tag_name> <group_name> <profile_name>', 'Add a tag to the given user profile'); help_screen_line('--add_tag_to_module', '<agent_name> <module_name> <tag_name>', 'Add a tag to the given module'); - - print "\n"; + + print "\n"; exit; } -############################################################################### +######################################################################## # -############################################################################### +######################################################################## sub api_call($$$;$$$) { my ($pa_config, $op, $op2, $id, $id2, $other) = @_; my $content = undef; - + eval { # Set the parameters for the POST request. my $params = {}; @@ -227,14 +228,15 @@ sub api_call($$$;$$$) { my $ua = new LWP::UserAgent; my $url = $pa_config->{"console_api_url"}; my $response = $ua->post($url, $params); - + if ($response->is_success) { $content = $response->decoded_content(); - } else { + } + else { $content = $response->decoded_content(); } }; - + return $content; } @@ -262,7 +264,7 @@ sub pandora_enable_group ($$$) { if ($group == 0){ db_do ($dbh, "UPDATE tagente SET disabled = 0"); } - else { + else { db_do ($dbh, "UPDATE tagente SET disabled = 0 WHERE id_grupo = $group"); } exit; @@ -272,13 +274,13 @@ sub pandora_enable_group ($$$) { # Init screen ############################################################################## sub pandora_manage_init ($) { - my $conf = shift; - + my $conf = shift; + $conf->{"verbosity"}=0; # Verbose 1 by default $conf->{"daemon"}=0; # Daemon 0 by default $conf->{'PID'}=""; # PID file not exist by default $conf->{"quiet"}=0; # Daemon 0 by default - + # Load config file from command line help_screen () if ($#ARGV < 0);