Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(inputs.upsd): Move to new sample.conf style #11471

Merged
merged 1 commit into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions plugins/inputs/upsd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ upsd should be installed and it's daemon should be running.

## Configuration

```toml
```toml @sample.conf
# Monitor UPSes connected via Network UPS Tools
[[inputs.upsd]]
## A running NUT server to connect to.
# If not provided will default to 127.0.0.1
# server = "127.0.0.1"

## The default NUT port 3493 can be overridden with:
# port = 3493

# username = "user"
# password = "password"
```
Expand Down
7 changes: 7 additions & 0 deletions plugins/inputs/upsd/sample.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Monitor UPSes connected via Network UPS Tools
[[inputs.upsd]]
## A running NUT server to connect to.
# server = "127.0.0.1"
# port = 3493
# username = "user"
# password = "password"
21 changes: 8 additions & 13 deletions plugins/inputs/upsd/upsd.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
//go:generate ../../../tools/readme_config_includer/generator
package upsd

import (
_ "embed"
"fmt"
"strings"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal/choice"
"github.com/influxdata/telegraf/plugins/inputs"
nut "github.com/robbiet480/go.nut"
"strings"
)

// DO NOT REMOVE THE NEXT TWO LINES! This is required to embed the sampleConfig data.
//go:embed sample.conf
var sampleConfig string

//See: https://networkupstools.org/docs/developer-guide.chunked/index.html

const defaultAddress = "127.0.0.1"
Expand All @@ -24,18 +31,6 @@ type Upsd struct {
batteryRuntimeTypeWarningIssued bool
}

func (*Upsd) Description() string {
return "Monitor UPSes connected via Network UPS Tools"
}

var sampleConfig = `
## A running NUT server to connect to.
# server = "127.0.0.1"
# port = 3493
# username = "user"
# password = "password"
`

func (*Upsd) SampleConfig() string {
return sampleConfig
}
Expand Down