Two snmp requests in one dci
-
Hello
What is the best approach to make dci that queries 2 separate snmp oids, does some math with them and then returns the output. is it possible to do in one dci, or is multiple required?
Example:
.1.3.6.1.2.1.25.2.3.1.6.131072 - returns 11320 (/1024 = 11mb)
.1.3.6.1.2.1.25.2.3.1.5.131072 - returns 16384 (/1024 = 16mb)
Output = 16-11 = 4mbIts Mikrotik disk usage.
-
It's possible to make script DCI that would take values from other DCIs and do the calculation. But if you don't need to keep the intermediary values, they you can do everything just in one DCI.
Create s script in script library and Script DCI that uses that script. Check this example for script contents: https://www.netxms.org/documentation/nxsl-latest/#func-snmpgetvalue
-
I hacked together something like this:
transport = CreateSNMPTransport($node); if (transport == null) { return null; } diskSize = SNMPGetValue(transport,".1.3.6.1.2.1.25.2.3.1.5.131072"); diskUsed = SNMPGetValue(transport,".1.3.6.1.2.1.25.2.3.1.6.131072"); if(diskSize == null || diskUsed == null) { return null; } free = diskSize - diskUsed; free = free * 1024; return free;" free = free * 1024; " is because otherwise unit b(IEC) was showing incorrectly.
is there anything that could be improved on this script?
-
Looks good. There's a small chance that SNMPGetValue may return null (e.g. communication gets broken exactly when these requests are made), so you may want to check diskSize and diskUsed for null.
-
-
Ups, i missed that line

Yes, it's correct
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login