summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ce2fb80)
raw | patch | inline | side by side (parent: ce2fb80)
author | Vincent Bernat <vincent@bernat.im> | |
Wed, 2 Dec 2015 09:55:39 +0000 (10:55 +0100) | ||
committer | Vincent Bernat <vincent@bernat.im> | |
Wed, 2 Dec 2015 11:03:53 +0000 (12:03 +0100) |
Some interesting MIB are indexed with an IP address (for example,
BGP4-MIB). Make collectd able to use those indexes as instances. Format
the IP as string. IPv6 are usually encoded as Octet String, so, they
should be already supported.
Signed-off-by: Vincent Bernat <vincent@bernat.im>
BGP4-MIB). Make collectd able to use those indexes as instances. Format
the IP as string. IPv6 are usually encoded as Octet String, so, they
should be already supported.
Signed-off-by: Vincent Bernat <vincent@bernat.im>
src/snmp.c | patch | blob | history |
diff --git a/src/snmp.c b/src/snmp.c
index 9f4714d343bd41216dfa340fd11010f110e77c72..23aefd51fe02d6e3b964b22bc2ac8f1ef732be0a 100644 (file)
--- a/src/snmp.c
+++ b/src/snmp.c
src = (char *) vb->val.string;
else if (vb->type == ASN_BIT_STR)
src = (char *) vb->val.bitstring;
+ else if (vb->type == ASN_IPADDRESS)
+ {
+ return ssnprintf (dst, dst_size, "%d.%d.%d.%d",
+ (uint8_t)vb->val.string[0],
+ (uint8_t)vb->val.string[1],
+ (uint8_t)vb->val.string[2],
+ (uint8_t)vb->val.string[3]);
+ }
else
{
dst[0] = 0;
}
/* Get instance name */
- if ((vb->type == ASN_OCTET_STR) || (vb->type == ASN_BIT_STR))
+ if ((vb->type == ASN_OCTET_STR) || (vb->type == ASN_BIT_STR) || (vb->type == ASN_IPADDRESS))
{
char *ptr;