Fix some bugs.
This commit is contained in:
parent
71a9cd112b
commit
89a50e8c79
|
|
@ -65,7 +65,7 @@ is provided so the application can be easily adapted to any environment.
|
|||
|
||||
`Config File Parameters`
|
||||
|
||||
sites default: ["all"]
|
||||
sites default: ["all"]
|
||||
This list of strings should represent the names of sites on the UniFi
|
||||
controller that will be polled for data. Pass `all` in the list to
|
||||
poll all sites. On startup, the application prints out all site names
|
||||
|
|
@ -73,20 +73,20 @@ is provided so the application can be easily adapted to any environment.
|
|||
next to them. The cryptic names go into the config file `sites` list.
|
||||
The controller's first site is not cryptic and is named `default`.
|
||||
|
||||
interval default: 30s
|
||||
interval default: 30s
|
||||
How often to poll the controller for updated client and device data.
|
||||
The UniFi Controller only updates traffic stats about every 30 seconds.
|
||||
|
||||
debug default: false
|
||||
debug default: false
|
||||
This turns on time stamps and line numbers in logs, outputs a few extra
|
||||
lines of information while processing.
|
||||
|
||||
quiet default: false
|
||||
quiet default: false
|
||||
Setting this to true will turn off per-device and per-interval logs. Only
|
||||
errors will be logged. Using this with debug=true adds line numbers to
|
||||
any error logs.
|
||||
|
||||
mode default: "influx"
|
||||
mode default: "influx"
|
||||
* Value: influx
|
||||
This default mode runs this application as a daemon. It will poll
|
||||
the controller at the configured interval. Providing an invalid value
|
||||
|
|
@ -101,7 +101,7 @@ is provided so the application can be easily adapted to any environment.
|
|||
This mode can also be combined with a "test database" in InfluxDB to
|
||||
give yourself a "test config file" you may run ad-hoc to test changes.
|
||||
|
||||
max_errors default: 0
|
||||
max_errors default: 0
|
||||
If you restart the UniFI controller, the poller will lose access until
|
||||
it is restarted. Specifying a number greater than -1 for max_errors will
|
||||
cause the poller to exit when it reaches the error count specified.
|
||||
|
|
@ -113,16 +113,16 @@ is provided so the application can be easily adapted to any environment.
|
|||
docker or launchd. The default setting of 0 will cause an exit after
|
||||
just 1 error. Recommended values are 0-5.
|
||||
|
||||
influx_url default: http://127.0.0.1:8086
|
||||
influx_url default: http://127.0.0.1:8086
|
||||
This is the URL where the Influx web server is available.
|
||||
|
||||
influx_user default: unifi
|
||||
influx_user default: unifi
|
||||
Username used to authenticate with InfluxDB.
|
||||
|
||||
influx_pass default: unifi
|
||||
influx_pass default: unifi
|
||||
Password used to authenticate with InfluxDB.
|
||||
|
||||
influx_db default: unifi
|
||||
influx_db default: unifi
|
||||
Custom database created in InfluxDB to use with this application.
|
||||
On first setup, log into InfluxDB and create access:
|
||||
$ influx -host localhost -port 8086
|
||||
|
|
@ -130,30 +130,33 @@ is provided so the application can be easily adapted to any environment.
|
|||
CREATE USER unifi WITH PASSWORD 'unifi' WITH ALL PRIVILEGES
|
||||
GRANT ALL ON unifi TO unifi
|
||||
|
||||
unifi_url default: https://127.0.0.1:8443
|
||||
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
|
||||
This is the URL where the UniFi Controller is available.
|
||||
|
||||
unifi_user default: influxdb
|
||||
unifi_user default: influxdb
|
||||
Username used to authenticate with UniFi controller. This should be a
|
||||
special service account created on the control with read-only access.
|
||||
|
||||
unifi_user no default ENV: UNIFI_PASSWORD
|
||||
unifi_user no default ENV: UNIFI_PASSWORD
|
||||
Password used to authenticate with UniFi controller. This can also be
|
||||
set in an environment variable instead of a configuration file.
|
||||
|
||||
collect_ids default: false
|
||||
collect_ids default: false
|
||||
Setting this parameter to true will enable collection of Intrusion
|
||||
Detection System data. IDS and IPS are the same data set. This is off
|
||||
by default because most controllers do not have this enabled. It also
|
||||
creates a lot of new metrics from controllers with a lot of IDS entries.
|
||||
|
||||
reauthenticate default: false
|
||||
reauthenticate default: false
|
||||
Setting this parameter to true will make UniFi Poller send a new login
|
||||
request on every interval. This generates a new cookie. Some controller
|
||||
or reverse proxy configurations require this. Do not enable it unless
|
||||
your configuration causes the poller to be logged out after some time.
|
||||
|
||||
verify_ssl default: false
|
||||
verify_ssl default: false
|
||||
If your UniFi controller has a valid SSL certificate, you can enable
|
||||
this option to validate it. Otherwise, any SSL certificate is valid.
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ influx_user = "unifi"
|
|||
influx_pass = "unifi"
|
||||
# Be sure to create this database.
|
||||
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.
|
||||
unifi_user = "influx"
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
"influx_user": "unifi",
|
||||
"influx_pass": "unifi",
|
||||
"influx_db": "unifi",
|
||||
"influx_insecure_ssl": false,
|
||||
"unifi_user": "influx",
|
||||
"unifi_pass": "",
|
||||
"unifi_url": "https://127.0.0.1:8443",
|
||||
|
|
|
|||
|
|
@ -63,7 +63,10 @@
|
|||
<influx_pass>unifi</influx_pass>
|
||||
<influx_url>http://127.0.0.1:8086</influx_url>
|
||||
<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.
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ influx_user: "unifi"
|
|||
influx_pass: "unifi"
|
||||
# Be sure to create this database.
|
||||
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.
|
||||
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"`
|
||||
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"`
|
||||
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"`
|
||||
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"`
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ func processVAPs(vt unifi.VapTable, rt unifi.RadioTable, rts unifi.RadioTableSta
|
|||
tags["channel"] = p.Channel.Txt
|
||||
tags["radio"] = p.Radio
|
||||
fields["current_antenna_gain"] = p.CurrentAntennaGain.Val
|
||||
fields["ht"] = p.Ht
|
||||
fields["ht"] = p.Ht.Txt
|
||||
fields["max_txpower"] = p.MaxTxpower.Val
|
||||
fields["min_rssi_enabled"] = p.MinRssiEnabled.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_temperature": u.HasTemperature.Txt,
|
||||
"jumboframe_enabled": u.JumboframeEnabled.Txt,
|
||||
"stp_priority": u.StpPriority,
|
||||
"stp_version": u.StpVersion,
|
||||
}
|
||||
fields = map[string]interface{}{
|
||||
|
|
@ -198,6 +197,7 @@ func UDMPoints(u *unifi.UDM, now time.Time) ([]*influx.Point, error) {
|
|||
"cpu": u.SystemStats.CPU.Val,
|
||||
"mem": u.SystemStats.Mem.Val,
|
||||
"system_uptime": u.SystemStats.Uptime.Val,
|
||||
"stp_priority": u.StpPriority.Val,
|
||||
"stat_bytes": u.Stat.Sw.Bytes.Val,
|
||||
"stat_rx_bytes": u.Stat.Sw.RxBytes.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,
|
||||
"networkgroup": p.Networkgroup,
|
||||
"site_id": p.SiteID,
|
||||
"ip": p.IP,
|
||||
"ip_subnet": p.IPSubnet,
|
||||
"mac": p.Mac,
|
||||
"name": p.Name,
|
||||
"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,
|
||||
}
|
||||
fields := map[string]interface{}{
|
||||
"domain_name": p.DomainName,
|
||||
"dhcpd_start": p.DhcpdStart,
|
||||
"dhcpd_stop": p.DhcpdStop,
|
||||
"ip": p.IP,
|
||||
"ip_subnet": p.IPSubnet,
|
||||
"mac": p.Mac,
|
||||
"name": p.Name,
|
||||
"num_sta": p.NumSta.Val,
|
||||
"purpose": p.Purpose,
|
||||
"rx_bytes": p.RxBytes.Val,
|
||||
"rx_packets": p.RxPackets.Val,
|
||||
"tx_bytes": p.TxBytes.Val,
|
||||
"tx_packets": p.TxPackets.Val,
|
||||
"ipv6_interface_type": p.Ipv6InterfaceType,
|
||||
"attr_hidden_id": p.AttrHiddenID,
|
||||
"num_sta": p.NumSta.Val,
|
||||
"rx_bytes": p.RxBytes.Val,
|
||||
"rx_packets": p.RxPackets.Val,
|
||||
"tx_bytes": p.TxBytes.Val,
|
||||
"tx_packets": p.TxPackets.Val,
|
||||
}
|
||||
pt, err = influx.NewPoint("usg_networks", tags, fields, now)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ func USWPoints(u *unifi.USW, now time.Time) ([]*influx.Point, error) {
|
|||
"has_fan": u.HasFan.Txt,
|
||||
"has_temperature": u.HasTemperature.Txt,
|
||||
"jumboframe_enabled": u.JumboframeEnabled.Txt,
|
||||
"stp_priority": u.StpPriority,
|
||||
"stp_version": u.StpVersion,
|
||||
}
|
||||
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,
|
||||
"cpu": u.SystemStats.CPU.Val,
|
||||
"mem": u.SystemStats.Mem.Val,
|
||||
"stp_priority": u.StpPriority.Val,
|
||||
"system_uptime": u.SystemStats.Uptime.Val,
|
||||
"stat_bytes": u.Stat.Bytes.Val,
|
||||
"stat_rx_bytes": u.Stat.RxBytes.Val,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package unifipoller
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
|
@ -96,9 +97,10 @@ func (u *UnifiPoller) Run() (err error) {
|
|||
// GetInfluxDB returns an InfluxDB interface.
|
||||
func (u *UnifiPoller) GetInfluxDB() (err error) {
|
||||
u.Influx, err = influx.NewHTTPClient(influx.HTTPConfig{
|
||||
Addr: u.Config.InfluxURL,
|
||||
Username: u.Config.InfluxUser,
|
||||
Password: u.Config.InfluxPass,
|
||||
Addr: u.Config.InfluxURL,
|
||||
Username: u.Config.InfluxUser,
|
||||
Password: u.Config.InfluxPass,
|
||||
TLSConfig: &tls.Config{InsecureSkipVerify: u.Config.InfxBadSSL},
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("influxdb: %v", err)
|
||||
|
|
|
|||
Loading…
Reference in New Issue