LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 09-02-2005, 09:05 AM   #1
cash_05
LQ Newbie
 
Registered: Sep 2003
Posts: 12

Rep: Reputation: 0
Unhappy Help on RRDTOOL and maybe perl needed!


Hi there,

Im learning perl and rrdtool now. I try to make
rrdtool to monitoring cpu loadavg. Everythings seems
working (rrd db created, updated, rrd images created,
updated. i check with doing a ls -l and compare the
timestamp on those files).

However, the is only one problem that screw the whole
things -- the graph is blank wiht no line

I tried many times but still not able to get it solve.
Thus, im posting my script here and hope someone can
help me.

# cat rrd_cpu.pl
#!/usr/bin/perl
use RRDs;
my $rrd = '/var/www/htdocs/rrd_db';
my $img = '/var/www/htdocs/rrd_images';
if (! -e "$rrd/cpu.rrd") {
RRDs::create "$rrd/cpu.rrd",
"-s 300",
"DS:1min:GAUGE:600:U:U",
"DS:5min:GAUGE:600:U:U",
"DS:15min:GAUGE:600:U:U",
"RRA:AVERAGE:0.5:1:576",
"RRA:AVERAGE:0.5:6:672",
"RRA:AVERAGE:0.5:24:732",
"RRA:AVERAGE:0.5:144:1460";
}
my $min1 = `cat /proc/loadavg | cut -d" " -f1`;
my $min5 = `cat /proc/loadavg | cut -d" " -f2`;
my $min15 = `cat /proc/loadavg | cut -d" " -f3`;

RRDs::update "$rrd/cpu.rrd",
"-t", "1min:5min:15min",
"N:$min1:$min5:$min15";

RRDs::graph "$img/cpu-day.png",
"--lazy",
"-s -1day",
"-t CPU information :: day",
"-h", "120", "-w", "600",
"-a", "PNG",
"-v Load AVG %",
"DEF:imin1=$rrd/cpu.rrd:1min:AVERAGE",
"DEF:imin5=$rrd/cpu.rrd:5min:AVERAGE",
"DEF:imin15=$rrd/cpu.rrd:15min:AVERAGE",
"LINE2:imin1#ff0000:1min",
"LINE2:imin5#009f32:5min",
"LINE2:imin15#0000ff:15min";

if ($ERROR = RRDs::error) { print "$0: unable
to generate cpu graph: $ERROR\n"; }
}

Thanks in advance.
 
Old 09-05-2005, 03:27 AM   #2
cash_05
LQ Newbie
 
Registered: Sep 2003
Posts: 12

Original Poster
Rep: Reputation: 0
(SOLVED)

Apparently, just need to remove the eol character from the source. This is how i do it,
$line = qx/uptime/;
# to chop the trailing newline
chomp $line;
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
perl-Video-Frequencies needed tjuii Suse/Novell 7 10-14-2005 02:09 AM
Help on sed and perl needed. cash_05 Programming 7 09-03-2005 04:33 PM
Perl guru needed J_Szucs Programming 1 10-11-2004 03:05 AM
Regex help needed in perl Dr Twox Programming 2 08-07-2004 05:58 AM
(Perl?)Script needed Cyrus XIII Programming 5 01-03-2004 11:45 AM


All times are GMT -5. The time now is 04:39 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration