2011-09-26 Vanessa Gil <vanessa.gil@artica.es>
* pandora_server/util/pandora_manage.pl: Fixed bad behaviour of several Pandora CLI options. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5005 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
65fe37d9da
commit
ae27a60b55
|
@ -1,3 +1,8 @@
|
|||
2011-09-26 Vanessa Gil <vanessa.gil@artica.es>
|
||||
|
||||
* pandora_server/util/pandora_manage.pl: Fixed bad behaviour of several
|
||||
Pandora CLI options.
|
||||
|
||||
2011-09-23 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* util/pandora_db.pl: Fixed bug when a blank space was behind
|
||||
|
|
|
@ -202,6 +202,7 @@ sub pandora_delete_template_module_action ($$$) {
|
|||
sub pandora_create_user ($$$$$) {
|
||||
my ($dbh, $name, $password, $is_admin, $comments) = @_;
|
||||
|
||||
|
||||
return db_insert ($dbh, 'id_user', 'INSERT INTO tusuario (id_user, fullname, password, comments, is_admin)
|
||||
VALUES (?, ?, ?, ?, ?)', $name, $name, $password, $comments, $is_admin);
|
||||
}
|
||||
|
@ -500,11 +501,6 @@ sub pandora_manage_main ($$$) {
|
|||
elsif ($param eq '--disable_group') {
|
||||
param_check($ltotal, 1);
|
||||
my $group_name = @ARGV[2];
|
||||
|
||||
# Remove spaces
|
||||
$group_name =~ s/^\s+//;
|
||||
$group_name =~ s/\s*$//;
|
||||
|
||||
my $id_group;
|
||||
|
||||
if($group_name eq "All") {
|
||||
|
@ -522,11 +518,6 @@ sub pandora_manage_main ($$$) {
|
|||
elsif ($param eq '--enable_group') {
|
||||
param_check($ltotal, 1);
|
||||
my $group_name = @ARGV[2];
|
||||
|
||||
# Remove spaces
|
||||
$group_name =~ s/^\s+//;
|
||||
$group_name =~ s/\s*$//;
|
||||
|
||||
my $id_group;
|
||||
|
||||
if($group_name eq "All") {
|
||||
|
@ -545,10 +536,6 @@ sub pandora_manage_main ($$$) {
|
|||
param_check($ltotal, 7, 3);
|
||||
my ($agent_name,$os_name,$group_name,$server_name,$address,$description,$interval) = @ARGV[2..8];
|
||||
|
||||
# Remove spaces
|
||||
$agent_name =~ s/^\s+//;
|
||||
$agent_name =~ s/\s*$//;
|
||||
|
||||
print "[INFO] Creating agent '$agent_name'\n\n";
|
||||
|
||||
$address = '' unless defined ($address);
|
||||
|
@ -565,10 +552,6 @@ sub pandora_manage_main ($$$) {
|
|||
param_check($ltotal, 1);
|
||||
my $agent_name = @ARGV[2];
|
||||
|
||||
# Remove spaces
|
||||
$agent_name =~ s/^\s+//;
|
||||
$agent_name =~ s/\s*$//;
|
||||
|
||||
$agent_name = decode_entities($agent_name);
|
||||
print "[INFO] Deleting agent '$agent_name'\n\n";
|
||||
|
||||
|
@ -587,13 +570,6 @@ sub pandora_manage_main ($$$) {
|
|||
my $module_name_def;
|
||||
my $module_type_def;
|
||||
|
||||
# Remove spaces
|
||||
$agent_name =~ s/^\s+//;
|
||||
$agent_name =~ s/\s*$//;
|
||||
|
||||
$module_name =~ s/^\s+//;
|
||||
$module_name =~ s/\s*$//;
|
||||
|
||||
print "[INFO] Adding module '$module_name' to agent '$agent_name'\n\n";
|
||||
|
||||
# If the module is local, we add it to the conf file
|
||||
|
@ -758,13 +734,6 @@ sub pandora_manage_main ($$$) {
|
|||
my $module_name_def;
|
||||
my $module_type_def;
|
||||
|
||||
# Remove spaces
|
||||
$agent_name =~ s/^\s+//;
|
||||
$agent_name =~ s/\s*$//;
|
||||
|
||||
$module_name =~ s/^\s+//;
|
||||
$module_name =~ s/\s*$//;
|
||||
|
||||
print "[INFO] Adding snmp module '$module_name' to agent '$agent_name'\n\n";
|
||||
|
||||
# The get_module_id has wrong name. Change in future
|
||||
|
@ -836,13 +805,6 @@ sub pandora_manage_main ($$$) {
|
|||
my $module_name_def;
|
||||
my $module_type_def;
|
||||
|
||||
# Remove spaces
|
||||
$agent_name =~ s/^\s+//;
|
||||
$agent_name =~ s/\s*$//;
|
||||
|
||||
$module_name =~ s/^\s+//;
|
||||
$module_name =~ s/\s*$//;
|
||||
|
||||
print "[INFO] Adding module '$module_name' to agent '$agent_name'\n\n";
|
||||
|
||||
# The get_module_id has wrong name. Change in future
|
||||
|
@ -901,13 +863,6 @@ sub pandora_manage_main ($$$) {
|
|||
param_check($ltotal, 2);
|
||||
my ($module_name,$agent_name) = @ARGV[2..3];
|
||||
|
||||
# Remove spaces
|
||||
$agent_name =~ s/^\s+//;
|
||||
$agent_name =~ s/\s*$//;
|
||||
|
||||
$module_name =~ s/^\s+//;
|
||||
$module_name =~ s/\s*$//;
|
||||
|
||||
print "[INFO] Deleting module '$module_name' from agent '$agent_name' \n\n";
|
||||
|
||||
my $id_agent = get_agent_id($dbh,$agent_name);
|
||||
|
@ -950,16 +905,6 @@ sub pandora_manage_main ($$$) {
|
|||
param_check($ltotal, 3);
|
||||
my ($template_name,$module_name,$agent_name) = @ARGV[2..4];
|
||||
|
||||
# Remove spaces
|
||||
$agent_name =~ s/^\s+//;
|
||||
$agent_name =~ s/\s*$//;
|
||||
|
||||
$module_name =~ s/^\s+//;
|
||||
$module_name =~ s/\s*$//;
|
||||
|
||||
$template_name =~ s/^\s+//;
|
||||
$template_name =~ s/\s*$//;
|
||||
|
||||
print "[INFO] Adding template '$template_name' to module '$module_name' from agent '$agent_name' \n\n";
|
||||
|
||||
my $id_agent = get_agent_id($dbh,$agent_name);
|
||||
|
@ -975,16 +920,6 @@ sub pandora_manage_main ($$$) {
|
|||
param_check($ltotal, 3);
|
||||
my ($template_name,$module_name,$agent_name) = @ARGV[2..4];
|
||||
|
||||
# Remove spaces
|
||||
$agent_name =~ s/^\s+//;
|
||||
$agent_name =~ s/\s*$//;
|
||||
|
||||
$module_name =~ s/^\s+//;
|
||||
$module_name =~ s/\s*$//;
|
||||
|
||||
$template_name =~ s/^\s+//;
|
||||
$template_name =~ s/\s*$//;
|
||||
|
||||
print "[INFO] Delete template '$template_name' from module '$module_name' from agent '$agent_name' \n\n";
|
||||
|
||||
my $id_agent = get_agent_id($dbh,$agent_name);
|
||||
|
@ -1003,19 +938,6 @@ sub pandora_manage_main ($$$) {
|
|||
param_check($ltotal, 6, 2);
|
||||
my ($action_name,$template_name,$module_name,$agent_name,$fires_min,$fires_max) = @ARGV[2..7];
|
||||
|
||||
# Remove spaces
|
||||
$agent_name =~ s/^\s+//;
|
||||
$agent_name =~ s/\s*$//;
|
||||
|
||||
$module_name =~ s/^\s+//;
|
||||
$module_name =~ s/\s*$//;
|
||||
|
||||
$template_name =~ s/^\s+//;
|
||||
$template_name =~ s/\s*$//;
|
||||
|
||||
$action_name =~ s/^\s+//;
|
||||
$action_name =~ s/\s*$//;
|
||||
|
||||
print "[INFO] Adding action '$action_name' to template '$template_name' in module '$module_name' from agent '$agent_name' with $fires_min min. fires and $fires_max max. fires\n\n";
|
||||
|
||||
my $id_agent = get_agent_id($dbh,$agent_name);
|
||||
|
@ -1045,19 +967,6 @@ sub pandora_manage_main ($$$) {
|
|||
param_check($ltotal, 4);
|
||||
my ($action_name,$template_name,$module_name,$agent_name) = @ARGV[2..5];
|
||||
|
||||
# Remove spaces
|
||||
$agent_name =~ s/^\s+//;
|
||||
$agent_name =~ s/\s*$//;
|
||||
|
||||
$module_name =~ s/^\s+//;
|
||||
$module_name =~ s/\s*$//;
|
||||
|
||||
$template_name =~ s/^\s+//;
|
||||
$template_name =~ s/\s*$//;
|
||||
|
||||
$action_name =~ s/^\s+//;
|
||||
$action_name =~ s/\s*$//;
|
||||
|
||||
print "[INFO] Deleting action '$action_name' from template '$template_name' in module '$module_name' from agent '$agent_name')\n\n";
|
||||
|
||||
my $id_agent = get_agent_id($dbh,$agent_name);
|
||||
|
@ -1076,17 +985,6 @@ sub pandora_manage_main ($$$) {
|
|||
elsif ($param eq '--data_module') {
|
||||
param_check($ltotal, 5, 1);
|
||||
my ($server_name,$agent_name,$module_name,$module_type,$datetime) = @ARGV[2..6];
|
||||
|
||||
# Remove spaces
|
||||
$agent_name =~ s/^\s+//;
|
||||
$agent_name =~ s/\s*$//;
|
||||
|
||||
$module_name =~ s/^\s+//;
|
||||
$module_name =~ s/\s*$//;
|
||||
|
||||
$server_name =~ s/^\s+//;
|
||||
$server_name =~ s/\s*$//;
|
||||
|
||||
my $utimestamp;
|
||||
|
||||
if(defined($datetime)) {
|
||||
|
@ -1129,10 +1027,6 @@ sub pandora_manage_main ($$$) {
|
|||
param_check($ltotal, 4, 1);
|
||||
my ($user_name,$password,$is_admin,$comments) = @ARGV[2..5];
|
||||
|
||||
# Remove spaces
|
||||
$user_name =~ s/^\s+//;
|
||||
$user_name =~ s/\s*$//;
|
||||
|
||||
$comments = (defined ($comments) ? safe_input($comments) : '' );
|
||||
|
||||
print "[INFO] Creating user '$user_name'\n\n";
|
||||
|
@ -1143,10 +1037,6 @@ sub pandora_manage_main ($$$) {
|
|||
param_check($ltotal, 1);
|
||||
my $user_name = @ARGV[2];
|
||||
|
||||
# Remove spaces
|
||||
$user_name =~ s/^\s+//;
|
||||
$user_name =~ s/\s*$//;
|
||||
|
||||
print "[INFO] Deleting user '$user_name' \n\n";
|
||||
|
||||
my $result = pandora_delete_user($dbh,$user_name);
|
||||
|
@ -1156,16 +1046,6 @@ sub pandora_manage_main ($$$) {
|
|||
param_check($ltotal, 3);
|
||||
my ($user_name,$profile_name,$group_name) = @ARGV[2..4];
|
||||
|
||||
# Remove spaces
|
||||
$user_name =~ s/^\s+//;
|
||||
$user_name =~ s/\s*$//;
|
||||
|
||||
$profile_name =~ s/^\s+//;
|
||||
$profile_name =~ s/\s*$//;
|
||||
|
||||
$group_name =~ s/^\s+//;
|
||||
$group_name =~ s/\s*$//;
|
||||
|
||||
my $id_profile = get_profile_id($dbh,$profile_name);
|
||||
exist_check($id_profile,'profile',$profile_name);
|
||||
|
||||
|
@ -1187,16 +1067,6 @@ sub pandora_manage_main ($$$) {
|
|||
param_check($ltotal, 3);
|
||||
my ($user_name,$profile_name,$group_name) = @ARGV[2..4];
|
||||
|
||||
# Remove spaces
|
||||
$user_name =~ s/^\s+//;
|
||||
$user_name =~ s/\s*$//;
|
||||
|
||||
$profile_name =~ s/^\s+//;
|
||||
$profile_name =~ s/\s*$//;
|
||||
|
||||
$group_name =~ s/^\s+//;
|
||||
$group_name =~ s/\s*$//;
|
||||
|
||||
my $id_profile = get_profile_id($dbh,$profile_name);
|
||||
exist_check($id_profile,'profile',$profile_name);
|
||||
|
||||
|
@ -1218,16 +1088,6 @@ sub pandora_manage_main ($$$) {
|
|||
param_check($ltotal, 8, 3);
|
||||
my ($event,$event_type,$agent_name,$module_name,$group_name,$event_status,$severity,$template_name) = @ARGV[2..9];
|
||||
|
||||
# Remove spaces
|
||||
$agent_name =~ s/^\s+//;
|
||||
$agent_name =~ s/\s*$//;
|
||||
|
||||
$event =~ s/^\s+//;
|
||||
$event =~ s/\s*$//;
|
||||
|
||||
$group_name =~ s/^\s+//;
|
||||
$group_name =~ s/\s*$//;
|
||||
|
||||
$event_status = 0 unless defined($event_status);
|
||||
$severity = 0 unless defined($severity);
|
||||
|
||||
|
@ -1266,17 +1126,6 @@ sub pandora_manage_main ($$$) {
|
|||
elsif ($param eq '--validate_event') {
|
||||
param_check($ltotal, 7, 6);
|
||||
my ($agent_name, $module_name, $datetime_min, $datetime_max, $user_name, $criticity, $template_name) = @ARGV[2..8];
|
||||
|
||||
# Remove spaces
|
||||
$agent_name =~ s/^\s+//;
|
||||
$agent_name =~ s/\s*$//;
|
||||
|
||||
$module_name =~ s/^\s+//;
|
||||
$module_name =~ s/\s*$//;
|
||||
|
||||
$template_name =~ s/^\s+//;
|
||||
$template_name =~ s/\s*$//;
|
||||
|
||||
my $id_agent = '';
|
||||
my $id_agentmodule = '';
|
||||
|
||||
|
@ -1325,10 +1174,6 @@ sub pandora_manage_main ($$$) {
|
|||
param_check($ltotal, 7, 1);
|
||||
my ($title, $description, $origin, $status, $priority, $group_name, $owner) = @ARGV[2..8];
|
||||
|
||||
# Remove spaces
|
||||
$group_name =~ s/^\s+//;
|
||||
$group_name =~ s/\s*$//;
|
||||
|
||||
my $id_group = get_group_id($dbh,$group_name);
|
||||
exist_check($id_group,'group',$group_name);
|
||||
|
||||
|
@ -1339,13 +1184,6 @@ sub pandora_manage_main ($$$) {
|
|||
param_check($ltotal, 3, 1);
|
||||
my ($opt, $name, $name2) = @ARGV[2..4];
|
||||
|
||||
# Remove spaces
|
||||
$name =~ s/^\s+//;
|
||||
$name =~ s/\s*$//;
|
||||
|
||||
$name2 =~ s/^\s+//;
|
||||
$name2 =~ s/\s*$//;
|
||||
|
||||
if($opt eq '-m' || $opt eq '--m') {
|
||||
# Delete module data
|
||||
param_check($ltotal, 3) unless ($name2 ne '');
|
||||
|
@ -1405,10 +1243,6 @@ sub pandora_manage_main ($$$) {
|
|||
param_check($ltotal, 1);
|
||||
my $policy_name = @ARGV[2];
|
||||
|
||||
# Remove spaces
|
||||
$policy_name =~ s/^\s+//;
|
||||
$policy_name =~ s/\s*$//;
|
||||
|
||||
my $configuration_data = "";
|
||||
|
||||
my $policy_id = enterprise_hook('get_policy_id',[$dbh, safe_input($policy_name)]);
|
||||
|
|
Loading…
Reference in New Issue