Skip to content

Commit

Permalink
Formatting wireless stat dump file (#18)
Browse files Browse the repository at this point in the history
* Formatting wireless stat dump file

Formatting the dump file in a more readable
way. Instead of dumping the map into single line
formatted every data item in different line.

* HOS-21217: Sorting the data items

Sorting the data items in a correct way.
  • Loading branch information
chayan-04 authored Sep 11, 2024
1 parent 75c3b0c commit 30274cf
Showing 1 changed file with 44 additions and 10 deletions.
54 changes: 44 additions & 10 deletions plugins/inputs/ah_wireless/ah_wireless.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"
"os/exec"
"fmt"
"sort"
"unsafe"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs"
Expand Down Expand Up @@ -883,15 +884,31 @@ func Gather_Rf_Stat(t *Ah_wireless, acc telegraf.Accumulator) error {

acc.AddGauge("RfStats", fields, nil)

var s string

s = "Stats of interface " + intfName + "\n\n"

for k, v := range fields {
if fmt.Sprint(v) == "0" { // Check if the value is zero
delete(fields, k)
}
}

var s string
s = string(fmt.Sprint(fields))
//log.Printf("%s",s)
keys := make([]string, 0, len(fields))

for k := range fields{
keys = append(keys, k)
}

sort.Strings(keys)

for _, k := range keys {
s = s + k + " : " + fmt.Sprint(fields[k]) + "\n"
}

s = s + "---------------------------------------------------------------------------------------------\n"

log.Printf("ah_wireless: radio status is processed")

dumpOutput(RF_STAT_OUT_FILE, s, 1)

Expand All @@ -912,6 +929,7 @@ func Gather_Client_Stat(t *Ah_wireless, acc telegraf.Accumulator) error {

var total_client_count int
var ii int
var client_mac string
total_client_count = 0
ii = 0

Expand All @@ -922,7 +940,7 @@ func Gather_Client_Stat(t *Ah_wireless, acc telegraf.Accumulator) error {
var ifindex2 int
var numassoc int
var stainfo *ah_ieee80211_sta_info
var client_mac string


var tx_total int64
var rx_total int64
Expand Down Expand Up @@ -1229,15 +1247,31 @@ func Gather_Client_Stat(t *Ah_wireless, acc telegraf.Accumulator) error {
}
t.numclient = total_client_count

var s string

s = "Stats of client [" + client_mac + "]\n\n"

for k, v := range fields2 {
if fmt.Sprint(v) == "0" { // Check if the value is zero
delete(fields2, k)
}
if fmt.Sprint(v) == "0" { // Check if the value is zero
delete(fields2, k)
}
}

keys := make([]string, 0, len(fields2))

for k := range fields2{
keys = append(keys, k)
}

var s string
s = string(fmt.Sprint(fields2))
//log.Printf("%s",s)
sort.Strings(keys)

for _, k := range keys {
s = s + k + " : " + fmt.Sprint(fields2[k]) + "\n"
}

s = s + "---------------------------------------------------------------------------------------------\n"

log.Printf("ah_wireless: client status is processed")

dumpOutput(CLT_STAT_OUT_FILE, s, 1)
return nil
Expand Down

0 comments on commit 30274cf

Please sign in to comment.