2011-11-29 Juan Manuel Ramon <juanmanuel.ramon@artica.es>

* util/pandora_manage.pl: Added checks of agent and module names at
	creation time.
	
	Fixes: #3439878



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5191 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
juanmanuelr 2011-11-29 10:05:25 +00:00
parent 17ec3e85af
commit 945a3572b5
2 changed files with 30 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2011-11-29 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* util/pandora_manage.pl: Added checks of agent and module names at
creation time.
Fixes: #3439878
2011-11-26 Junichi Satoh <junichi@rworks.jp>
* FreeBSD/pandora_server.conf: Synchronized with the generic

View File

@ -338,6 +338,14 @@ sub notexists_error ($$) {
exit 1;
}
###############################################################################
# Print a 'exists' error and exit the program.
###############################################################################
sub exists_error ($$) {
print (STDERR "[ERROR] Error: The $_[0] '$_[1]' already exists.\n\n");
exit 1;
}
###############################################################################
# Check the return of 'get id' and call the error if its equal to -1.
###############################################################################
@ -347,6 +355,15 @@ sub exist_check ($$$) {
}
}
###############################################################################
# Check the return of 'get id' and call the error if its not equal to -1.
###############################################################################
sub non_exist_check ($$$) {
if($_[0] != -1) {
exists_error($_[1],$_[2]);
}
}
###############################################################################
# Check the parameters.
# Param 0: # of received parameters
@ -487,6 +504,8 @@ sub cli_create_agent() {
exist_check($id_group,'group',$group_name);
my $os_id = get_os_id($dbh,$os_name);
exist_check($id_group,'operating system',$group_name);
my $agent_exists = get_agent_id($dbh,$agent_name);
non_exist_check($agent_exists, 'agent name', $agent_name);
pandora_create_agent ($conf, $server_name, $agent_name, $address, $id_group, 0, $os_id, $description, $interval, $dbh);
}
@ -521,6 +540,10 @@ sub cli_create_data_module() {
my $module_type_def;
print "[INFO] Adding module '$module_name' to agent '$agent_name'\n\n";
my $agent_id = get_agent_id($dbh,$agent_name);
my $module_exists = get_agent_module_id($dbh, $module_name, $agent_id);
non_exist_check($module_exists, 'module name', $module_name);
# If the module is local, we add it to the conf file
if(defined($definition_file) && (-e $definition_file) && (-e $conf->{incomingdir}.'/conf/'.md5($agent_name).'.conf')){
@ -575,7 +598,6 @@ sub cli_create_data_module() {
exit;
}
my $agent_id = get_agent_id($dbh,$agent_name);
exist_check($agent_id,'agent',$agent_name);
my $module_group_id = get_module_group_id($dbh,$module_group);