APC PDU SNMP Control
Module for providing basic management of APC PDUs. Such as turning outlets on and off, the current power state and total power draw for the PDU.
Installation
npm install apc-pdu-snmp
Usage
Currently the only option which is supported is host
when creating the object.
var apcPdu = ; var pdu = host: '' // IP Address/Hostname community: 'private' // Optional community;
A full range of examples can be found within the examples directory.
Method
getTotalOutlets(callback)
Get the total number of outlets on the PDU.
Arguments
callback(err, totalOutlets)
- Callback function for error/response handling
Example
pdu;
getOutletName(outletNumber, callback)
Get an outlet name as configured on the PDU.
Arguments
outletNumber
- Integer of the outlet number to get the name forcallback(err, name)
- Callback function for error/response handling
Example
Get the name out outlet 1.
pdu;
getOutletNames(callback)
Get all outlet names as configured on the PDU.
Arguments
callback(err, names)
- Callback function for error/response handling
Example
pdu;
The names variable will contain an object, keys as the outlet number and the value being the outlet name eg.
{
'1': 'Outlet 1',
'2': 'Outlet 2',
'3': 'Outlet 3'
}
getOutletPowerState(outletNumber, callback)
Get the power state of an outlet.
State variable will return either:
- 0 - off
- 1 - on
Arguments
outletNumber
- Integer of the outlet number to get the power state forcallback(err, state)
- Callback function for error/response handling
Example
Get the power state for outlet 1.
pdu;
getPowerDraw(callback)
Get the power draw of the whole PDU in amps.
Arguments
callback(err, amps)
- Callback function for error/response handling
Example
pdu;
getLowLoadThreshold(callback)
Get the configured low load warning threshold in amps.
Arguments
callback(err, amps)
- Callback function for error/response handling
Example
pdu;
getNearLoadThreshold(callback)
Get the configured near load warning threshold in amps.
Arguments
callback(err, amps)
- Callback function for error/response handling
Example
pdu;
getOverloadThreshold(callback)
Get the configured overload alarm threshold in amps.
Arguments
callback(err, amps)
- Callback function for error/response handling
Example
pdu;
getLoadState(callback)
Get the current load state.
Arguments
callback(err, state)
- Callback function for error/response handling. Thestate
variable will contain an integer as per the table below.
State | Translation |
---|---|
1 | bankLoadNormal |
2 | bankLoadLow |
3 | bankLoadNearOverload |
4 | bankLoadOverload |
The translated key is available within the library using apcPdu.loadState
, as shown in the example below.
Example
pdu;
setPowerState(outletNumber, state, callback)
Turn an outlet on/off.
Arguments
outletNumber
- Outlet as an integerstate
- Boolean, true is on, false is off. Alternatively a number, 3 is reboot.callback(err)
- Callback for error/success handling
Example
Turn outlet 1 on.
pdu;
The state variable should be a boolean or number. If a boolean, use true to turn an outlet on and false to turn and outlet off. If a number, use a raw sPDUOutletCtl code:
- outletOn: 1
- outletOff: 2
- outletReboot: 3
- outletUnknown: 4
- outletOnWithDelay: 5
- outletOffWithDelay: 6
- outletRebootWithDelay: 7
Notes
Hopefully will have some time in the future to improve the features and add some tests as using the examples for testing is pretty bad :)
All the MIBs have been hard coded into this module, for more details see the PowerNet-MIB ftp://ftp.apc.com/apc/public/software/pnetmib/mib/411/powernet411.mib
Acknowledgements
Wouldn't have been able to build this without this great article on SNMP for APC PDUs by Joshua Tobin SNMP Tutorial – APC PDUs