pcp
[Top] [All Lists]

mmv pmda: stuff always fails the first time?

To: pcp@xxxxxxxxxxx
Subject: mmv pmda: stuff always fails the first time?
From: Martin Hicks <mort@xxxxxxxx>
Date: Fri, 6 Nov 2009 10:39:00 -0500
User-agent: Mutt/1.5.20 (2009-06-14)
I have a super simple perl MMV PMDA that I was using as a demonstration
for someone at SGI, who wanted to see a value via PCP and graph it.

This was an excuse to look at the MMV pmda for the first time.  It seems
that the first time I try to store to mmv.reload it fails, and also when
I query a value the first time.

mort@laplace:~/src/pcpqa.git$ pmstore mmv.reload 1
mmv.reload: pmLookupDesc: Try again. Information not currently available
mort@laplace:~/src/pcpqa.git$ pmstore mmv.reload 1
mmv.reload old value=0 new value=1
mort@laplace:~/src/pcpqa.git$ pminfo mmv
mmv.reload
mmv.mymmv.export_value
mort@laplace:~/src/pcpqa.git$ pminfo -f mmv.mymmv
mmv.mymmv.export_value: pmLookupDesc: Try again. Information not currently 
available
mort@laplace:~/src/pcpqa.git$ pminfo -f mmv.mymmv

mmv.mymmv.export_value
    value 15


Is this something wrong with the way I wrote the PMDA, or is this a bug
in the MMV PMDA?

(My silly example is written this way because they wanted to export a
value that is printed in stdout of the program, and monitor it in
realtime:

run with:   ./gendata.sh | ./mmvtest.pl


mort@laplace:~$ cat ./gendata.sh

value=5

myf () {
   echo "abc"
   echo "def"
   echo "new value: $value"
   value=$(($value + 5))
   echo "ghi"
   echo "jkl"
}


while true; do
        myf
        sleep 10
done


mort@laplace:~$ cat ./mmvtest.pl
#!/usr/bin/perl

use strict;
use warnings;
use PCP::MMV;

my @indoms = ();
my @metrics = (
    ['export_value',
     1, MMV_TYPE_U64, MMV_INDOM_NULL,
     mmv_units(0,0,0,0,0,0), MMV_SEM_INSTANT,
     'A counter of some value', ''
    ]
);

my $handle = mmv_stats_init('mymmv', 0, MMV_FLAG_PROCESS, \@metrics, \@indoms);
die ("mmv_stats_init failed\n") unless (defined($handle));

while (my $line = <STDIN>) {
    print $line;
    next if not $line =~ /^new value:/;
    
    my $val;
    ($val = $line) =~ s/^new value: (\d+)/$1/;
    chomp $val;
    mmv_stats_set($handle, 'export_value', '', $val);
}


-- 
Martin Hicks || mort@xxxxxxxx || PGP/GnuPG: 0x4C7F2BEE

<Prev in Thread] Current Thread [Next in Thread>