On Thu, Jun 01, 2006 at 12:11:53PM +0530, Thati Ravi wrote:
Hi.
> hello everybody !!
>  i am new to RRDTool.
Welcome ;)

> Here is a problem (may be simple one )
> I am presently collecting the statuses of Network Devices (routers,etc).I am
> able to plot the graphs.
> But My requirement is  that
>  When Somebody  supplies a date (Start and End not in SECs) I should be able
> to list the averages(or Max)  per day between the given 2 dates in a tabular
> form with dates.
Thats not too complicated.
Assuming the resolution of your RRD-Databases is fits your needs.

First you have to convert the supplied date into the corresponding
UN*X epoch (seconds since 01-Jan-1970 00:00 UTC).

In PERL you can use the Time::Local module (should be installed
or get it from http://search.cpan.org/~drolsky/Time-Local-1.12/) and
do something like:

$time = timelocal($sec,$min,$hour,$mday,$mon,$year);

Having the start and stop date in the right format you can use
the xport function from the RRDs perl module (you can even do
math with this module !).

Now all you have todo to work with the data RRDs::xport() gave
you. E.g.:

 - call RRDs::xport() and it will return an array
my ($start,$end,$step,$columcnt,$legend,$data)=RRDs::xport(@cmd);

 - loop over the data the call to RRDs::xport() returned
   (convert the seconds since 01-Jan-1970 00:00 back to a "normal" date
    using the buildin PERL function localtime) and print your table

  foreach my $row (@$data)
  {
    (undef,my $min,my $hour,my $mday,my $mon,my 
$year,undef,undef,undef)=localtime($start);

    $line.=sprintf("%u\t%02u-%s-%04u 
%02u:%02u",$start,$mday,$Months[$mon],$year+1900,$hour,$min);

    $start+=$step;
    foreach my $val (@$row)
    {
      if ($val ne '')
      {
        $line.=sprintf("\t%.2f",$val);
      } else
      {
        $line.=sprintf("\t-\n",$val);
      }
    }
  }

Easy, isn't it ?

HTH,

Andreas.

-- 
Dipl.-Ing. Andreas Maus             science+computing ag
System Administration               Hagellocher Weg 71-75
mail: [EMAIL PROTECTED]   72070 Tuebingen, Germany
tel.: +49 7071 9457 456             www.science-computing.de

-- Binary/unsupported file stripped by Ecartis --
-- Err : No filename to use for decode, file stripped.
-- Type: application/pgp-signature


--
Unsubscribe mailto:[EMAIL PROTECTED]
Help        mailto:[EMAIL PROTECTED]
Archive     http://lists.ee.ethz.ch/rrd-users
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi

Reply via email to