Giter VIP home page Giter VIP logo

apcupsd's Introduction

apcupsd Test Status GoDoc Report Card

Package apcupsd provides a client for the apcupsd Network Information Server (NIS). MIT Licensed.

apcupsd's People

Contributors

fire833 avatar jonaz avatar maxxant avatar mdlayher avatar rschaeuble avatar supporterino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

apcupsd's Issues

apcupsd: determine if short dates are day-first or month-first

It would appear that the UPS can report dates such as January 2, 2006 as 1/2/2006 or 2/1/2006, and we have no way of determining which is correct at the moment. Perhaps it's a good idea to suggest some configuration setting, or perhaps there's a way to always work this out based on other information in the request.

failed collecting UPS metrics: invalid time duration

After install exporter and activate him, problem with time. In log:
apcupsd-exporter[31009]: 2021/11/18 15:34:21 failed collecting UPS metrics: invalid time duration

rpm -qa | grep apc
apcupsd-3.14.14-18.el7.x86_64

part of result command apcaccess status
BATTDATE : 11/14/2019
NOMOUTV : 230 Volts
FIRMWARE : UPS 10.1 (ID20)
END APC : 2021-11-18 15:51:01 +0300

XOFFBATT may have value "N/A", causing parsing to fail

I have just realized (unfortunately before submitting merge request #1) that the fields XONBATT and XOFFBAT are not always set to a date value. If no transfers to or from battery have happened since apcupsd started, the fields have the value "N/A".
In this case, parsing the value as date fails, causing the whole call to client.Status to fail.

I see two possible ways to fix this:

  • Handle the special case of "N/A" by returning nil from status.parseKVTime.
  • Let status.parseKVTime fail, but changeclient.Status to continue the loop even if one parse method fails (but log a warning message so the error isn't completely swallowed).

I think I'd prefer the second variant. Currently one single problematic value leads to no status being returned at all. I think it might be better to just have the one unparseable field set to nil but still get all the other values that could be parsed.

@mdlayher I'll gladly implement the fix and submit a new merge request, but I'd like to hear your preference first.

ALARMDEL can't be parsed as a time.Duration

Hello,

Currently in status.go, we have this bit of code, which parses the ALARMDEL value:

case keyAlarmDel:
		// No alarm delay configured.
		if v == "No alarm" {
			break
		}

s.AlarmDel, err = parse()

this accounts for the ALARMDEL having a value of "No alarm". Otherwise, it parses it as a time.Duration. However, this won't always work because there are two other possible non-duration values, per the apcupsd library's source (apcstatus.c):

case 'T':
         s_write(ups, "ALARMDEL : 30 Seconds\n");
         break;
      case 'L':
         s_write(ups, "ALARMDEL : Low Battery\n");
         break;
      case 'N':
         s_write(ups, "ALARMDEL : No alarm\n");
         break;
      case '0':
         s_write(ups, "ALARMDEL : 5 Seconds\n");
         break;
      default:
         s_write(ups, "ALARMDEL : Always\n");
         break;
      }

So, the two that aren't handled currently are 'Always' and 'Low Battery', with 'Always' meaning that alarms should sound immediately and continuously upon power fail, and 'Low Battery' meaning that the alarm should sound only after power fails and battery becomes low. (source).

So I guess 'Always' could be converted to just a '0' duration, but 'Low Battery' is unclear. So it seems like we'd either need to change the status.AlarmDel value to a string, or would have to come up with some duration number for 'Low Battery'?

Let me know what makes sense and I could test it out and make a PR. This is currently causing errors in a Telegraf plugin (influxdata/telegraf#8521).

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.