mdlayher / apcupsd

Package apcupsd provides a client for the apcupsd Network Information Server (NIS). MIT Licensed.
MIT License
45 stars 22 forks source link

MANDATE can be a different date format #6

Closed MariusSchiffer closed 5 years ago

MariusSchiffer commented 5 years ago

Apparently MANDATE can also be in a 03/06/09 format in addition to the normal Y-M-D format.

Example in the documentation: http://www.apcupsd.org/manual/manual.html#apcupsd-network-monitoring-cgi-programs

The prometheus exporter fails on my system with this error: parsing time "03/06/09" as "2006-01-02": cannot parse "6/09" as "2006" with a MANDATE of 03/06/09.

mdlayher commented 5 years ago

Of course it can, ha. To clarify, does "03/06/09" mean March 6th, 2009?

MariusSchiffer commented 5 years ago

Exactly, M/D/Y. MANDATE seems to be equal to the date on the quality assurance test document.

mdlayher commented 5 years ago

It's been a long time since I looked at this code, but it appears it doesn't parse MANDATE at all. Can you show the output of apcaccess and the logs from the exporter?

maxxant commented 5 years ago

status examples for two various UPS:

in first UPS: MANDATE : 2005-02-15 BATTDATE : 2001-09-25

in second: MANDATE : 07/31/99 BATTDATE : 07/31/99

and i have dirty fix for BATDATE in my GH fork: https://github.com/maxxant/apcupsd/commit/16f68f9400514fd62b4ce47eda18851fe1f81493

but for full coverage we needs fix all cases, which presents in apcupsd (that your can see in https://github.com/maxxant/apcupsd-status-examples)

mdlayher commented 5 years ago

That's a super useful repo for me, thanks! Want to open a pull request for your change? I have a couple small nits but we can work them out.

mdlayher commented 5 years ago

BATTDATE parsing should be fixed as of now, and we don't parse MANDATE at the moment. But now we can whenever needed.

toby11 commented 4 years ago

I have another example with a different format BATTDATE

BATTDATE : 12/28/2013

full apcaccess output here

APC : 001,044,1024 DATE : 2019-11-16 18:04:54 +0000 HOSTNAME : pve VERSION : 3.14.14 (31 May 2016) debian UPSNAME : APCUPS CABLE : Ethernet Link DRIVER : SNMP UPS Driver UPSMODE : Stand Alone STARTTIME: 2019-11-16 17:48:50 +0000 MODEL : Smart-UPS 750 STATUS : ONLINE LINEV : 230.0 Volts LOADPCT : 44.0 Percent BCHARGE : 100.0 Percent TIMELEFT : 23.0 Minutes MBATTCHG : 5 Percent MINTIMEL : 3 Minutes MAXTIME : 0 Seconds MAXLINEV : 237.0 Volts MINLINEV : 230.0 Volts OUTPUTV : 230.0 Volts SENSE : High DWAKE : 1000 Seconds DSHUTD : 20 Seconds DLOWBATT : 2 Minutes LOTRANS : 207.0 Volts HITRANS : 253.0 Volts ITEMP : 21.0 C ALARMDEL : 30 Seconds BATTV : 27.0 Volts LINEFREQ : 50.0 Hz LASTXFER : Line voltage notch or spike NUMXFERS : 0 TONBATT : 0 Seconds CUMONBATT: 0 Seconds XOFFBATT : N/A SELFTEST : OK STESTI : OFF STATFLAG : 0x05000008 MANDATE : 12/28/2013 SERIALNO : AS1352131956 BATTDATE : 12/28/2013 NOMOUTV : 230 Volts FIRMWARE : UPS 08.8 (ID18) END APC : 2019-11-16 18:04:58 +0000

netstx commented 4 years ago

I am still having this issue where BATTDATE can't be parsed. Telegraf version 1.14.3 (git: HEAD 1b35d6c2). apcupsd version 3.14.14 (31 May 2016) freebsd

APCUPSD output: ... MANDATE : 04/04/2014 BATTDATE : 02/15/2018 ...

Any suggestions?

mdlayher commented 4 years ago

I don't use telegraf, please file an issue there. This problem is resolved here.

netstx commented 4 years ago

Ok, will do. Thanks!