@@ -80,12 +80,13 @@ func (i *IPerfResults) ToTSV() string {
80
80
// NewIPerf parses an IPerf CSV output line into an IPerfCSVResult.
81
81
func NewIPerf (csvLine string ) (* IPerfCSVResult , error ) {
82
82
if len (csvLine ) == 0 {
83
- return nil , fmt .Errorf ("No iperf output received in csv line" )
83
+ return nil , fmt .Errorf ("no iperf output received in csv line" )
84
84
}
85
85
csvLine = strings .Trim (csvLine , "\n " )
86
86
slice := StrSlice (strings .Split (csvLine , "," ))
87
- if len (slice ) != 9 {
88
- return nil , fmt .Errorf ("Incorrect fields in the output: %v (%v out of 9)" , slice , len (slice ))
87
+ // iperf 2.19+ reports 15 fields, before it was just 9
88
+ if len (slice ) != 15 {
89
+ return nil , fmt .Errorf ("incorrect fields in the output: %v (%v out of 15)" , slice , len (slice ))
89
90
}
90
91
i := IPerfCSVResult {}
91
92
i .date = slice .get (0 )
@@ -127,17 +128,19 @@ type IPerf2EnhancedCSVResults struct {
127
128
128
129
// ParseIPerf2EnhancedResultsFromCSV parses results from iperf2 when given the -e (--enhancedreports)
129
130
// and `--reportstyle C` options.
130
- // Example output:
131
+ // Example output for version < 2.19 (agnhost < 2.53) :
131
132
// 20201210141800.884,10.244.2.24,47880,10.96.114.79,6789,3,0.0-1.0,1677852672,13422821376
132
133
// 20201210141801.881,10.244.2.24,47880,10.96.114.79,6789,3,1.0-2.0,1980760064,15846080512
133
134
// 20201210141802.883,10.244.2.24,47880,10.96.114.79,6789,3,2.0-3.0,1886650368,15093202944
134
- // 20201210141803.882,10.244.2.24,47880,10.96.114.79,6789,3,3.0-4.0,2035417088,16283336704
135
- // 20201210141804.879,10.244.2.24,47880,10.96.114.79,6789,3,4.0-5.0,1922957312,15383658496
136
- // 20201210141805.881,10.244.2.24,47880,10.96.114.79,6789,3,5.0-6.0,2095316992,16762535936
137
- // 20201210141806.882,10.244.2.24,47880,10.96.114.79,6789,3,6.0-7.0,1741291520,13930332160
138
- // 20201210141807.879,10.244.2.24,47880,10.96.114.79,6789,3,7.0-8.0,1862926336,14903410688
139
- // 20201210141808.878,10.244.2.24,47880,10.96.114.79,6789,3,8.0-9.0,1821245440,14569963520
140
- // 20201210141809.849,10.244.2.24,47880,10.96.114.79,6789,3,0.0-10.0,18752208896,15052492511
135
+ // Example output with version >= 2.19 (agnhost >= 2.53)
136
+ // +0000:20240908113035.128,192.168.9.3,58256,192.168.9.4,5001,1,0.0-1.0,5220466748,41763733984,-1,-1,-1,-1,0,0
137
+ // +0000:20240908113036.128,192.168.9.3,58256,192.168.9.4,5001,1,1.0-2.0,5127667712,41021341696,-1,-1,-1,-1,0,0
138
+ // +0000:20240908113037.128,192.168.9.3,58256,192.168.9.4,5001,1,2.0-3.0,5127405568,41019244544,-1,-1,-1,-1,0,0
139
+ // +0000:20240908113038.128,192.168.9.3,58256,192.168.9.4,5001,1,3.0-4.0,5173018624,41384148992,-1,-1,-1,-1,0,0
140
+ // +0000:20240908113039.128,192.168.9.3,58256,192.168.9.4,5001,1,4.0-5.0,5245894656,41967157248,-1,-1,-1,-1,0,0
141
+ // +0000:20240908113040.128,192.168.9.3,58256,192.168.9.4,5001,1,5.0-6.0,5213257728,41706061824,-1,-1,-1,-1,0,0
142
+ // +0000:20240908113041.128,192.168.9.3,58256,192.168.9.4,5001,1,6.0-7.0,5113118720,40904949760,-1,-1,-1,-1,0,0
143
+ // +0000:20240908113042.128,192.168.9.3,58256,192.168.9.4,5001,1,7.0-8.0,5242748928,41941991424,-1,-1,-1,-1,0,0
141
144
func ParseIPerf2EnhancedResultsFromCSV (output string ) (* IPerf2EnhancedCSVResults , error ) {
142
145
var parsedResults []* IPerfCSVResult
143
146
for _ , line := range strings .Split (output , "\n " ) {
@@ -147,7 +150,7 @@ func ParseIPerf2EnhancedResultsFromCSV(output string) (*IPerf2EnhancedCSVResults
147
150
}
148
151
parsedResults = append (parsedResults , parsed )
149
152
}
150
- if parsedResults == nil || len (parsedResults ) == 0 {
153
+ if len (parsedResults ) == 0 {
151
154
return nil , fmt .Errorf ("no results parsed from iperf2 output" )
152
155
}
153
156
// format:
0 commit comments