From 7f109ca452d3a8dbf3b53a378a2c6b0bf4438ade Mon Sep 17 00:00:00 2001 From: slerena Date: Thu, 5 Feb 2009 11:34:57 +0000 Subject: [PATCH] 2009-02-06 Sancho Lerena * util/plugin/multicast.pl: Multicast check plugin. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1428 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 4 +++ pandora_server/util/plugin/multicast.pl | 38 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 pandora_server/util/plugin/multicast.pl diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index cb350404c2..89e4e538a9 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,7 @@ +2009-02-06 Sancho Lerena + + * util/plugin/multicast.pl: Multicast check plugin. + 2009-02-04 Ramon Novoa * lib/PandoraFMS/DB.pm: Read template default action on alert diff --git a/pandora_server/util/plugin/multicast.pl b/pandora_server/util/plugin/multicast.pl new file mode 100755 index 0000000000..f8e5d6ca48 --- /dev/null +++ b/pandora_server/util/plugin/multicast.pl @@ -0,0 +1,38 @@ +#!/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); + +GetOptions( + "h" => sub { help() }, + "help" => sub { help() }, + "g=s" => \$group, + "p=s" => \$port, + "t=i" => \$timeout +); + +if(!$timeout){ + $timeout=5 +}; + +alarm($timeout); + +$SIG{ALRM} = sub {print "0"; exit 1; }; + +my $sock = IO::Socket::Multicast->new(Proto=>'udp', LocalPort=>$port); +$sock->mcast_add($group) || die "0"; + +my $data; +next unless $sock->recv($data,1024); +print "1"; +exit 0; + +sub help { + print "\nPandora FMS Plugin for Check Multicast\n\n"; + print "Syntax: \n\n ./multicast.pl -g -p -t \n\n"; + print "Sample usage: ./multicast.pl -g 239.255.255.255 -p 1234 -t 10 \n\n"; + exit -1; +}