louislam / uptime-kuma

A fancy self-hosted monitoring tool
https://uptime.kuma.pet
MIT License
52.88k stars 4.78k forks source link

SNMP Value Retrieval #1675

Closed wglenn01 closed 2 days ago

wglenn01 commented 2 years ago

โš ๏ธ Please verify that this feature request has NOT been suggested before.

๐Ÿท๏ธ Feature Request Type

New Monitor

๐Ÿ”– Feature description

I would love to be able to put in custom SNMP OID's per device to monitor the value of that OID with each update and display them in the table, would be SO helpful.

โœ”๏ธ Solution

Add SNMP monitoring for custom OID's per device.

โ“ Alternatives

No response

๐Ÿ“ Additional Context

No response

Computroniks commented 2 years ago

I am not sure if this is just slightly out of scope for Uptime Kuma. It feels like it would take the project closer to the likes of zabbix or checkmk as an entire system monitoring service as apposed to a system to monitor what the average user sees. However, it is @louislam descision. I would be interested to see what others thoughts are on this.

louislam commented 2 years ago

As long as it is about uptime and downtime, it could be a monitor type in Uptime Kuma.

But honestly, I probably won't implement this, as I don't use and I don't know what is SNMP.

Computroniks commented 2 years ago

SNMP is a protocol that is used to get metrics such as CPU and network utilization from devices, especially networking devices such as switches and routers. Here is a Wikipedia article with some more info: https://en.wikipedia.org/wiki/Simple_Network_Management_Protocol

Lucienest commented 1 year ago

This Issue should get bumped, as SNMP is really useful.

AlmightyJojo commented 1 year ago

I have yet to explore this project but am interested. However the first thing I did was look if SNMP was included. Its is very useful. But does take time to get configured and learn device OIDs.

I currently use Syncro RMM but have been looking for alternative solutions. The way Syncro does it is their main Windows based monitor agent installed at customer's local site gets designated as a SNMPv2 monitoring agent. It then does over LANs to query SNMP OIDs then reports back cloud via the designated monitoring agent.

Here's maybe some inspiration to consider adding SNMP. Lots good monitoring and info. Pics of Poweredge IDRAC8, N2024 2x switch stack, and APC UPS.

https://i.imgur.com/nSsMz7P.png https://i.imgur.com/SnBbQGT.png https://i.imgur.com/2H9l6Kx.png

phinnay commented 1 year ago

Bumping this as it'd be very useful for how I am using UptimeKuma.

@louislam Respectfully disagree that this is outside the scope of the application - SNMP is a way to query for data, the logic as to what that data does in UptimeKuma would be where ya'd want to be careful. I agree getting into the weeds with complicated checks is better suited to other products, (Icinga, Nagios, etc...) however querying SNMP for simple values like toner level or if a switch port is up / down is no more out of scope than the existing SQL monitoring that operates the same way.

I'd propose to literally copy how the SQL monitor works but for SNMP. Simply providing a red/yellow/green status and a graph over time of the queried value would be of tremendous value, even for home users.

Thanks again for a wonderful product and the time that has gone into it. I wish I was better with code to help implement this feature myself.

mattv8 commented 1 year ago

The perfect use-case for me would be to monitor the status of our security cameras- whether they are recording or not. While I can simply set up a ping-test for all of our cameras, this doesn't actually indicate to me that they are successfully recording to the NVR. We use a Lorex NVR system that has an SNMP interface with a query-able status for each camera.

Lucienest commented 1 year ago

Bump, please add support for it

wglenn01 commented 1 year ago

Yes again please.

GH-HNZ commented 1 year ago

adding basic SNMP protocol support with the possibility for custom OIDs would be good enough, later you can think of adding feats like OID discovery, and perhaps merging or grouping the SNMP checks into a single node or linking to an existing ICMP monitor, shouldn't be that complicated in my opinion.

charettemtb commented 1 year ago

Bump +1

Lucienest commented 1 year ago

Bump + 2

dev-Blaze commented 1 year ago

Bump +3

chakflying commented 1 year ago

You can upvote the original post instead of commenting. Comment won't get you there faster.

Lucienest commented 1 year ago

Please Bump + 4

CommanderStorm commented 1 year ago

@Lucienest @ThaBlazee @wglenn01 @charettemtb

Please refrain from posting +1 / requests for updates things on issues, as this makes issue-management harder. Issues are for discussing what needs to be done how by whom. We use ๐Ÿ‘๐Ÿป on issues to prioritise work.

Given that this Project is open source, you could also provide a Pull Request (with extensive screenshots, as I would not know where to get a device with SNMP) ๐Ÿ˜‰

PS: @Lucienest given that the comment from Nelson was not enough, I think being more explicit is in order. If you continue to +1 without any useful contribution, we will get you reported for abuse/spam. This is the fourth time you have commented in the spirit of `+1ยด. Uptime Kuma is maintained voluntarily by people in their spare time, please respect this.

vladaurosh commented 1 year ago

Given that this Project is open source, you could also provide a Pull Request (with extensive screenshots, as I would not know where to get a device with SNMP) ๐Ÿ˜‰

Cheap Mikrotik switch (40$ new) should get you SNMP. image

phinnay commented 1 year ago

Given that this Project is open source, you could also provide a Pull Request (with extensive screenshots, as I would not know where to get a device with SNMP) ๐Ÿ˜‰

I just noticed this was getting some activity!

SO many devices support SNMP, if you have a network printer, managed switch... anything there's a high chance of it supporting SNMP.

Without purchasing anything - Both windows and linux support SNMP reporting out the box. You can enable it in your OS and then query well known OIDs to pull values from your computer

Example: https://www.sysadmin.md/snmp-most-useful-linux-oids.html

Hope that helps!!

Slamkryp commented 11 months ago

+1 in this. SNMP is a great tool for monitoring states of many different kinds of equipment like switches, ups:s and all kinds of stuff. i would really like this to be implemented as its my primary way of monitoring networks and servers.

stacksjb commented 11 months ago

One extrememly useful area for this would be for monitoring uptime of connected devices, as opposed to devices directly.

For example, I have about 14 IoT devices connected wirelessly. Monitoring them seperately is a pain, and if my AP goes down, they all fire.

However, if I monitor my Wifi AP directly via SNMP, I can monitor them from the list of connected devices.

IMHO this kind of basic monitoring is exactly what should be supported.

CommanderStorm commented 11 months ago

exactly what should be supported

Given that monitors which come from the community work better (because the dev providing the implementation understands what SNMP is and has a device to test this on), this would be how to get this feature. => A reasonable PR implementing this feature is likely to get merged

See this PR for a somewhat similar monitor: https://github.com/louislam/uptime-kuma/pull/3178 Here is our contribution guide: https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md

markosole commented 11 months ago

I am happy to see interest in this, well the same thing I am looking for as well. I am using UptimeKuma for 50+ different services (what's supported) and last piece is (to fill the gaps) SNMP for devices and for a simple metrics. I will loook into extending it myself and will share some info. Fingers drossed!

NEBELWAENDE commented 10 months ago

Maybe this might be a light path or bridge to get over - i have seen, that "uptime kuma", which i like very much, fires up several ping commands (i use Ping Monitors in Uptime Kuma) as one can see on the console/syslog in the docker image i run. I am wondering if someone could figure out if the net-snmp commands snmpwalk and snmpget resp. snmptable command could be helpfull to get certain snmp values from e.g. printers routers and switches. just a thought that it could be a way ...

phinnay commented 10 months ago

Maybe this might be a light path or bridge to get over - i have seen, that "uptime kuma", which i like very much, fires up several ping commands (i use Ping Monitors in Uptime Kuma) as one can see on the console/syslog in the docker image i run. I am wondering if someone could figure out if the net-snmp commands snmpwalk and snmpget resp. snmptable command could be helpfull to get certain snmp values from e.g. printers routers and switches. just a thought that it could be a way ...

that would make a lot of sense!

To someone who knows coding this PR could be a literal copy/paste from the SQL monitor but switch out the heavy lifting by passing values to net-snmp

Love the product, hope this gets traction!

NEBELWAENDE commented 10 months ago

What about forking uptime kuma and Code SNMP Get via OID ourself? I am wondering, where to find SQL Monitor as an Example in the Code that Could be copied and adappted.

example of an OID-snmp monitor

```js const snmp = require('snmp-native'); // Configure SNMP parameters const session = new snmp.Session({ host: 'your_target_host', community: 'your_community_string' }); // Define the OID for CPU load average as a variable (this is just an example OID) const customOID = '1.3.6.1.2.1.25.3.3.1.2.1'; // Example OID for CPU load average // Define the threshold percentage as a variable const thresholdPercentage = 80; // Set the threshold to 80% // Convert the OID string to an array of integers const oid = customOID.split('.').map(Number); // Perform the SNMP query session.get({ oid }, (error, varbinds) => { if (error) { console.error('Error in SNMP query:', error); } else { varbinds.forEach((varbind) => { const cpuLoad = varbind.value; console.log(`OID: ${varbind.oid.join('.')} = ${cpuLoad}`); // Check if CPU load exceeds the threshold if (cpuLoad > thresholdPercentage) { console.log(`CPU load exceeded the ${thresholdPercentage}% threshold. Taking action...`); // Perform your desired action here when the CPU load exceeds the threshold } }); } // Close the SNMP session session.close(); }); ```

In this example, we use the OID 1.3.6.1.2.1.25.3.3.1.2.1 to query the average CPU load. The threshold is specified as a percentage, and the script compares the retrieved CPU load with this threshold. If the CPU load exceeds the threshold, it takes the specified action.

Please note that you may need to use a different OID from the Host Resources MIB to retrieve the specific CPU load that matches your requirements.

NEBELWAENDE commented 9 months ago
Example how to set up printer level monitoring

```js const snmp = require('snmp-native'); // Configure SNMP parameters const session = new snmp.Session({ host: 'your_printer_ip', community: 'your_community_string' }); // Define the OIDs for Toner Levels in Percentage as variables (these are example OIDs) const cyanTonerOID = '1.3.6.1.4.1.2435.2.4.3.1.15.1'; // Example OID for Cyan Toner Level (%) const magentaTonerOID = '1.3.6.1.4.1.2435.2.4.3.1.15.2'; // Example OID for Magenta Toner Level (%) const yellowTonerOID = '1.3.6.1.4.1.2435.2.4.3.1.15.3'; // Example OID for Yellow Toner Level (%) const blackTonerOID = '1.3.6.1.4.1.2435.2.4.3.1.15.4'; // Example OID for Black Toner Level (%) // Perform SNMP queries for toner levels in percentage for each color function queryTonerLevel(oid, colorName) { session.get({ oid }, (error, varbinds) => { if (error) { console.error(`Error in ${colorName} Toner SNMP query:`, error); } else { varbinds.forEach((varbind) => { const tonerLevel = varbind.value; console.log(`${colorName} Toner Level (%): ${tonerLevel}`); }); } }); } // Query toner levels for all colors queryTonerLevel(cyanTonerOID, 'Cyan'); queryTonerLevel(magentaTonerOID, 'Magenta'); queryTonerLevel(yellowTonerOID, 'Yellow'); queryTonerLevel(blackTonerOID, 'Black'); // Close the SNMP session (after all queries are completed) setTimeout(() => { session.close(); }, 1000); // Wait for 1 second before closing the session (adjust as needed) ```

In this program, we define separate OIDs for the percentage toner levels for Cyan, Magenta, Yellow, and Black toners. We then perform SNMP queries for each color, retrieve the toner level in percentage, and print the results. Finally, we close the SNMP session after all queries are completed. Please replace 'your_printer_ip' and 'your_community_string' with the correct values for your printer and SNMP setup.

vladaurosh commented 7 months ago

Would this help snmp get implemented in Uptime Kuma? I'd do it myself but I'm not developer.

https://github.com/node-red/node-red-nodes/tree/master/io/snmp

owlysk commented 5 months ago

Any news? I really want to have this feature to set up notification for printer toner.

apio-sys commented 5 months ago

IMHO this sounds out of scope of the product/goal here. Toner levels can easily trigger an alert from the printer itself. I think - but correct me if I'm wrong - that we want to monitor services running from outside our own network (hence SNMP is really out of scope since LAN oriented protocol) to make sure stuff is running for the rest of the world as it should be. That's just my opinion of course. I think the scope of v2 with numerous additions, especially yearly SLA figures is far more important.

owlysk commented 5 months ago

Yeah of course, SNMP protocol can do more, than check level of toner in printer. But my use case is monitoring toner in company. SNMP can monitor anything you want. I like to have one monitoring tool for all my needs and actually I need to monitor SNMP values, so I hope this feature will be added soon.

CommanderStorm commented 5 months ago

Any news

No PR has been raised with support for this. @NEBELWAENDE has posted some code which would need to be fittend into our monitoring-type's and tested that it works. An example for a PR implementing a monitoring-type is https://github.com/louislam/uptime-kuma/pull/3178

Our contribution guide is available here https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md

phinnay commented 5 months ago

IMHO this sounds out of scope of the product/goal here. Toner levels can easily trigger an alert from the printer itself. I think - but correct me if I'm wrong - that we want to monitor services running from outside our own network (hence SNMP is really out of scope since LAN oriented protocol) to make sure stuff is running for the rest of the world as it should be. That's just my opinion of course. I think the scope of v2 with numerous additions, especially yearly SLA figures is far more important.

i'd again respectfully disagree this is out of scope for uptime-kuma given the other non-uptime checks that have been added (SQL, API, etc...) as per my reply here https://github.com/louislam/uptime-kuma/issues/1675#issuecomment-1458343495

Toner level is one example of a value that can be monitored. It could just as easily be a switch port, or water level in the coffee maker.... SNMP is a protocol that would open up a whole new world of uses for this application.

wglenn01 commented 5 months ago

I agree, I would LOVE to have snmp monitoring added. Would be SO helpful as a WISP.

On Thu, Feb 1, 2024 at 6:11โ€ฏPM phinnay @.***> wrote:

IMHO this sounds out of scope of the product/goal here. Toner levels can easily trigger an alert from the printer itself. I think - but correct me if I'm wrong - that we want to monitor services running from outside our own network (hence SNMP is really out of scope since LAN oriented protocol) to make sure stuff is running for the rest of the world as it should be. That's just my opinion of course. I think the scope of v2 with numerous additions, especially yearly SLA figures is far more important.

i'd again respectfully disagree this is out of scope for uptime-kuma given the other non-uptime checks that have been added (SQL, API, etc...) as per my reply here #1675 (comment) https://github.com/louislam/uptime-kuma/issues/1675#issuecomment-1458343495

Toner level is one example of a value that can be monitored. It could just as easily be a switch port, or water level in the coffee maker.... SNMP is a protocol that would open up a whole new world of uses for this application.

โ€” Reply to this email directly, view it on GitHub https://github.com/louislam/uptime-kuma/issues/1675#issuecomment-1922605050, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF2FAX6NVTCB34MNOIQVR7TYRQ4K7AVCNFSM5WW4TXD2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJSGI3DANJQGUYA . You are receiving this because you were mentioned.Message ID: @.***>

AlmightyJojo commented 5 months ago

I recommend those looking for SNMP checkout Zabbix. Its powerful monitoring system. It is distributed monitoring solution where you can setup Zabbix proxy on remote sites LAN(s) and have Zabbix Server at your HQ. Proxy SNMPv2 monitors will only use community string to monitor SNMP devices on the local LAN (SNMPv2 unencrypted). The Zabbix proxy to server communication can then use encryption PSK or Cert to update the Zabbix server with everything the proxy is monitoring. Zabbix server then allows for tons a logic to setup alerts. For example Dell IDRAC server global heath check = 3 (ok) , alert if not equal to 3.

https://github.com/zabbix/zabbix https://www.zabbix.com/container_images

phinnay commented 5 months ago

I am quite familiar with Zabbix, and use enterprise class monitoring software in my day job all the time.

Uptime-kuma is an entirely different use-case. If i wanted to get that crazy I'd script up some middleware to dump SNMP values to SQL and check them with the existing uptime-kuma capabilities. Janitoring enterprise software is not something I want to do in my home / spare time. The simplicity of uptime-kuma is attractive for this reason.

My rationale for promoting this feature is so folks can punch in an OID and get basic information back, the same way all the other checks work. Nobody is suggesting this software needs to do anything or become anything remotely resembling Nagios/icinga/Zabbix/ELK.

AlmightyJojo commented 5 months ago

Janitoring enterprise software is not something I want to do in my home / spare time.

Ok, then don't use Zabbix if you don't want to...

CommanderStorm commented 5 months ago

@AlmightyJojo I have reworded your comment to be more civil. Being supportive is in the nature of open source and I'd ask you to not call people names just because they disagree with you.

CommanderStorm commented 5 months ago

(for those wondering: I merged a few comments to make this thread more readable ^^)

AlmightyJojo commented 5 months ago

Its half baked movie joke. No sense of humor in IT - buttercups all around me.

Slamkryp commented 5 months ago

It would be really nice with at least minimal snmp abilitys sรฅ you can monitor UPS and Switch temp and such things.

CommanderStorm commented 5 months ago

@Slamkryp I think my comment has moved so far to the top that reposting is beneficial

No PR has been raised with support for this. @ NEBELWAENDE has posted some code which would need to be fittend into our monitoring-type's and tested that it works. An example for a PR implementing a monitoring-type is #3178

Our contribution guide is available here https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md

Densen2002 commented 5 months ago

Good day to all,

I use Uptime Kuma to monitor "complex" devices and at the same time I use "Mikrotik TheDude!" to monitor my local network network devices that can send data via the SNMP protocol. The SNMP protocol is widely used in operator network devices and other industrial networks. Routers and access points such as Ruckus, Mikrotik and others provide a lot of useful information about the current state of the network.

It would be fantastic to combine both monitoring systems in Uptime Kuma. Or configure some interface so that Uptime Kuma can collect data via the SNMP protocol.

Densen2002 commented 5 months ago

I found a way to make friends - Uptime Kuma with Mirkotik without SNMP protocol support.

The task is to monitor in Uptime Kuma the status of Mikrotik and the map of its TheDude networks

  1. in Uptime Kuma we should create a New Monitor, select the PUSH type, and get a unique push URL, define the waiting interval, for example, 60 seconds, and the โ€œpolarityโ€ (Flip the status upside down. If the service is reachable, it is DOWN ).

for example http://192.168.80.87:3001/api/push/AdSiDEOE6s?status=up&msg=OK&ping=

  1. In Mikrotik, we should create a tool that will โ€œpeckโ€ push URL, informing us in Uptime Kuma about what we have in mind - whether it works or does not work. /tool fetch url=http://192.168.80.87:3001/api/push/AdSiDEOE6s?status=up&msg=OK&ping=" keep-result=no

  2. in Uptime Kuma we see that Mikrotik is alive and what we have in mind - whether it works or not.

You can create as many of these Monitors as you like.

The trick is that using the method described above, you can โ€œuploadโ€ various events and service states, for example, SNMP OIDs change or Network Watch Alerts, from the TheDude network map to the Uptime Kuma server. And so on.

camdenyoung commented 3 months ago

I would strongly support and encourage integration of SNMP. Its a fundamental and industry standard of monitoring network equipment.

To give some realworld use, for our temporary deployments we monitor not just that a switch is connected (simple ping response), but with SNMP, is an individual port up or down, has it negocitated at the correct link speed, is it full or half duplex. Any of these could alert to a potential uptime problem about to occur.

We also deploy many microwave links, so for monitoring purposes, we dont just want to know the link is up/connected, but what is the signal strenth (RSSI), what is the throughput, etc. This is all simply collected via SNMP. Just because you can get a ping response from the microwave link at the other end, doesnt mean the link isnt about to fail, or is running at an acceptable speed.

We currently use Nagios for our monitoring, which does the job, but its an awful system to actually setup and maintain, and just isnt user friendly for the rest of our less technical team compared to the fantastic interface you've created with Uptime Kuma.

Don't waste time on intergrating OID library's for individual products, leave that to user to enter the values they need to retrieve. Most quality equipment has this documented anyway and/or there are hundreds of products already out there that let you scan a device to find the OID you require anyway.

Slamkryp commented 3 months ago

SNMP would be really nice as most UPS:s, switches, server support SNMP. Just for the simple thing to get a notfication when UPS is running on battery would rule!

CommanderStorm commented 3 months ago

@Slamkryp You are repeating yourself. Please avoid spamming without additional information, context or value. Being less suttle: If you continue spamming, we will ban you as by our code of conduct

The state of this issue has NOT changed from my response to your last post: https://github.com/louislam/uptime-kuma/issues/1675#issuecomment-1925375148

No PR has been raised with support for this. @ NEBELWAENDE has posted some code which would need to be fittend into our monitoring-type's and tested that it works. An example for a PR implementing a monitoring-type is https://github.com/louislam/uptime-kuma/pull/3178

Our contribution guide is available here https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md

owlysk commented 3 months ago

Hello guys, I decided to try implement this monitor.

I think it should be like this: You will set up IP address of device, SNMP version number, community string for SNMPv1 & SNMPv2c and OID you want to check. One OID per monitor. Then I think you should set control value and condition. For example, I want to check, if OID value is greater than 30% (30% is my control value). Conditions will be:

Monitoring will check OID value against condition. If OID value is > than control value = UP. Otherwise it returns DOWN. If device will be offline, returns DOWN.

Is that behaviour correct?


For now I won't implement SNMPv3.

camdenyoung commented 3 months ago

Hi @owlysk, yes that's the fundamental concept, but keep in mind an OID from a network appliance can return a string or integer, depending on what element is being monitored.

Going back to my microwave link example from earlier, if I check the state of an ethernet port, the OID response would be the string of 'up' or 'down', but if I check the RSSI (signal strength) that would return a value anywhere between -128 (dBm) to -20 (dBm).

And thanks for looking into this! Really appreciate it. I wouldn't rush to implement SNMP v3. Yes its the newer (more secure protocol because it has auth) but I honestly would hazard a guess most implementations are still on v2, unless crossing wan connections.

chakflying commented 3 months ago

Sounds pretty good, but just in case you didn't know, you should take a look at how the json-query monitor works.

Ideally in the long term, we would want all value comparisons to work with the jsonata syntax, and reuse the database fields for better compatibility (see #3919). I don't think it's worth implementing custom value comparison functionality just for this monitor.

owlysk commented 2 months ago

@camdenyoung can you please provide output from snmpwalk for signal strength? I want to know what response look like.

@chakflying thank you, I didn't know that. I'll take a look.