Snmpset option

Hi,

Is it possible to include net-snmp-tools in the Hassio container or otherwise include a snmpset option in the snmp platform?

I used this instruction to control a few APC PDU’s with SNMP: SNMP based command line switch.
Now I install this manually (apk add net-snmp-tools) and it works beautifully, but it’s lost with each container rebuild ofcourse.

Here’s a simple workaround. Make it a switch :wink: (And then optionally create an automation that makes sure that switch is always On)

   - switch:
      unique_id: net_snmp_tools_installed
      command_on: "apk add net-snmp-tools"
      command_off: "apk del net-snmp-tools"
      command_state: "/usr/bin/snmpget -V 2>&1"
      value_template: "{{ value | string is match('NET-SNMP version: 5') }}"
      name: SNMP Tools Installed

Hi dazeller, thanks for the suggestion! Completely forgot about this thread… I also found a solution quite some time ago and I see that I started typing it in here, but never posted it… :upside_down_face:
This thread has been checked 700 times now, so i guess there are more people looking for this. What I did:

In configuration.yaml:
shell_command:
install_snmp: ‘/sbin/apk add net-snmp-tools’

Automation:
alias: Startup Install SNMPtools
description: “”
triggers:

  • trigger: homeassistant
    event: start
    conditions:
    actions:
  • action: shell_command.install_snmp
    metadata: {}
    data: {}
    mode: single

This installs snmp-tools in qemux86-64-homeassistant container, so it works from the gui.
If you want it to work from ssh/ssh/cli, add ‘apk add net-snmp-tools’ to configuration - init_commands in ‘Advanced SSH & Web Terminal’

And then for example to switch poe power on/off on a Cisco SG350 switchport:

command_line:

  • switch:
    name: switch-mk-ptgi09
    command_on: “/usr/bin/snmpset -v2c -c password 192.168.10.220 SNMPv2-SMI::mib-2.105.1.1.1.3.1.9 i 1”
    command_off: “/usr/bin/snmpset -v2c -c password 192.168.10.220 SNMPv2-SMI::mib-2.105.1.1.1.3.1.9 i 2”
    command_state: “/usr/bin/snmpget -v2c -c password 192.168.10.220 SNMPv2-SMI::mib-2.105.1.1.1.3.1.9”
    value_template: ‘{{ value == “0” }}’

Not sure where value_template is goood for. Just copied that from somewhere…

1 Like

This helped me fix being able to control POE on my ICX7150. It uses non-standard payload values, 3 for on and 2 for off. The payload_on and payload_off parameters stopped working in the standard SNMP switch setup a while back. The last digit of the OID is the port number.

 - switch:
      name: Port 1/1/32 Power
      command_on: /usr/bin/snmpset -Oqv -v 3 -l authPriv -u user -a SHA -A "auth"  -x AES -X "pass"  192.168.11.1 1.3.6.1.4.1.1991.1.1.2.14.2.2.1.2.32 integer 3
      command_off: /usr/bin/snmpset -Oqv -v 3 -l authPriv -u user -a SHA -A "auth"  -x AES -X "pass"  192.168.11.11 1.3.6.1.4.1.1991.1.1.2.14.2.2.1.2.32 integer 2
      command_state: /usr/bin/snmpget -Oqv -v 3 -l authPriv -u user -a SHA -A "auth"  -x AES -X "pass"  192.168.11.1 1.3.6.1.4.1.1991.1.1.2.14.2.2.1.2.32
      value_template: '{{ value == "3" }}'