Network
banshee/network-collection/network/mikrotik/snmp/routeros/
resources
The processor load and the memory of a MikroTik RouterOS router by SNMP (HOST-RESOURCES-MIB).
by banshee1 installation2 versions
// The processor and the memory of a MikroTik RouterOS router, by SNMP (HOST-RESOURCES-MIB, which RouterOS
// serves): the load of each processor and their average, and the memory used. The hardware health
// (temperatures, fans, power supplies) is read by network/mikrotik/snmp/health.
need('protocol:snmp');
per('core', 'Processors');
output('cpu-busy', 'number', array('label' => 'Average load', 'unit' => '%'));
output('core-busy', 'number', array('label' => 'Processor load', 'unit' => '%', 'per' => 'core'));
output('memory-total', 'number', array('label' => 'Memory', 'unit' => 'MiB'));
output('memory-used-percent', 'number', array('label' => 'Memory used', 'unit' => '%'));
watch.above('cpu-high', 'Processor saturated', 'cpu-busy', array('warning' => 80, 'critical' => 95, 'for' => '3 runs'));
watch.above('core-hot', 'A processor saturated', 'core-busy', array('warning' => 95, 'for' => '3 runs', 'enabled' => false));
watch.above('memory-high', 'Memory saturated', 'memory-used-percent', array('warning' => 85, 'critical' => 95, 'for' => '3 runs'));
// hrProcessorLoad, one row per processor: the load in percent over the last minute. The processors are
// named cpu0, cpu1... in the agent's order.
$loads = snmp.walk('1.3.6.1.2.1.25.3.3.1.2');
$cores = 0;
$total = 0;
foreach ($loads as $load) {
value('core-busy', $load, 'cpu' . $cores);
$total = $total + $load;
$cores = $cores + 1;
}
if ($cores == 0) {
fail('misconfigured', 'The agent does not serve the processor table (hrProcessorTable)',
'A device that is not RouterOS, such as a SwitchOS switch, or a view that does not grant HOST-RESOURCES-MIB to the poller.');
}
value('cpu-busy', number.round($total / $cores, 1));
// hrStorageTable: hrStorageType (an OID), hrStorageAllocationUnits (in bytes), hrStorageSize and
// hrStorageUsed (in allocation units). The memory is the row of the type hrStorageRam
// (1.3.6.1.2.1.25.2.1.2); the pattern accepts the OID written with or without a leading dot.
$storage = snmp.table(array(
'type' => '1.3.6.1.2.1.25.2.3.1.2',
'unit' => '1.3.6.1.2.1.25.2.3.1.4',
'size' => '1.3.6.1.2.1.25.2.3.1.5',
'used' => '1.3.6.1.2.1.25.2.3.1.6',
));
$found = false;
foreach ($storage as $row) {
if (text.like(list.get($row, 'type', ''), '*1.3.6.1.2.1.25.2.1.2')) {
$found = true;
$ram = $row;
break;
}
}
if (!$found) {
fail('misconfigured', 'The memory (hrStorageRam) is missing from hrStorageTable');
}
if (list.get($ram, 'size', 0) <= 0) {
fail('misconfigured', 'Memory of zero size in hrStorageTable');
}
value('memory-total', number.round($ram['size'] * $ram['unit'] / 1048576));
value('memory-used-percent', number.round(100 * $ram['used'] / $ram['size'], 1));