[Xymon] A few patches to improve SNMP data collection

Brian Scott Brian.Scott at bunyatech.com.au
Thu Jul 1 06:44:56 CEST 2021


Hi,

I've been poking about with SNMP data collection with xymon for the last 
few days and have a few patches that may be useful for the next release, 
or for others exploring SNMP processing.

The one for snmpmibs.cfg is from a post by Jeremy Laidman a while back 
so may already be in source control. It just removes a unwanted '(' from 
a mib definition. Thanks.

The graphs.cfg patch is for typing mistake in the graph definition for 
ifmib and ifmib1.

The xymon-snmpcollect.c one is for a programming error in automatically 
finding the snmphosts.cfg file if not specified on the command line.

Finally, the showgraph.c patch is an enhancement to create a new 
substitutable, @BLANK@, that outputs blanks to take up the same space as 
@RRDPARAM@ in the graph legend.

I've done a bit of a write-up of what I've done/found which I'll send a 
link to in the next few days.


Cheers,

Brian Scott

-------------- next part --------------
--- xymond/etcfiles/graphs.cfg.orig	2017-01-06 13:21:07.000000000 +1100
+++ xymond/etcfiles/graphs.cfg	2021-07-01 10:40:16.445246000 +1000
@@ -2039,8 +2039,8 @@
 	FNPATTERN ^ifmib.(.+).rrd
 	TITLE Traffic
 	YAXIS Bits/second
-	DEF:bytesin at RRDIDX@=@RRDFN@:InOctets:AVERAGE
-	DEF:bytesout at RRDIDX@=@RRDFN@:OutOctets:AVERAGE
+	DEF:bytesin at RRDIDX@=@RRDFN@:ifInOctets:AVERAGE
+	DEF:bytesout at RRDIDX@=@RRDFN@:ifOutOctets:AVERAGE
 	CDEF:bitsin at RRDIDX@=bytesin at RRDIDX@,8,*
 	CDEF:bitsout at RRDIDX@=bytesout at RRDIDX@,8,*
 	CDEF:mbitsin at RRDIDX@=bytesin at RRDIDX@,8,*,1000000,/
@@ -2061,8 +2061,8 @@
 	FNPATTERN ^ifmib.(.+).rrd
 	TITLE Traffic
 	YAXIS Packets/second
-	DEF:pktsin at RRDIDX@=@RRDFN@:InUcastPkts:AVERAGE
-	DEF:pktsout at RRDIDX@=@RRDFN@:OutUcastPkts:AVERAGE
+	DEF:pktsin at RRDIDX@=@RRDFN@:ifInUcastPkts:AVERAGE
+	DEF:pktsout at RRDIDX@=@RRDFN@:ifOutUcastPkts:AVERAGE
 	CDEF:mpktsin at RRDIDX@=pktsin at RRDIDX@,8,*,1000000,/
 	CDEF:mpktsout at RRDIDX@=pktsout at RRDIDX@,8,*,1000000,/
 	AREA:pktsin at RRDIDX@#00FF00:@RRDMETA@  inbound
-------------- next part --------------
--- xymonnet/xymon-snmpcollect.c.orig	2019-07-24 01:29:06.000000000 +1000
+++ xymonnet/xymon-snmpcollect.c	2021-06-29 18:06:50.300087000 +1000
@@ -1090,7 +1090,7 @@
 	readmibs(NULL, mibcheck);
 
 	if (configfn == NULL) {
-		configfn = (char *)malloc(PATH_MAX);
+		SBUF_MALLOC(configfn, PATH_MAX);
 		snprintf(configfn, configfn_buflen, "%s/etc/snmphosts.cfg", xgetenv("XYMONHOME"));
 	}
 	readconfig(configfn, mibcheck);
-------------- next part --------------
--- xymond/etcfiles/snmpmibs.cfg.orig	2015-10-02 00:42:42.000000000 +1000
+++ xymond/etcfiles/snmpmibs.cfg	2021-06-29 18:06:50.296917000 +1000
@@ -31,7 +31,7 @@
 [hrstorage]
 # storage has data for both memory- and disk-storage
 	keyidx (HOST-RESOURCES-MIB::hrStorageDescr)
-	keyidx [(HOST-RESOURCES-MIB::hrStorageType]
+	keyidx [HOST-RESOURCES-MIB::hrStorageType]
 	Type = HOST-RESOURCES-MIB::hrStorageType
 	Description = HOST-RESOURCES-MIB::hrStorageDescr
 	Units = HOST-RESOURCES-MIB::hrStorageAllocationUnits		/rrd:GAUGE
-------------- next part --------------
--- web/showgraph.c.orig	2019-08-13 05:23:00.000000000 +1000
+++ web/showgraph.c	2021-06-29 18:06:50.303487000 +1000
@@ -573,6 +573,17 @@
 			}
 			inp += 10;
 		}
+		else if (strncmp(inp, "@BLANK@", 7) == 0) {
+			/* Blanks the same length that RRDPARAM would have used */
+			if (rrddbs[rrdidx].rrdparam) {
+				SBUF_DEFINE(resultstr);
+				SBUF_MALLOC(resultstr, paramlen + 1);
+				snprintf(resultstr, resultstr_buflen, "%-*s", paramlen, "");
+				addtobuffer(result, resultstr);
+				xfree(resultstr);
+			}
+			inp += 7;
+		}
 		else if (strncmp(inp, "@RRDMETA@", 9) == 0) {
 			/* 
 			 * We do a colon-escape first, then change all commas to slashes as


More information about the Xymon mailing list