Welcome xmaverick,
Search on 'mrtg' or 'Multi Router Traffic Grapher', it's written in Perl, and produces graphs for daily, weekly, monthly and yearly cumulative data streams using SNMP. I have used it since 1997 and it has never failed (if I did the configs correctly). It can be used on any device that supports SNMP.
Funny, I just this week worked on updating the html output, to give total in/out data streams and total all. (Note: helps if you're paying by the MB like on a smartphone data plan)
You'll find that it's been enhanced and adapted to many other measurements, i.e. emails, spam, etc. I'm not affiliated with the project, just a happy user.
Good Luck
"Well done is better than well said." - Benjamin Franklin
| [reply] |
parse Graph Data that demonstrates network traffic spikes What data now? Use the name-of-the-format to search for parsing modules on cpan
| [reply] |
Are you trying to reverse engineer an image to extract actual numerical data from it?
| [reply] |
Yes, the graph is a web based tool. I'm interested in extracting the data from the graph but wondering what module to use for this type of project.
| [reply] |
Thats a very tough problem to solve. Just brainstorming about how to solve it reliably, I think the hardest part would be to get the axis tick mark values. How would you know, or get a program to detect what the graph's axis gradations are? Just for the sake of argument, if they were constant, and you could hard-code those into the program, you might be able to use one of the graphics modules, like Imager or ImageMagick, to do a pixel-by-pixel deconstruction of the image. Since most graphs have a constant background color, and a single graph color, you probably could analyze that data for peaks and lows. I'm not suggesting the following code is a solution, but it shows how to do a pixel-by-pixel deconstruction.
#!/usr/bin/perl
use strict;
use warnings;
use Imager;
# assumes a rgba image ( with alpha )
# otherwise use rgb instead of rgba
my $image_source = shift @ARGV;
my $image = Imager->new;
$image->read( file => $image_source )
or die "Cannot load $image: ", $image->errstr;
my $width = $image->getwidth();
my $height = $image->getheight();
print "Image dimensions: height = $height, width = $width\n";
# only grab some pixels on line 10
# for the whole image iterate over $width and $height
my $x = 10;
foreach my $y ( 10 .. 15 ) {
my $color = $image->getpixel( x => $x, y => $y );
my ( $r, $g, $b, $a ) = $color->rgba();
print " shade = $r, $g, $b\n";
}
| [reply] [d/l] |
A googling of "extract graph data from bitmap" yields a good few results. Sometimes you just need the right "search-engine-fu" to get what you're looking for. I didn't see any perl-specific bits, probably because I didn't search very hard. I just entered the first search phrase that popped into my head. But here are several candidates for you:
- There are third party solutions out there.
- The gnuplot docs contains a section for extracting data from graphs. The first link is to Engauge, an open source program. (The second link is broken...)
- Sourceforge has a project for this: Plot Digitizer that you may be able to use.
- If you're wanting to do it from scratch in perl, this thread shows an algorithm that might be a good starting point.
...roboticus
When your only tool is a hammer, all problems look like your thumb. | [reply] |