nordika Posted January 25, 2014 Share Posted January 25, 2014 Another question (I am really a newbie on this...) I have also installed apcupsd on my iMac. It is running well. I can see its status but... how can I see if it is running as slave on the iMac? Can't figure this out. Any help? Regards Anyone??? Thanks Quote Link to comment
trurl Posted January 25, 2014 Share Posted January 25, 2014 Another question (I am really a newbie on this...) I have also installed apcupsd on my iMac. It is running well. I can see its status but... how can I see if it is running as slave on the iMac? Can't figure this out. Any help? Regards Anyone??? Thanks Not sure I understand your question. I don't have iMac but I do have a Windows PC and my unRAID server both on a single UPS and both are running APCUPSD. The UPS interface cable (USB) is plugged into my unRAID, and my PC is getting the UPS status over the network from my unRAID. So, my PC is the slave. Is this what you are talking about? Quote Link to comment
nordika Posted January 25, 2014 Share Posted January 25, 2014 @trurl That is exactly how I have it but with a mac and not a pc. My doubt is how do I configure the time the mac will take to shutdown in case of a power failure? Because I want it to shutdown before my unRAID. Quote Link to comment
trurl Posted January 25, 2014 Share Posted January 25, 2014 @trurl That is exactly how I have it but with a mac and not a pc. My doubt is how do I configure the time the mac will take to shutdown in case of a power failure? Because I want it to shutdown before my unRAID. On my PC I had to manually edit apcupsd.conf. Quote Link to comment
nordika Posted January 25, 2014 Share Posted January 25, 2014 @trurl That is exactly how I have it but with a mac and not a pc. My doubt is how do I configure the time the mac will take to shutdown in case of a power failure? Because I want it to shutdown before my unRAID. On my PC I had to manually edit apcupsd.conf. Thanks Trurl, I will look up for that file on the mac. You cannot supply me with your apcupsd.conf for my guidance? Thanks Quote Link to comment
trurl Posted January 25, 2014 Share Posted January 25, 2014 @trurl That is exactly how I have it but with a mac and not a pc. My doubt is how do I configure the time the mac will take to shutdown in case of a power failure? Because I want it to shutdown before my unRAID. Just take a look at the file. It is well documented with comments. On my PC I had to manually edit apcupsd.conf. Thanks Trurl, I will look up for that file on the mac. You cannot supply me with your apcupsd.conf for my guidance? Thanks Quote Link to comment
nordika Posted January 25, 2014 Share Posted January 25, 2014 @trurl That is exactly how I have it but with a mac and not a pc. My doubt is how do I configure the time the mac will take to shutdown in case of a power failure? Because I want it to shutdown before my unRAID. Just take a look at the file. It is well documented with comments. On my PC I had to manually edit apcupsd.conf. Thanks Trurl, I will look up for that file on the mac. You cannot supply me with your apcupsd.conf for my guidance? Thanks Thanks trurl. Quote Link to comment
arcane Posted January 28, 2014 Share Posted January 28, 2014 I've been using the unMenu apcupsd package for a while with no problems. I'm having some trouble getting this plugin to work as the Daemon and Status are always Stopped and Offline. Tried a manual install and a reboot install but neither worked. Strangely enough, if I re-install the 3.14.8 version in unMenu, then the stats pop up. I also tried starting the service manually in /etc/rc.d/rc.apcupsd start and it says "Starting apcupsd power management.. Done." but when I stop the service, it doesn't appear it ever stopped as it reports: "Stopping apcupsd power management.. Nothing to stop." Any assistance would be appreciated. Thanks! Quote Link to comment
acurcione Posted March 30, 2014 Share Posted March 30, 2014 I had installed the APCUPSD daemon via unMenu initially, but have now got it being installed via the plugin. I see it in the Dynamix GUI and can get status and all that, but the GUI (Dynamix) doesn't actually allow me to change the configuration. It just doesn't allow me to edit anything. Why? Failing that I would just modify the config file, but for the life of me I can't figure out where I can do that and it NOT be overwritten. Can someone help me out here on either of these? One last thing, I've attached my syslog for someone to have a look at to make sure everything is working the way it's supposed to. I can see the plugin getting installed, but then it's doing or did something with an old version of the powerdown script. I have no idea if this is normal or not. Thanks in advance. syslog-20140330-115414.txt Quote Link to comment
acurcione Posted March 30, 2014 Share Posted March 30, 2014 I had installed the APCUPSD daemon via unMenu initially, but have now got it being installed via the plugin. I see it in the Dynamix GUI and can get status and all that, but the GUI (Dynamix) doesn't actually allow me to change the configuration. It just doesn't allow me to edit anything. Why? Failing that I would just modify the config file, but for the life of me I can't figure out where I can do that and it NOT be overwritten. Can someone help me out here on either of these? One last thing, I've attached my syslog for someone to have a look at to make sure everything is working the way it's supposed to. I can see the plugin getting installed, but then it's doing or did something with an old version of the powerdown script. I have no idea if this is normal or not. Thanks in advance. Not sure why I had to do it this way, but I managed to get the settings changed by editing /boot/config/plugins/apcupsd.cfg, refreshing the GUI page, and hitting apply. Now I only hope these settings actually stick on reboot. Still would like to know why I can't update the settings via the GUI though. Quote Link to comment
trurl Posted March 30, 2014 Share Posted March 30, 2014 I had installed the APCUPSD daemon via unMenu initially, but have now got it being installed via the plugin. I see it in the Dynamix GUI and can get status and all that, but the GUI (Dynamix) doesn't actually allow me to change the configuration. It just doesn't allow me to edit anything. Why? Failing that I would just modify the config file, but for the life of me I can't figure out where I can do that and it NOT be overwritten. Can someone help me out here on either of these? One last thing, I've attached my syslog for someone to have a look at to make sure everything is working the way it's supposed to. I can see the plugin getting installed, but then it's doing or did something with an old version of the powerdown script. I have no idea if this is normal or not. Thanks in advance. Not sure why I had to do it this way, but I managed to get the settings changed by editing /boot/config/plugins/apcupsd.cfg, refreshing the GUI page, and hitting apply. Now I only hope these settings actually stick on reboot. Still would like to know why I can't update the settings via the GUI though. I think you have to Enable the plugin before it will let you edit its settings. Quote Link to comment
acurcione Posted March 30, 2014 Share Posted March 30, 2014 I had installed the APCUPSD daemon via unMenu initially, but have now got it being installed via the plugin. I see it in the Dynamix GUI and can get status and all that, but the GUI (Dynamix) doesn't actually allow me to change the configuration. It just doesn't allow me to edit anything. Why? Failing that I would just modify the config file, but for the life of me I can't figure out where I can do that and it NOT be overwritten. Can someone help me out here on either of these? One last thing, I've attached my syslog for someone to have a look at to make sure everything is working the way it's supposed to. I can see the plugin getting installed, but then it's doing or did something with an old version of the powerdown script. I have no idea if this is normal or not. Thanks in advance. Not sure why I had to do it this way, but I managed to get the settings changed by editing /boot/config/plugins/apcupsd.cfg, refreshing the GUI page, and hitting apply. Now I only hope these settings actually stick on reboot. Still would like to know why I can't update the settings via the GUI though. I think you have to Enable the plugin before it will let you edit its settings. That's the first thing I did so it's enabled and says its online. Still can't change the settings from the GUI though. Sent from my iPad using Tapatalk Quote Link to comment
acurcione Posted March 30, 2014 Share Posted March 30, 2014 I had installed the APCUPSD daemon via unMenu initially, but have now got it being installed via the plugin. I see it in the Dynamix GUI and can get status and all that, but the GUI (Dynamix) doesn't actually allow me to change the configuration. It just doesn't allow me to edit anything. Why? Failing that I would just modify the config file, but for the life of me I can't figure out where I can do that and it NOT be overwritten. Can someone help me out here on either of these? One last thing, I've attached my syslog for someone to have a look at to make sure everything is working the way it's supposed to. I can see the plugin getting installed, but then it's doing or did something with an old version of the powerdown script. I have no idea if this is normal or not. Thanks in advance. Not sure why I had to do it this way, but I managed to get the settings changed by editing /boot/config/plugins/apcupsd.cfg, refreshing the GUI page, and hitting apply. Now I only hope these settings actually stick on reboot. Still would like to know why I can't update the settings via the GUI though. I think you have to Enable the plugin before it will let you edit its settings. Actually, it was the exact opposite. I disabled it and then was able to change the settings. I was thinking it had to be the other way around. Sent from my iPad using Tapatalk Quote Link to comment
Nezil Posted April 1, 2014 Share Posted April 1, 2014 I've been looking at the code of the updated 64-bit plugin for unRAID 6.0, and comparing it to the 32-bit unRAID 5.0.5 plugin discussed on this thread. The version of the plugin on the unRAID wiki was previously updated in July 2013, and since that time, there have been some pretty significant changes that really need to be made to this plugin. The changes between the up to date 64-bit version and this 32-bit version don't appear to be huge, and they are nicely documented by PeterB in the file itself. It should therefore be very easy to update the 32-bit plugin to match, and that is exactly what I've done. As some of you may be aware, I've been finding and fixing bugs in the APC UPS that I have (see thread here: http://lime-technology.com/forum/index.php?topic=32651.0), and in order to make the apcupsd plugin work with my system, I'd already modified it to remove the /sbin/poweroff line in /etc/rc.d/rc.6 so that my system was powered off by the UPS killing power, rather than the system itself. The idea behind this is so that the unRAID server will power back on itself once power is restored. Some motherboards have a setting to automatically power up after a loss in power, but mine only has the option for 'last state', so this modification was essential for me. Having said that, I was frustrated that when I manually shut down my server, I could never really tell if it had truly shut down, because my changes had affected every type of shutdown, even normal manual shut downs left the server fans still spinning. I took a look at the standard /etc/rc.d/rc.6 shutdown & reboot code, which by default looks like this: # Now halt (poweroff with APM or ACPI enabled kernels) or reboot. if [ "$command" = "reboot" ]; then echo "Rebooting." /sbin/reboot else /sbin/poweroff fi And with the default installation of apcupsd, is modified to look like this (assuming the configuration is set to Kill UPS) # Now halt (poweroff with APM or ACPI enabled kernels) or reboot. if [ "$command" = "reboot" ]; then echo "Rebooting." /sbin/reboot else /etc/apcupsd/apccontrol killpower; /sbin/poweroff fi As I said, my initial modification was simply to remove the /sbin/poweroff command from the end of the line, but I noticed that in every power down situation, apccontrol killpower is being called; even for a regular shutdown! As a test, I called apccontrol killpower and noticed that it fails with an error, noticing that the /etc/apcupsd/powerfail file is not present. It's good that the apcupsd software has the intelligence to look for this, but we should not be calling the killpower command if this is not a power fail shutdown event. A better modification to the /etc/rc.d/rc.6 file, would be this: # Now halt (poweroff with APM or ACPI enabled kernels) or reboot. if [ "$command" = "reboot" ]; then echo "Rebooting." /sbin/reboot else if [ -f /etc/apcupsd/powerfail ]; then /etc/apcupsd/apccontrol killpower else /sbin/poweroff fi fi This file check is actually what is recommended in the apcupsd documentation. As a nice aside, it also means that my unRAID system will properly power off when I shut it down manually. And so, to modify the plugin script... Quote Link to comment
Nezil Posted April 1, 2014 Share Posted April 1, 2014 Looking in the plugin script, the sections that I changed are from the function applyconfig() section of apcupsdconf.php In the code below, I have commented out the original commands, with my replacements immediately following: function applyconfig() { echo("Applying Settings..."); global $SERVICE, $UPSCABLE, $CUSTOMUPSCABLE, $UPSTYPE, $DEVICE, $BATTERYLEVEL, $MINUTES, $TIMEOUT, $KILLUPS, $newline, $log; if ($UPSCABLE == "custom") exec_log("sed -i -e '/^UPSCABLE/c\\UPSCABLE '$CUSTOMUPSCABLE'' /etc/apcupsd/apcupsd.conf"); else exec_log("sed -i -e '/^UPSCABLE/c\\UPSCABLE '$UPSCABLE'' /etc/apcupsd/apcupsd.conf"); exec_log("sed -i -e '/^UPSTYPE/c\\UPSTYPE '$UPSTYPE'' /etc/apcupsd/apcupsd.conf"); exec_log("sed -i -e '/^DEVICE/c\\DEVICE '$DEVICE'' /etc/apcupsd/apcupsd.conf"); # Modifications to correctly check for the presence of the apcupsd powerfail file, and allow for the UPS to power off the system # exec_log("! grep -q apccontrol /etc/rc.d/rc.6 && sed -i -e 's/\\/sbin\\/poweroff/\\/etc\\/apcupsd\\/apccontrol killpower; \\/sbin\\/poweroff/' /etc/rc.d/rc.6"); exec_log("! grep -q apcupsd /etc/rc.d/rc.6 && sed -i -e 's/\\/sbin\\/poweroff/if \[ -f \\/etc\\/apcupsd\\/powerfail \]\; then\\n \\/etc\\/apcupsd\\/apccontrol killpower\\n else\\n \\/sbin\\/poweroff\\n fi/' /etc/rc.d/rc.6"); exec_log("sed -i -e '/^BATTERYLEVEL/c\\BATTERYLEVEL '$BATTERYLEVEL'' /etc/apcupsd/apcupsd.conf"); exec_log("sed -i -e '/^MINUTES/c\\MINUTES '$MINUTES'' /etc/apcupsd/apcupsd.conf"); exec_log("sed -i -e '/^TIMEOUT/c\\TIMEOUT '$TIMEOUT'' /etc/apcupsd/apcupsd.conf"); if ($KILLUPS == "yes") { # exec_log("! grep -q apccontrol /etc/rc.d/rc.6 && sed -i -e 's/\\/sbin\\/poweroff/\\/etc\\/apcupsd\\/apccontrol killpower; \\/sbin\\/poweroff/' /etc/rc.d/rc.6"); exec_log("! grep -q apccontrol /etc/rc.d/rc.6 && sed -i -e '0,\\/sbin\\/poweroff/s/\\/sbin\\/poweroff/\\/etc\\/apcupsd\\/apccontrol killpower/' /etc/rc.d/rc.6"); } else { # exec_log("grep -q apccontrol /etc/rc.d/rc.6 && sed -i -e 's/\\/etc\\/apcupsd\\/apccontrol killpower; \\/sbin\\/poweroff/\\/sbin\\/poweroff/' /etc/rc.d/rc.6"); exec_log("grep -q apccontrol /etc/rc.d/rc.6 && sed -i -e 's/\\/etc\\/apcupsd\\/apccontrol killpower/\\/sbin\\/poweroff/' /etc/rc.d/rc.6"); } echo("Completed$newline"); } Quote Link to comment
Nezil Posted April 1, 2014 Share Posted April 1, 2014 Attached is an updated 32-bit version of the Apcupsd plugin. As usual, remove the .txt from the filename to use. This version contains the following updates since the version currently posted on the Wiki: 2013-09-28 - Made some corrections to stop the syslog log refresh issue. 2014-03-31 - Neil Robinson - Updated to apcupsd version 3.14.12, Updated Powerdown to version 2.06 2014-04-01 - Neil Robinson - Modifications to check for the apcupsd powerfail file, and allow the UPS to power off the system Does anyone know the process for validating, and then moving updated plugins to the wiki? Apcupsd-3.14.12-i486-2_nro.plg.txt Quote Link to comment
acurcione Posted April 1, 2014 Share Posted April 1, 2014 Attached is an updated 32-bit version of the Apcupsd plugin. As usual, remove the .txt from the filename to use. This version contains the following updates since the version currently posted on the Wiki: 2013-09-28 - Made some corrections to stop the syslog log refresh issue. 2014-03-31 - Neil Robinson - Updated to apcupsd version 3.14.12, Updated Powerdown to version 2.06 2014-04-01 - Neil Robinson - Modifications to check for the apcupsd powerfail file, and allow the UPS to power off the system Does anyone know the process for validating, and then moving updated plugins to the wiki? Sorry for the newbie question, but what's the normal upgrade procedure for plugins? Sent from my iPad using Tapatalk Quote Link to comment
Nezil Posted April 2, 2014 Share Posted April 2, 2014 Sorry for the newbie question, but what's the normal upgrade procedure for plugins? The best thing to do is to replace the plugin file on your flash drive, and reboot. Quote Link to comment
hoxbox382 Posted April 2, 2014 Share Posted April 2, 2014 Download or update xxx.plg file into /boot/config/plugins then run installplg xxx.plg It will automatically install on reboot as well. Quote Link to comment
Nezil Posted April 2, 2014 Share Posted April 2, 2014 I've added some more changes to the plugin, increasing the version number to 3_nro.plg (attached). I had often read that apcupsd could send emails letting the administrator know about certain events, but my installation at least had never done this. I have ssmtp installed (by Dynamix email notify), and wanted to run my mail through this because it works very well. Previous to this version of the plugin, /etc/apcupsd/apccontrol would be modified so that the variable $WALL, which by default is wall, would be changed to: mail -s 'unRAID_SERVER_UPS_Alert' root\ This command fails on my system, because mail is not installed. In any case, I'm not sure that I would want all of the 'wall' commands being sent to me by email; this was certainly not the intended configuration of apcupsd, which looks for additional script files to execute at each calling of apccontrol. Some of these script files are installed with the apcupsd package as examples, but the intention is that the user would customise these to their requirements as needed. Since unRAID runs in RAM, the script folder needs to be located on the flash drive to be preserved between reboots. The $APCUPSD_MAIL variable in the 3.14.10 package of apcupsd was defined in each custom script. In the 3.14.12 package now used, this variable is defined as an export variable in /etc/apcupsd/apccontrol. If you're trying to test your scripts using this variable, be sure to call them using apccontrol [event name] rather than directly. If you choose to have no user customised script files in the /boot/config/plugins/apcupsd/scripts folder, the default example scripts will be installed as normal. One important thing to note, is that the doshutdown script is first modified to the following by the plugin installation script: /sbin/powerdown exit 99 If you do create your own custom doshutdown script, it must contain these last two lines in order to correctly call the unRAID powerdown script. In addition to the updated plugin, I've attached some custom scripts that I'm using in my system. These are a slightly better reference than the default examples, and are written in a format compatible with ssmtp. To summarise, I have made three changes for this version: Removed the line which changes the $WALL variable in apccontrol Changed the $APCUPSD_MAIL variable to /usr/sbin/ssmtp in /etc/apcupsd/apccontrol Added the following code to look for user created scripts in the /boot/config/plugins/apcupsd/scripts folder. For each file present, the code removes the default script, and replaces it with a symlink to the user code for file in /boot/config/plugins/apcupsd/scripts/*; do rm /etc/apcupsd/${file##*/} ln -s $file /etc/apcupsd/${file##*/} done Apcupsd-3.14.12-i486-3_nro.plg.txt doshutdown.txt commfailure.txt commok.txt Quote Link to comment
acurcione Posted April 2, 2014 Share Posted April 2, 2014 I just installed this last version of the plugin and I'm getting a fatal error and it won't start. This is from the log: Apr 2 10:29:35 Tower apcupsd[9225]: apcupsd FATAL ERROR in apcconfig.c at line 672 Error opening configuration file (/etc/apcupsd/apcupsd.conf): No such file or directory Apr 2 10:29:35 Tower apcupsd[9225]: apcupsd error shutdown completed Apr 2 10:30:16 Tower apcupsd[9802]: apcupsd FATAL ERROR in apcconfig.c at line 672 Error opening configuration file (/etc/apcupsd/apcupsd.conf): No such file or directory Apr 2 10:30:16 Tower apcupsd[9802]: apcupsd error shutdown completed I did have the older version installed before this one. Ideas? Quote Link to comment
Nezil Posted April 2, 2014 Share Posted April 2, 2014 Oops... you're right. I need to look into this and find out why. I suggest you roll back to version 2_nro for now. I'll work on it this morning that have a fix in place ASAP. Quote Link to comment
Nezil Posted April 2, 2014 Share Posted April 2, 2014 I have found the problem, and the reason that I hadn't noticed it. If you either don't have the folder /boot/config/plugins/apcupsd/scripts, or you have it, but it's empty, the result of the for expression will be /boot/config/apcupsd/scripts/*, which will result in the following two commands: rm /etc/apcupsd/* ln -s /boot/config/apcupsd/scripts/* /etc/apcupsd/* Clearly this will result in apcupsd.conf missing when the application tries to start. I obviously didn't have this problem, because I have script files in the scripts folder. Apologies, and I'm working on a fix now! Quote Link to comment
Nezil Posted April 2, 2014 Share Posted April 2, 2014 The fix is as follows: if [ -d /boot/config/plugins/apcupsd/scripts ] && [ "$(ls -A /boot/config/plugins/apcupsd/scripts)" ]; then for file in /boot/config/plugins/apcupsd/scripts/*; do rm /etc/apcupsd/${file##*/} ln -s $file /etc/apcupsd/${file##*/} done fi The additional 'if' statement checks for the presence of a script folder, with files inside, before running the for loop. If the folder is missing or empty, no action is taken. An updated Version (4_nro) is attached. Apcupsd-3.14.12-i486-4_nro.plg.txt Quote Link to comment
acurcione Posted April 2, 2014 Share Posted April 2, 2014 The fix is as follows: if [ -d /boot/config/plugins/apcupsd/scripts ] && [ "$(ls -A /boot/config/plugins/apcupsd/scripts)" ]; then for file in /boot/config/plugins/apcupsd/scripts/*; do rm /etc/apcupsd/${file##*/} ln -s $file /etc/apcupsd/${file##*/} done fi The additional 'if' statement checks for the presence of a script folder, with files inside, before running the for loop. If the folder is missing or empty, no action is taken. An updated Version (4_nro) is attached. Thanks for this. I'll be trying it out in the morning! Sent from my iPad using Tapatalk Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.