nupst/ts/snmp/types.ts
2025-03-25 09:06:23 +00:00

90 lines
2.2 KiB
TypeScript

/**
* Type definitions for SNMP module
*/
/**
* UPS status interface
*/
export interface UpsStatus {
/** Current power status */
powerStatus: 'online' | 'onBattery' | 'unknown';
/** Battery capacity percentage */
batteryCapacity: number;
/** Remaining runtime in minutes */
batteryRuntime: number;
/** Raw values from SNMP responses */
raw: Record<string, any>;
}
/**
* SNMP OID Sets for different UPS brands
*/
export interface OIDSet {
/** OID for power status */
POWER_STATUS: string;
/** OID for battery capacity */
BATTERY_CAPACITY: string;
/** OID for battery runtime */
BATTERY_RUNTIME: string;
}
/**
* Supported UPS model types
*/
export type UpsModel = 'cyberpower' | 'apc' | 'eaton' | 'tripplite' | 'liebert' | 'custom';
/**
* SNMP Configuration interface
*/
export interface SnmpConfig {
/** SNMP server host */
host: string;
/** SNMP server port (default 161) */
port: number;
/** SNMP version (1, 2, or 3) */
version: number;
/** Timeout in milliseconds */
timeout: number;
// SNMPv1/v2c
/** Community string for SNMPv1/v2c */
community?: string;
// SNMPv3
/** Security level for SNMPv3 */
securityLevel?: 'noAuthNoPriv' | 'authNoPriv' | 'authPriv';
/** Username for SNMPv3 authentication */
username?: string;
/** Authentication protocol for SNMPv3 */
authProtocol?: 'MD5' | 'SHA';
/** Authentication key for SNMPv3 */
authKey?: string;
/** Privacy protocol for SNMPv3 */
privProtocol?: 'DES' | 'AES';
/** Privacy key for SNMPv3 */
privKey?: string;
// UPS model and custom OIDs
/** UPS model for OID selection */
upsModel?: UpsModel;
/** Custom OIDs when using custom UPS model */
customOIDs?: OIDSet;
}
/**
* SNMPv3 security parameters
*/
export interface SnmpV3SecurityParams {
/** Engine ID for the SNMP server */
msgAuthoritativeEngineID: Buffer;
/** Engine boots counter */
msgAuthoritativeEngineBoots: number;
/** Engine time counter */
msgAuthoritativeEngineTime: number;
/** Username for authentication */
msgUserName: string;
/** Authentication parameters */
msgAuthenticationParameters: Buffer;
/** Privacy parameters */
msgPrivacyParameters: Buffer;
}