hi Andrew,
your rule needs just few fixes. Firstly, you need to rewrite the first line
of your lcall action as

 lcall %time $1 -> ( sub { my $str = $_[0];\

This will pass $1 into the function as first input parameter and assign its
value to the $str variable inside the function.

Secondly, you would probably need to fix your regular expression pattern:
pattern=(\S+) .1.3.6.1.4.1.3607.2.20.0.430 192.168.11.15 Loss Of Signal in
(\S+) \(criticalServiceAffecting\),ifIndex=(.+)

The reason I'd propose a modification is that \S+ matches a string not
containing any whitespace, while your input date (for example, "Fri Nov 21
2014 15:04:32") contains several whitespace symbols. If the date appears in
the beginning of the line, you might consider the following regular
expression for matching it:
^((?:[[:alpha:]]{3} ){2}[\d ]\d \d{4} (?:\d{2}:){2}\d{2})
or perhaps just
^((?:\S+\s+){4}\S+)
if you just want to match the date as five non-whitespace fields.

hope this helps,
risto


2014-11-21 8:26 GMT+02:00 andrewarnier <andrewarn...@gmail.com>:

> Hi all,
>
> I want to get the trap time ,but the trap time format is  “Fri Nov 21 2014
> 15:04:32”  ,how to change the format to “2014-11-21 15:04:32” in my single
> rule ?
>
>
>
> I try to convert the datetime format in my sec fule, but my rule action
> can’t get the variable $1,
>
> Anyone knows what’s wrong with my rule ? how to fix ?
>
>
>
>
>
>
>
> type=Single
>
> ptype=Regexp
>
> pattern=(\S+) .1.3.6.1.4.1.3607.2.20.0.430 192.168.11.15 Loss Of Signal in
> (\S+) \(criticalServiceAffecting\),ifIndex=(.+)
>
> desc= CA -15600 Loss of signal events for interface $2($3)
>
> action=lcall %time -> ( sub { my $str = '$1';\
>
> my @months
> =('jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec');\
>
> my ($day,$mon,$date,$year,$time) = split(' ',lc($str));\
>
> my %month_hash;\
>
> @month_hash{@months} = (1 .. 12);\
>
> return "$year-$month_hash{$mon}-$date $time"; } );shellcmd
> /home/andrew/code/sendmail.sh "Loss Of Signal" "CA-15600 Loss of signal
> events for interface $2($3)" "%time"
>
>
>
>
>
>
>
>
>
> cheers,
>
> Andrew
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
> _______________________________________________
> Simple-evcorr-users mailing list
> Simple-evcorr-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users
>
>
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Simple-evcorr-users mailing list
Simple-evcorr-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users

Reply via email to