diff --git a/config.yml b/config.yml index b1f3545..5860189 100644 --- a/config.yml +++ b/config.yml @@ -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" diff --git a/main.go b/main.go index 2e9ba0c..ae4fe9e 100644 --- a/main.go +++ b/main.go @@ -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) { @@ -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)