Skip to Content.
Sympa Menu

perfsonar-user - Re: [perfsonar-user] export Throughput results?

Subject: perfSONAR User Q&A and Other Discussion

List archive

Re: [perfsonar-user] export Throughput results?


Chronological Thread 
  • From: Jason Zurawski <>
  • To: Joseph Bernard <>
  • Cc: , Performance Node Users <>
  • Subject: Re: [perfsonar-user] export Throughput results?
  • Date: Tue, 1 Oct 2013 10:39:18 -0400

Hey Joseph;

Find the attached crude attempt - change the perl path and location of your
perfSONAR libraries to be appropriate (e.g. you can do 'svn checkout
http://anonsvn.internet2.edu/svn/perfSONAR-PS/trunk' if you don't have a
local copy, may require you to CPAN some other non-perfSONAR things too), and
add in the MA of your choosing (I tested this against UNL and it seemed to
work ok). I just ran it and piped to a .csv file, and that also seemed to
import into excel cleanly (YMMV).

I will post this on the client example page too
(http://psps.perfsonar.net/client-doc.html).

Thanks;

-jason

#!/opt/local/bin/perl

use lib '/Users/zurawski/Desktop/pS_Test/trunk/Shared/lib';

use perfSONAR_PS::Client::MA;
use XML::Twig;
use Data::Dumper;
use XML::LibXML;

# Create client
my $ma = new perfSONAR_PS::Client::MA( { instance => 'http://perfsonar.unl.edu:8085/perfSONAR_PS/services/pSB' } );

# Define a subject (its blank to get everything)
my $subject = "<iperf:subject xmlns:iperf=\"http://ggf.org/ns/nmwg/tools/iperf/2.0\"; id=\"subject\">\n";
$subject .=   "    <nmwgt:endPointPair xmlns:nmwgt=\"http://ggf.org/ns/nmwg/topology/2.0/\"; />\n";
$subject .=   "</iperf:subject>\n";

# Set the eventType (iperf - for BWCTL data)
my @eventTypes = ('http://ggf.org/ns/nmwg/tools/iperf/2.0');

# Set time range - 1 full day
my $end = time;
my $start = $end - 24*3600;

# Send request to the above MA, this will get all hosts and data - note that some data may be blank
my $result = $ma->setupDataRequest(
        {
            subject    => $subject,
            eventTypes => \@eventTypes,
            start      => $start,
            end        => $end
        }
    );

my $xp = q{};
my $xp2 = q{};
my $parser = XML::LibXML->new();

# create an XPath object to parse
my $xpc = XML::LibXML::XPathContext->new;
$xpc->registerNs( 'nmwg', 'http://ggf.org/ns/nmwg/base/2.0/' );
$xpc->registerNs( 'nmwgt', 'http://ggf.org/ns/nmwg/topology/2.0/' );
$xpc->registerNs( 'iperf', 'http://ggf.org/ns/nmwg/tools/iperf/2.0/' );
$xpc->registerNs( 'nmwgr', 'http://ggf.org/ns/nmwg/result/2.0/' );

# iterate over each metadata element
foreach $metadata ( @{ $result->{"metadata"} } ) {
	$xp = $parser->parse_string( $metadata );
	my $m = $xpc->findnodes( '//nmwg:metadata', $xp->getDocumentElement );

	# extract the src/dest and id (used to find the correct data element)
	my $mid = $m->[0]->getAttribute( "id" );
	my $msrc = $xpc->find( '//nmwgt:src', $m->[0] );
	my $msrcv = $msrc->[0]->getAttribute( "value" );
	my $mdst = $xpc->find( '//nmwgt:dst', $m->[0] );
	my $mdstv = $mdst->[0]->getAttribute( "value" );

	# start CSV printing
	print "src,dst,time,value\n";

	# iterate around the data, we only one the data element that matches our metadata
	foreach $data ( @{ $result->{"data"} } ) {
	        $xp2 = $parser->parse_string( $data );
		my $rd = $xpc->find( '//nmwg:data[@metadataIdRef="' . $mid . '"]/nmwgr:datum', $xp2->getDocumentElement );  
		my $d = $xpc->find( '//nmwg:data[@metadataIdRef="' . $mid . '"]/iperf:datum', $xp2->getDocumentElement );  

		# check if we have any 'error' messages		
		if ( scalar @{ $rd } == 1 ) {
			print $msrcv, ",", $mdstv , ",N/A,Query returned 0 results\n";			
		}
		else {

			# If not, we will have a bunch of datatum elements, get the values out (note that we get it in bps).  
			foreach $d2 ( @{ $d } ) {
				print $msrcv, ",", $mdstv , ",";
				my $time = $d2->getAttribute( "timeValue" );
				my $throughput = $d2->getAttribute( "throughput" );
				print $time , "," , $throughput , " bps\n";
			}
		}
	}
	print "\n\n";
}


On Oct 1, 2013, at 9:00 AM, Joseph Bernard
<>
wrote:

> I need to make a report of our bandwidth tests and need the actual numbers.
> Is there an easy way to export the data collected by the Throughput Tests
> in a tabular format?
>
> Thanks,
> Joseph Bernard



Archive powered by MHonArc 2.6.16.

Top of Page