newbie help! MRTG's Perl module: RRDGRAPH and LTIME

newbie help! MRTG's Perl module: RRDGRAPH and LTIME

Post by Neil Matcha » Fri, 09 May 2003 11:58:00



I've been putting together a Perl script to generate graphs using MRTG's
RRDTOOL perl module and CGI.pm.

I'm at the point of adding the 'bells and whistles' to the graphs and have
hit a problem with the LTIME option.

I want to include the start/finish date/time's of the graphs in their
legends but all I seem to be able to get is the start/finish epoch times.

Is there any way (using the perl module) of getting
"year/month/day/hours/minutes" strings from the rrd achieve that I can use
in a GPRINT statement?

An "rrdtool dump" shows "<!-- 2003-05-08 11:00:00 EST / 1052182800 -->
<row><v> 0" so it 'looks like' the info is in there.

The end result I'm after from the GPRINT statement is:
"Start Date/Time 08:00:00 2003-05-02, End Date/Time 11:00:00 2003-05-08"

Here's the perl code I'm using:

sub makeTrafficGraph: {
  my $rrdGraphWidth = ($graphwidth / $rrdRow);
  if ($rrdRow ne "1") {
    $rrdGraphWidth = ($rrdGraphWidth - $graphwidthadjust);
  }

  my $graphTitle = ("$rrdDevice\, $interfaceName");
  if (($deviceText eq "") && ($portName ne "")) { $graphTitle = $portName };
  if (($deviceText ne "") && ($portName eq "")) { $graphTitle =
$deviceText };

    my $imageName =
("$rrdname\_$rrdInterval\_$rrdPeriod\_$rrdType\_$graphType\_$rrdRow");
    RRDs::graph "$rrdroot$network$imageName.png",
    "--title", "$graphTitle",
    "--start", "$graphStartDate",
# eg. "14:10 -2w" or "11:30 20030201"
    "--end", "$graphEndDate",
# eg. "23:59 20030508"
    "--step", "300",
    "--color", "GRID#999999",
    "--color", "FONT#000000",
    "--color", "SHADEB#000000",
    "--color", "CANVAS#FFFFFF",
    "--imgformat","PNG",
    "--width=$rrdGraphWidth",
#  "890"
    "--base", "$graphBaseLine",
                                      # "1000"
    "--height=$graphheight",
# "330"
    "--vertical-label","$graphVerticalTitle",
# "bits per second"
    "DEF:r01bytesave0=$rrdroot$network$rrdname\.rrd:ds0:$rrdType",
# "rrd path/name" "MAX"
    "DEF:r01bytesave1=$rrdroot$network$rrdname\.rrd:ds1:$rrdType",
# "rrd path/name" "MAX"
    "CDEF:r01inbound=r01bytesave0,UN,0,r01bytesave0,IF,$graphMultiplier,*",
# "8"
    "CDEF:r01outbound=r01bytesave1,UN,0,r01bytesave1,IF,$graphMultiplier,*",
# "8"
    "CDEF:graphtime=r01bytesave1,POP,LTIME",
    "AREA:r01inbound#00D000",
    "LINE1:r01inbound#00D000:$rrdDevice Inbound  $interfaceName\, Speed
$speed",
    "LINE1:r01outbound#0000D0:$rrdDevice Outbound $interfaceName\, Speed
$speed",
    "GPRINT:graphtime:MIN:Start Date/Time %lf, ",
    "GPRINT:graphtime:MAX:End Date/Time %lf";

    if ($ERROR = RRDs::error) {
      print $cgi->h3("ERROR Graph: $ERROR\n");
    }

Thanks in advance,
Neil M

 
 
 

newbie help! MRTG's Perl module: RRDGRAPH and LTIME

Post by Neil Matcha » Sat, 10 May 2003 08:03:03


Opp's,
The Perl module belongs to RRDTOOL, not MRTG. I hope this is the correct
group for rrdtool posts.

Neil M


Quote:> I've been putting together a Perl script to generate graphs using MRTG's
> RRDTOOL perl module and CGI.pm.

> I'm at the point of adding the 'bells and whistles' to the graphs and have
> hit a problem with the LTIME option.

> I want to include the start/finish date/time's of the graphs in their
> legends but all I seem to be able to get is the start/finish epoch times.

> Is there any way (using the perl module) of getting
> "year/month/day/hours/minutes" strings from the rrd achieve that I can use
> in a GPRINT statement?

> An "rrdtool dump" shows "<!-- 2003-05-08 11:00:00 EST / 1052182800 -->
> <row><v> 0" so it 'looks like' the info is in there.

> The end result I'm after from the GPRINT statement is:
> "Start Date/Time 08:00:00 2003-05-02, End Date/Time 11:00:00 2003-05-08"

> Here's the perl code I'm using:

> sub makeTrafficGraph: {
>   my $rrdGraphWidth = ($graphwidth / $rrdRow);
>   if ($rrdRow ne "1") {
>     $rrdGraphWidth = ($rrdGraphWidth - $graphwidthadjust);
>   }

>   my $graphTitle = ("$rrdDevice\, $interfaceName");
>   if (($deviceText eq "") && ($portName ne "")) { $graphTitle =
$portName };
>   if (($deviceText ne "") && ($portName eq "")) { $graphTitle =
> $deviceText };

>     my $imageName =
> ("$rrdname\_$rrdInterval\_$rrdPeriod\_$rrdType\_$graphType\_$rrdRow");
>     RRDs::graph "$rrdroot$network$imageName.png",
>     "--title", "$graphTitle",
>     "--start", "$graphStartDate",
> # eg. "14:10 -2w" or "11:30 20030201"
>     "--end", "$graphEndDate",
> # eg. "23:59 20030508"
>     "--step", "300",
>     "--color", "GRID#999999",
>     "--color", "FONT#000000",
>     "--color", "SHADEB#000000",
>     "--color", "CANVAS#FFFFFF",
>     "--imgformat","PNG",
>     "--width=$rrdGraphWidth",
> #  "890"
>     "--base", "$graphBaseLine",
>                                       # "1000"
>     "--height=$graphheight",
> # "330"
>     "--vertical-label","$graphVerticalTitle",
> # "bits per second"
>     "DEF:r01bytesave0=$rrdroot$network$rrdname\.rrd:ds0:$rrdType",
> # "rrd path/name" "MAX"
>     "DEF:r01bytesave1=$rrdroot$network$rrdname\.rrd:ds1:$rrdType",
> # "rrd path/name" "MAX"

"CDEF:r01inbound=r01bytesave0,UN,0,r01bytesave0,IF,$graphMultiplier,*",
Quote:> # "8"

"CDEF:r01outbound=r01bytesave1,UN,0,r01bytesave1,IF,$graphMultiplier,*",

- Show quoted text -

Quote:> # "8"
>     "CDEF:graphtime=r01bytesave1,POP,LTIME",
>     "AREA:r01inbound#00D000",
>     "LINE1:r01inbound#00D000:$rrdDevice Inbound  $interfaceName\, Speed
> $speed",
>     "LINE1:r01outbound#0000D0:$rrdDevice Outbound $interfaceName\, Speed
> $speed",
>     "GPRINT:graphtime:MIN:Start Date/Time %lf, ",
>     "GPRINT:graphtime:MAX:End Date/Time %lf";

>     if ($ERROR = RRDs::error) {
>       print $cgi->h3("ERROR Graph: $ERROR\n");
>     }

> Thanks in advance,
> Neil M


 
 
 

newbie help! MRTG's Perl module: RRDGRAPH and LTIME

Post by Neil Matcha » Tue, 13 May 2003 09:03:50


Got his working,
Thanks anyway,

Neil M


Quote:> I've been putting together a Perl script to generate graphs using MRTG's
> RRDTOOL perl module and CGI.pm.

> I'm at the point of adding the 'bells and whistles' to the graphs and have
> hit a problem with the LTIME option.

> I want to include the start/finish date/time's of the graphs in their
> legends but all I seem to be able to get is the start/finish epoch times.

> Is there any way (using the perl module) of getting
> "year/month/day/hours/minutes" strings from the rrd achieve that I can use
> in a GPRINT statement?

> An "rrdtool dump" shows "<!-- 2003-05-08 11:00:00 EST / 1052182800 -->
> <row><v> 0" so it 'looks like' the info is in there.

> The end result I'm after from the GPRINT statement is:
> "Start Date/Time 08:00:00 2003-05-02, End Date/Time 11:00:00 2003-05-08"

> Here's the perl code I'm using:

> sub makeTrafficGraph: {
>   my $rrdGraphWidth = ($graphwidth / $rrdRow);
>   if ($rrdRow ne "1") {
>     $rrdGraphWidth = ($rrdGraphWidth - $graphwidthadjust);
>   }

>   my $graphTitle = ("$rrdDevice\, $interfaceName");
>   if (($deviceText eq "") && ($portName ne "")) { $graphTitle =
$portName };
>   if (($deviceText ne "") && ($portName eq "")) { $graphTitle =
> $deviceText };

>     my $imageName =
> ("$rrdname\_$rrdInterval\_$rrdPeriod\_$rrdType\_$graphType\_$rrdRow");
>     RRDs::graph "$rrdroot$network$imageName.png",
>     "--title", "$graphTitle",
>     "--start", "$graphStartDate",
> # eg. "14:10 -2w" or "11:30 20030201"
>     "--end", "$graphEndDate",
> # eg. "23:59 20030508"
>     "--step", "300",
>     "--color", "GRID#999999",
>     "--color", "FONT#000000",
>     "--color", "SHADEB#000000",
>     "--color", "CANVAS#FFFFFF",
>     "--imgformat","PNG",
>     "--width=$rrdGraphWidth",
> #  "890"
>     "--base", "$graphBaseLine",
>                                       # "1000"
>     "--height=$graphheight",
> # "330"
>     "--vertical-label","$graphVerticalTitle",
> # "bits per second"
>     "DEF:r01bytesave0=$rrdroot$network$rrdname\.rrd:ds0:$rrdType",
> # "rrd path/name" "MAX"
>     "DEF:r01bytesave1=$rrdroot$network$rrdname\.rrd:ds1:$rrdType",
> # "rrd path/name" "MAX"

"CDEF:r01inbound=r01bytesave0,UN,0,r01bytesave0,IF,$graphMultiplier,*",
Quote:> # "8"

"CDEF:r01outbound=r01bytesave1,UN,0,r01bytesave1,IF,$graphMultiplier,*",

- Show quoted text -

Quote:> # "8"
>     "CDEF:graphtime=r01bytesave1,POP,LTIME",
>     "AREA:r01inbound#00D000",
>     "LINE1:r01inbound#00D000:$rrdDevice Inbound  $interfaceName\, Speed
> $speed",
>     "LINE1:r01outbound#0000D0:$rrdDevice Outbound $interfaceName\, Speed
> $speed",
>     "GPRINT:graphtime:MIN:Start Date/Time %lf, ",
>     "GPRINT:graphtime:MAX:End Date/Time %lf";

>     if ($ERROR = RRDs::error) {
>       print $cgi->h3("ERROR Graph: $ERROR\n");
>     }

> Thanks in advance,
> Neil M

 
 
 

1. perl mrtg mrtg.cfg

Hallo !
I want to monitor the cpu of my cisco router. The SNMP-OID
1.3.6.1.4.1.9.2.1.58.0
is ok and i get an answer of the last 5 minutes of my cpu utilisation. (when
i test it from an other  NodeManager Station)

when i start: perl mrtg mrtg.cfg

i get the following error. what is wrong ?????

C:\mrtg-2.9.7\bin>perl mrtg mrtg.kvb
ERROR: Line 16

23) in CFG file (mrtg.kvb)  does not make sense

mrtg.cfg:
# Router CPU load %

3

 MaxBytes[cpu.1]: 100
 Title[cpu.1]: CPU LOAD
 PageTop[cpu.1]: <H1>CPU Load %</H1>
 Unscaled[cpu.1]: ymwd
 ShortLegend[cpu.1]: %
 XSize[cpu.1]: 380
 YSize[cpu.1]: 100
 YLegend[cpu.1]: CPU Utilization
 Legend1[cpu.1]: CPU Utilization in % (Load)
 Legend2[cpu.1]: CPU Utilization in % (Load)
 Legend3[cpu.1]:
 Legend4[cpu.1]:
 LegendI[cpu.1]:
 LegendO[cpu.1]: &nbsp;Usage
 Options[cpu.1]:

2. Installing OS/2 GA on an EVEREX

3. Error message when running perl mrtg mrtg.cfg

4. Help. Netscape registry error message after install on Win2k Pro.

5. MRTG Newbie needs help with MRTG on Solaris 8 SPARC Edition

6. CNF: Important Announcement -- Quality Week Europe moves to March 2002

7. MRTG error: un\rateup'ute 'c:mrtg-2.9.0pre27

8. SCSI Controller for the 800XL ?

9. MRTG newbie help help

10. newbie MRTG question : how to add mib to MRTG ?

11. Configuration file 'puller' (Perl based)

12. Perl Module for Ciscos

13. handy perl modules for bind