Browse Source

Merge pull request #3812 from ktsaou/master

update net-snmp.js to latest version
Costa Tsaousis 6 years ago
parent
commit
f70a478742
2 changed files with 12 additions and 5 deletions
  1. 1 1
      CMakeLists.txt
  2. 11 4
      node.d/node_modules/net-snmp.js

+ 1 - 1
CMakeLists.txt

@@ -243,7 +243,7 @@ include_directories(AFTER .)
 add_definitions(-DHAVE_CONFIG_H -DCACHE_DIR="/var/cache/netdata" -DCONFIG_DIR="/etc/netdata" -DLOG_DIR="/var/log/netdata" -DPLUGINS_DIR="/usr/libexec/netdata" -DWEB_DIR="/usr/share/netdata" -DVARLIB_DIR="/var/lib/netdata")
 
 add_executable(netdata ${NETDATA_COMMON_FILES} ${NETDATA_LINUX_FILES})
-target_link_libraries (netdata m z uuid ${CMAKE_THREAD_LIBS_INIT})
+target_link_libraries (netdata m z uuid mnl netfilter_acct ${CMAKE_THREAD_LIBS_INIT})
 
 add_executable(netdata_freebsd ${NETDATA_COMMON_FILES} ${NETDATA_FREEBSD_FILES})
 target_link_libraries (netdata_freebsd m z uuid ${CMAKE_THREAD_LIBS_INIT})

+ 11 - 4
node.d/node_modules/net-snmp.js

@@ -578,6 +578,10 @@ var Session = function (target, community, options) {
 			? parseInt(options.sourcePort)
 			: undefined;
 
+	this.idBitsSize = (options && options.idBitsSize)
+			? parseInt(options.idBitsSize)
+			: 32;
+
 	this.reqs = {};
 	this.reqCount = 0;
 
@@ -609,8 +613,11 @@ Session.prototype.cancelRequests = function (error) {
 	}
 };
 
-function _generateId () {
-	return Math.floor (Math.random () + Math.random () * 10000000)
+function _generateId (bitSize) {
+	if (bitSize === 16) {
+		return Math.floor(Math.random() * 10000) % 65535;
+	}
+	return Math.floor(Math.random() * 100000000) % 4294967295;
 }
 
 Session.prototype.get = function (oids, responseCb) {
@@ -1044,7 +1051,7 @@ Session.prototype.simpleGet = function (pduClass, feedCb, varbinds,
 	var req = {};
 
 	try {
-		var id = _generateId ();
+		var id = _generateId (this.idBitsSize);
 		var pdu = new pduClass (id, varbinds, options);
 		var message = new RequestMessage (this.version, this.community, pdu);
 
@@ -1290,7 +1297,7 @@ Session.prototype.trap = function () {
 			pduVarbinds.push (varbind);
 		}
 		
-		var id = _generateId ();
+		var id = _generateId (this.idBitsSize);
 
 		if (this.version == Version2c) {
 			if (typeof typeOrOid != "string")