HeinleinSupport / check_mk_extensions

check_mk Plugins
https://www.heinlein-consulting.de/
GNU General Public License v2.0
233 stars 107 forks source link

Unkown UPS / no data #79

Closed dnlldl closed 3 years ago

dnlldl commented 3 years ago

Hello, First thing first, thanks for working on this plugin.

I'm having an issue with my UPS being detected as "Unkown UPS / no data". There is a typo in "unknown", and something isn't parsed correctly in the output for me:

<<<apcaccess:sep(58)>>> [[apcupsd.conf]] APC : 001,032,0752 DATE : 2021-03-18 21:27:02 -0400 HOSTNAME : server VERSION : 3.14.14 (31 May 2016) slackware UPSNAME : server CABLE : USB Cable DRIVER : USB UPS Driver UPSMODE : Stand Alone STARTTIME: 2021-03-14 04:40:04 -0400 MODEL : CP1500PFCLCD STATUS : ONLINE LINEV : 114.0 Volts LOADPCT : 12.0 Percent BCHARGE : 100.0 Percent TIMELEFT : 68.5 Minutes MBATTCHG : 20 Percent MINTIMEL : 20 Minutes MAXTIME : 0 Seconds OUTPUTV : 114.0 Volts DWAKE : -1 Seconds LOTRANS : 88.0 Volts HITRANS : 139.0 Volts ALARMDEL : No alarm NUMXFERS : 0 TONBATT : 0 Seconds CUMONBATT: 0 Seconds XOFFBATT : N/A SELFTEST : NO STATFLAG : 0x05000008 SERIALNO : 000000000000 NOMINV : 120 Volts NOMPOWER : 900 Watts END APC : 2021-03-18 21:27:03 -0400

Anothing thing I could suggest as an improvement would be to name the service with the UPS model or some sort of ID, since I'm not sure this would work well with multiple UPS hooked up to the same host in Checkmk.

dnlldl commented 3 years ago

I don't have the firmware parameter so quick fix for me is just to remove that last data.get

          yield Result(state=State.OK,
                     summary=", ".join([data['UPSNAME'],
                                        data.get('MODEL'),
                                        data.get('SERIALNO'),
                                        data.get('FIRMWARE')]))

I would suggest something a little bit more robust when parameters are missing. I don't think the SERIALNO is very relevant in my specific case either with my Cyberpower UPS.

dnlldl commented 3 years ago

I ended up with this:

     if 'MODEL' in data:
        yield Result(state=State.OK,summary=data.get('MODEL'))
    else:
        yield Result(state=State.UNKNOWN, summary='Unkown UPS / no data')

I'm not overly familiar with how Checkmk plugins work, I would like to change the service name from "APC apcupsd.conf Status" to "UPS CP1500PFCLCD Status". Not sure how I can make %s be the UPS MODEL, will do some more testings tomorrow.

gurubert commented 3 years ago

I'm not overly familiar with how Checkmk plugins work, I would like to change the service name from "APC apcupsd.conf Status" to "UPS CP1500PFCLCD Status". Not sure how I can make %s be the UPS MODEL, will do some more testings tomorrow.

This will not work as this needs to be a unique name. You could have two of the same models attached to a host. That's why the check uses the configuration file name.

dnlldl commented 3 years ago

I'm not overly familiar with how Checkmk plugins work, I would like to change the service name from "APC apcupsd.conf Status" to "UPS CP1500PFCLCD Status". Not sure how I can make %s be the UPS MODEL, will do some more testings tomorrow.

This will not work as this needs to be a unique name. You could have two of the same models attached to a host. That's why the check uses the configuration file name.

Granted, the serial number or something else could help here maybe. For my specific case however that would work, if you could point me in the right direction maybe.

gurubert commented 3 years ago

I will work on a change that will introduce a discovery ruleset. This will allow you to choose what will be used in the service description.

gurubert commented 3 years ago

Fixed by commit a7dcde105d392ef57090e86d241c2047887f6ac9

dnlldl commented 3 years ago

I just tested it, it works. Possibility to add a second setting to use the MODEL rather than the UPSNAME as the service name? UPSNAME isn't set on mine and it's USB so it just shows up as the HOSTNAME instead. Having the option to remove APC from the service name would be great as well (mine is from a different brand completely even though we access it with the APC daemon). Other than that, great work!