Re: Alarm event when monitoring log files
Martijn van Beers <[email protected]>
| Newsgroups | gmane.comp.lang.perl.poe |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 2008-09-10 at 17:51 +0330, Emmanuel Gadaix wrote:
> douglasstvnsn wrote:
>
> In the handler sub xdx_got_record, store the value and timestamp of the
> previous deactivate or activate. Then, when you get a new one , compare and
> suppress or send.
>
> Thanks but this will not work.
>
> I need to send "link deactivated" alarm when it has been deactivated (e.g.
> no "link active" message received) for more than a minute.
>
>
> So imagine the scenario whereby the log messages are:
>
> "link deactivated" at 17:00:00
> "link active" at 19:00:00
>
> I need to send the alarm at 17:01, not at 19:00
>
>
> And in the scenario like:
>
> "link deactivated" at 17:00:00
> "link active" at 17:00:30
>
> Then no alarm are sent (it was only deactivated 30 seconds).
So, you have to send the alarm at 17:01.
$alarm_id = $kernel->delay_set('sendalert', 60, $service); # at 17:00
$heap->{scheduled_alerts}->{$service} = $alarm_id;
and cancel it at 17:00:30
$alarm_id = delete $heap->{scheduled_alerts}->{$service};
$kernel->alarm_remove($alarm_id);
plus a new sendalert event handler that sends the alert, and clears the
scheduled_alerts hash for $service.
An unrelated note: use ARG0 and ARG1 instead of 10 and 11; it's much
clearer that way, and they get exported for you by default.
Martijn