2011-07-07 Sergio Martin <sergio.martin@artica.es>
* Makefile.PL lib/PandoraFMS/ReconServer.pm util/recon_scripts/snmpdevices.pl: Added disabled condition to recon tasks, readd NetAddr dependence and fix several bugs in addres loop into recon script git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4516 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
2f46bf9cc5
commit
76dcb56e61
|
@ -1,3 +1,11 @@
|
||||||
|
2011-07-07 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
|
* Makefile.PL
|
||||||
|
lib/PandoraFMS/ReconServer.pm
|
||||||
|
util/recon_scripts/snmpdevices.pl: Added disabled
|
||||||
|
condition to recon tasks, readd NetAddr dependence and
|
||||||
|
fix several bugs in addres loop into recon script
|
||||||
|
|
||||||
2011-07-01 Ramon Novoa <rnovoa@artica.es>
|
2011-07-01 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
* Makefile.PL: Removed NetAddr::IP from the dependency list. Not
|
* Makefile.PL: Removed NetAddr::IP from the dependency list. Not
|
||||||
|
|
|
@ -10,6 +10,7 @@ WriteMakefile(
|
||||||
VERSION_FROM => 'lib/PandoraFMS/Config.pm',
|
VERSION_FROM => 'lib/PandoraFMS/Config.pm',
|
||||||
AUTHOR => 'Artica ST <info@artica.es>',
|
AUTHOR => 'Artica ST <info@artica.es>',
|
||||||
PREREQ_PM => {
|
PREREQ_PM => {
|
||||||
|
NetAddr::IP => 0,
|
||||||
DBI => 0,
|
DBI => 0,
|
||||||
threads::shared => 0,
|
threads::shared => 0,
|
||||||
IO::Socket => 0,
|
IO::Socket => 0,
|
||||||
|
|
|
@ -97,6 +97,7 @@ sub data_producer ($) {
|
||||||
|
|
||||||
my @rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task
|
my @rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task
|
||||||
WHERE id_recon_server = ?
|
WHERE id_recon_server = ?
|
||||||
|
AND disabled = 0
|
||||||
AND utimestamp = 0 OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP())', $server_id);
|
AND utimestamp = 0 OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP())', $server_id);
|
||||||
foreach my $row (@rows) {
|
foreach my $row (@rows) {
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ sub show_help {
|
||||||
print "Usage:\n\n";
|
print "Usage:\n\n";
|
||||||
print " $0 <task_id> <group_id> <create_incident_flag> <custom_field1> <custom_field2> <custom_field3>\n\n";
|
print " $0 <task_id> <group_id> <create_incident_flag> <custom_field1> <custom_field2> <custom_field3>\n\n";
|
||||||
print " * custom_field1 = network. i.e.: 192.168.100.0/24\n";
|
print " * custom_field1 = network. i.e.: 192.168.100.0/24\n";
|
||||||
print " * custom_field2 = snmp_community. \n\n";
|
print " * custom_field2 = snmp_community. \n";
|
||||||
print " * custom_field3 = optative parameter to force process downed interfaces (use: '-a'). Only up interfaces are processed by default \n\n";
|
print " * custom_field3 = optative parameter to force process downed interfaces (use: '-a'). Only up interfaces are processed by default \n\n";
|
||||||
print " Additional information:\nWhen the script is called from a recon task, 'task_id' parameter is automatically filled, ";
|
print " Additional information:\nWhen the script is called from a recon task, 'task_id' parameter is automatically filled, ";
|
||||||
print "group_id and create_incident_flag are passed from interface form combos and custom fields manually filled.\n\n\n";
|
print "group_id and create_incident_flag are passed from interface form combos and custom fields manually filled.\n\n\n";
|
||||||
|
@ -125,7 +125,7 @@ sub process_module_snmp ($$$$$$$$$){
|
||||||
pandora_create_module_from_hash ($conf, \%parameters, $dbh);
|
pandora_create_module_from_hash ($conf, \%parameters, $dbh);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pandora_update_module_from_hash ($conf, \%parameters, $dbh, 'id_agente_modulo', $module_id);
|
pandora_update_module_from_hash ($conf, \%parameters, 'id_agente_modulo', $module_id, $dbh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,22 @@ if (! defined ($net_addr)) {
|
||||||
|
|
||||||
# Scan the network for hosts
|
# Scan the network for hosts
|
||||||
my ($total_hosts, $hosts_found, $addr_found) = ($net_addr->num, 0, '');
|
my ($total_hosts, $hosts_found, $addr_found) = ($net_addr->num, 0, '');
|
||||||
for (my $i = 1, $net_addr++; $net_addr <= $net_addr->broadcast; $i++, $net_addr++) {
|
|
||||||
|
my $last = 0;
|
||||||
|
for (my $i = 1; $net_addr <= $net_addr->broadcast; $i++, $net_addr++) {
|
||||||
|
if($last == 1) {
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
if($net_addr eq $net_addr++) {
|
||||||
|
$last = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($net_addr =~ /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.(\d{1,3})\b/) {
|
||||||
|
if($1 eq '0' || $1 eq '255') {
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my $addr = (split(/\//, $net_addr))[0];
|
my $addr = (split(/\//, $net_addr))[0];
|
||||||
$hosts_found ++;
|
$hosts_found ++;
|
||||||
|
@ -174,9 +189,6 @@ for (my $i = 1, $net_addr++; $net_addr <= $net_addr->broadcast; $i++, $net_addr+
|
||||||
# Update the recon task
|
# Update the recon task
|
||||||
update_recon_task ($dbh, $task_id, ceil ($i / ($total_hosts / 100)));
|
update_recon_task ($dbh, $task_id, ceil ($i / ($total_hosts / 100)));
|
||||||
|
|
||||||
# Does the host already exist?
|
|
||||||
next if (get_agent_from_addr ($dbh, $addr) > 0);
|
|
||||||
|
|
||||||
my $alive = 0;
|
my $alive = 0;
|
||||||
if (pandora_ping (\%conf, $addr) == 1) {
|
if (pandora_ping (\%conf, $addr) == 1) {
|
||||||
$alive = 1;
|
$alive = 1;
|
||||||
|
|
Loading…
Reference in New Issue