viral32111 / apc-ups-exporter

Prometheus exporter for APC UPS status data.
http://www.apcupsd.org/manual
GNU Affero General Public License v3.0
7 stars 1 forks source link

BATTDATE parse error #30

Open johnkozan opened 3 months ago

johnkozan commented 3 months ago

When I run apc-ups-exporter I get the following error.

The configured Network Information Server is: 127.0.0.1:3551.

Resetting all metrics...
Starting background metrics collection...
Serving metrics page at http://127.0.0.1:5000/metrics...

Connected to the Network Information Server.
parsing time "09/15/2023" as "2006-01-02": cannot parse "09/15/2023" as "2006"

apcupsd is connected to the UPS (SmartUPS X 3000) via SNMP.

apcaccess output:

APC      : 001,043,0996
DATE     : 2024-08-23 00:36:23 +0000
HOSTNAME : apcups
VERSION  : 3.14.14 (31 May 2016) debian
UPSNAME  : ups0
CABLE    : Ethernet Link
DRIVER   : SNMP UPS Driver
UPSMODE  : Stand Alone
STARTTIME: 2024-08-23 00:20:50 +0000
MODEL    : Smart-UPS X 3000
STATUS   : ONLINE
LINEV    : 119.0 Volts
LOADPCT  : 46.0 Percent
BCHARGE  : 100.0 Percent
TIMELEFT : 16.0 Minutes
MBATTCHG : 0 Percent
MINTIMEL : 0 Minutes
MAXTIME  : 0 Seconds
MAXLINEV : 123.0 Volts
MINLINEV : 118.0 Volts
OUTPUTV  : 120.0 Volts
SENSE    : High
DLOWBATT : 2 Minutes
LOTRANS  : 106.0 Volts
HITRANS  : 127.0 Volts
ITEMP    : 33.0 C
ALARMDEL : 30 Seconds
BATTV    : 135.0 Volts
LINEFREQ : 60.0 Hz
LASTXFER : No transfers since turnon
NUMXFERS : 0
TONBATT  : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
SELFTEST : NG
STESTI   : OFF
STATFLAG : 0x05000008
MANDATE  : 11/24/2018
SERIALNO : ...
BATTDATE : 09/15/2023
NOMOUTV  : 120 Volts
EXTBATTS : 0
FIRMWARE : UPS 07.4 (ID1003)
END APC  : 2024-08-23 00:36:40 +0000
viral32111 commented 3 months ago

I'll add support for parsing both date formats, thanks.

viral32111 commented 3 months ago

@johnkozan Would you be able to test the latest release? I've fixed this bug, and tried to add support for the additional metrics reported by your SmartUPS X 3000. I don't own this UPS myself, so I'm unable to test.

johnkozan commented 3 months ago

I'm getting this error now:

The configured Network Information Server is: 127.0.0.1:3551.

Resetting all metrics...
Starting background metrics collection...
Serving metrics page at http://127.0.0.1:5000/metrics...

Connected to the Network Information Server.
strconv.ParseFloat: parsing "OFF": invalid syntax
viral32111 commented 3 months ago

Heya, I've fixed this by incorporating more robust parsing of fields expected to be numeric. Values such as OFF, No alarm, NO, etc. will now be discarded and fallback to a default (-1 in most cases).

Would you be able to test the latest release to see if it works for you now?

Sorry about this being a bit back and forth.