Get graph data in text format instead of generating graph?

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
GoranTornqvist
Posts: 35
Joined: Wed Nov 10, 2004 5:43 am
Location: Stockholm
Contact:

Get graph data in text format instead of generating graph?

Post by GoranTornqvist »

Hello,
I want to enable access to the data in cacti thru a webservice...but the problem is, I don´t understand how to collect the data.

What I want is: Total Bandwidth Usage for last month in text-format, like:

13.5G or 149M
or something similar.

I got the graph:
graph_image.php?local_graph_id=28&rra_id=0&view_type=tree&graph_start=1114437492&graph_end=1117029492

How do I get the data in textformat?

I´m a PHP programmer so I´m not afraid to dig thru some scripts...but I need to know what I should look for :)

Thanks...

EDIT: Looks like I´m not the only one that needs to do this :)
http://forums.cacti.net/viewtopic.php?t=7712
Can any of the developers of cacti just give me a pointer perhaps?
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Well, the data that is graphed is stored in RRD files generated with RRDTool. :) Check out www.rrdtool.org for more information on exporting data from the RRD files.

Good luck :)
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
GoranTornqvist
Posts: 35
Joined: Wed Nov 10, 2004 5:43 am
Location: Stockholm
Contact:

Post by GoranTornqvist »

Thanks...
I understand that RRDTool files are used...though I can't say that this tool is obvious or simple to understand...and I have no deeper knowledge of cacti either.

I´ve managed to get data from a rrd-file like this:

Code: Select all

rrdtool xport --start now-720h --end now DEF:out=rra/switch_traffic_in_28.rrd:traffic_out:MAX XPORT:out:"out bytes"
switch_traffic_in_28.rrd is of type "bits/sec with Total bandwidth" in cacti.

I get a XML file that looks like this:

Code: Select all

<?xml version="1.0" encoding="ISO-8859-1"?>
<xport>
  <meta>
    <start>1116057600</start>
    <step>7200</step>
    <end>1118656800</end>
    <rows>362</rows>
    <columns>1</columns>
    <legend>
      <entry>out bytes</entry>
    </legend>
  </meta>
  <data>
    <row><t>1116057600</t><v>1.3456063333e+04</v></row>
    <row><t>1116064800</t><v>1.7400663333e+04</v></row>
    <row><t>1116072000</t><v>1.5801985689e+04</v></row>
    <row><t>1116079200</t><v>1.4365490467e+04</v></row>
    <row><t>1118656800</t><v>NaN</v></row>
  </data>
</xport>
I have trouble with:
- Understanding which parameters I should use for the "rrdtool xport" command.
- Interpreting the XML-output. I can't find any documentation about the output format.

If I find the correct parameters for the xport command I only need to loop thru all the rows in the XML and summarize the values to get the totals...that's the easy part :)

I lack the basic understanding of rrdtool...so if someone seen a howto that would be nice :)
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Ok, export is the wrong word....

There is a way to retrieve the last value inserted. I don't recall off hand how. Sorry.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
GoranTornqvist
Posts: 35
Joined: Wed Nov 10, 2004 5:43 am
Location: Stockholm
Contact:

Post by GoranTornqvist »

*boink*

anyone has any ideas on this?

thanks :)
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

you may use "rrdtool last" http://people.ee.ethz.ch/~oetiker/webto ... st.en.html to get the last update timestamp and then "rrdtool fetch" http://people.ee.ethz.ch/~oetiker/webto ... ch.en.html to get the specific data. But here has been a tool "cactiquery". Never installed it. But try to search the forum for it. It may fit your needs...
Reinhard
GoranTornqvist
Posts: 35
Joined: Wed Nov 10, 2004 5:43 am
Location: Stockholm
Contact:

Post by GoranTornqvist »

Thanks...Im well on my way now :)
Here's the thing, when I do rrdtool fetch like:

rrdtool fetch switch_traffic_in_24.rrd AVERAGE -s 20050901 -e 20050919

i get a lot of:

1127044800: 1.0029921389e+05 1.1126736736e+05
1127052000: 8.8105098833e+04 9.1622791134e+04

I need to add these together to get total bandwidth used, but I dont know what 1.0029921389e+05 means/how it should be handled :oops:
What kind of value is that?

Sorry for these newbie questions :oops:

PS: Im doing a webservice that returns bandwidth usage for a specific time interval
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

GoranTornqvist wrote:but I dont know what 1.0029921389e+05 means
This is an exponential notation. It means:

Code: Select all

Take the value 1.0029921389
multiply this value by 10 to the power of 5 (= 100,000)
this results in 100299.21389 in your case
Reinhard
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests