LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-12-2007, 02:19 PM   #1
bzzz
LQ Newbie
 
Registered: Mar 2007
Location: Sibiu, Romania (Europe)
Distribution: Debian Lenny
Posts: 16

Rep: Reputation: 0
Question RRDToll / Perl RRDs - not rendering


Hello.

I'm trying to rander some graphs using RRDTool and RRDs Perl module.
I have this script (got it from the internet):
Code:
#!/usr/bin/perl
use lib qw( /usr/local/rrdtool-1.2.19/lib/perl );
use RRDs;

my $rrd = '/var/lib/rrd';
my $img = '/var/www/graphs';

&ProcessInterface("cs", "cs.asconet.ro");

sub ProcessInterface
{
my $in = `cs`;
chomp($in);

print "Players: $in\n";

if (! -e "$rrd/$_[0].rrd")
{
print "creating rrd database for $_[0] interface...\n";
RRDs::create "$rrd/$_[0].rrd",
"-s 60",
"DS:in:DERIVE:60:0:200000",
"DS:out:DERIVE:60:0:200000",
"RRA:AVERAGE:0.5:1:576",
"RRA:AVERAGE:0.5:6:672",
"RRA:AVERAGE:0.5:24:732",
"RRA:AVERAGE:0.5:144:1460";
}

RRDs::update "$rrd/$_[0].rrd",
"-t", "in",
"N:$in";

&CreateGraph($_[0], "day", $_[1]);
&CreateGraph($_[0], "week", $_[1]);
&CreateGraph($_[0], "month", $_[1]);
&CreateGraph($_[0], "year", $_[1]);
}

sub CreateGraph
{

RRDs::graph "$img/$_[0]-$_[1].png",
"-s -1$_[1]",
"-t Counter-Strike Server ($_[2]) online players",
"--lazy",
"-h", "150", "-w", "600",
"-l 0",
"-a", "PNG",
"-v players",
"DEF:in=$rrd/$_[0].rrd:in:AVERAGE",
"DEF:out=$rrd/$_[0].rrd:out:AVERAGE",
"CDEF:out_neg=out,-1,*",
"AREA:in#660099:Players on cs.asconet.ro",
"LINE1:in#336600",
"LINE1:in#999999",
"GPRINT:in:MAX: Max\\: %5.1lf %s",
"GPRINT:in:AVERAGE: Avg\\: %5.1lf %S",
"GPRINT:in:LAST: Current\\: %5.1lf %Splayers\\n",
"HRULE:0#000000";
if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] traffic graph: $ERROR\n"; }
}
It renders me the graph, but without any drawing in it. The values from the bottom of the graphs are null (nan). The script called `cs` is made by me (parsing the quakestat result). I checked it and it works perfect. Here's the script (I know the isn't such a good way, but it works):
Code:
#!/usr/bin/php -e
<?php
// server
$server = "cs.asconet.ro";

// exec cmd
$x = shell_exec("quakestat -hls $server");

// parse
$x = explode("ro", $x);
$x = str_replace(" ", "", $x[1]);
$x = explode("/", $x);
$on_players = $x[0];

// return result
echo "$on_players\n";
?>
The original script is made to get the netspeed from the ifconfig, but the original has the same problem. I tryied to remove the lib from the line 2, but the problem persists. The RRDTool is installed from source (also tryied to install it from the apt-get repos).

If someone can help, please do it . Please don't give solves like "install cacti or cricket", I know that cacti and cricket works, but I want it like this.

Thanks a lot.
 
  


Reply



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
RHEL4u2 perl localtime() call issues (perl & glibc) Brad.Scalio@noaa.gov Linux - Enterprise 3 01-23-2007 09:27 PM
Problem with perl module for w3c validator to work on my local Apache+PHP+perl instal tbamt Linux - Software 0 12-16-2004 05:37 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM
chrooting apache v2 (php, ssl, perl support) ; perl configuration markus1982 Linux - Security 3 01-26-2003 06:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:48 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration