CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Help with perl script?

 



your_shadow03
New User

Nov 20, 2009, 10:39 PM

Post #1 of 1 (464 views)
Help with perl script? Can't Post

Hello Guys,

I am a new member and need quick help on understanding few scripts.

Let me explain you a scenerio. I am in verse to monitor a web server on Linux.All I got a script which will run on remote web Server and collect few details like:



time, Load, Load, Load, Memory used, Memory free, Cached, Swap used, Swap Free, Apache processes, Load Manager factor, Max apache, Busy
22we13:1258739458:0.79:0.83:0.78:2:151:23064:3830812:259252

I am doing it through ssh remoteuser@<ipaddr> "perl ./script-to-monitor count_pages" | /home/john/graph/mailme.pl

Now I tested with first running it in remote server itself and its running without any issue.

Next I am too getting it the o/p in my local monitoring system which I setup in Linux. But the problem is mailme.pl script which i couldnt understand.Here is the one:


Code
  

$| = 1;

while(<STDIN>){
last if /^\s*$/;
chomp();
s/^\s*subject\s*:\s*//i;
$subject = $_;
}

open( LOG, ">>$subject.log" );

$subject.='.rrd' if !/\.rrd$/;
my $filename = $subject;

print STDERR "$subject\n";

$last_reading = `rrdtool last $filename`;
chomp($last_reading);

while ($line = <>) {
$orig = $line;
chomp($line);
$line =~ s/^.+?://;
print LOG $line."\n";
@data = split /:/, $line;
next if(!$data[0]);
next if($data[0]<=$last_reading);
$cmd = "rrdtool update $filename $line";
#print $cmd;
print `$cmd`;
print "$orig"
}

Can anyone help me in understanding what this script is doing?


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives