Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
aa7498d93e
|
|||
b5b2e3ac0d
|
|||
ad9b3625e1
|
|||
56aec29c76
|
|||
85124d028d
|
|||
4ed32f8314
|
|||
4222e19573
|
2
LICENSE
2
LICENSE
@ -19,3 +19,5 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
|
@ -12,16 +12,33 @@
|
||||
"community": "public",
|
||||
"oidTopics": [
|
||||
{
|
||||
"oid": ".1.3.6.1.2.1.2.2.1.10.5",
|
||||
"oid": ".1.3.6.1.2.1.31.1.1.1.6.5",
|
||||
"label": "wan-in",
|
||||
"diff": "true"
|
||||
},
|
||||
{
|
||||
"oid": ".1.3.6.1.2.1.2.2.1.16.5",
|
||||
"oid": ".1.3.6.1.2.1.31.1.1.1.10.5",
|
||||
"label": "wan-out",
|
||||
"diff": "true"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"endpoint": "172.16.3.3",
|
||||
"label": "switch-cluster",
|
||||
"community": "public",
|
||||
"oidTopics": [
|
||||
{
|
||||
"oid": ".1.3.6.1.2.1.31.1.1.1.6.1",
|
||||
"label": "uplink-in",
|
||||
"diff": "true"
|
||||
},
|
||||
{
|
||||
"oid": ".1.3.6.1.2.1.31.1.1.1.10.1",
|
||||
"label": "uplink-out",
|
||||
"diff": "true"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ metadata:
|
||||
labels:
|
||||
app: snmp-nmqtt
|
||||
annotations:
|
||||
secret.reloader.stakater.com/reload: "snmp-mqtt-conf"
|
||||
secret.reloader.stakater.com/reload: snmp-mqtt-conf
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
|
@ -18,7 +18,6 @@ type variable_t struct {
|
||||
Label string `json:"label"`
|
||||
Variable string `json:"variable"`
|
||||
Value string `json:"value"`
|
||||
DiffValue string `json:"diffValue"`
|
||||
}
|
||||
|
||||
type message_t struct {
|
||||
@ -114,15 +113,15 @@ func Start() {
|
||||
convertedValue = fmt.Sprintf("%d", gosnmp.ToBigInt(variable.Value))
|
||||
}
|
||||
|
||||
diffValue := "-"
|
||||
if oidTopic.Diff == "true" {
|
||||
log.Println("Calculate difference to last value")
|
||||
key := endpoint.Endpoint + ":" + oidTopic.OID
|
||||
diff, err := calculateDifference(key, convertedValue)
|
||||
if err != nil {
|
||||
log.Printf("Error when building difference: %v", err)
|
||||
convertedValue = "-1"
|
||||
} else {
|
||||
diffValue = diff
|
||||
convertedValue = diff
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,7 +130,6 @@ func Start() {
|
||||
Label: oidTopic.Label,
|
||||
Variable: oidTopic.OID,
|
||||
Value: convertedValue,
|
||||
DiffValue: diffValue,
|
||||
}
|
||||
message.Variables[oidTopic.Label] = v
|
||||
|
||||
|
Reference in New Issue
Block a user