Howdy Monks,

I am using the File::Tail module to watch a busy log file and pipe the results to a fifo. But I am having trouble keeping it running. The following error occurs sporatically and I am not sure why seeing the code is fairly simple. The negative time value is the only thing changing in the error message. Any ideas?

Time::HiRes::sleep(-0.13635): negative time not invented yet at /usr/l +ocal/lib/perl5/site_perl/5.8.2/File/Tail.pm line 529.
#!/usr/local/bin/perl ## ### ### This script reads the page.log file, formats the data, and sends i +t ### to the nco_p_data FIFO for use by the pmgrd process. ### ### April 2, 2004 ### Added space for message and date to be seperate # # use File::Tail; # Preset variables my $LogFile="/opt/app/bmc/PATROL3.5/lib/psl/EMProg/CEM/page.log"; # my $PipeName="/opt/app/PatrolAdmin/docs/eventmgr/pipes/nco_p_data"; # my $fi=tie *FH,"File::Tail",(name=>$LogFile,reset_tail=>0); ### If told to stop kill process and not restart if ($ARGV[0] eq "stop"){ @procs=`ps -ef \| grep eventFIFO \| grep -v grep | gre +p -v $$`; foreach $line (@procs){ $line =~ /\w+\s+(\d+)\s/; $pid = $1; system(`kill $pid`); } exit 0; } unless( -p $PipeName) { unlink $PipeName; system("mkfifo -m 644 $PipeName") && die "Can't mkfifo $PipeNa +me: $!"; } while (FH) { $line = $fi->read; if($line =~ /(.*)\|~\|(.*)\|~\|([\W\w]+)\|~\|(.*)/) { $contline=""; $PagerID=$1; $Message=$2." ".$3; $Status=$4; } else { $contline=$contline.$line; if($contline =~ /(.*)\|~\|(.*)\|~\|([\w\W]+)\|~\|(.*)/ +) { $contline=""; $PagerID=$1; $Message=$2." ".$3; $Status=$4; $contline=""; } else { next; } } open(FIFO,">$PipeName") || die "Couldn't open file $PipeName - $!\n"; print FIFO "NEW|TODAY|NOW|\"\"|$PagerID|$Message|$Status\n"; close(FIFO); }

In reply to File::Tail or Time::HiRes by onegative

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.