APCUPSD Plugin discussion

Posted on
Tue Oct 30, 2018 7:34 pm
DaveL17 offline
User avatar
Posts: 6741
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: 86
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: 6741
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: 86
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: 6741
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: 6741
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.
EDIT: The log could be located at /var/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.)
EDIT: The lock file could be located at /private/var//tmp/LCK..
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...
Last edited by DaveL17 on Wed Jul 15, 2020 6:55 pm, edited 3 times in total.

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

[My Plugins] - [My Forums]

Posted on
Mon Oct 14, 2019 6:40 am
DaveL17 offline
User avatar
Posts: 6741
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: APCUPSD Plugin discussion

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.

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

[My Plugins] - [My Forums]

Posted on
Mon Oct 14, 2019 7:17 am
durosity offline
User avatar
Posts: 4320
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: APCUPSD Plugin discussion

Nice.. although that build still doesn’t seem to install on my test system. ¯\_(ツ)_/ ill report it back

Computer says no.

Posted on
Sun Oct 20, 2019 4:25 pm
DaveL17 offline
User avatar
Posts: 6741
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: APCUPSD Plugin discussion

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


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

[My Plugins] - [My Forums]

Posted on
Tue Oct 22, 2019 5:47 am
DaveL17 offline
User avatar
Posts: 6741
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: APCUPSD Plugin discussion

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`

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

[My Plugins] - [My Forums]

Posted on
Tue Oct 22, 2019 3:39 pm
durosity offline
User avatar
Posts: 4320
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: APCUPSD Plugin discussion

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,

Computer says no.

Posted on
Tue Oct 22, 2019 4:19 pm
DaveL17 offline
User avatar
Posts: 6741
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: APCUPSD Plugin discussion

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

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

[My Plugins] - [My Forums]

Posted on
Tue Oct 22, 2019 7:26 pm
MartyS offline
Posts: 86
Joined: May 06, 2008
Location: Charlotte, North Carolina

Re: APCUPSD Plugin discussion

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

/Marty

Posted on
Tue Oct 22, 2019 8:01 pm
DaveL17 offline
User avatar
Posts: 6741
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: APCUPSD Plugin discussion

Thanks for that. I have yet to put Catalina into production, so I'm grasping at straws here. :D

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

[My Plugins] - [My Forums]

Posted on
Sun Nov 24, 2019 7:22 pm
durosity offline
User avatar
Posts: 4320
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: APCUPSD Plugin discussion

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?

Computer says no.

Who is online

Users browsing this forum: No registered users and 4 guests

cron