APCUPSD Plugin discussion

Posted on
Tue Oct 30, 2018 7:47 am
MartyS offline
Posts: 69
Joined: May 06, 2008
Location: Charlotte, North Carolina

Re: APCUPSD Plugin discussion

For some reason, apcaccess cannot be executed and that's very likely the same reason that the apcupsd daemon isn't loaded (it wasn't listed in the `ps` output, just the monitoring agent). Why /usr/local/sbin wouldn't be found in your PATH for executables I have no idea—unless it's a new Mojave "thing."

You could try this command:
Code: Select all
/usr/local/sbin/apcaccess
to see what happens.

Before spending too much effort on this, please reinstall the OS X kit from http://apcupsd.org and see if by any chance that makes it work. It's a quick download and install.

/Marty

Posted on
Tue Oct 30, 2018 7:34 pm
DaveL17 offline
User avatar
Posts: 4337
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: APCUPSD Plugin discussion

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

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Oct 30, 2018 7:51 pm
MartyS offline
Posts: 69
Joined: May 06, 2008
Location: Charlotte, North Carolina

Re: APCUPSD Plugin discussion

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.

/Marty

Posted on
Tue Oct 30, 2018 8:24 pm
DaveL17 offline
User avatar
Posts: 4337
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: APCUPSD Plugin discussion

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

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Oct 30, 2018 8:34 pm
MartyS offline
Posts: 69
Joined: May 06, 2008
Location: Charlotte, North Carolina

Re: APCUPSD Plugin discussion

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

/Marty

Posted on
Tue Oct 30, 2018 8:48 pm
DaveL17 offline
User avatar
Posts: 4337
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: APCUPSD Plugin discussion

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

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed Nov 21, 2018 8:15 am
DaveL17 offline
User avatar
Posts: 4337
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: APCUPSD Plugin discussion

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...

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Who is online

Users browsing this forum: No registered users and 0 guests