Skip to content

Commit

Permalink
fix tnies values
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharkboy-j committed Dec 4, 2024
1 parent 6b08971 commit d17f0f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ oids:
- oid: "1.3.6.1.4.1.935.10.1.1.1" # upsEIdentity
- oid: "1.3.6.1.4.1.935.10.1.1.2" # upsESystemSummary
- oid: "1.3.6.1.4.1.935.10.1.1.3" # upsEBatterySystem

toNullIfEmpty: #only for int
- tne: "upsESystemInputVoltage"
- tne: "upsESystemOutputLoad"
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ type Config struct {
OIDs []struct {
OID string `yaml:"oid"`
} `yaml:"oids"`
Tnies []struct {
Tnie string `yaml:"tne"`
} `yaml:"toNullIfEmpty"`
}

func loadConfig(filename string) (*Config, error) {
Expand Down Expand Up @@ -179,8 +182,12 @@ func starts(params *gosnmp.GoSNMP, config *Config) {

}

if toExport["upsESystemInputVoltage"].(int64) <= 0 {
delete(toExport, "upsESystemInputVoltage")
for _, v := range config.Tnies {
if mapVal, ok := toExport[v.Tnie]; ok {
if mapVal.(int64) <= 0 {
delete(toExport, v.Tnie)
}
}
}

go PushData(toExport, tm)
Expand Down

0 comments on commit d17f0f8

Please sign in to comment.