GithubHelp home page GithubHelp logo

jaffarc / apc-ups-snmp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from phillipsnick/apc-ups-snmp

0.0 1.0 0.0 12 KB

Library for reading values of APC UPS battery via the network

License: MIT License

JavaScript 100.00%

apc-ups-snmp's Introduction

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.
Status Translation
1 unknown
2 batteryNormal
3 batteryLow
4 batteryInFaultCondition

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 Cause Translation
1 noTransfer
2 highLineVoltage
3 brownout
4 blackout
5 smallMomentarySag
6 deepMomentarySag
7 smallMomentarySpike
8 largeMomentarySpike
9 selfTest
10 rateOfVoltageChange

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.
Indicator Translation
1 noBatteryNeedsReplacing
2 batteryNeedsReplacing

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.
Result Translation
1 ok
2 failed
3 invalidTest
4 testInProgress

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.