Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Linux Graph producing utility ?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
paulizaz
n00b
n00b


Joined: 09 Jan 2007
Posts: 18

PostPosted: Tue Mar 20, 2007 2:59 pm    Post subject: Linux Graph producing utility ? Reply with quote

Hi all,

Im looking for any linux utility that you can pass data into and it will produce a website viewable graph (e.g. jpg image).

Has anyone had expereince in professional documentation reports like this?

Im new to Linux and dont really know where to start,
Any help appreciated


thanks.
Back to top
View user's profile Send private message
Janne Pikkarainen
Veteran
Veteran


Joined: 29 Jul 2003
Posts: 1143
Location: Helsinki, Finland

PostPosted: Tue Mar 20, 2007 3:07 pm    Post subject: Reply with quote

You mean apps like mrtg or RRDtool?
_________________
Yes, I'm the man. Now it's your turn to decide if I meant "Yes, I'm the male." or "Yes, I am the Unix Manual Page.".
Back to top
View user's profile Send private message
jt_
n00b
n00b


Joined: 15 Mar 2007
Posts: 61

PostPosted: Tue Mar 20, 2007 3:07 pm    Post subject: Reply with quote

While not specifically a "linux utility", there's some Perl and PHP (and I'm sure others) ways of doing this. Poke around CPAN, and/or checkout JPGraph.
Back to top
View user's profile Send private message
paulizaz
n00b
n00b


Joined: 09 Jan 2007
Posts: 18

PostPosted: Tue Mar 20, 2007 3:28 pm    Post subject: Reply with quote

Thanks,

I dont need to monitor system data as such, so I dont think MRTG is quite right.
The data I will use is seperate from Linux, its actually data from a call centre I want to produce graphical statistics for.

RRDtool looks complicated but I'll take a look.

Thanks
Back to top
View user's profile Send private message
paulizaz
n00b
n00b


Joined: 09 Jan 2007
Posts: 18

PostPosted: Tue Mar 20, 2007 4:09 pm    Post subject: Reply with quote

JPGraph looks ideal at first glance, but I probably need it under comercial use. Therefore it needs to be a free licence (e.g. GNU General Public License).

Any suggestions?
Back to top
View user's profile Send private message
jt_
n00b
n00b


Joined: 15 Mar 2007
Posts: 61

PostPosted: Tue Mar 20, 2007 4:38 pm    Post subject: Reply with quote

JPGraph is basically just a framework for working with GD.

Here's a pretty decent summary for the Perl module: http://linuxgazette.net/issue83/padala.html
Back to top
View user's profile Send private message
nutbar21
Apprentice
Apprentice


Joined: 05 Dec 2004
Posts: 205
Location: USA

PostPosted: Tue Mar 20, 2007 9:12 pm    Post subject: Reply with quote

GNUPlot is absolutely perfect for this. I've done some great performance/load graphs of our uPortal project at my university with it.
_________________
"Your voice is like the sound of sirens to a house on fire..." -The Alkaline Trio
Back to top
View user's profile Send private message
paulizaz
n00b
n00b


Joined: 09 Jan 2007
Posts: 18

PostPosted: Thu Mar 22, 2007 11:19 am    Post subject: Reply with quote

Thanks for the examples.

Slight change, (more detail)....

Currently an SQL script is used to abstract data into an excel file which needs manuall graph prodcution every month, therfore the need for automation.

I want to run some kind of Perl script to automate the process of producing a graph straight from the database on a monthly bases .

More difficult but appreciate any help.
Back to top
View user's profile Send private message
styrmis
n00b
n00b


Joined: 21 Jan 2006
Posts: 48

PostPosted: Thu Mar 22, 2007 12:54 pm    Post subject: Reply with quote

I agree with r3solve, Gnuplot should be sufficient.

1) Your script could create a data file (column separated values).
2) Create a Gnuplot file which would generate a JPG or PNG from the data.
3) Profit!

The demo gallery can be very useful to get started: http://gnuplot.sourceforge.net/demo_4.0/
Back to top
View user's profile Send private message
paulizaz
n00b
n00b


Joined: 09 Jan 2007
Posts: 18

PostPosted: Thu Mar 22, 2007 1:18 pm    Post subject: Reply with quote

thanks for the input styrmis,

But would this be automated?

Becuase it is done on a regular basis with many similar sets of data, thus producing many graphs I need this process to be Automated.

Database > Script obtains data > Need something to autmatically create graphs.


What do you suggest?

Thanks again.
Back to top
View user's profile Send private message
nutbar21
Apprentice
Apprentice


Joined: 05 Dec 2004
Posts: 205
Location: USA

PostPosted: Thu Mar 22, 2007 1:29 pm    Post subject: Reply with quote

I have a script set to run at the end of every month that does the following:

1. parse relevant data from sar logs
2. place data into comma separated form
3. run the gnuplot file which is set to output a jpg into a directory on our webserver

Once the script has completed, any user can visit the stats web page and all months' data graphs will be available without any further attention on my part. It is all automatic.
_________________
"Your voice is like the sound of sirens to a house on fire..." -The Alkaline Trio
Back to top
View user's profile Send private message
styrmis
n00b
n00b


Joined: 21 Jan 2006
Posts: 48

PostPosted: Thu Mar 22, 2007 1:57 pm    Post subject: Reply with quote

paulizaz,

r3solve's method is very close to what you could do, except you'll be pulling the data in from a database.

The whole process can be automated:

1) Fetch data from database
2) Output to a [CT]SV* file.
3) Generate a Gnuplot file. This will just be print statements in your script; the only parts that will change will be the file name of the source data, and the target file.
4) Execute gnuplot, passing it the script file as an argument.
5) Make the image available in some way (such as the way r3solve in which r3solve does).

* I use tab-delimited values but it appears that comma-delimited is fine too.

Here's an example data file and gnuplot script. Check the link I posted above for more examples.

Gnuplot script:
Code:

# The 'term' controls what type of output Gnuplot will produce.
set term png

# The file to write the image to.
set output '/tmp/graph.png'

set xlabel 'x'
set ylabel 'x^2'

set title 'x^2'

set key outside

# The '1:2' part tells Gnuplot to plot one series using the values for
# column 1 and column 2.
plot '/tmp/xsquared.dat' using 1:2 title 'Training'

# If you want to plot more than one series you can use a plot command like:
# plot '/tmp/xsquared.dat' using 1:2 title 'Training', \
# '/tmp/xsquared.dat' using 3:4 title 'Testing'


Data:
Code:

# TestingX      TestingY
-3.000000       -0.130768
-2.800000       -0.128497
-2.600000       -0.125270
-2.400000       -0.120807
-2.200000       -0.114808
-2.000000       -0.107000
-1.800000       -0.097206
-1.600000       -0.085445
-1.400000       -0.071995
-1.200000       -0.057394
-1.000000       -0.042335
-0.800000       -0.027487
-0.600000       -0.013362
-0.400000       -0.000274
-0.200000       0.011612
0.000000        0.022230
0.200000        0.031584
0.400000        0.039748
0.600000        0.046852
0.800000        0.053064
1.000000        0.058562
1.200000        0.063518
1.400000        0.068081
1.600000        0.072373
1.800000        0.076491
2.000000        0.080504
2.200000        0.084459
2.400000        0.088386
2.600000        0.092300
2.800000        0.096203
3.000000        0.100090
Back to top
View user's profile Send private message
paulizaz
n00b
n00b


Joined: 09 Jan 2007
Posts: 18

PostPosted: Mon Mar 26, 2007 11:15 am    Post subject: Reply with quote

Thanks I will look into this.

Am trying to avoid GNUplot - Any other advice, resources etc still appreciated.
Back to top
View user's profile Send private message
Hobbes-X
l33t
l33t


Joined: 04 Feb 2004
Posts: 823
Location: Seattle, WA

PostPosted: Mon Mar 26, 2007 11:15 pm    Post subject: Reply with quote

paulizaz wrote:

I want to run some kind of Perl script to automate the process of producing a graph straight from the database on a monthly bases .

More difficult but appreciate any help.


If you're looking to use Perl, have you considered any of the CPAN graph modules? There looks to be quite a few available, even some that interface with the hated GNUplot. :wink:
Back to top
View user's profile Send private message
paulizaz
n00b
n00b


Joined: 09 Jan 2007
Posts: 18

PostPosted: Tue Apr 03, 2007 10:54 am    Post subject: Reply with quote

Resolves and styrmis examples, e.g.:

Quote:

I have a script set to run at the end of every month that does the following:

1. parse relevant data from sar logs
2. place data into comma separated form
3. run the gnuplot file which is set to output a jpg into a directory on our webserver

Once the script has completed, any user can visit the stats web page and all months' data graphs will be available without any further attention on my part. It is all automatic.


This sounds perfect but I dont have the technical skills to be able to connect all these stages through scripting.
Are there no easier methods for a young Newbie Like myself?

Thanks again.....
Back to top
View user's profile Send private message
styrmis
n00b
n00b


Joined: 21 Jan 2006
Posts: 48

PostPosted: Tue Apr 03, 2007 12:09 pm    Post subject: Reply with quote

paulizaz wrote:

This sounds perfect but I dont have the technical skills to be able to connect all these stages through scripting.
Are there no easier methods for a young Newbie Like myself?


Perhaps you can find someone to do the programming part for you?

You need a script that will query the database and instead of placing it in Excel, writes out a file like in my example (the data).

Then you need another script that will write out a Gnuplot file (like in my example) which will fill in the right file name (the file name of the data that has been written e.g. '2007-04-03.dat' to distinguish it from other days' data).

Finally, you need a script which will:

1) Execute the first script to get the data.
2) Take the file name from (1) and execute the second script, writing a one-off Gnuplot file which will read the file from (1) and plot it, saving it as a JPEG/PNG.
3) Copy the image to your webserver and possibly update a page to reflect the change.

If you break it down into stages like this it shouldn't be too hard. For (1) you can refer to the many tutorials on how to interface with databases from scripting languages like Perl or Ruby. I'd recommend Ruby as it's quite simple to learn.

For (2), very little changes each time, so this script will just write out the same Gnuplot file each time except it will change things like the path to the data file and the output destination.

(3) could just be a simple Bash script.
Back to top
View user's profile Send private message
cconroy
Tux's lil' helper
Tux's lil' helper


Joined: 26 Apr 2005
Posts: 81

PostPosted: Tue Apr 03, 2007 2:40 pm    Post subject: Reply with quote

I just recently worked on a project that required dynamic graph generation on a website. We ended up using the GD graphing library (http://www.libgd.org/). It's got bindings for several languages.

I had to hack up the following ruby script to use the output of it though, as my cgi-scripts could not write to the /var/www/ directory...

Code:
#!/usr/bin/ruby
require 'cgi'

$imageDirPath = "/tmp/"

cgi = CGI.new("html4")
imageName = cgi.params['name']

File.open("#{$imageDirPath}#{imageName}.png") { |image|
    contents = image.gets(nil) #read the whole file
    print "Content-type: image/png\n\n"
    print contents
}


Then I just had my other scripts generate an <img src="getImage.rb?name=imageNameHere"> in the target HTML.

Might be useful for you.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum