Closed robitmoh closed 3 years ago
Hi @robitmoh , thanks for submitting this
When we create the measurement tagvalue, we support the following types, according to gosnmp
If I'm not wrong, the MAC address is returned as an OctetString, so the measurement is retrieving its value without any conversion, and, furthermore, we have no clue if its a MAC or not.
Actually, we support parsing a provided MAC, but only on metrics, with DataSrcType: HWADDRESS
. Remember that you can check the field IsTag
to send the metric as a Tag
So:
OIDIndex
and attached metrics?If you can't achieve your desired behaviour, it can be done defining as new type on Index Format Tag
. We currently support STRING (default) or DEC2ASCII transformators.
Thanks, Regards!
Hi @sbengo yes te MAC is returned in OctetString but can't simple converted to string in python I can convert like this EUI(hexlify(value.val).decode('UTF-8'), dialect=mac_unix_expanded) (https://netaddr.readthedocs.io/en/latest/tutorial_02.html) I don't know how is in go I think the multi index is needed Expl: cable modem SNR in headend SNMPv2-SMI::enterprises.4491.2.1.20.1.4.1.4.1.721465 = INTEGER: 381 baseoid SNMPv2-SMI::enterprises.4491.2.1.20.1.4.1.4.[cable modem id].[upstream id] = INTEGER: 381
to identify the cable modem cablemodem id: (measurement index0) DOCS-IF-MIB::docsIfCmtsCmStatusMacAddress.[ 1 ] = STRING: 24:76:7d:48:30:0
the upstream frequency: (measurement index1) DOCS-IF-MIB::docsIfUpChannelFrequency.721465 = INTEGER: 42600000 hertz
the MAC address tag is require because this is a one identify glue with headend - cablemodem - management system
Thanks your help! Regards!
Hi @sbengo
I made a small patch (hope in january I can take a pull request )
git diff formatindextag.go
diff --git a/pkg/data/measurement/formatindextag.go b/pkg/data/measurement/formatindextag.go
index cd470a0..fb3f199 100644
--- a/pkg/data/measurement/formatindextag.go
+++ b/pkg/data/measurement/formatindextag.go
@@ -5,6 +5,7 @@ import (
"regexp"
"strconv"
"strings"
+ "net"
"github.com/sirupsen/logrus"
)
@@ -195,6 +196,9 @@ func formatTag(l *logrus.Logger, format string, data map[string]string, def stri
switch {
case transformation == "STRING":
decoded = section
+ case transformation == "MAC":
+ decoded = net.HardwareAddr(section).String()
+ l.Debugf("FormatTag[%s]: MAC : value %s : Decoded %s", format, v, decoded)
case strings.HasPrefix(transformation, "DEC2ASCII"):
decoded = formatDec2ASCII(section)
l.Debugf("FormatTag[%s]: DEC2ASCII : value %s : Decoded %s", format, v, decoded)
Usage: in the measurement index: The Index Tag Format :${VAL1|DOT[0:]|MAC}
I'm not have problem with index1 bit index0 is not good the snmpwalk res:
the problem the index0 value is wrong format in influxdb I think is a convert problem from hwdata format to string