Add wan2 metrics to InfluxDB.
This commit is contained in:
parent
910304e7f6
commit
562e244451
|
|
@ -41,6 +41,8 @@ func (u USG) Points() ([]*influx.Point, error) {
|
|||
"version_incompatible": u.VersionIncompatible.Txt,
|
||||
"usg_caps": strconv.FormatFloat(u.UsgCaps, 'f', 6, 64),
|
||||
"speedtest-status-saved": u.SpeedtestStatusSaved.Txt,
|
||||
"wan1_up": u.Wan2.Up.Txt,
|
||||
"wan2_up": u.Wan2.Up.Txt,
|
||||
}
|
||||
fields := map[string]interface{}{
|
||||
"ip": u.IP,
|
||||
|
|
@ -71,60 +73,84 @@ func (u USG) Points() ([]*influx.Point, error) {
|
|||
"speedtest-status_upload": u.SpeedtestStatus.StatusUpload,
|
||||
"speedtest-status_xput_download": u.SpeedtestStatus.XputDownload,
|
||||
"speedtest-status_xput_upload": u.SpeedtestStatus.XputUpload,
|
||||
// have two WANs? mmmm, go ahead and add it. ;)
|
||||
"config_network_wan_type": u.ConfigNetworkWan.Type,
|
||||
"wan1_bytes-r": u.Wan1.BytesR,
|
||||
"wan1_enable": u.Wan1.Enable.Val,
|
||||
"wan1_full_duplex": u.Wan1.FullDuplex.Val,
|
||||
"wan1_purpose": "uplink", // because it should have a purpose.
|
||||
"wan1_gateway": u.Wan1.Gateway,
|
||||
"wan1_ifname": u.Wan1.Ifname,
|
||||
"wan1_ip": u.Wan1.IP,
|
||||
"wan1_mac": u.Wan1.Mac,
|
||||
"wan1_max_speed": u.Wan1.MaxSpeed,
|
||||
"wan1_name": u.Wan1.Name,
|
||||
"wan1_netmask": u.Wan1.Netmask,
|
||||
"wan1_rx_bytes": u.Wan1.RxBytes.Val,
|
||||
"wan1_rx_bytes-r": u.Wan1.RxBytesR,
|
||||
"wan1_rx_dropped": u.Wan1.RxDropped,
|
||||
"wan1_rx_errors": u.Wan1.RxErrors,
|
||||
"wan1_rx_multicast": u.Wan1.RxMulticast,
|
||||
"wan1_rx_packets": u.Wan1.RxPackets,
|
||||
"wan1_type": u.Wan1.Type,
|
||||
"wan1_speed": u.Wan1.Speed,
|
||||
"wan1_up": u.Wan1.Up.Val,
|
||||
"wan1_tx_bytes": u.Wan1.TxBytes.Val,
|
||||
"wan1_tx_bytes-r": u.Wan1.TxBytesR,
|
||||
"wan1_tx_dropped": u.Wan1.TxDropped,
|
||||
"wan1_tx_errors": u.Wan1.TxErrors,
|
||||
"wan1_tx_packets": u.Wan1.TxPackets,
|
||||
"loadavg_1": u.SysStats.Loadavg1,
|
||||
"loadavg_5": u.SysStats.Loadavg5,
|
||||
"loadavg_15": u.SysStats.Loadavg15,
|
||||
"mem_used": u.SysStats.MemUsed,
|
||||
"mem_buffer": u.SysStats.MemBuffer,
|
||||
"mem_total": u.SysStats.MemTotal,
|
||||
"cpu": u.SystemStats.CPU,
|
||||
"mem": u.SystemStats.Mem,
|
||||
"system_uptime": u.SystemStats.Uptime,
|
||||
"stat_duration": u.Stat.Duration,
|
||||
"stat_datetime": u.Stat.Datetime,
|
||||
"gw": u.Stat.Gw,
|
||||
"false": "false", // to fill holes in graphs.
|
||||
"lan-rx_bytes": u.Stat.LanRxBytes,
|
||||
"lan-rx_packets": u.Stat.LanRxPackets,
|
||||
"lan-tx_bytes": u.Stat.LanTxBytes,
|
||||
"lan-tx_packets": u.Stat.LanTxPackets,
|
||||
"wan-rx_bytes": u.Stat.WanRxBytes,
|
||||
"wan-rx_dropped": u.Stat.WanRxDropped,
|
||||
"wan-rx_packets": u.Stat.WanRxPackets,
|
||||
"wan-tx_bytes": u.Stat.WanTxBytes,
|
||||
"wan-tx_packets": u.Stat.WanTxPackets,
|
||||
"uplink_name": u.Uplink.Name,
|
||||
"uplink_latency": u.Uplink.Latency,
|
||||
"uplink_speed": u.Uplink.Speed,
|
||||
"uplink_num_ports": u.Uplink.NumPort,
|
||||
"uplink_max_speed": u.Uplink.MaxSpeed,
|
||||
"config_network_wan_type": u.ConfigNetworkWan.Type,
|
||||
"wan1_bytes-r": u.Wan1.BytesR.Val,
|
||||
"wan1_enable": u.Wan1.Enable.Val,
|
||||
"wan1_full_duplex": u.Wan1.FullDuplex.Val,
|
||||
"wan1_purpose": "uplink", // because it should have a purpose.
|
||||
"wan1_gateway": u.Wan1.Gateway,
|
||||
"wan1_ifname": u.Wan1.Ifname,
|
||||
"wan1_ip": u.Wan1.IP,
|
||||
"wan1_mac": u.Wan1.Mac,
|
||||
"wan1_max_speed": u.Wan1.MaxSpeed.Val,
|
||||
"wan1_name": u.Wan1.Name,
|
||||
"wan1_netmask": u.Wan1.Netmask,
|
||||
"wan1_rx_bytes": u.Wan1.RxBytes.Val,
|
||||
"wan1_rx_bytes-r": u.Wan1.RxBytesR.Val,
|
||||
"wan1_rx_dropped": u.Wan1.RxDropped.Val,
|
||||
"wan1_rx_errors": u.Wan1.RxErrors.Val,
|
||||
"wan1_rx_multicast": u.Wan1.RxMulticast.Val,
|
||||
"wan1_rx_packets": u.Wan1.RxPackets.Val,
|
||||
"wan1_type": u.Wan1.Type,
|
||||
"wan1_speed": u.Wan1.Speed.Val,
|
||||
"wan1_up": u.Wan1.Up.Val,
|
||||
"wan1_tx_bytes": u.Wan1.TxBytes.Val,
|
||||
"wan1_tx_bytes-r": u.Wan1.TxBytesR.Val,
|
||||
"wan1_tx_dropped": u.Wan1.TxDropped.Val,
|
||||
"wan1_tx_errors": u.Wan1.TxErrors.Val,
|
||||
"wan1_tx_packets": u.Wan1.TxPackets.Val,
|
||||
"wan2_bytes-r": u.Wan2.BytesR.Val,
|
||||
"wan2_enable": u.Wan2.Enable.Val,
|
||||
"wan2_full_duplex": u.Wan2.FullDuplex.Val,
|
||||
"wan2_purpose": "uplink", // because it should have a purpose.
|
||||
"wan2_gateway": u.Wan2.Gateway,
|
||||
"wan2_ifname": u.Wan2.Ifname,
|
||||
"wan2_ip": u.Wan2.IP,
|
||||
"wan2_mac": u.Wan2.Mac,
|
||||
"wan2_max_speed": u.Wan2.MaxSpeed.Val,
|
||||
"wan2_name": u.Wan2.Name,
|
||||
"wan2_netmask": u.Wan2.Netmask,
|
||||
"wan2_rx_bytes": u.Wan2.RxBytes.Val,
|
||||
"wan2_rx_bytes-r": u.Wan2.RxBytesR.Val,
|
||||
"wan2_rx_dropped": u.Wan2.RxDropped.Val,
|
||||
"wan2_rx_errors": u.Wan2.RxErrors.Val,
|
||||
"wan2_rx_multicast": u.Wan2.RxMulticast.Val,
|
||||
"wan2_rx_packets": u.Wan2.RxPackets.Val,
|
||||
"wan2_type": u.Wan2.Type,
|
||||
"wan2_speed": u.Wan2.Speed.Val,
|
||||
"wan2_up": u.Wan2.Up.Val,
|
||||
"wan2_tx_bytes": u.Wan2.TxBytes.Val,
|
||||
"wan2_tx_bytes-r": u.Wan2.TxBytesR.Val,
|
||||
"wan2_tx_dropped": u.Wan2.TxDropped.Val,
|
||||
"wan2_tx_errors": u.Wan2.TxErrors.Val,
|
||||
"wan2_tx_packets": u.Wan2.TxPackets.Val,
|
||||
"loadavg_1": u.SysStats.Loadavg1,
|
||||
"loadavg_5": u.SysStats.Loadavg5,
|
||||
"loadavg_15": u.SysStats.Loadavg15,
|
||||
"mem_used": u.SysStats.MemUsed,
|
||||
"mem_buffer": u.SysStats.MemBuffer,
|
||||
"mem_total": u.SysStats.MemTotal,
|
||||
"cpu": u.SystemStats.CPU,
|
||||
"mem": u.SystemStats.Mem,
|
||||
"system_uptime": u.SystemStats.Uptime,
|
||||
"stat_duration": u.Stat.Duration,
|
||||
"stat_datetime": u.Stat.Datetime,
|
||||
"gw": u.Stat.Gw,
|
||||
"false": "false", // to fill holes in graphs.
|
||||
"lan-rx_bytes": u.Stat.LanRxBytes,
|
||||
"lan-rx_packets": u.Stat.LanRxPackets,
|
||||
"lan-tx_bytes": u.Stat.LanTxBytes,
|
||||
"lan-tx_packets": u.Stat.LanTxPackets,
|
||||
"wan-rx_bytes": u.Stat.WanRxBytes,
|
||||
"wan-rx_dropped": u.Stat.WanRxDropped,
|
||||
"wan-rx_packets": u.Stat.WanRxPackets,
|
||||
"wan-tx_bytes": u.Stat.WanTxBytes,
|
||||
"wan-tx_packets": u.Stat.WanTxPackets,
|
||||
"uplink_name": u.Uplink.Name,
|
||||
"uplink_latency": u.Uplink.Latency,
|
||||
"uplink_speed": u.Uplink.Speed,
|
||||
"uplink_num_ports": u.Uplink.NumPort,
|
||||
"uplink_max_speed": u.Uplink.MaxSpeed,
|
||||
}
|
||||
pt, err := influx.NewPoint("usg", tags, fields, time.Now())
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ type USG struct {
|
|||
Version string `json:"version"`
|
||||
VersionIncompatible FlexBool `json:"version_incompatible"`
|
||||
Wan1 struct {
|
||||
BytesR float64 `json:"bytes-r"`
|
||||
BytesR FlexInt `json:"bytes-r"`
|
||||
DNS []string `json:"dns"`
|
||||
Enable FlexBool `json:"enable"`
|
||||
FullDuplex FlexBool `json:"full_duplex"`
|
||||
|
|
@ -214,26 +214,26 @@ type USG struct {
|
|||
Ifname string `json:"ifname"`
|
||||
IP string `json:"ip"`
|
||||
Mac string `json:"mac"`
|
||||
MaxSpeed float64 `json:"max_speed"`
|
||||
MaxSpeed FlexInt `json:"max_speed"`
|
||||
Name string `json:"name"`
|
||||
Netmask string `json:"netmask"`
|
||||
RxBytes FlexInt `json:"rx_bytes"`
|
||||
RxBytesR float64 `json:"rx_bytes-r"`
|
||||
RxDropped float64 `json:"rx_dropped"`
|
||||
RxErrors float64 `json:"rx_errors"`
|
||||
RxMulticast float64 `json:"rx_multicast"`
|
||||
RxPackets float64 `json:"rx_packets"`
|
||||
Speed float64 `json:"speed"`
|
||||
RxBytesR FlexInt `json:"rx_bytes-r"`
|
||||
RxDropped FlexInt `json:"rx_dropped"`
|
||||
RxErrors FlexInt `json:"rx_errors"`
|
||||
RxMulticast FlexInt `json:"rx_multicast"`
|
||||
RxPackets FlexInt `json:"rx_packets"`
|
||||
Speed FlexInt `json:"speed"`
|
||||
TxBytes FlexInt `json:"tx_bytes"`
|
||||
TxBytesR float64 `json:"tx_bytes-r"`
|
||||
TxDropped float64 `json:"tx_dropped"`
|
||||
TxErrors float64 `json:"tx_errors"`
|
||||
TxPackets float64 `json:"tx_packets"`
|
||||
TxBytesR FlexInt `json:"tx_bytes-r"`
|
||||
TxDropped FlexInt `json:"tx_dropped"`
|
||||
TxErrors FlexInt `json:"tx_errors"`
|
||||
TxPackets FlexInt `json:"tx_packets"`
|
||||
Type string `json:"type"`
|
||||
Up FlexBool `json:"up"`
|
||||
} `json:"wan1"`
|
||||
Wan2 struct {
|
||||
BytesR float64 `json:"bytes-r"`
|
||||
BytesR FlexInt `json:"bytes-r"`
|
||||
DNS []string `json:"dns"`
|
||||
Enable FlexBool `json:"enable"`
|
||||
FullDuplex FlexBool `json:"full_duplex"`
|
||||
|
|
@ -241,21 +241,21 @@ type USG struct {
|
|||
Ifname string `json:"ifname"`
|
||||
IP string `json:"ip"`
|
||||
Mac string `json:"mac"`
|
||||
MaxSpeed float64 `json:"max_speed"`
|
||||
MaxSpeed FlexInt `json:"max_speed"`
|
||||
Name string `json:"name"`
|
||||
Netmask string `json:"netmask"`
|
||||
RxBytes FlexInt `json:"rx_bytes"`
|
||||
RxBytesR float64 `json:"rx_bytes-r"`
|
||||
RxDropped float64 `json:"rx_dropped"`
|
||||
RxErrors float64 `json:"rx_errors"`
|
||||
RxMulticast float64 `json:"rx_multicast"`
|
||||
RxPackets float64 `json:"rx_packets"`
|
||||
Speed float64 `json:"speed"`
|
||||
RxBytesR FlexInt `json:"rx_bytes-r"`
|
||||
RxDropped FlexInt `json:"rx_dropped"`
|
||||
RxErrors FlexInt `json:"rx_errors"`
|
||||
RxMulticast FlexInt `json:"rx_multicast"`
|
||||
RxPackets FlexInt `json:"rx_packets"`
|
||||
Speed FlexInt `json:"speed"`
|
||||
TxBytes FlexInt `json:"tx_bytes"`
|
||||
TxBytesR float64 `json:"tx_bytes-r"`
|
||||
TxDropped float64 `json:"tx_dropped"`
|
||||
TxErrors float64 `json:"tx_errors"`
|
||||
TxPackets float64 `json:"tx_packets"`
|
||||
TxBytesR FlexInt `json:"tx_bytes-r"`
|
||||
TxDropped FlexInt `json:"tx_dropped"`
|
||||
TxErrors FlexInt `json:"tx_errors"`
|
||||
TxPackets FlexInt `json:"tx_packets"`
|
||||
Type string `json:"type"`
|
||||
Up FlexBool `json:"up"`
|
||||
} `json:"wan2"`
|
||||
|
|
|
|||
Loading…
Reference in New Issue