UPS on macOS Sierra 10.12 with snmp problem

I’m using Smart-UPS RT 10000 XL on my network and wanted to use it also with my iMac runing macOS Sierra 10.12. An AP9619 card enables user to monitor UPS status with SNMP. For that purpose I installed apcupsd package using Homebrew:

brew install apcupsd

Configuration file is located at:

/usr/local/etc/apcupsd/apcupsd.conf

and there was a need to change some things:

UPSCABLE smart
UPSTYPE snmp
DEVICE 192.168.1.13:161:APC:public

Everything seemed to work, but after some time I noticed that power failure didn’t shut down my iMac.
I noticed that after reboot status check

/usr/local/Cellar/apcupsd/3.14.14/sbin/apcaccess status

resulted in something like that:

APC      : 001,018,0459
DATE     : 2018-02-03 13:27:16 +0100  
HOSTNAME : My-iMac.local
VERSION  : 3.14.14 (31 May 2016) darwin
UPSNAME  : My-iMac.local
CABLE    : Ethernet Link
DRIVER   : SNMP UPS Driver
UPSMODE  : Stand Alone
STARTTIME: 2018-02-03 13:08:14 +0100  
STATUS   : 
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
NUMXFERS : 0
TONBATT  : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
STATFLAG : 0x05000000
END APC  : 2018-02-03 13:27:44 +0100

I seemed that UPS was not visible. After restarting service

sudo sudo launchctl stop org.apcupsd.apcupsd
sudo sudo launchctl start org.apcupsd.apcupsd

everything was going back to normal:

APC      : 001,046,1075
DATE     : 2018-02-03 13:45:42 +0100  
HOSTNAME : My-iMac.local
VERSION  : 3.14.14 (31 May 2016) darwin
UPSNAME  : UPS
CABLE    : Ethernet Link
DRIVER   : SNMP UPS Driver
UPSMODE  : Stand Alone
STARTTIME: 2018-02-03 13:45:39 +0100  
MODEL    : Smart-UPS RT 10000 XL
STATUS   : ONLINE 
LINEV    : 243.0 Volts
LOADPCT  : 15.0 Percent
BCHARGE  : 100.0 Percent
TIMELEFT : 114.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
MAXLINEV : 243.0 Volts
MINLINEV : 236.0 Volts
OUTPUTV  : 229.0 Volts
SENSE    : Unknown
DWAKE    : 0 Seconds
DSHUTD   : 20 Seconds
DLOWBATT : 2 Minutes
LOTRANS  : 196.0 Volts
HITRANS  : 253.0 Volts
RETPCT   : 0.0 Percent
ITEMP    : 25.0 C
ALARMDEL : 5 Seconds
BATTV    : 218.0 Volts
LINEFREQ : 49.0 Hz
LASTXFER : Unacceptable line voltage changes
NUMXFERS : 0
TONBATT  : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
SELFTEST : OK
STESTI   : 336
STATFLAG : 0x05000008
MANDATE  : 07/11/07
SERIALNO : IS000000000
BATTDATE : 07/11/07
NOMOUTV  : 230 Volts
EXTBATTS : 2
FIRMWARE : 476.17.W
END APC  : 2018-02-03 13:45:45 +0100 

After some debugging I realized that daemon is started before network was ready (don’t know if it is a brew package problem or my configuration is specific).
Turned out that apcupsd wasn’t able to use network connection initialized after it’s start. My solution is not very elegant, but fully satisfying – addition of some delay

/bin/sleep  180

in the second line of

/usr/local/Cellar/apcupsd/3.14.14/sbin/apcupsd-start

was sufficient.

Leave a Reply

Your email address will not be published. Required fields are marked *