npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

apc-ups-snmp

v0.2.4

Published

Library for reading values of APC UPS battery via the network

Downloads

8

Readme

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)