mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-03 20:14:52 +02:00
2008-06-17 Sancho Lerena <slerena@artica.es>
* pandora_recon: First code to implement traceroute functionality using Pureperl modul git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@867 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
b2071280e0
commit
a1a5799516
@ -1,3 +1,8 @@
|
|||||||
|
2008-06-17 Sancho Lerena <slerena@artica.es>
|
||||||
|
|
||||||
|
* pandora_recon: First code to implement traceroute functionality
|
||||||
|
using Pureperl module.
|
||||||
|
|
||||||
2008-06-16 Sancho Lerena <slerena@artica.es>
|
2008-06-16 Sancho Lerena <slerena@artica.es>
|
||||||
|
|
||||||
* pandora_snmpconsole: Solved a few bugs detected by Manu.
|
* pandora_snmpconsole: Solved a few bugs detected by Manu.
|
||||||
|
@ -26,6 +26,7 @@ use Date::Manip; # Needed to manipulate DateTime formats
|
|||||||
use Net::Ping;
|
use Net::Ping;
|
||||||
use Time::Local; # DateTime basic manipulation
|
use Time::Local; # DateTime basic manipulation
|
||||||
use NetAddr::IP; # To manage IP Addresses
|
use NetAddr::IP; # To manage IP Addresses
|
||||||
|
use Net::Traceroute::PurePerl; # Traceroute in rawsockets (need root)
|
||||||
use POSIX; # to use ceil() function
|
use POSIX; # to use ceil() function
|
||||||
use Socket; # to resolve address
|
use Socket; # to resolve address
|
||||||
use threads;
|
use threads;
|
||||||
@ -124,7 +125,7 @@ sub pandora_recon_subsystem {
|
|||||||
logger($pa_config,"Recon Server: Executing task [$task_name]",8);
|
logger($pa_config,"Recon Server: Executing task [$task_name]",8);
|
||||||
# EXEC TASK and mark as "in progress" != -1
|
# EXEC TASK and mark as "in progress" != -1
|
||||||
pandora_update_reconstatus ($pa_config, $dbh, $id_task, 0);
|
pandora_update_reconstatus ($pa_config, $dbh, $id_task, 0);
|
||||||
pandora_exec_task ($pa_config, $id_task);
|
pandora_recon_exec_task ($pa_config, $id_task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$exec_sql->finish();
|
$exec_sql->finish();
|
||||||
@ -136,7 +137,7 @@ sub pandora_recon_subsystem {
|
|||||||
# SUB pandora_exec_task (pa_config, id_task)
|
# SUB pandora_exec_task (pa_config, id_task)
|
||||||
# Execute task
|
# Execute task
|
||||||
##########################################################################
|
##########################################################################
|
||||||
sub pandora_exec_task {
|
sub pandora_recon_exec_task {
|
||||||
my $pa_config = $_[0];
|
my $pa_config = $_[0];
|
||||||
my $id_task = $_[1];
|
my $id_task = $_[1];
|
||||||
my $target_ip; # Real ip to check
|
my $target_ip; # Real ip to check
|
||||||
@ -440,6 +441,41 @@ sub pandora_task_create_agentmodules {
|
|||||||
$exec_sql->finish();
|
$exec_sql->finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub pandora_traceroute {
|
||||||
|
|
||||||
|
my $t = new Net::Traceroute::PurePerl(
|
||||||
|
backend => 'PurePerl', # this optional
|
||||||
|
host => '192.168.50.2',
|
||||||
|
debug => 0,
|
||||||
|
max_ttl => 15,
|
||||||
|
query_timeout => 2,
|
||||||
|
packetlen => 40,
|
||||||
|
protocol => 'icmp', # udp or icmp
|
||||||
|
);
|
||||||
|
|
||||||
|
my $timeout = 15;
|
||||||
|
my $success = 0;
|
||||||
|
|
||||||
|
eval {
|
||||||
|
local $SIG{ALRM} = sub { die "alarm" };
|
||||||
|
alarm $timeout;
|
||||||
|
$success = $t->traceroute();
|
||||||
|
alarm 0;
|
||||||
|
};
|
||||||
|
if ($@){
|
||||||
|
print "Traceroute timed out\n" if ($@ and $@ eq "alarm");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($success){
|
||||||
|
print "Total of ".$t->hops." hops for that target \n";
|
||||||
|
for (my $ax=1; $ax <= $t->hops; $ax++){
|
||||||
|
print $t->hop_query_host($ax, 0);
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
# pandora_shutdown ()
|
# pandora_shutdown ()
|
||||||
# Close system
|
# Close system
|
||||||
@ -447,7 +483,6 @@ sub pandora_task_create_agentmodules {
|
|||||||
sub pandora_shutdown {
|
sub pandora_shutdown {
|
||||||
logger (\%pa_config,"Pandora FMS Server '".$pa_config{'servername'}.$pa_config{"servermode"}."' Shutdown by signal ",0);
|
logger (\%pa_config,"Pandora FMS Server '".$pa_config{'servername'}.$pa_config{"servermode"}."' Shutdown by signal ",0);
|
||||||
print " [*] Shutting down ".$pa_config{'servername'}.$pa_config{"servermode"} ."(received signal)...\n";
|
print " [*] Shutting down ".$pa_config{'servername'}.$pa_config{"servermode"} ."(received signal)...\n";
|
||||||
pandora_event (\%pa_config, $pa_config{'servername'}.$pa_config{"servermode"}." going Down", 0,
|
pandora_event (\%pa_config, $pa_config{'servername'}.$pa_config{"servermode"}." going Down", 0, 0, 4, 0, 0, "system", $dbh);
|
||||||
0, 4, 0, 0, "system", $dbh);
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user