initial working version
This commit is contained in:
1
reporter.go
Normal file
1
reporter.go
Normal file
@@ -0,0 +1 @@
|
|||||||
|
package iperf
|
||||||
@@ -2,10 +2,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/BGrewell/go-conversions"
|
|
||||||
"github.com/BGrewell/go-iperf"
|
"github.com/BGrewell/go-iperf"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -22,8 +20,17 @@ func main() {
|
|||||||
c.SetOmitSec(omitSec)
|
c.SetOmitSec(omitSec)
|
||||||
c.SetProto((iperf.Protocol)(proto))
|
c.SetProto((iperf.Protocol)(proto))
|
||||||
c.SetLength(length)
|
c.SetLength(length)
|
||||||
|
c.SetJSON(false)
|
||||||
|
c.SetIncludeServer(false)
|
||||||
|
c.SetTimeSec(20)
|
||||||
|
c.SetStreams(2)
|
||||||
|
reports := c.SetModeLive()
|
||||||
|
|
||||||
fmt.Printf("blockcount: %s\n", c.BlockCount())
|
go func() {
|
||||||
|
for report := range reports {
|
||||||
|
fmt.Println(report.String())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
err := c.Start()
|
err := c.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -31,20 +38,24 @@ func main() {
|
|||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
for c.Running {
|
// Method 1: Wait for the test to finish by pulling from the 'Done' channel which will block until something is put in or it's closed
|
||||||
time.Sleep(100 * time.Millisecond)
|
<- c.Done
|
||||||
}
|
|
||||||
|
|
||||||
if c.Report().Error != "" {
|
// Method 2: Poll the c.Running state and wait for it to be 'false'
|
||||||
fmt.Println(c.Report().Error)
|
//for c.Running {
|
||||||
} else {
|
// time.Sleep(100 * time.Millisecond)
|
||||||
for _, entry := range c.Report().End.Streams {
|
//}
|
||||||
fmt.Println(entry.String())
|
|
||||||
}
|
//if c.Report().Error != "" {
|
||||||
for _, entry := range c.Report().ServerOutputJson.End.Streams {
|
// fmt.Println(c.Report().Error)
|
||||||
fmt.Println(entry.String())
|
//} else {
|
||||||
}
|
// for _, entry := range c.Report().End.Streams {
|
||||||
fmt.Printf("DL Rate: %s\n", conversions.IntBitRateToString(int64(c.Report().End.SumReceived.BitsPerSecond)))
|
// fmt.Println(entry.String())
|
||||||
fmt.Printf("UL Rate: %s\n", conversions.IntBitRateToString(int64(c.Report().End.SumSent.BitsPerSecond)))
|
// }
|
||||||
}
|
// for _, entry := range c.Report().ServerOutputJson.End.Streams {
|
||||||
|
// fmt.Println(entry.String())
|
||||||
|
// }
|
||||||
|
// fmt.Printf("DL Rate: %s\n", conversions.IntBitRateToString(int64(c.Report().End.SumReceived.BitsPerSecond)))
|
||||||
|
// fmt.Printf("UL Rate: %s\n", conversions.IntBitRateToString(int64(c.Report().End.SumSent.BitsPerSecond)))
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user