2011-04-13 Sancho Lerena <slerena@artica.es>

* lib/PandoraFMS/ReconServer.pm: Fixed bug #3286027. Fix also
        the "non finished" status for the Script Recon tasks, and as
        new feature implements the "manual" recon task, works only when
        you press the button.

	Ported from Branch 3.2



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4205 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2011-04-13 14:59:18 +00:00
parent a5108dc3b2
commit 677a608511
2 changed files with 27 additions and 6 deletions

View File

@ -1,3 +1,11 @@
2011-04-13 Sancho Lerena <slerena@artica.es>
* lib/PandoraFMS/ReconServer.pm: Fixed bug #3286027. Fix also
the "non finished" status for the Script Recon tasks, and as
new feature implements the "manual" recon task, works only when
you press the button.
2011-04-10 Junichi Satoh <junichi@rworks.jp>
* lib/PandoraFMS/DB.pm: Moved mysql_enable_utf8 to after database

View File

@ -86,9 +86,14 @@ sub data_producer ($) {
my $server_id = get_server_id ($dbh, $pa_config->{'servername'}, $self->getServerType ());
return @tasks unless defined ($server_id);
# Manual tasks have interval_sweep = 0
# Manual tasks are "forced" like the other, setting the utimestamp to 1
# By default, after create a tasks it takes the utimestamp to 0
# Status -1 means "done".
my @rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task
WHERE id_recon_server = ?
AND (utimestamp = 0 OR (utimestamp + interval_sweep) < UNIX_TIMESTAMP())', $server_id);
AND (utimestamp = 1) OR (status = -1 AND interval_sweep > 0 AND (utimestamp = 0 OR (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))', $server_id);
foreach my $row (@rows) {
# Update task status
@ -110,11 +115,13 @@ sub data_consumer ($$) {
# Get recon task data
my $task = get_db_single_row ($dbh, 'SELECT * FROM trecon_task WHERE id_rt = ?', $task_id);
return -1 unless defined ($task);
# Is it a recon script?
if (defined ($task->{'id_recon_script'})) {
exec_recon_script ($pa_config, $dbh, $task);
return;
if ($task->{'id_recon_script'} > 0){
exec_recon_script ($pa_config, $dbh, $task);
return;
}
}
# Get a NetAddr::IP object for the target network
@ -130,12 +137,13 @@ sub data_consumer ($$) {
for (my $i = 1, $net_addr++; $net_addr < $net_addr->broadcast; $i++, $net_addr++) {
my $addr = (split(/\//, $net_addr))[0];
# Update the recon task or break if it does not exist anymore
last if (update_recon_task ($dbh, $task_id, ceil ($i / ($total_hosts / 100))) eq '0E0');
# Does the host already exist?
next if (get_agent_from_addr ($dbh, $addr) > 0);
next if (get_agent_from_addr ($dbh, $addr) > 0);
my $alive = 0;
if (pandora_ping ($pa_config, $addr) == 1) {
@ -183,6 +191,7 @@ sub data_consumer ($$) {
# and store also it's position.
if($pa_config->{'activate_gis'} == 1 && $pa_config->{'recon_reverse_geolocation_mode'} !~ m/^disabled$/i) {
# Try to get aproximated positional information for the Agent.
my $region_info = undef;
if ($pa_config->{'recon_reverse_geolocation_mode'} =~ m/^sql$/i) {
@ -461,6 +470,10 @@ sub exec_recon_script ($$$) {
my $field4 = safe_output($task->{'field4'});
`$command $task->{'id_rt'} $task->{'id_group'} $task->{'create_incident'} $field1 $field2 $field3 $field4`;
# Notify this recon task is ended
update_recon_task ($dbh, $task->{'id_rt'}, -1);
return 0;
}