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

THANKS IN ADVANCE!

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