Open GSzabados opened 2 months ago
Hey there @nmaggioni, mind taking a look at this issue as it has been labeled with an integration (snmp
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
snmp documentation snmp source (message by IssueLinks)
That's correct, the current SNMP integration only offers polling/scraping capabilities. If you need to receive traps two alternatives come to my mind:
By taking a (very) quick look at other Local Push integrations I'd say that if one were to develop a SNMP trap listener it could be useful to look at how, for example, the Wiffi component [3] [4] sets things up and then rely on the existing pysnmp dependency for receiving and parsing traps (here's an example but watch out, it's using old and unsupported code; I couldn't find the same functionalities in pysnmp's new hlapi.asyncio
API).
If you already have a Node-RED instance running or you're willing to set it up, I'd vote for that solution. That way you can also leverage more complex handling logics in case you need to trigger something or do multiple checks when a trap is received (ex.: NAS goes on UPS and sends trap, you poll the UPS itself to get accurate runtime stats, schedule a check a few mins later, eventually shut down the NAS through SSH and, when it stops replying to ICMP pings, turn off the plug it's connected to). How does that sound?
Thanks for the detailed reply. I did try to avoid Node-RED until now, as I did not want to add another point of failure. But I might will go down to that route. And I generally though that the documentation must have not been updated, as the integration was added to HA years ago...
Unfortunately the need arose recently to monitor the aforementioned NAS, as it produced a drive failure message without any logged event, just the LED came on, and the software was telling that there is a drive failure. The drive and the NAS has passed all tests, but it was still thinking the drive has a failure, which I couldn't track down what was the reason for. Magically, a restart cleared the drive failure, but I need to monitor the device to find out what could have been the issue...
@GSzabados SNMP protocols remain the same for years, so there is little need to update the documentation frequently.
Due to the nature of UDP/SNMP, the device vendors shouldn't merely use TRAP/INFORM messages to notify monitoring tools but should also make warnings/errors queryable via GET/GETBULK.
As far as I can see, it is rather big a burden to host a TRAP/INFORM monitoring daemon in HA merely for badly designed devices (and such a small SNMP user base). If you really need such a thing, you should choose a separate tool (many good SNMP monitoring tools are out there) and configure your SNMP devices to report there.
@lextm, your comment is just full or unreasonable arguments.
Like a device shouldn't only push, but should be pull. Seriously, you have not looked around in Zigbee land, or any sleepy device? Sleepy devices mostly only push...
The SNMP protocol has not changed, but still trap is not implemented.
Big burden to host? What other devices integration do? Listen for incoming push messages? Like the Ecowitt integration? It could be handled as a catch all, and let the user to set up needed SNMP addresses. It could be easily a trigger.
Small user base, ok, but would be still better than hacking around dodgy scripts on NAS devices or anything else which could support out of the box SNMP.
@GSzabados The references I posted in my previous comment are more than enough to demonstrate that it's not just a matter of "listening for incoming push messages". Home Assistant is not a network monitoring solution and, while it can fit that role to some extent for a typical household, it eventually reaches its maximum flexibility and needs to be paired up with domain-specific tools.
If you do not want to stand up proper monitors such as LibreNMS, Observium and the likes, the Node-RED solution I proposed is very low effort to run and maintain and will tailor perfectly to your needs.
would be still better than hacking around dodgy scripts on NAS devices or anything else which could support out of the box SNMP
Well, in this case if your NAS is just sending TRAPs instead of also archiving those errors in a local history for later queries, I must say that it is not respecting the best practices itself: what if the host that should be receiving the TRAP is momentarily not available when it gets sent due to having network issues itself? If the originating device doesn't store the message locally there will never be any way to know that an alert was sent. Take a look at how CISCO-SYSLOG-MIB works for example.
As I wrote before, the device in question is a WD EX2 Ultra. It cannot be more domestic/household equipment than that...
Feel free to look at this topic to understand more about dodgy scripts.
https://community.home-assistant.io/t/western-digital-my-cloud/40610
Again sleepy devices usually just send state changes and they cannot be queried. And they do not care about thar the recipient is working or not.
It is great that CISCO built their MIB that way, but other manufacturers chose different ways and which cannot be configured/altered.
I don't mind the NodeRed solution, but still have not had time to set it up. And I still think that it is an overhead.
Regarding not being a network monitoring tool. Just have a short look on these lists:
https://www.home-assistant.io/integrations/#network
https://www.home-assistant.io/integrations/#system-monitor
Or maybe Home Assistant is not a Finacial tool either... https://www.home-assistant.io/integrations/#finance
The problem
There seems to be a missing basic functionality of SNMP integration or it is not documented at all. I cannot figure out how to define a sensor for incoming SNMP notification from a WD EX2 Ultra device. The documentation refers to polling only but there is not mention of receiving SNMP messages.
What version of Home Assistant Core has the issue?
core-2024.5.2
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
SNMP
Link to integration documentation on our website
https://www.home-assistant.io/integrations/snmp#sensor
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information