Commit 17d42b3c authored by Olav Kvittem's avatar Olav Kvittem

mtr does not allow -i for noenroot - dropped. Use local json-file mp_list.json...

mtr does not allow -i for noenroot - dropped. Use local json-file mp_list.json for name compeltion. mp_list.sh should be in cron
parent 3a120ccf
......@@ -15,7 +15,7 @@
<script type="text/javascript" src="/js/jquery-ui-1.10.3/jquery-1.9.1.js"></script>
<script>
var mp_url="https://kind.uninett.no/autoregister/utstyr_mp.json";
var mp_url="mp_list.json";
function make_select( elm, url){
// var html='<button id=traceroute onclick="traceroute( $(\'#tr_host\').val(), $(\'#tr_times\').val(), $(\'#tr_size\').val(), $(\'#tr_interval\').val() )">Trace route</button> to ';
......
var mp_url="../mp_list.json";
var graf_no=0;
var x_name=[]; // the name of hops in tooltip
function debug_log ( msg){
if(typeof(console) === 'undefined') { /* ie < 9 adaption */
if ( debugging){
alert( msg );
}
} else {
console.log( msg );
}
}
//--------------------------------------------------------------------------------
function make_table(mtr_rows){
}
//--------------------------------------------------------------------------------
// compute order of magnitude
function order(num, unit){
var i=0;
while ( num / Math.pow(unit,i) > unit){
i++;
}
return i;
}
//--------------------------------------------------------------------------------
//
function iperf(direction, host, nobs, interval, parallel, port){
if ( ! nobs ) nobs=10;
if (nobs > 100) {
nobs=100;
alert ('Max number of seconds allowed for test is 100');
}
if (interval > nobs) interval=nobs;
if ( ! host) host="";
var title=true;
$("#busy").show();
var url='iperf-json.pl?host=' + host + '&nobs=' + nobs + '&interval=' + interval + "&direction=" + direction + '&parallel=' + parallel + '&port=' + port;
console.log(url);
var bytes=[], thru=[]; series=[];
x_name=[document.location.host];
var title='Bandwidth report ' + direction + ' ' + host + ' at ' + new Date().toLocaleTimeString();
// var UWAP = require("/_/js/require.js");
var request = $.ajax( { url: url, dataType: 'json', timeout: (nobs+2)*1000, // in ms need +2 sec for iperf
headers: { "X-TOKEN": "virre-virre-vapp" } } );
request.fail( function( jqXHR, status, error){
$("#tracetablecontainer").prepend( '<h3>'+title + ': ' + status + '/' + error +'</h3>'); // error mess
$('#traces').tabs( "enable", 1);
$('#traces').tabs({ active:1});
$("#busy").hide();
});
request.done( function( iperfr){
// UWAP.data.get( url, {"handler": "iperf"}, function(data) {
$("#busy").hide();
$('#traces').tabs( "enable", 0);
$('#traces').tabs( "enable", 1);
if (iperfr.error){
$("#tracetablecontainer").prepend( '<h3>'+title + ': ' + iperfr["error"] +'</h3>'); // error message
$('#traces').tabs({ active:1});
} else if ( ! iperfr.intervals){
$("#tracetablecontainer").prepend( '<h3>'+title + ': Invalid response</h3> '+iperfr)
$('#traces').tabs({ active:1});
} else {
var bfactor, Bfactor;
var html='<table cellpadding="0" cellspacing="0" border="0" class="display" id="tracetable">';
html+='<caption>'+ title + '</caption>';
html += '<thead><th>Interval<th>Transfer<th>Bandwidth<th>Send window<th>Retransmits</thead><tbody>'+"\n";
var xtime=0.0;
var streams=[];
$.each(iperfr.intervals, function(interval) {
if ( iperfr.intervals[interval].streams.sum){
streams=[iperfr.intervals[interval].streams.sum];
} else {
streams=iperfr.intervals[interval].streams;
}
$.each(streams, function(strno) {
var str=streams[strno];
var units=[" ", "K", "M", "G", "T"];
var border=order(str.bits_per_second, 1000);
var Border=order(str.bytes, 1024);
var Bunit=units[Border];
var bunit=units[border];
Bfactor= Math.pow(1024, Border);
bfactor= Math.pow(1024, border);
var win=0; // not present with reverse
if (str.snd_cwnd) win=str.snd_cwnd;
var worder=order( win, 1024);
var wfactor= Math.pow(1024, worder);
var retrans=0;
if (str.retransmits) retrans=str.retransmits;
html += '<tr><td>' + str.start.toFixed(1) + " sec"
+ '<td>' + (str.bytes/Bfactor).toFixed(2) + ' ' + units[Border] + "bytes"
+ '<td>' + (str.bits_per_second/bfactor).toFixed(2) + ' ' + units[border] + "bits/sec"
+ '<td>' + (win/wfactor).toFixed(0) + " " + units[worder] + "bytes"
+ '<td>' + retrans
+ "\n";
xtime= str.start;
if ( ! bytes[strno]) bytes[strno]=[];
bytes[strno].push( [ xtime, str.bytes / Bfactor ] );
if ( ! thru[strno]) thru[strno]=[];
thru[strno].push( [ xtime, str.bits_per_second / bfactor] );
});
});
for ( strno=0; strno < bytes.length; strno++){
series.push({ name: 'Flow '+strno, data: thru[strno], type: 'line'});
}
var str;
if ( iperfr.end.sum_received ){
if ( direction == "to" ){
str=iperfr.end.sum_sent;
} else {
str=iperfr.end.sum_received;
}
} else if ( iperfr.end){
if ( direction == "to" ){
str=iperfr.end.streams[0].sender;
} else {
str=iperfr.end.streams[0].receiver;
}
}
thru_avg=str.bits_per_second/bfactor/bytes.length;
bytes_avg=str.bytes/Bfactor/bytes.length;
html+= '</tbody></table><p> ';
// console.log(html);
$("#tracetablecontainer").prepend(html + '<p> <br><hr>');
$('#tracetable').dataTable( { "bPaginate": false, "bAutoWidth": false, "bFilter": false,
"oLanguage": { "sSearch": "Filter lines:" } });
// var series= [{name:'test', data: [2,4,8,16,25,36,49,64,81]}];
series.push( {name: 'Average', data: [ [0, thru_avg] , [xtime, thru_avg] ]} );
/* { name: 'Data', data: bytes, type: 'line'} */
tegn_graf('graf', 'Bandwidth graph', $('#direction').val() + ' ' + $('#tr_host').val() + ' at ' + new Date().toLocaleTimeString(), series, '', graf_no++,
$('#tracetablecontainer').width());
$('#traces').tabs({ active:0});
// $('#traces').show();
}
});
// request.fail(function( jqXHR, status, error){
// alert( status+error+ ' for url :' + url);
// });
}
//------------------------------------------------------------------------------
//
function make_select_ny( elm, url){
// var html='<button id=traceroute onclick="traceroute( $(\'#tr_host\').val(), $(\'#tr_times\').val(), $(\'#tr_size\').val(), $(\'#tr_interval\').val() )">Trace route</button> to ';
// commented code is to produce a select_menu rather than jquery ui autocomplete
// html+= '<form name="traceroute_form" id="traceroute_form">';
// html+= '<select name="tr_opt" id="tr_opt">';
// html+= '<option value="">My host</option>';
var html='<form name="traceroute_form" id="traceroute_form"';
html+= 'action="javascript:traceroute( $(\'#tr_host\').val(), $(\'#tr_times\').val(), $(\'#tr_size\').val(), $(\'#tr_interval\').val() )">';
html+='<table><tr><td>';
html+='<input type="submit" value="Trace route" class="btn btn-primary btn-lg" /> to ';
// html+='<input id=tr_host value="" placeholder="my host" title="Automatisk utfylling av mleplenavn"></input>';
var html2=' <td> &nbsp;';
html2='<input id=tr_times value=3 style="width:3em;text-align:right"> times</input>';
html2+=', using <input id=tr_size value=64 style="width:3em;text-align:right"> bytes packets</input>';
html2+=', every <input id=tr_interval value=0.1 style="width:3em;text-align:right"> seconds.';
html2+='</table>';
html2+='</form>';
// $(elm).html(html);
html+= '<select name="tr_opt" id="tr_opt" style=width:15em>';
html+= '<option value="">My-own-host</option>';
var items=["caida.org", "uninett.no", "nordu.net"];
for (var item in items){
html+= '<option value="' + items[item] + '">' + items[item] + '</option>';
}
var request=$.ajax( {url: url, type: 'GET', dataType: 'json', crossDomain: true } );
request.done( function( mps){
// console.log(mps);
mps.sort( function(a, b) {
var textA = a.navn.toLowerCase();
var textB = b.navn.toLowerCase();
if (textA < textB)
return -1;
if (textA > textB)
return 1;
return 0;
});
$.each(mps, function(mp) {
items.push( mps[mp].navn);
html+='<option value="' + mps[mp].navn + '">' + mps[mp].navn + '</option>';
// + mps[mp].nettinstallasjon + ': '
});
html+='</select></form>';
$(elm).html(html+html2);
// $( "#tr_host" ).autocomplete({ source: items });
$("#tr_opt").select2();
});
request.fail( function( jqXHR, status, error){
console.log('Listing beacons faild from '+ url + ' : ' + status + ', ' + error);
});
/* var rq=$.JSONget(url, function(data){console.log(data)});
rq.fail( function( jqXHR, error){
console.log(error+ url);
});
*/
}
//--------------------------------------------------------------------------------
function make_select( elm, url){
// var html='<button id=iperf onclick="iperf( $(\'#tr_host\').val(), $(\'#tr_times\').val(), $(\'#tr_size\').val(), $(\'#tr_interval\').val() )">Trace route</button> to ';
// commented code is to produce a select_menu rather than jquery ui autocomplete
// html+= '<form name="iperf_form" id="iperf_form">';
// html+= '<select name="tr_opt" id="tr_opt">';
// html+= '<option value="">My host</option>';
var html='<form name="iperf_form" id="iperf_form"';
html+= 'action="javascript:iperf( $(\'#direction\').val(), $(\'#tr_host\').val(), $(\'#tr_times\').val(), $(\'#tr_interval\').val(), $(\'#tr_parallel\').val(), $(\'#tr_port\').val() )">';
html+='<table><tr><td>';
html+='<input class="btn btn-primary btn-lg" type="submit" value="Test" class=button/> ';
html+='<select id=direction style=width=6em><option value="to">to</option><option value="from">from</option></select>';
html+='<input id=tr_host value="" placeholder="my host" title="Automatisk utfylling av mleplenavn"></input>';
html+='<span id=select-house></span>';
var html2=' <td> &nbsp;';
html2+=' for <input id=tr_times value=5 style="width:2em;text-align:right"> seconds</input>';
// html+=', using <input id=tr_size value=64 style="width:3em;text-align:right"> bytes packets</input>';
html2+=', report every <input id=tr_interval value=0.5 style="width:2em;text-align:right"> seconds';
html2+=', with <input id=tr_parallel value="1" title="Number of parallel sessions" style=width:1em></input> parallels ';
html2+='on port <input id=tr_port value="5001" title="Default port for iperf3 is 5201" style=width:3em></input>';
html2+='</table>';
html2+='</form>';
$(elm).html(html+html2); // make sure something is shown
// html = '<select name="tr_opt" id="tr_opt" style=width:15em>';
// html+= '<option value="">My-own-host</option>';
var items=[];
var request=$.ajax( {url: url, type: 'GET', dataType: 'json', crossDomain: true } );
request.done( function( mps){
// console.log(mps);
mps.sort( function(a, b) {
var textA = a.navn.toLowerCase();
var textB = b.navn.toLowerCase();
if (textA < textB)
return -1;
if (textA > textB)
return 1;
return 0;
});
$.each(mps, function(mp) {
items.push( mps[mp].navn);
// html+='<option value="' + mps[mp].navn + '">' + mps[mp].navn + '</option>';
// + mps[mp].nettinstallasjon + ': '
});
// html+='</select></form>';
// $(elm).html(html+'</select></form>');
// $("#select-house").html(html);
$( "#tr_host" ).autocomplete({ source: items });
// $("#tr_opt").select2();
});
request.fail( function( jqXHR, status, error){
console.log('Listing beacons faild from '+ url + ' : ' + status + ', ' + error);
});
/* var rq=$.JSONget(url, function(data){console.log(data)});
rq.fail( function( jqXHR, error){
console.log(error+ url);
});
*/
}
//------------------------------------------------------------------------------
//
function tegn_graf( div, tittel, subtittel, tider, leg_band, grafno, width ){
var divid=div+(grafno);
if ( $('#' + divid).length <= null ){
$('#'+div).prepend('<div id=' + divid + '></div><p> <hr>');
// debug_log('div created: ' + divid );
}
// $.highcharts({
// $('#graf').highcharts({
// $('#graf'+grafno).highcharts({
var grafen = new Highcharts.Chart({
chart: {
renderTo : divid,
zoomType: 'xy',
width: width
},
title: {
text: tittel
},
subtitle: {
text: subtittel
},
xAxis: {
title : {text: 'Seconds'},
minorTickInterval : 1
// plotBands: leg_band
},
yAxis: [
{ labels: {format: '{value}Mbit/s'}, // min:0,
title: { text: 'Bandwidth'}, minorTickInterval : 'auto',
plotLines: [{ value: 0, width: 2, color: '#808080' }]
},
/* { labels: {format: '{value}MByte'}, min:0,
title: { text: 'Data'}, minorTickInterval : 'auto',
opposite: true
} */
],
tooltip: { formatter: tooltip_pc,
shared: false},
legend: { // title:{ text: 'Parameters',itemStyle: {fontSize: '18px'} },
layout: 'vertical',
align: 'middle',
verticalAlign: 'middle',
x: 70, y:-100,
borderWidth: 0,
itemStyle: {
// color: '#000000',
// fontWeight: 'bold',
paddingBottom: '2px',
fontSize: '14px'
}
},
plotOptions: { series: {marker: { enabled: true, states: { hover: { enabled: true}}}}},
series: tider
});
$('#'+divid).show();
} // of tegn_graf
//--------------------------------------------------------------------------------
function tooltip_ms(){
var s= '<b>' + x_name[this.x] + '</b>';
$.each( this.points, function(i, point){
var unit ='ms';
if ( point.series.name == 'Loss') {unit='%'};
s += ' <br>' + point.series.name + ': ' + point.y.toFixed(1) + unit;
});
return s;
}
function tooltip_pc(){
var unit ='Mbit/s';
if ( this.series.name == "Loss") {unit='%'};
return '<b>' + x_name[0] + '</b>' + ' <br>' + this.series.name + ': ' + this.y.toFixed(1) + unit;
}
//--------------------------------------------------------------------------------
$(document).ready( function(){
$("#busy").hide();
// $("#traces").hide();
$("#traces").tabs({disabled: [0, 1], active:2});
});
//--------------------------------------------------------------------------------
function ResultsUpload(dlspeed, ulspeed, rtt){
$.ajax({
type: "POST",
url: "jsresult.php?system=iperf&start=" + start + '&dlspeed=' + dlspeed + '&ulspeed=' + ulspeed + '&webrtt=' + rtt,
success: function(data, textStatus, jqXHR) {
// alert( 'Stats upload: ' + data + " : " + textStatus);
},
error: function( jqXHR, textStatus, errorThrown){
alert( 'Stats upload: ' + textStatus + " : " + errorThrown);
}
})
}
#! /usr/bin/perl
#
# run mtr and produce json document
# usage : traceroute.json?host=host_name_or_address&count=repetitions
# returns json-document with mtr output
# Olav Kvittem ( Olav.Kvittem@uninett.no )
#
# use CGI;
use CGI qw/:standard -debug/;
use JSON;
my $q = CGI->new;
print $q->header('application/json');
$feilmelding = "<h3><font color=red>%s</font></h3>\n";
if ( $q->http('HTTP_X_TOKEN') ne "virre-virre-vapp" ){
my %msg;
$msg{error}="Access to iperf denied : unauthorized";
push(@mtr, %msg);
print STDERR "Error: ";
my %headers = map { $_ => $q->http($_) } $q->http();
print STDERR "Wrong secret : Got the following headers:\n";
for my $header ( keys %headers ) {
print STDERR "$header: $headers{$header}\n";
}
print encode_json \%msg;
} else {
# print STDERR 'host', $q->param('host'), $q->param('nobs'), $q->param('psize');
my $host = $q->param('host'); # && ( $host =~ m/^[a-zA-Z0-9\.\/\-_\:]+$/);
my $nobs = $q->param('nobs'); # && ( $nobs =~ m/^[0-9]+$/ );
my $psize = $q->param('psize'); # && ( psize =~ m/^[0-9]+$/ );
my $parallel = $q->param('parallel'); # && ( psize =~ m/^[0-9]+$/ );
my $port = $q->param('port'); # && ( psize =~ m/^[0-9]+$/ );
my $interval = $q->param('interval'); # && ( psize =~ m/^[0-9]+$/ );
my $direction = $q->param('direction');
$host =~ s/[^a-zA-Z0-9\.\/\-_\:]+/_/g; # protect
$nobs =~ s/[^0-9]+/_/g;
$psize =~ s/[^0-9]+/_/g;
$port =~ s/[^0-9]+/_/g;
$parallel =~ s/[^0-9]+/_/g;
$direction =~ s/[^a-zA-Z0-9\.\/\-_]+/_/g;
$host = $q->remote_host if $host eq "";
$nobs = 3 if $nobs < 1;
$psize = 64 if $psize < 1;
$parallel = 1 if $port < 1;
$port = 5001 if $port < 1;
$interval= 0.1 if $interval <= 0;
if ($direction eq "from"){
$dirparm="-R";
} else {
$dirparm="";
}
my $cmd= "/usr/local/bin/iperf3 -i $interval -t $nobs -c $host -P $parallel -p $port --json $dirparm";
# open MTR, $cmd || die "Could not open : $cmd : $!";
my $mtr = `$cmd`;
if ( $? != 0){
$mtr = '{ "error": "' . $! . ' : Error running iperf"}';
# print STDERR "Error: $cmd";
}
print $mtr;
}
exit(0);
var mp_url="https://kind.uninett.no/autoregister/utstyr_mp.json";
var mp_url='mp_list.json';
var mp_list=[];
function make_select( elm, url){
// var html='<button id=traceroute onclick="traceroute( $(\'#tr_host\').val(), $(\'#tr_times\').val(), $(\'#tr_size\').val(), $(\'#tr_interval\').val() )">Trace route</button> to ';
......
#!/bin/sh
# get list om measurement beacons
wget -q -O mp_list.new https://kind.uninett.no/autoregister/utstyr_mp.json
if test -s mp_list.new ; then
mv mp_list.new mp_list.json
fi
var mp_url="https://kind.uninett.no/autoregister/utstyr_mp.json";
var mp_url='../mp_list.json';
var x_name=[]; // the name of hops in tooltip
var graf_no=0;
......@@ -31,7 +31,7 @@ function traceroute(host, nobs, psize, interval){
if ( ! host) host="";
var html='<table cellpadding="0" cellspacing="0" border="0" class="display" id="tracetable">';
html+='<caption>Route report at ' + new Date().toLocaleTimeString() + '</caption><thead>';
// html+='<caption>Route report at ' + new Date().toLocaleTimeString() + '</caption><thead>';
var title=true;
$("#busy").show();
......@@ -44,7 +44,7 @@ function traceroute(host, nobs, psize, interval){
// var UWAP = require("/_/js/require.js");
var request = $.ajax( { url: url, dataType: 'json',
headers: { "X_TOKEN": "virre-virre-vapp" } } );
headers: { "X-TOKEN": "virre-virre-vapp" } } );
request.fail( function( jqXHR, status, error){
alert('Traceroute failed from '+ url + ' : ' + status + ', ' + error );
});
......@@ -55,30 +55,35 @@ function traceroute(host, nobs, psize, interval){
alert( mtr_rows[0] + ' : ' + mtr_rows[1] );
$("#busy").hide();
} else { // normally ok data
// row 0 is date and row 1 contains headers
$.each(mtr_rows, function(tr) {
if (tr == 1){ html+= '</thead><tbody>'};
html+='<tr>';
$.each(mtr_rows[tr], function(td) {
if (tr == 0){
html+='<th align=left>' + mtr_rows[tr][td];
} else {
var a='';
if ( td == 1 ){
html+='<td><a target=mping href="http://mping.uninett.no/cgi-bin/mping/loss_mam?host=' + mtr_rows[tr][td] + '&group=uninett&date=130628&lang=no">' + mtr_rows[tr][td] + '</a>';
if (tr == 0){ // header line
html+='<caption>Route report at ' + mtr_rows[tr][1] + '</caption><thead>';
} else {
if (tr == 2){ html+= '</thead><tbody>'};
html+='<tr>';
$.each(mtr_rows[tr], function(td) {
if (tr == 1){
html+='<th align=left>' + mtr_rows[tr][td];
} else {
html+='<td>' + mtr_rows[tr][td];
var a='';
if ( td == 1 ){
html+='<td><a target=mping href="http://mping.uninett.no/cgi-bin/mping/loss_mam?host=' + mtr_rows[tr][td] + '&group=uninett&date=130628&lang=no">' + mtr_rows[tr][td] + '</a>';
} else {
html+='<td>' + mtr_rows[tr][td];
}
}
// console.log(mtr_rows[tr]);
});
if ( tr > 1 ){
x_name.push( mtr_rows[tr][1] );
loss.push( parseFloat( mtr_rows[tr][2] ) );
avg.push( parseFloat( mtr_rows[tr][5] ) );
best.push( parseFloat( mtr_rows[tr][6] ) );
wrst.push( parseFloat( mtr_rows[tr][7] ) );
stdev.push( parseFloat( mtr_rows[tr][8] ) );
}
// console.log(mtr_rows[tr]);
});
if ( tr > 0 ){
x_name.push( mtr_rows[tr][1] );
loss.push( parseFloat( mtr_rows[tr][2] ) );
avg.push( parseFloat( mtr_rows[tr][5] ) );
best.push( parseFloat( mtr_rows[tr][6] ) );
wrst.push( parseFloat( mtr_rows[tr][7] ) );
stdev.push( parseFloat( mtr_rows[tr][8] ) );
}
});
......@@ -94,7 +99,8 @@ function traceroute(host, nobs, psize, interval){
{ name: 'Best', data: best, type: 'scatter'},
{ name: 'Loss', data: loss, type: 'scatter', yAxis: 1},
];
tegn_graf('graf', 'Latency graph ', 'To ' + $('#tr_host').val() + ' at ' + new Date().toLocaleTimeString(), series, '', graf_no++,
tegn_graf('graf', 'Latency graph ', 'To ' + $('#tr_host').val() +
' at ' + new Date().toLocaleTimeString(), series, '', graf_no++,
$('#tracetablecontainer').width());
$('#traces').tabs( "enable", 0);
$('#traces').tabs( "enable", 1);
......@@ -120,14 +126,14 @@ function make_select( elm, url){
// html+= '<select name="tr_opt" id="tr_opt">';
// html+= '<option value="">My host</option>';
var html='<form name="traceroute_form" id="traceroute_form"';
html+= 'action="javascript:traceroute( $(\'#tr_host\').val(), $(\'#tr_times\').val(), $(\'#tr_size\').val(), $(\'#tr_interval\').val() )">';
html+= 'action="javascript:traceroute( $(\'#tr_host\').val(), $(\'#tr_times\').val(), $(\'#tr_size\').val(), 1 /* $(\'#tr_interval\').val()*/ )">';
html+='<table><tr><td>';
html+='<input type="submit" value="Trace route" class="btn btn-primary btn-lg" /> to ';
html+='<input id=tr_host value="" placeholder="my host" title="Automatisk utfylling av mleplenavn"></input>';
var html2=' <td> &nbsp;';
html2='<input id=tr_times value=3 style="width:3em;text-align:right"> times</input>';
html2+=', using <input id=tr_size value=64 style="width:3em;text-align:right"> bytes packets</input>';
html2+=', every <input id=tr_interval value=0.1 style="width:3em;text-align:right"> seconds.';
html2+=', using <input id=tr_size value=64 style="width:3em;text-align:right"> bytes packets.</input>';
//ok html2+=', every <input id=tr_interval value=0.1 style="width:3em;text-align:right"> seconds.';
html2+='</table>';
html2+='</form>';
......
......@@ -39,25 +39,33 @@ if ( $q->http('HTTP_X_TOKEN') ne "virre-virre-vapp"){
$nobs = 3 if $nobs < 1;
$psize = 64 if $psize < 1;
$interval= 0.1 if $interval <= 0;
my $cmd= "/usr/bin/mtr -c $nobs -s $psize -i $interval --report --report-wide $host";
# my $cmd= "/usr/bin/mtr -c $nobs -s $psize -i $interval --report --report-wide $host";
# mtr does not like interval less than 1sek from nonroot and therefore purposeless
my $cmd= "/usr/bin/mtr -c $nobs -s $psize --report --report-wide $host";
# open MTR, $cmd || die "Could not open : $cmd : $!";
my $mtr = `$cmd`;
if ( $? != 0){
push(@mtr, "Error" , $! || "Might be unknown host");
print STDERR "Error: $cmd";
$error=$!;
push(@mtr, "Error" , $error || "Might be unknown host");
printf STDERR "Error: $cmd : $error \n";
} else { # ok
# print STDERR "Kode $? : $cmd";
#while(<MTR>){
foreach ( split(/\n/, $mtr) ){
s/^\s+//; # leading blanks
@F = split( /\s+/ );
if ($F[0] = /(\d+)[^\d]+/){
$F[0]=$1;
if (/^(Start): (.*)/){ # header line
push( @mtr, [$1, $2]);
} else {
s/^\s+//; # leading blanks
@F = split( /\s+/ );
if ($F[0] = /(\d+)[^\d]+/){
$F[0]=$1;
}
push( @mtr, [@F] );
}
push( @mtr, [@F] );
}
}
}
......
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