All,
I'm trying to get a simple log monitor to work on Perl 5.8.0 with the
latest POE. The code was based off the
sample log watcher written for FreeBSD.
/* Code Start
#!/usr/bin/perl
# $Id$
use warnings;
use strict;
use POE;
use POE::Wheel::FollowTail;
my $device = "dka100";
my $dir = "[rsa.agent.bin]";
my $file = "check-logs.txt";
my $msg_file = File::Spec::VMS->catpath( $device, $dir, $file );
my %logs_to_watch =
( msg => $msg_file );
print %logs_to_watch;
print %logs_to_watch;
POE::Session->create
( inline_states =>
{ _start => \&begin_watchers,
msg_record => \&msg_got_record,
# Handle log resets and errors the same way for each file.
log_reset => \&generic_log_reset,
log_error => \&generic_log_error,
}
);
sub begin_watchers {
my $heap = $_[HEAP];
while ( my ( $service, $log_file ) = each %logs_to_watch ) {
my $log_watcher = POE::Wheel::FollowTail->new
( Filename => $log_file,
InputEvent => $service . "_record",
ResetEvent => "log_reset",
ErrorEvent => "log_error",
);
$heap->{services}->{ $log_watcher->ID } = $service;
$heap->{watchers}->{ $log_watcher->ID } = $log_watcher;
}
}
sub msg_got_record {
my $log_record = $_[ARG0];
print $log_record, "\n";
}
# Handle log resets the same way for each file. Simply recognize that
# the log file was reset.
sub generic_log_reset {
my ( $heap, $wheel_id ) = @_[ HEAP, ARG0 ];
my $service = $heap->{services}->{$wheel_id};
print "--- $service log reset at ", scalar(gmtime), " GMT\n";
}
# Handle log errors the same way for each file. Recognize that an
# error occurred while watching the file, and shut the watcher down.
# If this were a real log watcher, it would periodically try to resume
# watching the log file.
sub generic_log_error {
my ( $heap, $operation, $errno, $error_string, $wheel_id ) =
@_[ HEAP, ARG0, ARG1, ARG2, ARG3 ];
my $service = $heap->{services}->{$wheel_id};
print "--- $service log $operation error $errno: $error_string\n";
print "--- Shutting down $service log watcher.\n";
delete $heap->{services}->{$wheel_id};
delete $heap->{watchers}->{$wheel_id};
}
*/ Code End
Error message is:
kite_hab15$ perl simple_log.pl
msgdka100:[rsa.agent.bin]check-logs.txthandle= GLOB(0x814c2c)
filename= dka100:[rsa.agent.bin]check-logs.txt
fcntl(GLOB(0x814c2c), F_GETFL, etc.) fails: invalid argument
at /perl_root/lib/site_perl/POE/Wheel/FollowTail.pm line 136
POE::Kernel's run() method was never called.
%SYSTEM-F-ABORT, abort
TIA,
Bob Safran
425.739.3228
ALSTOM's T&D Energy Automation & Information Business
CONFIDENTIALITY: This e-mail and any attachments are confidential and may
be privileged. If you are not a named recipient, please notify the sender
immediately and do not disclose the contents to another person, use it for
any purpose or store or copy the information in any medium.