I have been playing with the SNMP binding for openHAB and have achieved some good results.
I’ll layout some examples below. (I’ll edit and add more detail as I get time)
When debugging SNMP OIDs I use Ireasoning MIB Free to poll the OID or do a walk and find the ones I need.
SECURITY! it is best practice to think of the community string as a password. I have replaced my actual strings with public and private for these posts but at work I use a 16 character random generated password and at home I use something a “little” less extreme. Any device on the network can issue a command to SNMP and if the device is setup with common names it is easier for someone to hack the machine.
At my work where I have an openHAB system running to monitor alot of different systems, currently employed are MQTT, Modbus/TCP, SNMP, and Mail.
MQTT monitors arduino ethernet devices placed in the server rooms to send info on temp, humidity air conditioner power status and weather the door is open or closed.
Mail is used for error reporting within the rules in case something goes wrong.
Modbus/TCP monitors various temperature & pressure senders as well as control light stacks and temperature controllers.
SNMP monitors the Printers toner lvls and places it in one neat window.
Group Printer <printer>
Group Jerry_Printer "Jerry's Xerox 7100N" <_7100n> (Printer)
Group ATAL_Printer "ATAL Xerox 7100N" <_7100n> (Printer)
Group AR_Printer "Accounts Receivable Xerox 4250" <_4250> (Printer)
Group HR_Printer "Human Resource Xerox 4250" <_4250> (Printer)
Group CS_Printer "Customer Service Xerox 4250" <_4250> (Printer)
Group CFO_Printer "Chief Financial Officer Xerox 4250" <_4250> (Printer)
Group ENG1_Printer "Upstairs Engineering HP 5520" <_4250> (Printer)
Number Jerry_Printer_K_T "Jerry's Black Toner [%d%%]" <_7100n> (Jerry_Printer) { snmp="<[192.168.1.94:public:1.3.6.1.2.1.43.11.1.1.9.1.1:60000:JS(K_7100.js)]"}
Number Jerry_Printer_C_T "Jerry's Cyan Toner [%d%%]" <_7100n> (Jerry_Printer) { snmp="<[192.168.1.94:public:1.3.6.1.2.1.43.11.1.1.9.1.4:60000:JS(C_7100.js)]"}
Number Jerry_Printer_M_T "Jerry's Magenta Toner [%d%%]" <_7100n> (Jerry_Printer) { snmp="<[192.168.1.94:public:1.3.6.1.2.1.43.11.1.1.9.1.3:60000:JS(M_7100.js)]"}
Number Jerry_Printer_Y_T "Jerry's Yellow Toner [%d%%]" <_7100n> (Jerry_Printer) { snmp="<[192.168.1.94:public:1.3.6.1.2.1.43.11.1.1.9.1.2:60000:JS(Y_7100.js)]"}
Number ATAL_Printer_K_T "ATAL Black Toner [%d%%]" <_7100n> (ATAL_Printer) { snmp="<[192.168.1.89:public:1.3.6.1.2.1.43.11.1.1.9.1.1:60000:JS(K_7100.js)]"}
Number ATAL_Printer_C_T "ATAL Cyan Toner [%d%%]" <_7100n> (ATAL_Printer) { snmp="<[192.168.1.89:public:1.3.6.1.2.1.43.11.1.1.9.1.4:60000:JS(C_7100.js)]"}
Number ATAL_Printer_M_T "ATAL Magenta Toner [%d%%]" <_7100n> (ATAL_Printer) { snmp="<[192.168.1.89:public:1.3.6.1.2.1.43.11.1.1.9.1.3:60000:JS(M_7100.js)]"}
Number ATAL_Printer_Y_T "ATAL Yellow Toner [%d%%]" <_7100n> (ATAL_Printer) { snmp="<[192.168.1.89:public:1.3.6.1.2.1.43.11.1.1.9.1.2:60000:JS(Y_7100.js)]"}
Number AR_Printer_1 "AR Black Toner [%d%%]" <_4250> (AR_Printer) { snmp="<[192.168.1.101:public:1.3.6.1.2.1.43.11.1.1.9.1.1:60000:JS(K_4250.js)]"}
Number HR_Printer_1 "HR Black Toner [%d%%]" <_4250> (HR_Printer) { snmp="<[192.168.1.102:public:1.3.6.1.2.1.43.11.1.1.9.1.1:60000:JS(K_4250.js)]"}
Number CS_Printer_1 "CS Black Toner [%d%%]" <_4250> (CS_Printer) { snmp="<[192.168.1.98:public:1.3.6.1.2.1.43.11.1.1.9.1.1:60000:JS(K_4250.js)]"}
Number CFO_Printer_1 "CFO Black Toner [%d%%]" <_4250> (CFO_Printer) { snmp="<[192.168.1.100:public:1.3.6.1.2.1.43.11.1.1.9.1.1:60000:JS(K_4250.js)]"}
String LBL_Printer_1 "Assembly Label Printer Status [%s]" <_4250> (Printer) { http="<[http://192.168.1.92/info.html:60000:REGEX(.*?Error Message</B></TD><TD height=20>(.*?)</TD>.*)]"}
Number ENG1_Printer_K_T "Upstairs Engineering Black Toner [%d%%]" <_7100n> (ENG1_Printer) { snmp="<[192.168.1.99:public:1.3.6.1.2.1.43.11.1.1.9.1.1:60000:JS(_5520.js)]"}
Number ENG1_Printer_C_T "Upstairs Engineering Cyan Toner [%d%%]" <_7100n> (ENG1_Printer) { snmp="<[192.168.1.99:public:1.3.6.1.2.1.43.11.1.1.9.1.2:60000:JS(_5520.js)]"}
Number ENG1_Printer_M_T "Upstairs Engineering Magenta Toner [%d%%]" <_7100n> (ENG1_Printer) { snmp="<[192.168.1.99:public:1.3.6.1.2.1.43.11.1.1.9.1.3:60000:JS(_5520.js)]"}
Number ENG1_Printer_Y_T "Upstairs Engineering Yellow Toner [%d%%]" <_7100n> (ENG1_Printer) { snmp="<[192.168.1.99:public:1.3.6.1.2.1.43.11.1.1.9.1.4:60000:JS(_5520.js)]"}
my JS example for converting the value from the SNMP query to a precentage is here. “25000” is the max lvl of the toner
K_7100.js
(function(i){ return Math.round(i / 25000 * 100); })(input)
In the sitemap all I had to place was 2 lines because the groups break it down for me.
Frame label="Printers" {
Group item=Printer label="Printer Status"
}