From 00524c0a3fcdce6bc6b0fbf5d4eed9703cfcc837 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Fri, 26 Jan 2024 14:44:23 +0100 Subject: [PATCH] label in snmp measurements --- queries/hottis.sql | 8 ++++++++ src/udi/handlers/snmp/snmp.go | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/queries/hottis.sql b/queries/hottis.sql index b83447b..99067a1 100644 --- a/queries/hottis.sql +++ b/queries/hottis.sql @@ -87,3 +87,11 @@ create or replace view locative_v as values->'Trigger'->>'value' as direction from measurements where application = 'Locative'; + +create or replace view router_v as + select time, + device, + cast(values->'wan-in'->>'value' as int) as wanInOctetsPerSeconds, + cast(values->'wan-out'->>'value' as int) as wanOutOctetsPerSeconds + from measurements + where application = 'SNMP' and device = '172.16.3.1'; diff --git a/src/udi/handlers/snmp/snmp.go b/src/udi/handlers/snmp/snmp.go index a6604b6..899f946 100644 --- a/src/udi/handlers/snmp/snmp.go +++ b/src/udi/handlers/snmp/snmp.go @@ -52,7 +52,9 @@ func (self *SnmpHandler) Handle(message handler.MessageT) { measurement.Application = "SNMP" measurement.Device = observation.Device - measurement.Attributes = make(map[string]interface{}) + measurement.Attributes = map[string]interface{} { + "Label": observation.Label, + } measurement.Values = make(map[string]database.VariableType) for k, v := range observation.Variables {