From dfac299c4a6729e98ac82d99d3c05bb5f5aa93be Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Mon, 20 Sep 2010 15:25:15 +0000 Subject: [PATCH] 2010-09-20 Sergio Martin * util/pandora_manage.pl: Improved the last feature of CLI deleting the modules of all conf files of the incoming directory now git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3261 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 6 ++++++ pandora_server/util/pandora_manage.pl | 25 ++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 9b9c46d65f..1ada2d2a12 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,9 @@ +2010-09-20 Sergio Martin + + * util/pandora_manage.pl: Improved the last feature + of CLI deleting the modules of all conf files of + the incoming directory now + 2010-09-20 Sergio Martin * util/pandora_manage.pl: Added to CLI the deletion diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 0deac09466..70cd2e68aa 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -698,7 +698,7 @@ sub help_screen{ help_screen_line('--validate_event', ' ', 'Validate events'); help_screen_line('--create_incident', ' <description> <origin> <status> <priority 0 for Informative, 1 for Low, 2 for Medium, 3 for Serious, 4 for Very serious or 5 for Maintenance> <group> [<owner>]', 'Create incidents'); help_screen_line('--delete_data', '-m <module_name> <agent_name> | -a <agent_name> | -g <group_name>', 'Delete historic data of a module, the modules of an agent or the modules of the agents of a group'); - help_screen_line('--delete_not_policy_modules', 'Delete all modules without policy from configuration file', '<agent_conf_file>'); + help_screen_line('--delete_not_policy_modules', '', 'Delete all modules without policy from configuration file'); print "\n"; exit; } @@ -998,11 +998,26 @@ sub pandora_manage_main ($$$) { } elsif ($param =~ m/--delete_not_policy_modules/i) { - param_check($ltotal, 1); - my $conf_file = @ARGV[2]; + param_check($ltotal, 0); - print "[INFO] Deleting modules without policy from conf file \n\n"; - pandora_delete_not_policy_modules($conf_file); + my $incomingdir; + + $incomingdir = $conf->{incomingdir}.'/conf/'; + + # Open the folder + opendir FOLDER, $incomingdir || die "[ERROR] Opening incoming directory"; + + # Store the list of files + my @files = readdir(FOLDER); + my $file; + + print "[INFO] Deleting modules without policy from conf files \n\n"; + foreach $file (@files) + { + if($file ne '.' && $file ne '..') { + pandora_delete_not_policy_modules($incomingdir.$file); + } + } } elsif ($param =~ m/--create_template_module/i) { param_check($ltotal, 3);