Commit caa4023a authored by Dan Gebhardt's avatar Dan Gebhardt

Initial changes to support tool generalization. All command-line

arguments and result parsing handled by separate application wrappers.
Currently fping and iperf supported.
Not fully functional at this point: user interface needs extending
to support the generalization, as well as getting the results back
to "opsrecv".

Also merged some of Mike's changes to allow for "private" managers
to use during testing.
parent 7db5d15b
This diff is collapsed.
This diff is collapsed.
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2006, 2007 University of Utah and the Flux Group.
# All rights reserved.
#
use strict;
my %params = (@ARGV);
my $execpath = "/tmp/fping";
my %ERRID = ( #kept the same as defined in libwanetmon for backwards compatibility
unknown => -3,
timeout => -1,
unknownhost => -4,
ICMPunreachable => -5
);
#
# Check for existence of all required params
#
# TODO
#
# Add optional args, if they exist
#
my %optional_exec_args; #TODO
#
# Form arguments specific to this execuable
#
my $execargs = " -t $params{timeout} -s -r $params{retries} $params{target}";
#
# Execute testing application
#
#print "FPING WRAPPER... executing= $execpath $execargs\n";
my $raw = `sudo $execpath $execargs 2>&1`;
#print "FPING WRAPPER... parsing raw= $raw\n";
#
# Parse output
#
$_ = $raw;
my $measr = 0;
my $error = 0;
if( /^ICMP / )
{
$error = $ERRID{ICMPunreachable};
}elsif( /address not found/ ){
$error = $ERRID{unknownhost};
}elsif( /2 timeouts/ ){
$error = $ERRID{timeout};
}elsif( /[\s]+([\S]*) ms \(avg round trip time\)/ ){
$measr = "$1" if( $1 ne "0.00" );
}else{
$error = $ERRID{unknown};
}
#print "MEASR=$measr, ERROR=$error\n";
#
# Output result
#
print "latency=$measr,error=$error\n";
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2006, 2007 University of Utah and the Flux Group.
# All rights reserved.
#
use strict;
my %params = (@ARGV);
my $execpath = "/tmp/iperf";
my %ERRID = ( #kept the same as defined in libwanetmon for backwards compatibility
unknown => -3,
timeout => -1,
unknownhost => -4,
iperfHostUnreachable => -6
);
#
# Check for existence of all required params
#
# TODO
#
# Add optional args, if they exist
#
my %optional_exec_args; #TODO
#
# Form arguments specific to this execuable
#
my $execargs = " -fk -c $params{target} -t $params{duration} -p $params{port}";
#
# Execute testing application
#
my $raw = `$execpath $execargs`;
#print "RAW = $raw\n";
#
# Parse output
#
$_ = $raw;
my $measr = 0;
my $error = 0;
if( /connect failed: Connection timed out/ ){
# this one shouldn't happen, if the timeout check done by
# bgmon is set low enough.
$error = $ERRID{timeout};
}elsif( /write1 failed:/ ){
$error = $ERRID{iperfHostUnreachable};
}elsif( /error: Name or service not known/ ){
$error = $ERRID{unknownhost};
}elsif( /\s+(\S*)\s+([MK])bits\/sec/ ){
$measr = $1;
if( $2 eq "M" ){
$measr *= 1000;
}
}else{
$error = $ERRID{unknown};
}
#print "MEASR=$measr, ERROR=$error\n";
#
# Output result
#
print "bw=$measr,error=$error\n";
...@@ -27,12 +27,29 @@ sub usage { ...@@ -27,12 +27,29 @@ sub usage {
my $debug = 0; my $debug = 0;
my $impotent = 0; my $impotent = 0;
my $nocap = 0;
my $bwperiod = 5;
#
# $evexpt is the experiment ("pid/eid") in which the entire bgmon framework
# (probes, manager, clients) is running. This is used for confining Emulab
# events (client/manager communication) to just that experiment. The
# '-e pid/eid' option to the manager sets the context for that instance.
#
# $bgmonexpt is an incompletely implemented feature that allows multiple
# probe experiments to share the manager. Here the client specifies the
# experiment of the probes (passed in the message) and one common manager
# muxes/demuxes messages to the different probe experiments. There are
# still seperate opsrecv processes. It isn't yet clear how useful this
# might be.
#
my $evexpt = "__none"; my $evexpt = "__none";
my $bgmonexpt;
my $default_bgmonexpt = "tbres/pelabbgmon"; my $default_bgmonexpt = "tbres/pelabbgmon";
my $bgmonexpt;
my ($server,$port,$cmdport); my ($server,$port,$cmdport);
my %opt = (); my %opt = ();
if (!getopts("s:p:c:dih", \%opt)) { if (!getopts("s:p:c:dNihe:", \%opt)) {
exit &usage; exit &usage;
} }
...@@ -58,9 +75,10 @@ if ($opt{s}) { $server = $opt{s}; } else { $server = "localhost"; } ...@@ -58,9 +75,10 @@ if ($opt{s}) { $server = $opt{s}; } else { $server = "localhost"; }
if ($opt{p}) { $port = $opt{p}; } if ($opt{p}) { $port = $opt{p}; }
if ($opt{c}) { $cmdport = $opt{c};} else { $cmdport = 5052; } if ($opt{c}) { $cmdport = $opt{c};} else { $cmdport = 5052; }
if ($opt{h}) { exit &usage; } if ($opt{h}) { exit &usage; }
#if ($opt{e}) { $evexpt = $opt{e}; } if ($opt{e}) { $evexpt = $opt{e}; setevexpid($evexpt); $bgmonexpt=$evexpt;}
if ($opt{d}) { $debug = 1; } if ($opt{d}) { $debug = 1; }
if ($opt{i}) { $impotent = 1; } if ($opt{i}) { $impotent = 1; }
if ($opt{N}) { $nocap = 1; print "*** No bandwidth cap enforced\n"; }
if (@ARGV !=0) { exit &usage; } if (@ARGV !=0) { exit &usage; }
...@@ -87,6 +105,7 @@ if ($port) { $URL .= ":$port"; } ...@@ -87,6 +105,7 @@ if ($port) { $URL .= ":$port"; }
# Register for normal "manager client" notifications # Register for normal "manager client" notifications
my $handle_mc = event_register($URL,0); my $handle_mc = event_register($URL,0);
if (!$handle_mc) { die "Unable to register with event system\n"; } if (!$handle_mc) { die "Unable to register with event system\n"; }
my $tuple = address_tuple_alloc(); my $tuple = address_tuple_alloc();
if (!$tuple) { die "Could not allocate an address tuple\n"; } if (!$tuple) { die "Could not allocate an address tuple\n"; }
...@@ -116,7 +135,7 @@ $sel->add($socket_cmd); ...@@ -116,7 +135,7 @@ $sel->add($socket_cmd);
print "setting cmdport $cmdport and cmdexpt $bgmonexpt\n"; print "setting cmdport $cmdport and cmdexpt $bgmonexpt\n";
setcmdport($cmdport); setcmdport($cmdport);
setexpid($default_bgmonexpt); setexpid($bgmonexpt);
#main() #main()
...@@ -181,8 +200,16 @@ sub callbackFunc($$$) { ...@@ -181,8 +200,16 @@ sub callbackFunc($$$) {
print "EVENT: $time $objtype $eventtype\n" print "EVENT: $time $objtype $eventtype\n"
if ($debug); if ($debug);
# XXX just to make sure we get the event
if( $eventtype eq "TEST" ){
my $managerID = event_notification_get_string($handle,
$notification,
"managerID");
print "got TEST event: managerID=$managerID\n";
}
# TODO: Does this have to be listed in lib/libtb/tbdefs.h ?? # TODO: Does this have to be listed in lib/libtb/tbdefs.h ??
if( $eventtype eq "EDIT" ){ elsif( $eventtype eq "EDIT" ){
# #
# Got a request to modify a path's test freq # Got a request to modify a path's test freq
# #
...@@ -208,17 +235,46 @@ sub callbackFunc($$$) { ...@@ -208,17 +235,46 @@ sub callbackFunc($$$) {
my $newexpid = event_notification_get_string($handle, my $newexpid = event_notification_get_string($handle,
$notification, $notification,
"expid"); "expid");
#
#XXX / TODO: stuff for tool generalization
# hacked in here for now, but source should be from the
# managerclient' message (?)
#
my $toolname;
my $toolwrapperpath;
my $tooltype; #one-shot or continuous
my $req_params; #params required, but universal for each tool instance
my $opt_params = "";
if( $testtype eq "bw" ){
$toolname = "iperf";
$toolwrapperpath = "/tmp/iperfwrapper";
$tooltype = "one-shot";
$req_params = "port 5002 duration 5";
}elsif( $testtype eq "latency"){
$toolname = "fping";
$toolwrapperpath = "/tmp/fpingwrapper";
$tooltype = "one-shot";
$req_params = "timeout 10000 printstats 1 retries 1";
}
if( !defined $newexpid || $newexpid eq "" ){ if( !defined $newexpid || $newexpid eq "" ){
$newexpid = $bgmonexpt; $newexpid = $bgmonexpt;
} }
my %cmd = ( expid => $newexpid, my %cmd = ( expid => $newexpid,
cmdtype => $eventtype, cmdtype => $eventtype,
dstnode => $dstnode, dstnode => $dstnode,
testtype => $testtype, testtype => $testtype,
testper => "$period", testper => "$period",
duration => "$duration", duration => "$duration",
managerID => $managerID managerID => $managerID
,toolname => $toolname
,toolwrapperpath=>$toolwrapperpath
,tooltype => $tooltype
,req_params=> $req_params
,opt_params=> $opt_params
); );
...@@ -254,18 +310,46 @@ sub callbackFunc($$$) { ...@@ -254,18 +310,46 @@ sub callbackFunc($$$) {
my $newexpid = event_notification_get_string($handle, my $newexpid = event_notification_get_string($handle,
$notification, $notification,
"expid"); "expid");
#
#XXX / TODO: stuff for tool generalization
# hacked in here for now, but source should be from the
# managerclient' message (?)
#
my $toolname;
my $toolwrapperpath;
my $tooltype; #one-shot or continuous
my $req_params; #params required, but universal for each tool instance
my $opt_params = "";
if( $testtype eq "bw" ){
$toolname = "iperf";
$toolwrapperpath = "/tmp/iperfwrapper.pl";
$tooltype = "one-shot";
$req_params = "port 5002 duration 5";
}elsif( $testtype eq "latency"){
$toolname = "fping";
$toolwrapperpath = "/tmp/fpingwrapper.pl";
$tooltype = "one-shot";
$req_params = "timeout 10000 retries 1";
}
if( !defined $newexpid || $newexpid eq "" ){ if( !defined $newexpid || $newexpid eq "" ){
$newexpid = $bgmonexpt; $newexpid = $bgmonexpt;
} }
my %cmd = ( expid => $newexpid, my %cmd = ( expid => $newexpid,
cmdtype => $eventtype, cmdtype => $eventtype,
destnodes => $destnodes, destnodes => $destnodes,
srcnode => $srcnode, srcnode => $srcnode,
testtype => $testtype, testtype => $testtype,
testper => "$testper", testper => "$testper",
duration => "$duration" duration => "$duration"
,managerID => $managerID ,managerID => $managerID
,toolname => $toolname
,toolwrapperpath=>$toolwrapperpath
,tooltype => $tooltype
,req_params=> $req_params
,opt_params=> $opt_params
); );
print "got $eventtype:$srcnode,$destnodes,$testtype,". print "got $eventtype:$srcnode,$destnodes,$testtype,".
...@@ -277,8 +361,11 @@ sub callbackFunc($$$) { ...@@ -277,8 +361,11 @@ sub callbackFunc($$$) {
# sendcmd( $srcnode, \%cmd ); # sendcmd( $srcnode, \%cmd );
# } # }
if( isCmdValid(\%cmd) ){ if( isCmdValid(\%cmd) ){
print "sending cmd from $srcnode\n"; # print "sending cmd from $srcnode\n";
sendcmd( $srcnode, \%cmd ); print "sending cmd to $srcnode on behalf of $managerID\n";
sendcmd( $srcnode, \%cmd );
}else{
print "rejecting $testtype cmd for $srcnode\n";
} }
} }
elsif( $eventtype eq "STOPALL" ){ elsif( $eventtype eq "STOPALL" ){
...@@ -315,11 +402,21 @@ sub isCmdValid($) ...@@ -315,11 +402,21 @@ sub isCmdValid($)
#list of invalid conditions #list of invalid conditions
if( $cmdref->{managerID} ne "automanagerclient" ){ if( $cmdref->{managerID} ne "automanagerclient" ){
#managerclient is not the AMC #managerclient is not the AMC
if( $cmdref->{duration} eq "0" ){ if( $cmdref->{duration} == 0 ){
#only AMC can send "forever" commands #only AMC can send "forever" commands
$valid = 0; return(0);
}elsif( $cmdref->{testtype} eq "bw" ) }
{ if( $cmdref->{testtype} eq "bw" ){
# Cannot specify period less than test length
if ( $cmdref->{testper} < $bwperiod ){
return(0);
}
# No caps enforced
if ($nocap) {
return(1);
}
my @destnodes; my @destnodes;
if( $cmdref->{cmdtype} eq "INIT" ){ if( $cmdref->{cmdtype} eq "INIT" ){
@destnodes = split(" ",$cmdref->{destnodes}); @destnodes = split(" ",$cmdref->{destnodes});
......
...@@ -56,7 +56,7 @@ else { $settings{managerID} = "default"; } ...@@ -56,7 +56,7 @@ else { $settings{managerID} = "default"; }
if ($opt{s}) { $server = $opt{s}; } else { $server = "localhost"; } if ($opt{s}) { $server = $opt{s}; } else { $server = "localhost"; }
if ($opt{p}) { $port = $opt{p}; } if ($opt{p}) { $port = $opt{p}; }
if ($opt{h}) { exit &usage; } if ($opt{h}) { exit &usage; }
if ($opt{e}) { $settings{"bgmonexpt"} = $opt{e}; } if ($opt{e}) { $settings{"bgmonexpt"} = $opt{e}; setevexpid($opt{e});}
if ($opt{d}) { $settings{"testduration"} = $opt{d}; } if ($opt{d}) { $settings{"testduration"} = $opt{d}; }
if ($opt{a}) { $settings{"allpairs"} = 1; } if ($opt{a}) { $settings{"allpairs"} = 1; }
if ($opt{L}) { $settings{"noLatency"} = 1; } if ($opt{L}) { $settings{"noLatency"} = 1; }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
rm bgmon.tar.gz rm bgmon.tar.gz
#tar -czf bgmon.tar.gz bgmon.pl runbgmon event.pm #tar -czf bgmon.tar.gz bgmon.pl runbgmon event.pm
tar -czf bgmon.tar.gz bgmon.pl libwanetmon.pm Cmdqueue.pm runbgmon tar -czf bgmon.tar.gz bgmon.pl libwanetmon.pm Cmdqueue.pm runbgmon iperfwrapper.pl
cp bgmon.tar.gz /proj/tbres/gebhardt/wanetmonstuff/ cp bgmon.tar.gz /proj/tbres/gebhardt/wanetmonstuff/
#rm /proj/tbres/gebhardt/wanetmonstuff/iperfd.tar.gz #rm /proj/tbres/gebhardt/wanetmonstuff/iperfd.tar.gz
#rm /proj/tbres/gebhardt/wanetmonstuff/fping.tar.gz #rm /proj/tbres/gebhardt/wanetmonstuff/fping.tar.gz
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment