-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNMP Value Retrieval #1675
Comments
This comment was marked as resolved.
This comment was marked as resolved.
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. |
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 |
This comment was marked as spam.
This comment was marked as spam.
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. https://i.imgur.com/nSsMz7P.png |
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. |
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. |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
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. |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as resolved.
This comment was marked as resolved.
|
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: Hope that helps!! |
This comment was marked as spam.
This comment was marked as spam.
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. |
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. See this PR for a somewhat similar monitor: #3178 |
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. |
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! |
This comment was marked as resolved.
This comment was marked as resolved.
This comment has been minimized.
This comment has been minimized.
This comment was marked as duplicate.
This comment was marked as duplicate.
@Slamkryp I think my comment has moved so far to the top that reposting is beneficial
|
This comment was marked as duplicate.
This comment was marked as duplicate.
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
for example
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. |
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. |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as resolved.
This comment was marked as resolved.
Hello guys, I think it should be like this:
Monitoring will check OID value against condition. If Is that behaviour correct? For now I won't implement SNMPv3. |
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. |
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. |
@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. |
Hey @owlysk I've started working on implementing this feature. It's nowhere near complete, but I'm dropping my work thus far into PR #4717. I've laid the framework for your control_value logic. I'll continue to work on this next week (I'm assuming I won't have time over the weekend but ya never know). |
@owlysk I'm wondering if you'd be able to take a look. I'm basically stuck with a strange timeout issue. See my PR, specifically, #issuecomment-2083823715 |
Apologies @owlysk, I've been away the last week. I'm back in the office now if you still need me to send through an snmpwalk? |
@owlysk @mattv8 below is the result for RSSI (signal strength) from a Siklu EH-710 microwave link as an example snmpget -v 2c -c public 10.27.2.82 .1.3.6.1.4.1.31926.2.1.1.19.1 Setting thresholds is where it matters with sensors such as these. A link that is powered up, but has no wireless connection will return a value of -128 (dBm). A connection anywhere between -20 (dBm) through -55 (dBm) is generally a healthy link, but is relative to what the physical distance the links are connecting across. So, with the above example unit that is reporting a -26 RSSI, I might set a warning threshold at -30 and then a critical if it equals or passes -40 for example. |
@camdenyoung I'm essentially implementing @owlysk's suggested logic for checking SNMP:
However, one potential issue I foresee is that often times OID's will report values in binary, or OctetString (more on that here). So we need to have logic in place to handle those situations. In my PR I was originally going to use snmp-native, but I am switching to net-snmp because has SNMP walking. As I work on this feature, I wrote an SNMP walking script, which I used to try to parse my Cisco SG-300 switch. I let the walk run for 30 minutes or so and it reported back 211,468 unique OID's parsable in Cisco's default RO library... So I think implementing an SNMP walk for this feature is impractical. Which is frustrating because unless you already know the OID you're wanting to monitor, there isn't some central directory to easily look up, for example, CPU usage on my Cisco switch... Posting my SNMP walking script for the record: Click to view codeconst fs = require('fs');
const snmp = require('net-snmp');
// Configuration
const monitor = {
ipAddress: 'changeme',
port: '161',
communityString: 'public',
snmpVersion: '2c',
rootOid: '1.3.6.1',// This is pretty high level
};
// SNMP options
const options = {
port: monitor.port,
retries: 1,
timeout: 5000,
version: snmp.Version2c,
};
// Create SNMP session
const session = snmp.createSession(monitor.ipAddress, monitor.communityString, options);
// Create writable stream for CSV
const csvStream = fs.createWriteStream('snmp_data.csv');
// Function to handle SNMP walk feed callback
function feedCb(varbinds) {
for (const varbind of varbinds) {
if (!snmp.isVarbindError(varbind) && varbind.value !== null && varbind.value !== undefined) {
console.log(`OID: ${varbind.oid}, Type: ${findType(varbind.type)}, Value: ${varbind.value}`);
const csvRow = `${varbind.oid},${findType(varbind.type)},${varbind.value}\n`;
csvStream.write(csvRow);
}
}
}
// Function to handle SNMP walk done callback
function doneCb(error) {
if (error) {
console.error(error.toString());
} else {
console.log('SNMP walk completed.');
}
}
// Start SNMP walk from the specified OID
session.walk(monitor.rootOid, 20, feedCb, doneCb);
// Function to find the corresponding type name for a given value
function findType(value) {
const typeName = Object.entries(snmp.ObjectType).find(([key, val]) => val === value);
return typeName ? typeName[0] : 'Unknown';
} |
As you've just discovered, I wouldn't worry about implementing any OID scanning functionality. There are thousands of tools out there that the user can utilise to find the right OID for the sensor / status to be monitored. Leave it to the user to know what OID to enter, then only functionality required from the uptime kuma perspective is the logic behind the alert. Is the value true or false, or is the threshold met or exceeded, etc. On a side note though, it might be worth having a look over librenms GitHub. This is a much higher level (and as a result, significantly more complicated) monitoring solution, but it might help explain how they have implemented the scanning functionality as well as the monitoring side. |
Thanks for the tip to librenms, I'll take a look. I'll also continue working on the PR tomorrow morning, but I was able to get basic functionality working at least, so I can sleep tonight... |
Alright I finished this monitor and have requested review of the PR. For now, I'm not going to implement any sort of OID discovery-- it's just too complicated. I'm going to assume people know the OID they want to monitor already and can paste it in. If anyone wants to check out this feature, you can clone my PR #4717 and test for yourself. It's working well so far in my dev environment. docker run --rm -it -p 3000:3000 -p 3001:3001 --pull always -e 'UPTIME_KUMA_GH_REPO=mattv8:snmp-monitor' louislam/uptime-kuma:pr-test2 |
@camdenyoung Thank you for snmpwalk result. @mattv8 was quicker in implementation, than me :) @mattv8 I'm testing your PR but I always get error - |
Hey @owlysk I got lucky and had some spare time. 🙂 I'm currently working through the error you're seeing. There is an issue with how my code is parsing strings: |
This comment was marked as outdated.
This comment was marked as outdated.
@owlysk I have committed my code fixing the issue you were encountering. Please re-pull the updated docker image with my latest commits. If you're still seeing FWIW I'm testing on my Cisco SG-300 switch. I had to go into the device's web interface and turn on the SNMP server, and configure a community string as well as a "view" which turns on a specific set of OID's. |
@mattv8 Where can I pull the container to do some testing myself? |
Rather than pull it into a Docker container, it's IMO easiest to clone the PR to a local directory and spin up the server from there. Here are the commands to do that: git clone https://github.com/louislam/uptime-kuma.git # Assuming you have git installed cd uptime-kuma # Change into the directory you just cloned git fetch origin pull/4717/head:pr-4717 && git checkout pr-4717 # Check out this PR npm ci # Assuming you have node and npm installed npm run dev # This will start the server on http://localhost:3000 |
🏷️ 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
The text was updated successfully, but these errors were encountered: