file formatting fixes

This commit is contained in:
Cody Lee 2022-11-23 22:08:48 -06:00
parent 0f0398d7a7
commit c811ebc1bb
No known key found for this signature in database
5 changed files with 58 additions and 55 deletions

View File

@ -81,7 +81,8 @@ documentation support. This project succeeds because of them. Thank you!
</p> </p>
## Copyright & License ## Copyright & License
<img style="float: right;" align="right" width="200px" src="https://unpoller.com/img/unpoller.png"> <img style="float: right;" align="right" width="200px" src="https://unpoller.com/img/unpoller.png">
- Copyright © 2018-2020 David Newhall II. - Copyright © 2018-2020 David Newhall II.
- See [LICENSE](LICENSE) for license information. - See [LICENSE](LICENSE) for license information.

View File

@ -6,8 +6,7 @@ This module ties the inputs together with the outputs.
Aggregates metrics on request. Provides CLI app and args parsing. Aggregates metrics on request. Provides CLI app and args parsing.
## Ideal
# Ideal
This library has no notion of "UniFi" or controllers, or Influx, or Prometheus. This library has no notion of "UniFi" or controllers, or Influx, or Prometheus.
This library simply provides an input interface and an output interface. This library simply provides an input interface and an output interface.
@ -17,10 +16,10 @@ Cisco gear, or any other network (or even non-network) data. The existing plugin
should provide ample example of how to use this library, but at some point the should provide ample example of how to use this library, but at some point the
godoc will improve. godoc will improve.
# Features ## Features
- Automatically unmarshal's plugin config structs from config file and/or env variables. - Automatically unmarshal's plugin config structs from config file and/or env variables.
- Initializes all "imported" plugins on startup. - Initializes all "imported" plugins on startup.
- Provides input plugins a Logger, requires an interface for Metrics and Events retrieval. - Provides input plugins a Logger, requires an interface for Metrics and Events retrieval.
- Provides Output plugins an interface to retrieve Metrics and Events, and a Logger. - Provides Output plugins an interface to retrieve Metrics and Events, and a Logger.
- Provides automatic aggregation of Metrics and Events from multiple sources. - Provides automatic aggregation of Metrics and Events from multiple sources.

View File

@ -14,6 +14,7 @@ adding methods to update data, and I'm okay with that. I'll even help add them.
Pull requests, feature requests, code reviews and feedback are welcomed! Pull requests, feature requests, code reviews and feedback are welcomed!
Here's a working example: Here's a working example:
```golang ```golang
package main package main
@ -21,44 +22,44 @@ import "log"
import "github.com/unpoller/unpoller/core/unifi" import "github.com/unpoller/unpoller/core/unifi"
func main() { func main() {
c := *unifi.Config{ c := *unifi.Config{
User: "admin", User: "admin",
Pass: "superSecret1234", Pass: "superSecret1234",
URL: "https://127.0.0.1:8443/", URL: "https://127.0.0.1:8443/",
// Log with log.Printf or make your own interface that accepts (msg, fmt) // Log with log.Printf or make your own interface that accepts (msg, fmt)
ErrorLog: log.Printf, ErrorLog: log.Printf,
DebugLog: log.Printf, DebugLog: log.Printf,
} }
uni, err := unifi.NewUnifi(c) uni, err := unifi.NewUnifi(c)
if err != nil { if err != nil {
log.Fatalln("Error:", err) log.Fatalln("Error:", err)
} }
sites, err := uni.GetSites() sites, err := uni.GetSites()
if err != nil { if err != nil {
log.Fatalln("Error:", err) log.Fatalln("Error:", err)
} }
clients, err := uni.GetClients(sites) clients, err := uni.GetClients(sites)
if err != nil { if err != nil {
log.Fatalln("Error:", err) log.Fatalln("Error:", err)
} }
devices, err := uni.GetDevices(sites) devices, err := uni.GetDevices(sites)
if err != nil { if err != nil {
log.Fatalln("Error:", err) log.Fatalln("Error:", err)
} }
log.Println(len(sites), "Unifi Sites Found: ", sites) log.Println(len(sites), "Unifi Sites Found: ", sites)
log.Println(len(clients), "Clients connected:") log.Println(len(clients), "Clients connected:")
for i, client := range clients { for i, client := range clients {
log.Println(i+1, client.ID, client.Hostname, client.IP, client.Name, client.LastSeen) log.Println(i+1, client.ID, client.Hostname, client.IP, client.Name, client.LastSeen)
} }
log.Println(len(devices.USWs), "Unifi Switches Found") log.Println(len(devices.USWs), "Unifi Switches Found")
log.Println(len(devices.USGs), "Unifi Gateways Found") log.Println(len(devices.USGs), "Unifi Gateways Found")
log.Println(len(devices.UAPs), "Unifi Wireless APs Found:") log.Println(len(devices.UAPs), "Unifi Wireless APs Found:")
for i, uap := range devices.UAPs { for i, uap := range devices.UAPs {
log.Println(i+1, uap.Name, uap.IP) log.Println(i+1, uap.Name, uap.IP)
} }
} }
``` ```

View File

@ -17,21 +17,21 @@ _This needs a better godoc and examples._
## Overview ## Overview
- Recent logs from poller are visible. - Recent logs from poller are visible.
- Uptime and Version are displayed across the top. - Uptime and Version are displayed across the top.
### Controllers ### Controllers
- The web server interface allows you to see the configuration for each controller. - The web server interface allows you to see the configuration for each controller.
- Some meta data about each controller is displayed, such as sites, clients and devices. - Some meta data about each controller is displayed, such as sites, clients and devices.
- Example config: [up.json.example](https://github.com/unifi-poller/unifi-poller/blob/master/examples/up.json.example) - Example config: [up.json.example](https://github.com/unifi-poller/unifi-poller/blob/master/examples/up.json.example)
### Input Plugins ### Input Plugins
- You may view input plugin configuration. Currently only UniFi. - You may view input plugin configuration. Currently only UniFi.
- The example config above shows input plugin data. - The example config above shows input plugin data.
### Output Plugins ### Output Plugins
- You may view output plugin configuration. Currently Prometheus and InfluxDB. - You may view output plugin configuration. Currently Prometheus and InfluxDB.
- The example config above shows output plugin data. - The example config above shows output plugin data.

View File

@ -13,7 +13,8 @@ notification if it changes. The possibilities are endless.
You must compile your plugin using the unifi-poller source for the version you're You must compile your plugin using the unifi-poller source for the version you're
using. In other words, to build a plugin for version 2.0.1, do this: using. In other words, to build a plugin for version 2.0.1, do this:
```
```bash
mkdir -p $GOPATH/src/github.com/unifi-poller mkdir -p $GOPATH/src/github.com/unifi-poller
cd $GOPATH/src/github.com/unifi-poller cd $GOPATH/src/github.com/unifi-poller
@ -25,4 +26,5 @@ git checkout v2.0.1
cp -r <your plugin> plugins/ cp -r <your plugin> plugins/
GOOS=linux make plugins GOOS=linux make plugins
``` ```
The plugin you copy in *must* have a `main.go` file for `make plugins` to build it. The plugin you copy in *must* have a `main.go` file for `make plugins` to build it.