Page 9 of 10

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

Re: APCUPSD Plugin discussion

PostPosted: Mon Oct 14, 2019 6:40 am
by DaveL17
There is a 64-bit build of the apcupsd daemon now available on Sourceforge. The build was done by Adam K. from the project team.
https://sourceforge.net/projects/apcupsd/files/Testing/apcupsd-3.14.14-macos-x86_64/Apcupsd-3.14.14.dmg/download

Disclaimer! This build just dropped last night, and I have not tried it. Note "Testing" in the target URL.

All the usual warnings apply.

Re: APCUPSD Plugin discussion

PostPosted: Mon Oct 14, 2019 7:17 am
by durosity
Nice.. although that build still doesn’t seem to install on my test system. ¯\_(ツ)_/ ill report it back

Re: APCUPSD Plugin discussion

PostPosted: Sun Oct 20, 2019 4:25 pm
by DaveL17
Seems others were having some trouble, too. New build posted:

Here's a version that installs the kext in /Library/Extensions instead of /System/Library/Extensions:

https://sourceforge.net/projects/apcupsd/files/Testing/apcupsd-3.14.14-macos-x86_64-2/Apcupsd-3.14.14.dmg/download


Re: APCUPSD Plugin discussion

PostPosted: Tue Oct 22, 2019 5:47 am
by DaveL17
It looks like a valid 64-bit version of APCUPSD has been built. The package is still posted to the testing environment so your mileage may vary. Several users have posted success with this one.

https://sourceforge.net/projects/apcupsd/files/Testing/apcupsd-3.14.14-macos-x86_64-3/Apcupsd-3.14.14.dmg/download

For those that are curious, with Catalina, it seems that Apple changed the security for a couple of the locations that were used in the past to store package files including `/usr/share` and `/System/Library/Extensions`. It sounds like this new build uses `/usr/local/share` and `/Library/Extensions`

Re: APCUPSD Plugin discussion

PostPosted: Tue Oct 22, 2019 3:39 pm
by durosity
Interesting.. I can now get it installed and it works for exactly a second after startup then loses comms.... ¯\_(ツ)_/¯. I'm guessing that something else running on the system is conflicting with it but that'll be fun to work out,

Re: APCUPSD Plugin discussion

PostPosted: Tue Oct 22, 2019 4:19 pm
by DaveL17
Run apcaccess from the terminal. It could be that the plugin will need to be updated for the new version of apcupsd.

That’s just a guess though.


Sent from my iPhone using Tapatalk Pro

Re: APCUPSD Plugin discussion

PostPosted: Tue Oct 22, 2019 7:26 pm
by MartyS
DaveL17 wrote:
Run apcaccess from the terminal. It could be that the plugin will need to be updated for the new version of apcupsd.

That’s just a guess though.

Since some components got moved to different writable locations for Catalina, the apcaccess utility may have moved as well—in which case I'll be more than happy to update the plugin to check yet another location.

But if it's apcupsd that is dying then yes, there's more debugging to be done outside of the plugin. Do check for the presence of the lock and PID files... one or both might already exist and if so it will have an older PID associated with them. Remove them and try reloading the LaunchDaemon via org.apcupsd.apcupsd.plist. The default names of the files to look for are:

Code: Select all
/var/run/apcupsd.pid
/var/tmp/LCK..

Re: APCUPSD Plugin discussion

PostPosted: Tue Oct 22, 2019 8:01 pm
by DaveL17
Thanks for that. I have yet to put Catalina into production, so I'm grasping at straws here. :D

Re: APCUPSD Plugin discussion

PostPosted: Sun Nov 24, 2019 7:22 pm
by durosity
Kinda off topic (me? never!) but I'm struggling with configuring apcupsd to monitor two separate UPSes. I can get it working absolutely fine with either one separately (both through network cards rather than USB) but trying to amend the instructions for linux to macOS is proving more than I can handle. I've got as far as having the two separate config files but when searching for the init.d apcupsd file to get it to read the two seperate configs I'm coming up empty handed. Debian instructions here https://wiki.debian.org/apcupsd#Configu ... evices.29.. closest I could find to a solution and I'm sure I used this when I got it working back a few years ago but my mind isn't what it was back then.. I'm struggling to do even basic things these days ¯\_(ツ)_/¯ Got any ideas?