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.