fix(snmp): Fix Eaton UPS support by updating power status OID and adjusting battery runtime conversion.
This commit is contained in:
parent
5bb775b17d
commit
896233914f
@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-03-25 - 2.5.1 - fix(snmp)
|
||||
Fix Eaton UPS support by updating power status OID and adjusting battery runtime conversion.
|
||||
|
||||
- Updated Eaton UPS power status OID to '1.3.6.1.4.1.534.1.4.4.0' to correctly detect online/battery status.
|
||||
- Added conversion for Eaton UPS battery runtime from seconds to minutes in SNMP manager.
|
||||
|
||||
## 2025-03-25 - 2.5.0 - feat(cli)
|
||||
Automatically restart running NUPST service after configuration changes in interactive setup
|
||||
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@serve.zone/nupst',
|
||||
version: '2.5.0',
|
||||
version: '2.5.1',
|
||||
description: 'Node.js UPS Shutdown Tool for SNMP-enabled UPS devices'
|
||||
}
|
||||
|
@ -348,6 +348,14 @@ export class NupstSnmp {
|
||||
} else if (powerStatusValue === 3) {
|
||||
powerStatus = 'onBattery';
|
||||
}
|
||||
} else if (config.upsModel === 'eaton') {
|
||||
// Eaton UPS: xupsOutputSource values
|
||||
// 3=normal/mains, 5=battery, etc.
|
||||
if (powerStatusValue === 3) {
|
||||
powerStatus = 'online';
|
||||
} else if (powerStatusValue === 5) {
|
||||
powerStatus = 'onBattery';
|
||||
}
|
||||
} else {
|
||||
// Default interpretation for other UPS models
|
||||
if (powerStatusValue === 1) {
|
||||
@ -357,14 +365,21 @@ export class NupstSnmp {
|
||||
}
|
||||
}
|
||||
|
||||
// Convert TimeTicks to minutes for CyberPower runtime (value is in 1/100 seconds)
|
||||
// Convert to minutes for UPS models with different time units
|
||||
let processedRuntime = batteryRuntime;
|
||||
|
||||
if (config.upsModel === 'cyberpower' && batteryRuntime > 0) {
|
||||
// TimeTicks is in 1/100 seconds, convert to minutes
|
||||
// CyberPower: TimeTicks is in 1/100 seconds, convert to minutes
|
||||
processedRuntime = Math.floor(batteryRuntime / 6000); // 6000 ticks = 1 minute
|
||||
if (this.debug) {
|
||||
console.log(`Converting CyberPower runtime from ${batteryRuntime} ticks to ${processedRuntime} minutes`);
|
||||
}
|
||||
} else if (config.upsModel === 'eaton' && batteryRuntime > 0) {
|
||||
// Eaton: Runtime is in seconds, convert to minutes
|
||||
processedRuntime = Math.floor(batteryRuntime / 60);
|
||||
if (this.debug) {
|
||||
console.log(`Converting Eaton runtime from ${batteryRuntime} seconds to ${processedRuntime} minutes`);
|
||||
}
|
||||
}
|
||||
|
||||
const result = {
|
||||
|
@ -25,9 +25,9 @@ export class UpsOidSets {
|
||||
|
||||
// Eaton OIDs
|
||||
eaton: {
|
||||
POWER_STATUS: '1.3.6.1.4.1.534.1.1.2.0', // Power status
|
||||
BATTERY_CAPACITY: '1.3.6.1.4.1.534.1.2.4.0', // Battery capacity in percentage
|
||||
BATTERY_RUNTIME: '1.3.6.1.4.1.534.1.2.1.0', // Remaining runtime in minutes
|
||||
POWER_STATUS: '1.3.6.1.4.1.534.1.4.4.0', // xupsOutputSource (3=normal/mains, 5=battery)
|
||||
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)
|
||||
},
|
||||
|
||||
// TrippLite OIDs
|
||||
|
Loading…
x
Reference in New Issue
Block a user