2025-10-18 11:59:55 +00:00
|
|
|
import type { IOidSet, TUpsModel } from './types.ts';
|
2025-03-25 09:06:23 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* OID sets for different UPS models
|
|
|
|
|
* Contains mappings between UPS models and their SNMP OIDs
|
|
|
|
|
*/
|
|
|
|
|
export class UpsOidSets {
|
|
|
|
|
/**
|
|
|
|
|
* OID sets for different UPS models
|
|
|
|
|
*/
|
2025-03-25 10:21:21 +00:00
|
|
|
private static readonly UPS_OID_SETS: Record<TUpsModel, IOidSet> = {
|
2025-03-25 09:06:23 +00:00
|
|
|
// Cyberpower OIDs for RMCARD205 (based on CyberPower_MIB_v2.11)
|
|
|
|
|
cyberpower: {
|
2025-10-19 23:48:13 +00:00
|
|
|
POWER_STATUS: '1.3.6.1.4.1.3808.1.1.1.4.1.1.0', // upsBaseOutputStatus
|
2025-03-25 09:06:23 +00:00
|
|
|
BATTERY_CAPACITY: '1.3.6.1.4.1.3808.1.1.1.2.2.1.0', // upsAdvanceBatteryCapacity (percentage)
|
|
|
|
|
BATTERY_RUNTIME: '1.3.6.1.4.1.3808.1.1.1.2.2.4.0', // upsAdvanceBatteryRunTimeRemaining (TimeTicks)
|
2025-10-23 12:25:59 +00:00
|
|
|
OUTPUT_LOAD: '1.3.6.1.4.1.3808.1.1.1.4.2.3.0', // upsAdvanceOutputLoad (percentage)
|
|
|
|
|
OUTPUT_POWER: '1.3.6.1.4.1.3808.1.1.1.4.2.5.0', // upsAdvanceOutputPower (watts)
|
|
|
|
|
OUTPUT_VOLTAGE: '1.3.6.1.4.1.3808.1.1.1.4.2.1.0', // upsAdvanceOutputVoltage (0.1V scale)
|
|
|
|
|
OUTPUT_CURRENT: '1.3.6.1.4.1.3808.1.1.1.4.2.4.0', // upsAdvanceOutputCurrent (0.1A scale)
|
2025-10-19 23:48:13 +00:00
|
|
|
POWER_STATUS_VALUES: {
|
|
|
|
|
online: 2, // upsBaseOutputStatus: 2=onLine
|
|
|
|
|
onBattery: 3, // upsBaseOutputStatus: 3=onBattery
|
|
|
|
|
},
|
2025-03-25 09:06:23 +00:00
|
|
|
},
|
2025-10-19 13:14:18 +00:00
|
|
|
|
2025-10-23 12:45:29 +00:00
|
|
|
// APC OIDs (PowerNet MIB)
|
2025-03-25 09:06:23 +00:00
|
|
|
apc: {
|
2025-10-19 23:48:13 +00:00
|
|
|
POWER_STATUS: '1.3.6.1.4.1.318.1.1.1.4.1.1.0', // upsBasicOutputStatus
|
2025-03-25 09:06:23 +00:00
|
|
|
BATTERY_CAPACITY: '1.3.6.1.4.1.318.1.1.1.2.2.1.0', // Battery capacity in percentage
|
|
|
|
|
BATTERY_RUNTIME: '1.3.6.1.4.1.318.1.1.1.2.2.3.0', // Remaining runtime in minutes
|
2025-10-23 12:25:59 +00:00
|
|
|
OUTPUT_LOAD: '1.3.6.1.4.1.318.1.1.1.4.2.3.0', // upsAdvOutputLoad (percentage)
|
2025-10-23 12:45:29 +00:00
|
|
|
OUTPUT_POWER: '1.3.6.1.4.1.318.1.1.1.4.2.8.0', // upsAdvOutputActivePower (watts)
|
2025-10-23 12:25:59 +00:00
|
|
|
OUTPUT_VOLTAGE: '1.3.6.1.4.1.318.1.1.1.4.2.1.0', // upsAdvOutputVoltage
|
|
|
|
|
OUTPUT_CURRENT: '1.3.6.1.4.1.318.1.1.1.4.2.4.0', // upsAdvOutputCurrent
|
2025-10-19 23:48:13 +00:00
|
|
|
POWER_STATUS_VALUES: {
|
|
|
|
|
online: 2, // upsBasicOutputStatus: 2=onLine
|
|
|
|
|
onBattery: 3, // upsBasicOutputStatus: 3=onBattery
|
|
|
|
|
},
|
2025-03-25 09:06:23 +00:00
|
|
|
},
|
2025-10-19 13:14:18 +00:00
|
|
|
|
2025-10-23 12:45:29 +00:00
|
|
|
// Eaton OIDs (XUPS-MIB)
|
2025-03-25 09:06:23 +00:00
|
|
|
eaton: {
|
2025-10-19 23:48:13 +00:00
|
|
|
POWER_STATUS: '1.3.6.1.4.1.534.1.4.4.0', // xupsOutputSource
|
2025-03-25 14:47:57 +00:00
|
|
|
BATTERY_CAPACITY: '1.3.6.1.4.1.534.1.2.4.0', // xupsBatCapacity (percentage)
|
|
|
|
|
BATTERY_RUNTIME: '1.3.6.1.4.1.534.1.2.1.0', // xupsBatTimeRemaining (seconds)
|
2025-10-23 12:45:29 +00:00
|
|
|
OUTPUT_LOAD: '1.3.6.1.4.1.534.1.4.4.1.8.1', // xupsOutputPercentLoad (phase 1)
|
|
|
|
|
OUTPUT_POWER: '1.3.6.1.4.1.534.1.4.4.1.4.1', // xupsOutputWatts (phase 1)
|
|
|
|
|
OUTPUT_VOLTAGE: '1.3.6.1.4.1.534.1.4.4.1.2.1', // xupsOutputVoltage (phase 1)
|
|
|
|
|
OUTPUT_CURRENT: '1.3.6.1.4.1.534.1.4.4.1.3.1', // xupsOutputCurrent (phase 1)
|
2025-10-19 23:48:13 +00:00
|
|
|
POWER_STATUS_VALUES: {
|
|
|
|
|
online: 3, // xupsOutputSource: 3=normal (mains power)
|
|
|
|
|
onBattery: 5, // xupsOutputSource: 5=battery
|
|
|
|
|
},
|
2025-03-25 09:06:23 +00:00
|
|
|
},
|
2025-10-19 13:14:18 +00:00
|
|
|
|
2025-03-25 09:06:23 +00:00
|
|
|
// TrippLite OIDs
|
|
|
|
|
tripplite: {
|
2025-10-19 23:48:13 +00:00
|
|
|
POWER_STATUS: '1.3.6.1.4.1.850.1.1.3.1.1.1.0', // tlUpsOutputSource
|
2025-03-25 09:06:23 +00:00
|
|
|
BATTERY_CAPACITY: '1.3.6.1.4.1.850.1.1.3.2.4.1.0', // Battery capacity in percentage
|
|
|
|
|
BATTERY_RUNTIME: '1.3.6.1.4.1.850.1.1.3.2.2.1.0', // Remaining runtime in minutes
|
2025-10-23 12:25:59 +00:00
|
|
|
OUTPUT_LOAD: '1.3.6.1.2.1.33.1.4.4.1.5.1', // RFC 1628: upsOutputPercentLoad
|
|
|
|
|
OUTPUT_POWER: '1.3.6.1.2.1.33.1.4.4.1.4.1', // RFC 1628: upsOutputPower (watts)
|
|
|
|
|
OUTPUT_VOLTAGE: '1.3.6.1.2.1.33.1.4.4.1.2.1', // RFC 1628: upsOutputVoltage
|
|
|
|
|
OUTPUT_CURRENT: '1.3.6.1.2.1.33.1.4.4.1.3.1', // RFC 1628: upsOutputCurrent (0.1A scale)
|
2025-10-19 23:48:13 +00:00
|
|
|
POWER_STATUS_VALUES: {
|
|
|
|
|
online: 2, // tlUpsOutputSource: 2=normal (mains power)
|
|
|
|
|
onBattery: 3, // tlUpsOutputSource: 3=onBattery
|
|
|
|
|
},
|
2025-03-25 09:06:23 +00:00
|
|
|
},
|
2025-10-19 13:14:18 +00:00
|
|
|
|
2025-03-25 09:06:23 +00:00
|
|
|
// Liebert/Vertiv OIDs
|
|
|
|
|
liebert: {
|
2025-10-19 23:48:13 +00:00
|
|
|
POWER_STATUS: '1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.2.1', // lgpPwrOutputSource
|
2025-03-25 09:06:23 +00:00
|
|
|
BATTERY_CAPACITY: '1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4.1', // Battery capacity in percentage
|
|
|
|
|
BATTERY_RUNTIME: '1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.5.1', // Remaining runtime in minutes
|
2025-10-23 12:25:59 +00:00
|
|
|
OUTPUT_LOAD: '1.3.6.1.2.1.33.1.4.4.1.5.1', // RFC 1628: upsOutputPercentLoad
|
|
|
|
|
OUTPUT_POWER: '1.3.6.1.2.1.33.1.4.4.1.4.1', // RFC 1628: upsOutputPower (watts)
|
|
|
|
|
OUTPUT_VOLTAGE: '1.3.6.1.2.1.33.1.4.4.1.2.1', // RFC 1628: upsOutputVoltage
|
|
|
|
|
OUTPUT_CURRENT: '1.3.6.1.2.1.33.1.4.4.1.3.1', // RFC 1628: upsOutputCurrent (0.1A scale)
|
2025-10-19 23:48:13 +00:00
|
|
|
POWER_STATUS_VALUES: {
|
|
|
|
|
online: 2, // lgpPwrOutputSource: 2=normal (mains power)
|
|
|
|
|
onBattery: 3, // lgpPwrOutputSource: 3=onBattery
|
|
|
|
|
},
|
2025-03-25 09:06:23 +00:00
|
|
|
},
|
2025-10-19 13:14:18 +00:00
|
|
|
|
2025-03-25 09:06:23 +00:00
|
|
|
// Custom OIDs (to be provided by the user)
|
|
|
|
|
custom: {
|
|
|
|
|
POWER_STATUS: '',
|
|
|
|
|
BATTERY_CAPACITY: '',
|
|
|
|
|
BATTERY_RUNTIME: '',
|
2025-10-23 12:25:59 +00:00
|
|
|
OUTPUT_LOAD: '',
|
|
|
|
|
OUTPUT_POWER: '',
|
|
|
|
|
OUTPUT_VOLTAGE: '',
|
|
|
|
|
OUTPUT_CURRENT: '',
|
2025-10-19 13:14:18 +00:00
|
|
|
},
|
2025-03-25 09:06:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get OID set for a specific UPS model
|
|
|
|
|
* @param model UPS model name
|
|
|
|
|
* @returns OID set for the model
|
|
|
|
|
*/
|
2025-03-25 10:21:21 +00:00
|
|
|
public static getOidSet(model: TUpsModel): IOidSet {
|
2025-03-25 09:06:23 +00:00
|
|
|
return this.UPS_OID_SETS[model];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get standard RFC 1628 OID set as fallback
|
|
|
|
|
* @returns Standard OID set
|
|
|
|
|
*/
|
|
|
|
|
public static getStandardOids(): Record<string, string> {
|
|
|
|
|
return {
|
2025-10-19 13:14:18 +00:00
|
|
|
'power status': '1.3.6.1.2.1.33.1.4.1.0', // upsOutputSource
|
|
|
|
|
'battery capacity': '1.3.6.1.2.1.33.1.2.4.0', // upsEstimatedChargeRemaining
|
|
|
|
|
'battery runtime': '1.3.6.1.2.1.33.1.2.3.0', // upsEstimatedMinutesRemaining
|
2025-10-23 12:25:59 +00:00
|
|
|
'output load': '1.3.6.1.2.1.33.1.4.4.1.5.1', // upsOutputPercentLoad (indexed by line)
|
|
|
|
|
'output power': '1.3.6.1.2.1.33.1.4.4.1.4.1', // upsOutputPower in watts (indexed by line)
|
|
|
|
|
'output voltage': '1.3.6.1.2.1.33.1.4.4.1.2.1', // upsOutputVoltage (indexed by line)
|
|
|
|
|
'output current': '1.3.6.1.2.1.33.1.4.4.1.3.1', // upsOutputCurrent in 0.1A (indexed by line)
|
2025-03-25 09:06:23 +00:00
|
|
|
};
|
|
|
|
|
}
|
2025-10-19 13:14:18 +00:00
|
|
|
}
|