mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-08-26 04:08:44 +02:00
* bin/pandora_network: Better management of snmpget binary call, using a config setup variable and checking it in startup. * pandora_server.conf: new options added (snmpget, UDP multicast) * Config.pm: New options managed (snmpget), new version updated (3.0-dev) * DB.pm: Fixed two issues that makes me some problems on undefined values. * Tools.pm: New function to manage numerical data. * util/plugin/multicast.pl: Fixed plugin for multicast check. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1508 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
59 lines
1020 B
Perl
Executable File
59 lines
1020 B
Perl
Executable File
#!/usr/bin/perl -w
|
|
use strict;
|
|
use IO::Socket::Multicast;
|
|
use Getopt::Long;
|
|
|
|
# Sample usage: ./multicast.pl -g 239.255.255.255 -p 1234 -t 30
|
|
my ($group,$port,$timeout);
|
|
|
|
$timeout = 10;
|
|
|
|
GetOptions(
|
|
"h" => sub { help() },
|
|
"help" => sub { help() },
|
|
"g=s" => \$group,
|
|
"p=s" => \$port,
|
|
"t=i" => \$timeout
|
|
);
|
|
|
|
alarm($timeout);
|
|
|
|
$SIG{ALRM} = sub { die_return_timeout(); };
|
|
|
|
#die_return(); };
|
|
|
|
sub die_return {
|
|
print "0";
|
|
exit 1;
|
|
}
|
|
|
|
sub die_return_timeout {
|
|
print "0";
|
|
exit -1;
|
|
}
|
|
|
|
my $sock;
|
|
eval {
|
|
while (!defined($sock)){
|
|
$sock = IO::Socket::Multicast->new(Proto=>'udp', LocalPort=>$port);
|
|
}
|
|
|
|
$sock->mcast_add($group) || die_return();
|
|
|
|
my $data;
|
|
next unless $sock->recv($data,1);
|
|
print "1";
|
|
exit 0;
|
|
};
|
|
if ($@){
|
|
die_return_timeout();
|
|
}
|
|
|
|
sub help {
|
|
print "\nPandora FMS Plugin for Check Multicast\n\n";
|
|
print "Syntax: \n\n ./multicast.pl -g <group> -p <port> -t <timeout> \n\n";
|
|
print "Sample usage: ./multicast.pl -g 239.255.255.255 -p 1234 -t 10 \n\n";
|
|
exit -1;
|
|
}
|
|
|