Page 9 of 9

Re: APCUPSD Plugin discussion

PostPosted: Tue Oct 30, 2018 7:34 pm
by DaveL17
MartyS wrote:
You could try this command:
Code: Select all
/usr/local/sbin/apcaccess
to see what happens.


Code: Select all
Error contacting apcupsd @ localhost:3551: Connection refused

Now to try the reinstall option... :D

Re: APCUPSD Plugin discussion

PostPosted: Tue Oct 30, 2018 7:51 pm
by MartyS
Code: Select all
Error contacting apcupsd @ localhost:3551: Connection refused
That's exactly what I'd expect to see when the daemon isn't running.

The Indigo plugin will be able to find the apcaccess tool even though your PATH isn't setup for Terminal to find it. But without the daemon running, apcaccess won't be able to get any status from the UPS and nothing will get passed to the plugin.

Hopefully your reinstall will correct this daemon issue.

Re: APCUPSD Plugin discussion

PostPosted: Tue Oct 30, 2018 8:24 pm
by DaveL17
Success. It was either of two things.

1. I noticed in the docs that if the reinstall was on top of an old one, then apcupsd.conf would be retained and a new file (apcupsd.conf.new) would be created. After a couple of failed reinstall attempts, I deleted apcupsd.conf and renamed apcupsd.conf.new to apcupsd.conf.
2. This iMac has been booting a little slowly for a while now and, instead of entering user credentials immediately after rebooting, I poured myself a libation and then logged in. This may have given the daemon enough time to spool up before the user account tried to connect to it.

Regardless, looks like I'm in business. Thanks for the help.

Now to work on the slow boot issue... :D :D

Re: APCUPSD Plugin discussion

PostPosted: Tue Oct 30, 2018 8:34 pm
by MartyS
DaveL17 wrote:
Success. It was either of two things.

1. I noticed in the docs that if the reinstall was on top of an old one, then apcupsd.conf would be retained and a new file (apcupsd.conf.new) would be created. After a couple of failed reinstall attempts, I deleted apcupsd.conf and renamed apcupsd.conf.new to apcupsd.conf.
2. This iMac has been booting a little slowly for a while now and, instead of entering user credentials immediately after rebooting, I poured myself a libation and then logged in. This may have given the daemon enough time to spool up before the user account tried to connect to it.

Regardless, looks like I'm in business. Thanks for the help.

Now to work on the slow boot issue... :D :D

It's certainly likely that anything "wrong" with apcupsd.conf would prevent the daemon from starting... leading to nothing else in the software chain working. The daemon is started via a LaunchDaemon file (/Library/LaunchDaemons/org.apcupsd.apcupsd.plist) completely independent from any user logging in. Maybe the iMac just wanted you happy, and noticed you get the libation and things worked out better for you. :P

Re: APCUPSD Plugin discussion

PostPosted: Tue Oct 30, 2018 8:48 pm
by DaveL17
I wish I knew for sure what it was, but in case it was the libation, I'll note that for future troubleshooting!

Cheers,
Dave

Re: APCUPSD Plugin discussion

PostPosted: Wed Nov 21, 2018 8:15 am
by DaveL17
So it seems that I spoke too soon. I once again lost the ability to launch the apcupsd daemon. A little more research yielded the following results. Take these steps at your own risk.

My first clue was the apcupsd events log, which is located at /etc/log/apcupsd.events.
Code: Select all
cat apcupsd.events

Result:
Code: Select all
2018-11-21 06:58:23 -0600  Valid lock file for pid=118, but not ours pid=115
2018-11-21 06:58:23 -0600  apcupsd FATAL ERROR in apcupsd.c at line 221
Unable to create UPS lock file.
  If apcupsd or apctest is already running,
  please stop it and run this program again.
2018-11-21 06:58:23 -0600  Valid lock file for pid=118, but not ours pid=115
2018-11-21 06:58:23 -0600  apcupsd error shutdown completed

The important bit is the lock file mismatch. The lock file itself is located at /private/var/tmp/Lock.. (note that the two dots at the end are part of the filename.)
Code: Select all
cat Lock..

Result:
Code: Select all
0000000118^@

Change the lock file entry to the valid lock PID.
Code: Select all
sudo nano LCK..

Enter password. Using cursor and delete keys, replace the 8 with a 5.
Code: Select all
0000000115^@

control O to write out.
control X to exit.
Reboot.

apcupsd starts normally.
Code: Select all
2018-11-21 07:50:03 -0600  apcupsd 3.14.14 (31 May 2016) darwin startup succeeded

If you find you have this error, it's likely that the numbers in the above example will not always be the same. Again, there is some risk to mucking things up with this patch, but I think the risk is pretty low. Regardless, no warranty expressed or implied...