tail display ....in perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting tail display ....in perl
# 1  
Old 01-15-2008
Error tail display ....in perl

hi
we have 3 servers and we have a script to monitor cpu usage of all 3 servers and writes into one file on one of the server where we monitor all those servers ( by doing tail -f filename ) so we decided to create script ( perl ) that will read values from this file and display it should be like "top" command it will refresh on its own without quitting ...can u guys provide me ideas ?

sample log file is as follows :

Code:
20080115_172824_Hpux1571        801     Hpux1571        0       0
20080115_172826_Hpux1570        801     Hpux1570        6       0
20080115_172832_Hpux1572        801     Hpux1572        65      0
20080115_172835_Hpux1571        801     Hpux1571        0       0
20080115_172838_Hpux1570        801     Hpux1570        1       0
20080115_172844_Hpux1572        801     Hpux1572        60      0
20080115_172847_Hpux1571        801     Hpux1571        0       0
20080115_172849_Hpux1570        801     Hpux1570        6       0

my current scripts prints like this :
Code:
Hpux1571       :       0
 Hpux1570       :       6
 Hpux1572       :       65
 Hpux1571       :       0
 Hpux1570       :       1
 Hpux1572       :       60

it should display like :
Code:
$tailit.pl  
Hpux1570      :        6
Hpux1571      :        0
Hpux1572      :        65

extracting values is not a problem , problem is that displaying only latest values from them .....
suggest something ...
# 2  
Old 01-15-2008
I guess there's more than one way to do it, as perl suggests Smilie
First, by using "Fail-Tail or using seek, a suggestions from Larry Smilie
# 3  
Old 01-15-2008
thanx for ur reply ..
but getting information from file is done ...with File::Tail module i want to display such way that only latest values for each server will be displayed ..
like its shown in top command on HP-UX page keeps on refreshing till u hit <CNTR-C>
to make it more simple
its should update server CPU usage only without quitting ..

Code:
server name :     cpu usage 
hpux1571     :    cpu usage refreshing *
hpux1570     :    cpu usage refreshing * 
hpux1572     :    cpu usage refreshing *

only lines marked with "*" should change as soon as they find new value for that server in logfile.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

How to display certain line of file only using head or tail in 1 command?

First month learning about the Linux terminal and it has been a challenge yet fun so far. We're learning by using a gameshell. I'm trying to display a certain line ( only allowed 1 command ) from a file only using the head or tail. I'm pretty about this answer: head -23 history.txt | tail -1... (1 Reply)
Discussion started by: forzatekk
1 Replies

2. Shell Programming and Scripting

Perl error while using File::Tail

Hi, Can someone help with this PERL code; I am getting this error while running below code: And this is the code: use File::Tail; $file=File::Tail->new("/some/log/file"); while (defined($line=$file->read)) { print "$line"; } I don't usually use PERL therefore I am not... (1 Reply)
Discussion started by: INHF
1 Replies

3. UNIX for Dummies Questions & Answers

head\tail how to display middle lines

hay i need to display middle line: 1 2 3 4 5 how can i display 3-4? (6 Replies)
Discussion started by: margan_ron
6 Replies

4. Shell Programming and Scripting

Display Specific line number using tail command

Hi , 1)i want to display specific line number using tail command. e.g. display 10 line from end. Please help... 2)Want to display line 10 to 15 (from end)using tail command) (2 Replies)
Discussion started by: vivek1489
2 Replies

5. Shell Programming and Scripting

bash script to display tail

Hi everyone, I'm trying to write a script to format a file using unix2dos. I want to output all but the first 14 lines in a file. Then I want to pipe this to unix2dos to convert the output to a file that's easily readable on windows. Here's what I have: export Lines=`wc -l < $1` export... (11 Replies)
Discussion started by: LuminalZero
11 Replies

6. UNIX for Dummies Questions & Answers

Display lines 30 to 40 of a text file using head and/or tail commands

Assume that the text file contains over 40 lines. How do you do this?!?!? (5 Replies)
Discussion started by: phunkypants
5 Replies

7. Shell Programming and Scripting

how to tail a file in perl

Can any one please help why does tail -f does not work in the below code: Thanks in advance. #!/usr/bin/perl -w my $path = "/home/cs/logs/"; my $log = "log.txt"; `cd $path`; `tail -f $log`; (3 Replies)
Discussion started by: sureshcisco
3 Replies

8. Shell Programming and Scripting

how to read tail -F command output in perl

Hi All, How I will read the output of the tail -F command in perl. I have text file with below contains file1.txt 1 2 3 4 $running=1; sub openLog($) { (my $log) = @_; (1 Reply)
Discussion started by: pravin27
1 Replies

9. UNIX for Dummies Questions & Answers

how to display line number for tail -f

Hi, Just wonder if there is any quick way to display line number when monitoring a log file with tail -f? (4 Replies)
Discussion started by: iengca
4 Replies

10. Shell Programming and Scripting

Tail-alike display of new files in directory

The system I work on, produces several kinds of status-files in a single directory. I would like to be able to see the files as they are added to this directory. I was wondering if it would be possible to get a "tail -f" alike view of the ls-command, in such a way that a newly added file is... (4 Replies)
Discussion started by: rschelkers
4 Replies
Login or Register to Ask a Question