Calculating with multiple oids

Started by Egert143, February 13, 2024, 01:15:39 PM

Previous topic - Next topic

Egert143

Hello

I would like to monitor router memory usage but in order for that i need to poll 4 seperate values and do some math with them. What would be the cleanest approach to solve this problem?

Oids:
.1.3.6.1.2.1.25.2.3.1.3.1 [STRING] = Physical memory
.1.3.6.1.2.1.25.2.3.1.4.1 [INTEGER] = 1024 (hrStorageAllocationUnits)
.1.3.6.1.2.1.25.2.3.1.5.1 [INTEGER] = 160908 (hrStorageSize)
.1.3.6.1.2.1.25.2.3.1.6.1 [INTEGER] = 128164 (hrStorageUsed)

Demo math:
125,16*100 / 157,13 = 79,65%

Desired output:
Physical memory = 79,65%

Filipp Sudanov

At some point in the future, when https://track.radensolutions.com/issue/NX-2322 will be implemented it would be possible to specify muliple OIDs and they will appear as variables in transformation script.

For now - either a script DCI that does all SNMP job and calculation and returns final result, or SNMP DCI that reads one OID and the rest being read in transformation script, e.g.:
totalMem = $1;

transport = $node->createSNMPTransport(); 
if (transport == null) return null;

freeMem = transport->getValue(".1.3.6.1.4.1.14823.2.2.1.1.1.11.1.4.1");
if (freeMem == null) return null;

return format(100UL * freeMem / totalMem, 1, 0);

The only bonus of the first approach is that you can perform recalculation for historical collected values.