[SOLVED] apcupsd - is there a way to get a UPSes status?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336
Rep:
apcupsd - is there a way to get a UPSes status?
Is there a way with apcupsd to get current ups status? Like battery percentage left, that kind of thing? I've been struggling trying to get it to work with an old UPS, and after it just made the UPS shut off (causing the server to go down) I decided to just try with my UPS upstairs instead (just wired the management through my patch panel for now). I got it going to the point where it detects a power outage, but is there not a way I can query the status to get more info?
I have it setup to eventually shut down but it would be nice to get status such as how long I have before it does so, and so on.
There's a GUI utility that I downloaded but it just says connection refused.
I know it's running, because if I unplug the UPS I do get a power failure notice.
Another thing, how do I change the shutdown sequence? The documentation says to edit apccontrol but it's very vague as to what you have to do. I tried a bunch of things, no luck. It just calls shutdown, I want to call my own script as I need to do a graceful shutdown of VMs.
Have a look in /etc/apcupsd/apcupsd.conf (it may be in a different location on your box). The following settings should be all that is needed:
Code:
NETSERVER on
NISPORT 3551
As far as the shutdown script goes, I run Slackware and the apcupsd installer modified the system shutdown script to include the /etc/apcupsd/apccontrol killpower command. The man page for apccontrol says not to modify apccontrol, but instead:
Code:
The recommended way to customise an event action is simply to create an
executable program or script file with the same name as the event and put
that file in the /etc/apcupsd directory. Now, when the selected event occurs,
apccontrol will execute your program or script.
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336
Original Poster
Rep:
Yep the server command is on. Basically I have pretty much everything set as default.
For the custom shutdown I also tried creating a file as the doc says but it still wont call it. It's like if any of the changes I'm making arn't actually taking effect. I do restart the service each time as well.
Basically, you can create your own script for a specific case i.e. powercut, killpower, onbattery etc. If your script exists it will be called first when apccontrol executes.
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336
Original Poster
Rep:
Hmm maybe my problem is I need to create a file for all of the possible causes of a shutdown, not just the doshutdown command. I will try that and see if that helps.
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336
Original Poster
Rep:
Ok so it turns out that's what it is, I need to have a script for each command, not just doshutdown. Guess it makes sense eh. It works now. I don't really care about the status part anymore though it would be nice. I figured this would be harder to troubleshoot and the status would have helped troubleshoot, but I got it working and that's what counts.
When the system needs to shut down for any reason the same script gets called and all my VMs are turned off and given a grace period of 3 minutes then the system itself is shut down. Should give enough time.
Moved the UPS to the server room and it's all setup now. Was having too much trouble with the existing UPS there, so I swapped with my workstation.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.