2010-10-21 Sergio Martin <sergio.martin@artica.es>

* lib/PandoraFMS/DB.pm: Added a generic update function to return
	the number of changes

	* util/pandora_manage.pl: Added the unblock policies to the CLI and
	the block/unblock policies when it are applied.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3441 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2010-10-21 14:26:46 +00:00
parent 63d971d91d
commit 3ffd3faecc
3 changed files with 40 additions and 7 deletions

View File

@ -1,3 +1,11 @@
2010-10-21 Sergio Martin <sergio.martin@artica.es>
* lib/PandoraFMS/DB.pm: Added a generic update function to return
the number of changes
* util/pandora_manage.pl: Added the unblock policies to the CLI and
the block/unblock policies when it are applied.
2010-10-21 Junichi Satoh <junichi@rworks.jp> 2010-10-21 Junichi Satoh <junichi@rworks.jp>
* lib/PandoraFMS/Tools.pm: Fixed timeout option for FreeBSD ping. * lib/PandoraFMS/Tools.pm: Fixed timeout option for FreeBSD ping.

View File

@ -32,6 +32,7 @@ our @EXPORT = qw(
db_do db_do
db_process_insert db_process_insert
db_insert db_insert
db_update
get_action_id get_action_id
get_agent_id get_agent_id
get_agent_name get_agent_name
@ -332,6 +333,17 @@ sub db_insert ($$;@) {
return $dbh->{'mysql_insertid'}; return $dbh->{'mysql_insertid'};
} }
##########################################################################
## SQL update. Returns the number of updated rows.
##########################################################################
sub db_update ($$;@) {
my ($dbh, $query, @values) = @_;
my $rows = $dbh->do($query, undef, @values);
return $rows;
}
########################################################################## ##########################################################################
## SQL insert. Returns the ID of the inserted row. ## SQL insert. Returns the ID of the inserted row.
########################################################################## ##########################################################################

View File

@ -533,6 +533,7 @@ sub help_screen{
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_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'); help_screen_line('--delete_not_policy_modules', '', 'Delete all modules without policy from configuration file');
help_screen_line('--apply_policy', '<policy_name>', 'Force apply a policy'); help_screen_line('--apply_policy', '<policy_name>', 'Force apply a policy');
help_screen_line('--force_unblock_policies', '', 'Force unblock the policies');
print "\n"; print "\n";
exit; exit;
} }
@ -1309,6 +1310,14 @@ sub pandora_manage_main ($$$) {
my $configuration_data = ""; my $configuration_data = "";
my $policy_id = enterprise_hook('get_policy_id',[$dbh, $policy_name]); my $policy_id = enterprise_hook('get_policy_id',[$dbh, $policy_name]);
exist_check($policy_id,'policy',$policy_name);
my $blocked_policies = enterprise_hook('pandora_block_policies', [$dbh]);
if($blocked_policies eq '0E0') {
print "[ERROR] The policies are blocked in other terminal.\n\n";
exit;
}
# Get the agents # Get the agents
my $array_pointer_ag = enterprise_hook('get_policy_agents',[$dbh, $policy_id]); my $array_pointer_ag = enterprise_hook('get_policy_agents',[$dbh, $policy_id]);
@ -1400,6 +1409,10 @@ sub pandora_manage_main ($$$) {
enterprise_hook('pandora_create_collection_conf_info',[$conf, $policy_name, $collection_data,$agent_name,$dbh]); enterprise_hook('pandora_create_collection_conf_info',[$conf, $policy_name, $collection_data,$agent_name,$dbh]);
} }
} }
enterprise_hook('pandora_unblock_policies', [$dbh]);
}
elsif ($param eq '--force_unblock_policies') {
enterprise_hook('pandora_unblock_policies', [$dbh]);
} }
else { else {
print "[ERROR] Invalid option '$param'.\n\n"; print "[ERROR] Invalid option '$param'.\n\n";