From 4e2322ae899bcbe8e8149fc6b82b021f910a37f0 Mon Sep 17 00:00:00 2001 From: "Thierry bordaz (tbordaz)" Date: Tue, 16 Apr 2013 14:53:13 +0200 Subject: [PATCH] Ticket 205 - snmp counters index strings for multiple network interfaces with ip addr and tcp port pairs Bug Description: When a host contains several interfaces, if several DS instances listen on the same port (but on different interfaces) the snmp report will only contain one of those instances. Fix Description: The fix is to define a new cn=config attribute (nsslapd-snmp-index) that is a number. The value of this attribute will replace the instance port number (nsslapd-port) in the snmp report. https://fedorahosted.org/389/ticket/205 Reviewed by: ? Platforms tested: Fedora 17 Flag Day: no Doc impact: yes. A new config attribute needs to be described ("nsslapd-snmp-index"). nsslapd-snmp-index: This attribute is an optional numeric value. It specifies an index (identifier) that would be appened to the RHDS MIB OIDs of the instance. If it is defined it will replace in the reported OID the 'port' (nsslapd-port). In case of several RHDS instances listening on the same port (on different interfaces), it offers a means to link the reported snmp counters to a given instance. --- ldap/servers/snmp/main.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c index 53af972..68f512f 100644 --- a/ldap/servers/snmp/main.c +++ b/ldap/servers/snmp/main.c @@ -329,6 +329,8 @@ load_config(char *conf_path) } else if ((p = strstr(line, "server")) != NULL) { int got_port = 0; int got_rundir = 0; + int got_snmp_index = 0; + long snmp_index = -1; int lineno = 0; char *entry = NULL; char *instancename = NULL; @@ -426,7 +428,10 @@ load_config(char *conf_path) /* Look for port and rundir attributes */ while ((dse_line = ldif_getline(&entryp)) != NULL) { ldif_parse_line(dse_line, &attr, &val, &vlen); - if (strcmp(attr, "nsslapd-port") == 0) { + if (strcmp(attr, "nsslapd-snmp-index") == 0) { + snmp_index = atol(val); + got_snmp_index = 1; + } else if (strcmp(attr, "nsslapd-port") == 0) { serv_p->port = atol(val); got_port = 1; } else if (strcmp(attr, "nsslapd-rundir") == 0) { @@ -447,11 +452,6 @@ load_config(char *conf_path) got_rundir = 1; } - /* Stop processing this entry if we found the - * port and rundir settings */ - if (got_port && got_rundir) { - break; - } } /* The port and rundir settings must be in the * cn=config entry, so we can stop reading through @@ -479,6 +479,14 @@ load_config(char *conf_path) error = 1; goto close_and_exit; } + + /* in case a snmp index is specified, it replace the nsslapd-port + * This would allow to give an index to a snmp report, rather than using + * the TCP interface port number (because the same port may be listen on multiple interfaces) + */ + if (got_snmp_index) { + serv_p->port = snmp_index; + } /* Insert server instance into linked list */ serv_p->next = server_head; -- 1.7.11.7