Fix some bugs.
This commit is contained in:
parent
4104c35b91
commit
186837d512
|
|
@ -130,6 +130,9 @@ is provided so the application can be easily adapted to any environment.
|
||||||
CREATE USER unifi WITH PASSWORD 'unifi' WITH ALL PRIVILEGES
|
CREATE USER unifi WITH PASSWORD 'unifi' WITH ALL PRIVILEGES
|
||||||
GRANT ALL ON unifi TO unifi
|
GRANT ALL ON unifi TO unifi
|
||||||
|
|
||||||
|
influx_insecure_ssl default: false
|
||||||
|
Setting this to true will allow use of InfluxDB with an invalid SSL certificate.
|
||||||
|
|
||||||
unifi_url default: https://127.0.0.1:8443
|
unifi_url default: https://127.0.0.1:8443
|
||||||
This is the URL where the UniFi Controller is available.
|
This is the URL where the UniFi Controller is available.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,8 @@ influx_user = "unifi"
|
||||||
influx_pass = "unifi"
|
influx_pass = "unifi"
|
||||||
# Be sure to create this database.
|
# Be sure to create this database.
|
||||||
influx_db = "unifi"
|
influx_db = "unifi"
|
||||||
|
# If your InfluxDB uses an invalid SSL cert, set this to true.
|
||||||
|
influx_insecure_ssl = false
|
||||||
|
|
||||||
# Make a read-only user in the UniFi Admin Settings.
|
# Make a read-only user in the UniFi Admin Settings.
|
||||||
unifi_user = "influx"
|
unifi_user = "influx"
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
"influx_user": "unifi",
|
"influx_user": "unifi",
|
||||||
"influx_pass": "unifi",
|
"influx_pass": "unifi",
|
||||||
"influx_db": "unifi",
|
"influx_db": "unifi",
|
||||||
|
"influx_insecure_ssl": false,
|
||||||
"unifi_user": "influx",
|
"unifi_user": "influx",
|
||||||
"unifi_pass": "",
|
"unifi_pass": "",
|
||||||
"unifi_url": "https://127.0.0.1:8443",
|
"unifi_url": "https://127.0.0.1:8443",
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,10 @@
|
||||||
<influx_pass>unifi</influx_pass>
|
<influx_pass>unifi</influx_pass>
|
||||||
<influx_url>http://127.0.0.1:8086</influx_url>
|
<influx_url>http://127.0.0.1:8086</influx_url>
|
||||||
<influx_user>unifi</influx_user>
|
<influx_user>unifi</influx_user>
|
||||||
|
<!--
|
||||||
|
# If your InfluxDB uses an invalid SSL cert, set this to true.
|
||||||
|
-->
|
||||||
|
<influx_insecure_ssl>false</influx_insecure_ssl>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
# Make a read-only user in the UniFi Admin Settings.
|
# Make a read-only user in the UniFi Admin Settings.
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,8 @@ influx_user: "unifi"
|
||||||
influx_pass: "unifi"
|
influx_pass: "unifi"
|
||||||
# Be sure to create this database.
|
# Be sure to create this database.
|
||||||
influx_db: "unifi"
|
influx_db: "unifi"
|
||||||
|
# If your InfluxDB uses an invalid SSL cert, set this to true.
|
||||||
|
influx_insecure_ssl: false
|
||||||
|
|
||||||
# Make a read-only user in the UniFi Admin Settings.
|
# Make a read-only user in the UniFi Admin Settings.
|
||||||
unifi_user: "influx"
|
unifi_user: "influx"
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ type Config struct {
|
||||||
VerifySSL bool `json:"verify_ssl" toml:"verify_ssl" xml:"verify_ssl" yaml:"verify_ssl" env:"VERIFY_SSL"`
|
VerifySSL bool `json:"verify_ssl" toml:"verify_ssl" xml:"verify_ssl" yaml:"verify_ssl" env:"VERIFY_SSL"`
|
||||||
CollectIDS bool `json:"collect_ids" toml:"collect_ids" xml:"collect_ids" yaml:"collect_ids" env:"COLLECT_IDS"`
|
CollectIDS bool `json:"collect_ids" toml:"collect_ids" xml:"collect_ids" yaml:"collect_ids" env:"COLLECT_IDS"`
|
||||||
ReAuth bool `json:"reauthenticate" toml:"reauthenticate" xml:"reauthenticate" yaml:"reauthenticate" env:"REAUTHENTICATE"`
|
ReAuth bool `json:"reauthenticate" toml:"reauthenticate" xml:"reauthenticate" yaml:"reauthenticate" env:"REAUTHENTICATE"`
|
||||||
|
InfxBadSSL bool `json:"influx_insecure_ssl" toml:"influx_insecure_ssl" xml:"influx_insecure_ssl" yaml:"influx_insecure_ssl" env:"INFLUX_INSECURE_SSL"`
|
||||||
Mode string `json:"mode" toml:"mode" xml:"mode" yaml:"mode" env:"POLLING_MODE"`
|
Mode string `json:"mode" toml:"mode" xml:"mode" yaml:"mode" env:"POLLING_MODE"`
|
||||||
InfluxURL string `json:"influx_url,_omitempty" toml:"influx_url,_omitempty" xml:"influx_url" yaml:"influx_url" env:"INFLUX_URL"`
|
InfluxURL string `json:"influx_url,_omitempty" toml:"influx_url,_omitempty" xml:"influx_url" yaml:"influx_url" env:"INFLUX_URL"`
|
||||||
InfluxUser string `json:"influx_user,_omitempty" toml:"influx_user,_omitempty" xml:"influx_user" yaml:"influx_user" env:"INFLUX_USER"`
|
InfluxUser string `json:"influx_user,_omitempty" toml:"influx_user,_omitempty" xml:"influx_user" yaml:"influx_user" env:"INFLUX_USER"`
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ func processVAPs(vt unifi.VapTable, rt unifi.RadioTable, rts unifi.RadioTableSta
|
||||||
tags["channel"] = p.Channel.Txt
|
tags["channel"] = p.Channel.Txt
|
||||||
tags["radio"] = p.Radio
|
tags["radio"] = p.Radio
|
||||||
fields["current_antenna_gain"] = p.CurrentAntennaGain.Val
|
fields["current_antenna_gain"] = p.CurrentAntennaGain.Val
|
||||||
fields["ht"] = p.Ht
|
fields["ht"] = p.Ht.Txt
|
||||||
fields["max_txpower"] = p.MaxTxpower.Val
|
fields["max_txpower"] = p.MaxTxpower.Val
|
||||||
fields["min_rssi_enabled"] = p.MinRssiEnabled.Val
|
fields["min_rssi_enabled"] = p.MinRssiEnabled.Val
|
||||||
fields["min_txpower"] = p.MinTxpower.Val
|
fields["min_txpower"] = p.MinTxpower.Val
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,6 @@ func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
|
||||||
"has_fan": u.HasFan.Txt,
|
"has_fan": u.HasFan.Txt,
|
||||||
"has_temperature": u.HasTemperature.Txt,
|
"has_temperature": u.HasTemperature.Txt,
|
||||||
"jumboframe_enabled": u.JumboframeEnabled.Txt,
|
"jumboframe_enabled": u.JumboframeEnabled.Txt,
|
||||||
"stp_priority": u.StpPriority,
|
|
||||||
"stp_version": u.StpVersion,
|
"stp_version": u.StpVersion,
|
||||||
}
|
}
|
||||||
fields = map[string]interface{}{
|
fields = map[string]interface{}{
|
||||||
|
|
@ -198,6 +197,7 @@ func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
|
||||||
"cpu": u.SystemStats.CPU.Val,
|
"cpu": u.SystemStats.CPU.Val,
|
||||||
"mem": u.SystemStats.Mem.Val,
|
"mem": u.SystemStats.Mem.Val,
|
||||||
"system_uptime": u.SystemStats.Uptime.Val,
|
"system_uptime": u.SystemStats.Uptime.Val,
|
||||||
|
"stp_priority": u.StpPriority.Val,
|
||||||
"stat_bytes": u.Stat.Sw.Bytes.Val,
|
"stat_bytes": u.Stat.Sw.Bytes.Val,
|
||||||
"stat_rx_bytes": u.Stat.Sw.RxBytes.Val,
|
"stat_rx_bytes": u.Stat.Sw.RxBytes.Val,
|
||||||
"stat_rx_crypts": u.Stat.Sw.RxCrypts.Val,
|
"stat_rx_crypts": u.Stat.Sw.RxCrypts.Val,
|
||||||
|
|
|
||||||
|
|
@ -170,23 +170,23 @@ func USGPoints(u *unifi.USG, now time.Time) ([]*influx.Point, error) {
|
||||||
"is_nat": p.IsNat.Txt,
|
"is_nat": p.IsNat.Txt,
|
||||||
"networkgroup": p.Networkgroup,
|
"networkgroup": p.Networkgroup,
|
||||||
"site_id": p.SiteID,
|
"site_id": p.SiteID,
|
||||||
}
|
|
||||||
fields := map[string]interface{}{
|
|
||||||
"domain_name": p.DomainName,
|
|
||||||
"dhcpd_start": p.DhcpdStart,
|
|
||||||
"dhcpd_stop": p.DhcpdStop,
|
|
||||||
"ip": p.IP,
|
"ip": p.IP,
|
||||||
"ip_subnet": p.IPSubnet,
|
"ip_subnet": p.IPSubnet,
|
||||||
"mac": p.Mac,
|
"mac": p.Mac,
|
||||||
"name": p.Name,
|
"name": p.Name,
|
||||||
"num_sta": p.NumSta.Val,
|
"domain_name": p.DomainName,
|
||||||
|
"dhcpd_start": p.DhcpdStart,
|
||||||
|
"dhcpd_stop": p.DhcpdStop,
|
||||||
|
"ipv6_interface_type": p.Ipv6InterfaceType,
|
||||||
|
"attr_hidden_id": p.AttrHiddenID,
|
||||||
"purpose": p.Purpose,
|
"purpose": p.Purpose,
|
||||||
|
}
|
||||||
|
fields := map[string]interface{}{
|
||||||
|
"num_sta": p.NumSta.Val,
|
||||||
"rx_bytes": p.RxBytes.Val,
|
"rx_bytes": p.RxBytes.Val,
|
||||||
"rx_packets": p.RxPackets.Val,
|
"rx_packets": p.RxPackets.Val,
|
||||||
"tx_bytes": p.TxBytes.Val,
|
"tx_bytes": p.TxBytes.Val,
|
||||||
"tx_packets": p.TxPackets.Val,
|
"tx_packets": p.TxPackets.Val,
|
||||||
"ipv6_interface_type": p.Ipv6InterfaceType,
|
|
||||||
"attr_hidden_id": p.AttrHiddenID,
|
|
||||||
}
|
}
|
||||||
pt, err = influx.NewPoint("usg_networks", tags, fields, now)
|
pt, err = influx.NewPoint("usg_networks", tags, fields, now)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ func USWPoints(u *unifi.USW, now time.Time) ([]*influx.Point, error) {
|
||||||
"has_fan": u.HasFan.Txt,
|
"has_fan": u.HasFan.Txt,
|
||||||
"has_temperature": u.HasTemperature.Txt,
|
"has_temperature": u.HasTemperature.Txt,
|
||||||
"jumboframe_enabled": u.JumboframeEnabled.Txt,
|
"jumboframe_enabled": u.JumboframeEnabled.Txt,
|
||||||
"stp_priority": u.StpPriority,
|
|
||||||
"stp_version": u.StpVersion,
|
"stp_version": u.StpVersion,
|
||||||
}
|
}
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
|
|
@ -63,6 +62,7 @@ func USWPoints(u *unifi.USW, now time.Time) ([]*influx.Point, error) {
|
||||||
"mem_total": u.SysStats.MemTotal.Val,
|
"mem_total": u.SysStats.MemTotal.Val,
|
||||||
"cpu": u.SystemStats.CPU.Val,
|
"cpu": u.SystemStats.CPU.Val,
|
||||||
"mem": u.SystemStats.Mem.Val,
|
"mem": u.SystemStats.Mem.Val,
|
||||||
|
"stp_priority": u.StpPriority.Val,
|
||||||
"system_uptime": u.SystemStats.Uptime.Val,
|
"system_uptime": u.SystemStats.Uptime.Val,
|
||||||
"stat_bytes": u.Stat.Bytes.Val,
|
"stat_bytes": u.Stat.Bytes.Val,
|
||||||
"stat_rx_bytes": u.Stat.RxBytes.Val,
|
"stat_rx_bytes": u.Stat.RxBytes.Val,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package unifipoller
|
package unifipoller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -99,6 +100,7 @@ func (u *UnifiPoller) GetInfluxDB() (err error) {
|
||||||
Addr: u.Config.InfluxURL,
|
Addr: u.Config.InfluxURL,
|
||||||
Username: u.Config.InfluxUser,
|
Username: u.Config.InfluxUser,
|
||||||
Password: u.Config.InfluxPass,
|
Password: u.Config.InfluxPass,
|
||||||
|
TLSConfig: &tls.Config{InsecureSkipVerify: u.Config.InfxBadSSL},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("influxdb: %v", err)
|
return fmt.Errorf("influxdb: %v", err)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue