On Thu, Oct 24, 2013 at 12:37 PM, Balasubramaniam Natarajan <
[email protected]> wrote:
> Hi
>
> I am trying to understand how do we use the keyword *perlcode* in the
> swatch configuration file, Could you point me in the correct direction ?
> I do not know perl and may be due to this I am failing at understating what
> goggling brings up.
>
>
I guess I figure it out, perlcode is to arbitrarily call a snipped of perl
code inside the conf file of a watch.
# cat test.conf
perlcode my $initialmatch =
qr{^\w+\s+\w+\s+\d+\s+\d{2}:\d{2}:\d{2}\s+\w+\s+\d{4}\s+\icmp\s+(\d+\.\d+\.\d+\.\d+)};
perlcode my ($src_ip) = ($_ =~ $initialmatch);
watchfor /icmp/
echo
throttle 00:00:05, key=$src_ip
# swatch -c test.conf -t test.log
*** swatch version 3.2.3 (pid:6639) started at Fri Oct 25 12:55:49 EDT 2013
Fri Oct 25 12:40:38 EDT 2013 icmp 2.1.1.1 detected
Fri Oct 25 12:40:38 EDT 2013 icmp 2.1.1.1 detected (seen 11 times)
Fri Oct 25 12:40:38 EDT 2013 icmp 1.1.1.1 detected
Fri Oct 25 12:40:38 EDT 2013 icmp 1.1.1.1 detected (seen 20 times)
Fri Oct 25 12:40:38 EDT 2013 icmp 2.1.1.1 detected (seen 2 times)
^CCaught a SIGINT -- sending a TERM signal to 6640
#
--
Regards,
Balasubramaniam Natarajan
www.blog.etutorshop.com
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
ILUGC Mailing List Guidelines:
http://ilugc.in/mailinglist-guidelines