0.2.4 • Published 10 years ago

apc-ups-snmp v0.2.4

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

APC UPS SNMP

Library for reading values of APC UPS battery via the network.

Installation

npm install apc-ups-snmp

Usage

var apcUps = require('apc-ups-snmp');

var ups = new apcUps({
  host: '' // IP Address/Hostname
});

A full range of examples can be found within the examples directory

Methods

Note that in the web GUI a number of values are reported with 1-2 decimal places. The SNMP implementation by APC does not support decimals.

getModel(callback)

Get the UPS Model number, eg 'Smart-UPS 2200 RM'

Arguments

  • callback(err, model) - Callback function for error/response handling

Example

ups.getModel(function(err, model) {{
  if (err) {
    console.log(err);
    return;
  }

  console.log('The UPS model is:', model);
});

getTemperature(callback)

Get the internal temperature of the UPS.

Arguments

  • callback(err, temperature) - Callback function for error/response handling

Example

ups.getTemperature(function(err, temperature) {
  if (err) {
    console.log(err);
    return;
  }

  console.log('The current temperature is:', temp, 'C');
});

getInputVoltage(callback)

Get the input voltage.

Arguments

  • callback(err, voltage) - Callback function for error/response handling

Example

ups.getInputVoltage(function(err, voltage) {
  if (err) {
    console.log(err);
    return;
  }

  console.log('The current input voltage is:', voltage, 'VAC');
});

getInputFrequency(callback)

Get the input frequency.

Arguments

  • callback(err, hz) - Callback function for error/response handling

Example

ups.getInputFrequency(function(err, hz) {
  if (err) {
    console.log(err);
    return;
  }

  console.log('The current input frequency is:', hz, 'Hz');
});

getOutputVoltage(callback)

Get the output voltage.

Arguments

  • callback(err, voltage) - Callback function for error/response handling

Example

ups.getOutputVoltage(function(err, voltage) {
  if (err) {
    console.log(err);
    return;
  }

  console.log('The current output voltage is:', voltage, 'VAC');
});

getOutputFrequency(callback)

Get the output frequency.

Arguments

  • callback(err, hz) - Callback function for error/response handling

Example

ups.getOutputFrequency(function(err, hz) {
  if (err) {
    console.log(err);
    return;
  }

  console.log('The current output frequency is:', hz, 'Hz');
});

getOutputLoadPercentage(callback)

Get the output load percentage.

Arguments

  • callback(err, percentage) - Callback function for error/response handling

Example

ups.getOutputLoadPercentage(function(err, percentage) {
  if (err) {
    console.log(err);
    return;
  }

  console.log('The current load is:', percentage, '%');
});

getOutputLoad(callback)

Get the output in amps.

Arguments

  • callback(err, amps) - Callback function for error/response handling

Example

ups.getOutputLoad(function(err, amps) {
  if (err) {
    console.log(err);
    return;
  }

  console.log('The current load is:', amps, 'amps');
});

getBatteryCapacity(callback)

Get the battery capacity percentage.

Arguments

  • callback(err, percentage) - Callback function for error/response handling

Example

ups.getBatteryCapacity(function(err, percentage) {
  if (err) {
    console.log(err);
    return;
  }

  console.log('The current battery capacity is:', percentage, '%');
});

getBatteryStatus(callback)

Get the battery status.

Arguments

  • callback(err, status) - Callback function for error/response handling, see the table below for translated statuses.
StatusTranslation
1unknown
2batteryNormal
3batteryLow
4batteryInFaultCondition

The translated key is available within the library using ups.batteryStatus[#], as shown in the example below.

Example

ups.getBatteryStatus(function(err, status) {
  if (err) {
    console.log(err);
    return;
  }

  console.log('The current battery status is', ups.batteryStatus[status], '(', status, ')');
});

getBatteryRunTime(callback)

Get the battery runtime remaining in minutes.

Arguments

  • callback(err, percentage) - Callback function for error/response handling

Example

ups.getBatteryRunTime(function(err, minutes) {
  if (err) {
    console.log(err);
    return;
  }

  console.log('Expected battery run time is', minutes, 'minutes');
});

getLastFailCause(callback)

Get the reason for last transfer to battery power.

Arguments

  • callback(err, failCause) - Callback function for error/response handling, see the table below for translated causes.

Fail CauseTranslation
1noTransfer
2highLineVoltage
3brownout
4blackout
5smallMomentarySag
6deepMomentarySag
7smallMomentarySpike
8largeMomentarySpike
9selfTest
10rateOfVoltageChange

The translated key is available within the library using ups.failCause[#], as shown in the example below.

ups.getLastFailCause(function(err, failCause) {
  if (err) {
    console.log(err);
    return;
  }

  console.log('The last reason for transfer to battery power is,', apcUps.failCause[failCause], '(', failCause, ')');
});

getBatteryReplaceIndicator(callback)

Get the battery replacement indicator.

Arguments

  • callback(err, failCause) - Callback function for error/response handling, see the table below for translated indicators.
IndicatorTranslation
1noBatteryNeedsReplacing
2batteryNeedsReplacing

The translated key is available within the library using ups.batteryIndicator[#], as shown in the example below.

ups.getBatteryReplaceIndicator(function(err, indicator) {
  if (err) {
    console.log(err);
    return;
  }

  console.log('Battery replace indicator is', apcUps.batteryIndicator[indicator], '(', indicator, ')');
});

getLastDiagnosticsTestDate(callback)

Get date self diagnostics was last run.

Note the date will be formatted as mm/dd/yy.

Arguments

  • callback(err, date) - Callback function for error/response handling

Example

ups.getLastDiagnosticsTestDate(function(err, date) {
  if (err) {
    console.log(err);
    return;
  }

  console.log('The last diagnostics test was performed on', date, '(mm/dd/yy)');
});

getLastDiagnosticsTestResult(callback)

Get the last self diagnostics result.

Arguments

  • callback(err, result) - Callback function for error/response handling, see the table below for translated results.
ResultTranslation
1ok
2failed
3invalidTest
4testInProgress

The translated key is available within the library using ups.testResult[#], as shown in the example below.

Example

ups.getLastDiagnosticsTestResult(function(err, result) {
  if (err) {
    console.log(err);
    return;
  }

  console.log('The last diagnostics test result was', apcUps.testResult[result], '(', result, ')');
});

Notes

Have only implemented a few basic values to begin with, have plans for a few more just need to find some time to add these in.

All the MIBs have been hard coded into this module, for more details see the PowerNet-MIB at ftp://ftp.apc.com/apc/public/software/pnetmib/mib/411/powernet411.mib

Licence

The MIT License (MIT)

0.2.4

10 years ago

0.2.2

10 years ago

0.1.0

10 years ago

0.0.1

10 years ago