mdlayher / apcupsd_exporter

Prometheus exporter that exposes metrics from apcupsd's NIS. MIT Licensed.
MIT License
156 stars 65 forks source link

Certain dates reported by UPS cause an error #14

Closed Fanman03 closed 2 years ago

Fanman03 commented 3 years ago

My APC Back-UPS 550 ES reports the following when I run apcaccess

https://i.imgur.com/fE9q8WJ.png

As you can see, the battery date is reported as 1980-00-00. Because this is not a valid date, it causes issues when apcupsd_exporter tries to parse it. The following error is shown when I open http://localhost:9162/metrics in the browser

An error has occurred:

error collecting metric Desc{fqName: "apcupsd_battery_volts", help: "Current UPS battery voltage.", constLabels: {}, variableLabels: [hostname ups_name model]}: parsing time "1980-00-00": month out of range

Any help to allow me to retrieve data from my UPS would be much appreciated. Thank you!

HaleyACS commented 3 years ago

Second this. Similar issue here with:

error collecting metric Desc{fqName: "apcupsd_battery_volts", help: "Current UPS battery voltage.", constLabels: {}, variableLabels: [hostname ups_name model]}: time: invalid duration Noalarm

apcaccess returns:

APC      : 001,036,0882
DATE     : 2021-08-27 09:45:19 +0200  
HOSTNAME : server.solsys.org
VERSION  : 3.14.14 (31 May 2016) debian
UPSNAME  : BR1500GI
CABLE    : USB Cable
DRIVER   : USB UPS Driver
UPSMODE  : ShareUPS Master
STARTTIME: 2021-08-26 15:30:54 +0200  
MODEL    : Back-UPS BR1500GI 
STATUS   : ONLINE 
LINEV    : 240.0 Volts
LOADPCT  : 3.0 Percent
BCHARGE  : 100.0 Percent
TIMELEFT : 156.2 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
SENSE    : Medium
LOTRANS  : 176.0 Volts
HITRANS  : 294.0 Volts
ALARMDEL : No alarm
BATTV    : 27.3 Volts
LASTXFER : No transfers since turnon
NUMXFERS : 0
TONBATT  : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
SELFTEST : NO
STATFLAG : 0x05000008
SERIALNO : 3B1142X12083  
BATTDATE : 2020-03-13
NOMINV   : 230 Volts
NOMBATTV : 24.0 Volts
NOMPOWER : 865 Watts
FIRMWARE : 878.L3 .I USB FW:L3
END APC  : 2021-08-27 09:46:04 +0200
mdlayher commented 2 years ago

Should be fixed now hopefully. apcupsd makes this difficult by sending everything as human-readable strings instead of regular numbers.