uptime-kuma icon indicating copy to clipboard operation
uptime-kuma copied to clipboard

SNMP Value Retrieval

Open wglenn01 opened this issue 2 years ago โ€ข 62 comments

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

  • [X] I checked and didn't find similar feature request

๐Ÿท๏ธ 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

wglenn01 avatar May 23 '22 19:05 wglenn01

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.

Computroniks avatar May 31 '22 15:05 Computroniks

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.

louislam avatar May 31 '22 16:05 louislam

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

Computroniks avatar May 31 '22 16:05 Computroniks

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

Lucienest avatar Dec 12 '22 14:12 Lucienest

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

AlmightyJojo avatar Jan 06 '23 16:01 AlmightyJojo

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.

phinnay avatar Mar 07 '23 15:03 phinnay

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.

mattv8 avatar Apr 19 '23 19:04 mattv8

Bump, please add support for it

Lucienest avatar Apr 23 '23 15:04 Lucienest

Yes again please.

wglenn01 avatar Apr 23 '23 15:04 wglenn01

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.

GH-HNZ avatar May 03 '23 16:05 GH-HNZ

Bump +1

charettemtb avatar May 04 '23 18:05 charettemtb

Bump + 2

Lucienest avatar May 05 '23 16:05 Lucienest

Bump +3

dev-Blaze avatar May 18 '23 06:05 dev-Blaze

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

chakflying avatar May 18 '23 11:05 chakflying

Please Bump + 4

Lucienest avatar May 23 '23 07:05 Lucienest

@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.

CommanderStorm avatar May 23 '23 08:05 CommanderStorm

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

vladaurosh avatar Jul 06 '23 21:07 vladaurosh

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!!

phinnay avatar Jul 06 '23 22:07 phinnay

+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.

Slamkryp avatar Aug 01 '23 13:08 Slamkryp

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.

stacksjb avatar Aug 03 '23 16:08 stacksjb

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

CommanderStorm avatar Aug 03 '23 17:08 CommanderStorm

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!

markosole avatar Aug 15 '23 12:08 markosole

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 ...

NEBELWAENDE avatar Sep 20 '23 08:09 NEBELWAENDE

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!

phinnay avatar Sep 20 '23 13:09 phinnay

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

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 avatar Sep 22 '23 06:09 NEBELWAENDE

Example how to set up printer level monitoring

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.

NEBELWAENDE avatar Sep 22 '23 11:09 NEBELWAENDE

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

vladaurosh avatar Dec 10 '23 12:12 vladaurosh

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

owlysk avatar Feb 01 '24 21:02 owlysk

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.

apio-sys avatar Feb 01 '24 21:02 apio-sys

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.

owlysk avatar Feb 01 '24 21:02 owlysk