From 1dfb547080f39aac10465afa908feb6954f353de Mon Sep 17 00:00:00 2001 From: Martin/Geno Date: Mon, 18 Jun 2018 15:21:07 +0200 Subject: [PATCH] [TASK] add support for wifictld --- data/nodeinfo.go | 21 +++++++++++---------- data/statistics.go | 1 + data/wifictld.go | 26 ++++++++++++++++++++++++++ database/influxdb/node.go | 11 +++++++++++ 4 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 data/wifictld.go diff --git a/data/nodeinfo.go b/data/nodeinfo.go index 86cff15..11190ba 100644 --- a/data/nodeinfo.go +++ b/data/nodeinfo.go @@ -2,16 +2,17 @@ package data // Nodeinfo struct type Nodeinfo struct { - NodeID string `json:"node_id"` - Network Network `json:"network"` - Owner *Owner `json:"owner"` - System System `json:"system"` - Hostname string `json:"hostname"` - Location *Location `json:"location,omitempty"` - Software Software `json:"software"` - Hardware Hardware `json:"hardware"` - VPN bool `json:"vpn"` - Wireless *Wireless `json:"wireless,omitempty"` + NodeID string `json:"node_id"` + Network Network `json:"network"` + Owner *Owner `json:"owner"` + System System `json:"system"` + Hostname string `json:"hostname"` + Location *Location `json:"location,omitempty"` + Software Software `json:"software"` + Hardware Hardware `json:"hardware"` + VPN bool `json:"vpn"` + Wireless *Wireless `json:"wireless,omitempty"` + Wifictld *WifiCTLDNodeinfo `json:"wifictld,omitempty"` } // NetworkInterface struct diff --git a/data/statistics.go b/data/statistics.go index 365e3e6..4764156 100644 --- a/data/statistics.go +++ b/data/statistics.go @@ -32,6 +32,7 @@ type Statistics struct { } `json:"traffic,omitempty"` Switch map[string]*SwitchPort `json:"switch,omitempty"` Wireless WirelessStatistics `json:"wireless,omitempty"` + Wifictld *WifiCTLDStatistics `json:"wifictld,omitempty"` ProcStats *ProcStats `json:"stat,omitempty"` } diff --git a/data/wifictld.go b/data/wifictld.go new file mode 100644 index 0000000..ba7de82 --- /dev/null +++ b/data/wifictld.go @@ -0,0 +1,26 @@ +package data + +// WifiCTLDNodeinfo struct (defined in: https://chaos.expert/genofire/wifictld/blob/preview/wireless/wifictld/src/ubus_service.c - ubus_get_config) +type WifiCTLDNodeinfo struct { + Verbose uint8 `json:"verbose,omitempty"` + ClientTryThreashold uint32 `json:"client_try_threashold,omitempty"` + ClientSignalThreashold int32 `json:"client_signal_threashold,omitempty"` + ClientCleanEvery uint32 `json:"client_clean_every,omitempty"` + ClientCleanOlderThen uint32 `json:"client_clean_older_then,omitempty"` + ClientCleanAuthed uint8 `json:"client_clean_authed,omitempty"` + ClientForce uint8 `json:"client_force,omitempty"` + ClientForceProbe uint8 `json:"client_force_probe,omitempty"` + ClientProbeSteering uint8 `json:"client_probe_steering,omitempty"` + ClientProbeLearning uint8 `json:"client_probe_learning,omitempty"` +} + +// WifiCTLDStatistics struct (defined in: https://chaos.expert/genofire/wifictld/blob/preview/wireless/respondd-module-wifictld/src/respondd.c - respondd_provider_statistics) +type WifiCTLDStatistics struct { + Total uint32 `json:"total,omitempty"` + Client24 uint32 `json:"client24,omitempty"` + Client5 uint32 `json:"client5,omitempty"` + Authed uint32 `json:"authed,omitempty"` + Connected uint32 `json:"connected,omitempty"` + HighestTryProbe uint32 `json:"highest_try_probe,omitempty"` + HighestTryAuth uint32 `json:"highest_try_auth,omitempty"` +} diff --git a/database/influxdb/node.go b/database/influxdb/node.go index daf3c83..eaf26ce 100644 --- a/database/influxdb/node.go +++ b/database/influxdb/node.go @@ -153,6 +153,17 @@ func (conn *Connection) InsertNode(node *runtime.Node) { tags.SetString("frequency"+suffix, strconv.Itoa(int(airtime.Frequency))) } + // Add Wifictld statistics + if wifictld := stats.Wifictld; wifictld != nil { + fields["wifictld.total"] = wifictld.Total + fields["wifictld.client24"] = wifictld.Client24 + fields["wifictld.client5"] = wifictld.Client5 + fields["wifictld.authed"] = wifictld.Authed + fields["wifictld.connected"] = wifictld.Connected + fields["wifictld.highest_try_probe"] = wifictld.HighestTryProbe + fields["wifictld.highest_try_auth"] = wifictld.HighestTryAuth + } + conn.addPoint(MeasurementNode, tags, fields, time) // Add DHCP statistics