Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Graph with VMstat output

by Jabox (Sexton)
on Jun 02, 2014 at 18:53 UTC ( #1088300=perlquestion: print w/replies, xml ) Need Help??

Jabox has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to make a graph with two different data in the same graph. So the graph would look like

Process Graph

| | | * | + | __________________

* = uninterupted + = waiting

The data

Proc * + 9 8

So far what I did was

push(@$run_stats_all, $run); push(@$unint_stats_all, $unint);

And I want to add those two by doing

would this part work?
my @proc = ([@$run_stats_all],[@$unit_stats_all]); push (@procdata, @proc);

And then use the following to create graph

$obj->createGraph( $input_file, $num_samples, 'Processe +s', 'proc_data', \@procdata, \@proclabels ),

the $obj is a module to create the graph which works on mpstat and iostat just not sure how to do vmstat

I just want to know if that code up there would work or would it get messy and mess it up?

It was easier on mpstat and iostat because mpstat has CPU and iostat has sda devices


P.S. I am still very bad doing perl... so if it doesn't add up at all I apologize. Trying to improve my troubleshooting / critical thinking skills while doing these kinds of codes

Replies are listed 'Best First'.
Re: Graph with VMstat output
by zentara (Archbishop) on Jun 02, 2014 at 21:24 UTC
    My advice is to break down the problem into small junks which you can understand. First, see if you can create a GD graph manually with your data, then if successful, see if your object output is suitable for input to GD::graph.

    GD graph has some nested arrays it uses for input, for example, see how the data is arranged in the following example. Make sure your input is like that.

    #!/usr/bin/perl -w use strict; use GD::Graph::bars; my @data = ( [qw(a b c d e f g)], [1,2,3,4,5,6,7] ); my $graph = GD::Graph::bars->new(200, 200); $graph->set( transparent => '0', bgclr => 'lgray', boxclr => 'white', fgclr => 'white', cycle_clrs => '1', x_label => 'X Label', y_label => 'Y label', ); my $gd = $graph->plot(\@data); binmode STDOUT; #print "Content-type: image/png\n\n"; print $gd->png();

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: Graph with VMstat output
by hexcoder (Deacon) on Jun 02, 2014 at 22:07 UTC
    Adding to zentara's good advice...

    Your line
    my @proc = ([@$run_stats_all],[@$unit_stats_all]);
    has the same structure as the line in zentaras example
    my @data = ...

    You can find out about nested structures by using the core module Data::Dumper

    use Data::Dumper; print Dumper( \@proc );
    It would show the values of @proc along with their internal structure.

    Anyway, in this case @proc will have two entries. Each is a reference to an anonymous array.
    The first array holds the run_stats_all values,
    the second one holds the unit_stats_all values.

    Hope that helps!

Re: Graph with VMstat output
by InfiniteSilence (Curate) on Jun 02, 2014 at 20:22 UTC

    So...what graph module are you using to call createGraph()? Is it GD::3DBarGrapher or SVGGraph or what?

    Celebrate Intellectual Diversity

      Ah I'm using GD::Graph

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1088300]
Approved by Old_Gray_Bear
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2022-12-05 20:22 GMT
Find Nodes?
    Voting Booth?

    No recent polls found