PeterB

APCUPSD plugin adapted for v6, 64 bit!

98 posts in this topic

Okay, I seem to have a working apcupsd on a V6.0beta1 test-bed.

 

Edit: The plugin has been updated to -2pb incorporating dlandon's v2 powerdown package.

Further Edit: The plugin has been updated to -3pb, incorporating Tom's recommendation for removing the 'timezone' log message.

 

I have included a little patch for the powerdown package, which eliminates a 'double' shutdown in many circumstances.  This was causing powerdown to take much longer than necessary, and creating two logfiles on the flash drive.

 

Edit: This has been fixed in the powerdown v2.0 release, so my patch is no longer required, and has been removed.

 

I have tested the ability to perform a powerdown - set the max time to 10 seconds (using an ethernet connection to apcupsd running on my live server) and pulled the mains from the UPS.  The test machine shut down cleanly:

 

Jan 24 10:09:36 Tower64 apcupsd[3473]: Power failure.
Jan 24 10:09:42 Tower64 apcupsd[3473]: Running on UPS batteries.
Jan 24 10:09:53 Tower64 apcupsd[3473]: Reached run time limit on batteries.
Jan 24 10:09:53 Tower64 apcupsd[3473]: Initiating system shutdown!
Jan 24 10:09:53 Tower64 apcupsd[3473]: User logins prohibited
Jan 24 10:09:53 Tower64 logger: Powerdown initiated
Jan 24 10:09:53 Tower64 logger: Initiating Shutdown with 
Jan 24 10:09:53 Tower64 shutdown[3542]: shutting down for system halt
Jan 24 10:09:53 Tower64 init: Switching to runlevel: 0
Jan 24 10:09:54 Tower64 rc.unRAID[3553]: Stopping unRAID.
Jan 24 10:09:54 Tower64 version[3554]: Linux version 3.10.24p-unRAID (root@develop64) (gcc version 4.8.2 (GCC) ) #7 SMP Mon Jan 20 11:43:35 PST 2014

 

... and I restored power before the main server went off.

 

The only (minor) problem I have with the plugin is that it appears to fail the download of the apcupsd package when automatically installing at boot time.  However, it installs cleanly when using the installplg command from console.  If anyone can find out why this happens, I'll be interested to hear!

 

Edit: This would appear to be an issue that can only be fixed cleanly in unRAID itself.  While it is possible to work around the problem, each plugin author would have to incorporate the workaround code.  In the meanwhile, if the apcupsd plugin fails to complete installation, the installplg command should be invoked manually, as described in a post further down this thread.

Apcupsd-3.14.10-x86_64_3pb.plg.txt

0

Share this post


Link to post
Share on other sites

The only (minor) problem I have with the plugin is that it appears to fail the download of the apcupsd package when automatically installing at boot time.  However, it installs cleanly when using the installplg command from console.  If anyone can find out why this happens, I'll be interested to hear!

 

I'm not a Linux guy, so I'm not sure how to do this, but I suspect the issue is simply that you need to make the install script wait until UnRAID has finished loading before it attempts the install.  I think it's trying to install before you have an internet connection to download the package.    Hopefully somebody will chime in with the fix  (I don't think it's very difficult).

 

0

Share this post


Link to post
Share on other sites

The only (minor) problem I have with the plugin is that it appears to fail the download of the apcupsd package when automatically installing at boot time.  However, it installs cleanly when using the installplg command from console.  If anyone can find out why this happens, I'll be interested to hear!

 

I'm not a Linux guy, so I'm not sure how to do this, but I suspect the issue is simply that you need to make the install script wait until UnRAID has finished loading before it attempts the install.  I think it's trying to install before you have an internet connection to download the package.    Hopefully somebody will chime in with the fix  (I don't think it's very difficult).

 

But is this something that each plugin author should have to deal with?  I would value Tom's take on this - I think that it might be better if unRAID didn't start running entries from the /boot/config/plugins folder until the network is fully up and working.

 

In any case, a .plg file is simply xml - I'm not sure that it would be so easy for the .plg file to delay its own execution.

0

Share this post


Link to post
Share on other sites

Okay, I seem to have a working apcupsd on a V6.0beta1 test-bed.

 

The only (minor) problem I have with the plugin is that it appears to fail the download of the apcupsd package when automatically installing at boot time.  However, it installs cleanly when using the installplg command from console.  If anyone can find out why this happens, I'll be interested to hear!

 

PeterB, I really appreciate your efforts in getting this ready to use so quickly. 

 

One thing I think you should post is the command to manually install the new package.  (I think I know what it is but I am not completely sure so I would rather have someone who has done it provide the instructions!) 

 

Frank

0

Share this post


Link to post
Share on other sites
One thing I think you should post is the command to manually install the new package.  (I think I know what it is but I am not completely sure so I would rather have someone who has done it provide the instructions!) 

 

Fair comment.  Obviously, general use of the installplg command has been covered by Tom, but I can give a specific for apcupsd.

 

The Apcupsd-3.14.10-x86_64_pab.plg file (you have to delete the .txt extension, that is only used to trick this forum into allowing the file to be given as an attachment) should be copied to the config/plugins folder of your flash drive (can be done by physically connecting the drive to another machine, or to the network share with unRAID running).

 

Then, log into the unRAID console, or telnet/ssh, whichever you're familiar with, and set your default directory to the plugins folder:

 cd /boot/config/plugins

 

Then use the installplg command:

installplg Apcupsd-3.14.10-x86_64_pab.plg

 

Apcupsd should now be permanently installed on your boot drive, and should reload every time the system boots up.

 

Now go to the emhttp web interface, 'Settings' tab.  APC UPS Daemon should appear with a large green battery image.  Click on that to enter the apcupsd settings page.

 

There are several combinations of possible settings but, for most people, they will have a 'Smart' model ups, connected directly to their unRAID server via usb.

 

For this scenario, the settings should be:

UPS Cable: Smart
UPS Type: usb
Device: 'blank'

 

The other settings dictate when the computer will be instructed to shut down, and will depend on your exact configuration/preferences (my settings in brackets):

Battery Level:  Shutdown when the remaining battery charge falls to this percentage. (10)

or:

Minutes:  Shutdown when the estimated remaining run time on battery falls to this number of minutes (5)

or:

Timeout:  Shutdown when the system has been running on battery for this many seconds (300)

 

Normally you will want to set Kill UPS: to 'Yes'.  This forces the UPS to turn off after the computer has shut down.

I like to see full status, so have Show Full Status set to 'Yes'.

 

Finally, ensure that 'Enable APC UPS Daemon' is set to 'Yes' and then click the 'Apply' or 'Done' button.

 

This should make your UPS fully active.  If you want to change settings, you have to set 'Enable ...' to 'No', make the changes and set 'Enable ...' to 'Yes' again.

 

I hope that these brief guidelines are helpful.

0

Share this post


Link to post
Share on other sites

Thank you for the detailed instructions, this is exactly what I was looking for.

0

Share this post


Link to post
Share on other sites

There have been issues with apcupsd weekly log rotation and a constant unRAID log refresh.  These have been addressed here: http://lime-technology.com/forum/index.php?topic=29605.0 for unRAID v 5.0.

 

I have incorporated your 64 bit apcupsd into the attached plugin that fixed these log problems and I have added network ready logic so the plugin will not try 'wget' until the network is ready.  This fixed the plugin installation on a boot.  I cannot take credit for this logic.  I got it from the lms plugin that overbyrn wrote.

 

Feel free to incorporate these changes as you see fit in your plugin in the first post.  Feel free to take the attached plugin and rename it to your version.

 

I am working on SNAP to get it running on v6.0 (it is working), but I'm having a problem with apcupsd shutting down after a drive has been  mounted with SNAP.  unRAID hangs and won't shut down.  When I force a shutdown (reset button) I get a corrupted file on the USB stick.  Kinda ugly.  I don't know whether it is SNAP or apcupsd causing the problem.  I'll continue to work on it to find out what is hanging up on shutdown.  I may have additional fixes for apcupsd based on what I find.

Apcupsd-3.14.10-x86_64_rlw-dl.plg.txt

0

Share this post


Link to post
Share on other sites

There have been issues with apcupsd weekly log rotation and a constant unRAID log refresh.  These have been addressed here: http://lime-technology.com/forum/index.php?topic=29605.0 for unRAID v 5.0.

 

Thanks for your input.  Yes, I am well aware of the log file rotation problem, for which I produced a fixed plugin in April last year.  However, Zoggy/Riot's fix is much cleaner than mine and I have already included that in my 64-bit plugin.

 

I will look more closely at the log file refresh problem (which hasn't affected me for many months), and consider incorporating your fix.

 

I have incorporated your 64 bit apcupsd ino the attached plugin that fixed these log problems and I have added network ready logic so the plugin will not try 'wget' until the network is ready.  This fixed the plugin installation on a boot.  I cannot take credit for this logic.  I got it from the lms plugin that overbyrn wrote.

 

Thank you for pointing me at that.  However, I really do think that it is up to Tom to address this issue, rather than every plugin author having to include this logic.  For this reason, I do not agree with adding it into the realeased plugin.

 

Feel free to incorporate these changes as you see fit in your plugin in the first post.  Feel free to take the attached plugin and rename it to your version.

 

Thanks for that.

 

I am working on SNAP to get it running on v6.0 (it is working), but I'm having a problem with apcupsd shutting down after a drive has been  mounted with SNAP.  unRAID hangs and won't shut down.  When I force a shutdown (reset button) I get a corrupted file on the USB stick.  Kinda ugly.  I don't know whether it is SNAP or apcupsd causing the problem.  I'll continue to work on it to find out what is hanging up on shutdown.  I may have additional fixes for apcupsd based on what I find.

 

Without more information, it is diffcult to judge.  However, I think that it is much more likely that the problem lies with the powerdown package (on which apcupsd relies), rather than apcupsd itself.

 

You are aware that there are situations with which powerdown does not cope?  For instance, if you have a console/telnet session in which the default directory is set to an array disk, then the array will not stop.  Similarly, open files on array disks, via network shares, can cause the shutdown process to hang.

0

Share this post


Link to post
Share on other sites
Thank you for pointing me at that.  However, I really do think that it is up to Tom to address this issue, rather than every plugin author having to include this logic.  For this reason, I do not agree with adding it into the realeased plugin.

 

Tom addressing the issue would be the cleanest solution.

 

I am working on SNAP to get it running on v6.0 (it is working), but I'm having a problem with apcupsd shutting down after a drive has been  mounted with SNAP.  unRAID hangs and won't shut down.  When I force a shutdown (reset button) I get a corrupted file on the USB stick.  Kinda ugly.  I don't know whether it is SNAP or apcupsd causing the problem.  I'll continue to work on it to find out what is hanging up on shutdown.  I may have additional fixes for apcupsd based on what I find.

 

Without more information, it is diffcult to judge.  However, I think that it is much more likely that the problem lies with the powerdown package (on which apcupsd relies), rather than apcupsd itself.

 

You are aware that there are situations which powerdown does not cope?  For instance, if you have a console/telnet session in which the default directory is set to an array disk (even cache), then the array will not stop.  Similarly, files on array disks, via network shares, can cause the shutdown process to hang.

 

After some testing I agree with you that it is the powerdown package.  Without it being installed I have no problems with SNAP.  Not much I can do about that.

0

Share this post


Link to post
Share on other sites

I just tested the new apcupsd with ver 6.0 beta1.  I was going to shut the server down to load a drive to test the preclear_disk script so I decided to do it by pulling the plug.  (Thus killing two birds with one stone.)

 

Everything worked great.  I have the timeout set at 30 seconds and it seemed to take forever to that period to elapse.  ;)   

 

On reboot, everything came up normal.

0

Share this post


Link to post
Share on other sites

New release attached to first post, incorporating dlandon's powerdown v2.

0

Share this post


Link to post
Share on other sites

If using the Dynamix webui do we need to comment out the lines that install the powerdown script? Powerdown script is now installed as part of the dynamix webui; or am I missing something?

 

Kryspy

0

Share this post


Link to post
Share on other sites

If using the Dynamix webui do we need to comment out the lines that install the powerdown script? Powerdown script is now installed as part of the dynamix webui; or am I missing something?

 

Kryspy

 

No. If both are the same version there is no harm.  If apcupsd is the older version of Powerdown, it will overwrite the one installed by Dynamix because Dynamix loads first.

 

The last one there wins.

 

Take a look at your log and you'll see the Powerdown package load messages and the version.

0

Share this post


Link to post
Share on other sites

Thank you for pointing me at that.  However, I really do think that it is up to Tom to address this issue, rather than every plugin author having to include this logic.  For this reason, I do not agree with adding it into the realeased plugin.

 

Tom addressing the issue would be the cleanest solution.

 

 

What issue?  I think you're talking about a condition where 'installplg' is being called to install plugins at boot time, but the network is not up at that time... But, why does the network need to be up?  That is, when the plugin is initially installed, at that time it downloads all the necessary files required for the plugin and stores them on the flash device; hence, upon next boot 'installplg' should see that all the files are still there and not need to download anything and hence, not need the network up.

 

Am I missing something, or is there something else I need to address?

0

Share this post


Link to post
Share on other sites

I would presume for someone who does not use installplg to actually install the plugin and reboots instead. (I was this type of user for a long time).

 

Thank you for pointing me at that.  However, I really do think that it is up to Tom to address this issue, rather than every plugin author having to include this logic.  For this reason, I do not agree with adding it into the realeased plugin.

 

Tom addressing the issue would be the cleanest solution.

 

 

What issue?  I think you're talking about a condition where 'installplg' is being called to install plugins at boot time, but the network is not up at that time... But, why does the network need to be up?  That is, when the plugin is initially installed, at that time it downloads all the necessary files required for the plugin and stores them on the flash device; hence, upon next boot 'installplg' should see that all the files are still there and not need to download anything and hence, not need the network up.

 

Am I missing something, or is there something else I need to address?

0

Share this post


Link to post
Share on other sites

I would presume for someone who does not use installplg to actually install the plugin and reboots instead. (I was this type of user for a long time).

 

Indeed - many people expect to be able to copy the .plg file to the /boot/config/plugins folder and then simply reboot to install the plugin.

 

I refer you to your post: here.

0

Share this post


Link to post
Share on other sites

I would presume for someone who does not use installplg to actually install the plugin and reboots instead. (I was this type of user for a long time).

 

Indeed - many people expect to be able to copy the .plg file to the /boot/config/plugins folder and then simply reboot to install the plugin.

 

I refer you to your post: here.

 

Right, ok, that's what I thought.  The upcoming plugin manager handles this differently by calling 'installplg' when a user selects a plugin to install, eliminating the need to reboot in order to install a plugin.

0

Share this post


Link to post
Share on other sites

Thanks PeterB! Test tonight worked as expected with VMs, along with dlandon update to powerdown.

0

Share this post


Link to post
Share on other sites

Thank you for providing and maintaining this plugin! I've been noticing this warning message in my syslog lately and when I installed the plugin I saw it again so I'd thought I'd ask about it......

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /usr/local/emhttp/plugins/apcupsd/apcupsdctl.php on line 81

success

My assumption the warning comes from the apcupsd slackware package and it doesn't seem to be a real problem. Any ideas?

0

Share this post


Link to post
Share on other sites
My assumption the warning comes from the apcupsd slackware package and it doesn't seem to be a real problem. Any ideas?

 

It's actually a change in PHP which gives rise to this message, which is complaining that the system timezone hasn't been reflected into the PHP configuration.

 

What I'm still trying to find out is how the PHP code associated with the apcupsd plugin can discover the current system timezone setting.  When I have that information I will be very happy to add the appropriate timezone setting function in the PHP.

 

Whether it's a real problem, or not, I'm not absolutely certain - I suspect that time fields from the UPS status are being incorrectly reported (unless your timezone happens to be UTC).

0

Share this post


Link to post
Share on other sites

I have add time zone code, and the messages is gone, do not have the code right now, can look at this when I'm home

 

 

Sent from my iPhone using Tapatalk 2

0

Share this post


Link to post
Share on other sites

I don't think it's critical since I think the date command is only called to put a time and date in the log.  I just inserted my timezone in the two spots it was called. But if you got the code to insert the timezone that's even better.

0

Share this post


Link to post
Share on other sites
I just inserted my timezone in the two spots it was called. But if you got the code to insert the timezone that's even better.

Of course - I wouldn't dream of releasing with my timezone hard-coded.

0

Share this post


Link to post
Share on other sites

I have add time zone code, and the messages is gone, do not have the code right now, can look at this when I'm home

 

Great!  If you know how to determine the timezone set in the web interface configuration, that will be most useful.

0

Share this post


Link to post
Share on other sites

I think this should do it. I don't get an error anymore. To change the php.ini would require a little more effort.

<FILE Name="/usr/local/emhttp/plugins/apcupsd/apcupsdctl.php">
<INLINE>
<![CDATA[
<?PHP
  $logfile = "/var/log/plugins/apcupsd";
  $configfile = "/boot/config/plugins/apcupsd/apcupsd.cfg";
  $ident_cfg = parse_ini_file( "/boot/config/ident.cfg");
  $timeZone = $ident_cfg["timeZone"];
  $apcupsd_installing = file_exists( "/tmp/apcupsd-install") ? "yes" : "no";
  date_default_timezone_set($timeZone);

0

Share this post


Link to post
Share on other sites

Copyright © 2005-2017 Lime Technology, Inc. unRAID® is a registered trademark of Lime Technology, Inc.