Skip to content

Commit

Permalink
fix(inputs.upsd): Move to new sample.conf style (#11471)
Browse files Browse the repository at this point in the history
  • Loading branch information
srebhan authored Jul 8, 2022
1 parent e4afb2b commit bf0d261
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
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

0 comments on commit bf0d261

Please sign in to comment.