2011-06-28 Sergio Martin <sergio.martin@artica.es>
* lib/PandoraFMS/DB.pm lib/PandoraFMS/ReconServer.pm: Moved add_address function to DB to common uses and create add_new_address_agent function into DB library with repeated code for the same git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4492 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
be3c0077d3
commit
a033c48b6f
|
@ -1,3 +1,10 @@
|
||||||
|
2011-06-28 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
|
* lib/PandoraFMS/DB.pm
|
||||||
|
lib/PandoraFMS/ReconServer.pm: Moved add_address function
|
||||||
|
to DB to common uses and create add_new_address_agent function
|
||||||
|
into DB library with repeated code for the same
|
||||||
|
|
||||||
2011-06-27 Junichi Satoh <junichi@rworks.jp>
|
2011-06-27 Junichi Satoh <junichi@rworks.jp>
|
||||||
|
|
||||||
* lib/PandoraFMS/NetworkServer.pm: Fixed SNMP PROC modules always
|
* lib/PandoraFMS/NetworkServer.pm: Fixed SNMP PROC modules always
|
||||||
|
|
|
@ -28,6 +28,8 @@ our @ISA = ("Exporter");
|
||||||
our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
|
our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
|
||||||
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
||||||
our @EXPORT = qw(
|
our @EXPORT = qw(
|
||||||
|
add_address
|
||||||
|
add_new_address_agent
|
||||||
db_connect
|
db_connect
|
||||||
db_disconnect
|
db_disconnect
|
||||||
db_do
|
db_do
|
||||||
|
@ -39,6 +41,7 @@ our @EXPORT = qw(
|
||||||
db_text
|
db_text
|
||||||
db_update
|
db_update
|
||||||
get_action_id
|
get_action_id
|
||||||
|
get_addr_id
|
||||||
get_agent_id
|
get_agent_id
|
||||||
get_agent_address
|
get_agent_address
|
||||||
get_agent_group
|
get_agent_group
|
||||||
|
@ -512,6 +515,35 @@ sub db_process_update($$$$$;@) {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# Add the given address to taddress.
|
||||||
|
##########################################################################
|
||||||
|
sub add_address ($$) {
|
||||||
|
my ($dbh, $ip_address) = @_;
|
||||||
|
|
||||||
|
return db_insert ($dbh, 'id_a', 'INSERT INTO taddress (ip) VALUES (?)', $ip_address);
|
||||||
|
}
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# Assign the new address to the agent
|
||||||
|
##########################################################################
|
||||||
|
sub add_new_address_agent ($$$) {
|
||||||
|
my ($dbh, $addr_id, $agent_id) = @_;
|
||||||
|
|
||||||
|
db_do ($dbh, 'INSERT INTO taddress_agent (`id_a`, `id_agent`)
|
||||||
|
VALUES (?, ?)', $addr_id, $agent_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# Return the ID of the given address, -1 if it does not exist.
|
||||||
|
##########################################################################
|
||||||
|
sub get_addr_id ($$) {
|
||||||
|
my ($dbh, $addr) = @_;
|
||||||
|
|
||||||
|
my $addr_id = get_db_value ($dbh, 'SELECT id_a FROM taddress WHERE ip = ?', $addr);
|
||||||
|
return (defined ($addr_id) ? $addr_id : -1);
|
||||||
|
}
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
## Generic SQL sentence.
|
## Generic SQL sentence.
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
|
@ -288,8 +288,7 @@ sub data_consumer ($$) {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Assign the new address to the agent
|
# Assign the new address to the agent
|
||||||
db_do ($dbh, 'INSERT INTO taddress_agent (`id_a`, `id_agent`)
|
add_new_address_agent ($dbh, $addr_id, $agent_id);
|
||||||
VALUES (?, ?)', $addr_id, $agent_id);
|
|
||||||
|
|
||||||
# Create network profile modules for the agent
|
# Create network profile modules for the agent
|
||||||
create_network_profile_modules ($pa_config, $dbh, $agent_id, $task->{'id_network_profile'}, $addr, $task->{'snmp_community'});
|
create_network_profile_modules ($pa_config, $dbh, $agent_id, $task->{'id_network_profile'}, $addr, $task->{'snmp_community'});
|
||||||
|
@ -432,8 +431,7 @@ sub get_host_parent ($$$$$$){
|
||||||
my $agent_id = pandora_create_agent ($pa_config, $pa_config->{'servername'}, $parent_name, $parent_addr, $group, $parent_parent, $id_os, '', 300, $dbh);
|
my $agent_id = pandora_create_agent ($pa_config, $pa_config->{'servername'}, $parent_name, $parent_addr, $group, $parent_parent, $id_os, '', 300, $dbh);
|
||||||
|
|
||||||
# Assign the new address to the agent
|
# Assign the new address to the agent
|
||||||
db_do ($dbh, 'INSERT INTO taddress_agent (`id_a`, `id_agent`)
|
add_new_address_agent ($dbh, $addr_id, $agent_id);
|
||||||
VALUES (?, ?)', $addr_id, $agent_id);
|
|
||||||
|
|
||||||
return $agent_id;
|
return $agent_id;
|
||||||
}
|
}
|
||||||
|
@ -484,16 +482,6 @@ sub guess_os {
|
||||||
return pandora_get_os ($output);
|
return pandora_get_os ($output);
|
||||||
}
|
}
|
||||||
|
|
||||||
##########################################################################
|
|
||||||
# Return the ID of the given address, -1 if it does not exist.
|
|
||||||
##########################################################################
|
|
||||||
sub get_addr_id ($$) {
|
|
||||||
my ($dbh, $addr) = @_;
|
|
||||||
|
|
||||||
my $addr_id = get_db_value ($dbh, 'SELECT id_a FROM taddress WHERE ip = ?', $addr);
|
|
||||||
return (defined ($addr_id) ? $addr_id : -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# Return the ID of the agent with the given IP.
|
# Return the ID of the agent with the given IP.
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
@ -518,15 +506,6 @@ sub update_recon_task ($$$) {
|
||||||
db_do ($dbh, 'UPDATE trecon_task SET utimestamp = ?, status = ? WHERE id_rt = ?', time (), $status, $id_task);
|
db_do ($dbh, 'UPDATE trecon_task SET utimestamp = ?, status = ? WHERE id_rt = ?', time (), $status, $id_task);
|
||||||
}
|
}
|
||||||
|
|
||||||
##########################################################################
|
|
||||||
# Add the given address to taddress.
|
|
||||||
##########################################################################
|
|
||||||
sub add_address ($$) {
|
|
||||||
my ($dbh, $ip_address) = @_;
|
|
||||||
|
|
||||||
return db_insert ($dbh, 'id_a', 'INSERT INTO taddress (ip) VALUES (?)', $ip_address);
|
|
||||||
}
|
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# Create network profile modules for the given agent.
|
# Create network profile modules for the given agent.
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
Loading…
Reference in New Issue