Examples
banshee/examples-collection/examples/protocols/
snmp-table
Example: snmp.table, columns lined up by index; the state of each interface.
by banshee1 installation1 version
Published on October 27, 2026. First version in this collection.
// snmp.table: read several columns of a table and line them up by their index, one row per index.
// The collector reads the state of each interface of a device.
need('protocol:snmp');
per('interface', 'Interfaces');
output('status', 'text', array('label' => 'State (ifOperStatus)', 'per' => 'interface'));
watch.state('down', 'Interface down', 'status', array('critical' => array('2')));
// ifName (IF-MIB) and ifOperStatus (1 up, 2 down...), rows by ifIndex:
// array('1' => array('name' => 'ether1', 'status' => '1'), ...).
$rows = snmp.table(array(
'name' => '1.3.6.1.2.1.31.1.1.1.1',
'status' => '1.3.6.1.2.1.2.2.1.8',
));
foreach ($rows as $index => $row) {
// A column the agent lacks for an index is absent from its row: the index names the interface then.
value('status', $row['status'], list.get($row, 'name', 'if' . $index));
}