mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-09 14:03:12 +08:00
Move getKey() to util.ts
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const { MonitorType } = require("./monitor-type");
|
||||
const { UP, DOWN, log } = require("../../src/util");
|
||||
const { UP, DOWN, log, getKey } = require("../../src/util");
|
||||
const snmp = require("net-snmp");
|
||||
|
||||
class SNMPMonitorType extends MonitorType {
|
||||
@@ -17,16 +17,6 @@ class SNMPMonitorType extends MonitorType {
|
||||
version: getKey(snmp.Version, monitor.snmpVersion) || snmp.Version2c,
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the key from the provided object corresponding to the given value.
|
||||
* @param {object} obj - The object to search.
|
||||
* @param {*} value - The value to search for.
|
||||
* @returns {string|null} - The key associated with the value, or null if not found.
|
||||
*/
|
||||
function getKey(obj, value) {
|
||||
return Object.keys(obj).find(key => obj[key] === value) || null;
|
||||
}
|
||||
|
||||
try {
|
||||
const session = snmp.createSession(monitor.hostname, monitor.snmpCommunityString, options);
|
||||
|
||||
|
Reference in New Issue
Block a user