Changes

From SME Server
Jump to navigationJump to search
Line 1: Line 1: −
==Installation of Latest Version==
+
{{Level|Medium}}
 +
==Installation of apcupsd==
 +
===Introduction===
 
Apcupsd can be used for power management and controlling most of APC's UPS models on Unix and Windows machines. Apcupsd works with most of APC's Smart-UPS models as well as most simple signalling models such a Back-UPS, and BackUPS-Office. During a power failure, apcupsd will inform the users about the power failure and that a shutdown may occur. If power is not restored, a system shutdown will follow when the battery is exhausted, a timeout (seconds) expires, or runtime expires based on internal APC calculations determined by power consumption rates. Apcupsd is licensed under the GPL version 2.  
 
Apcupsd can be used for power management and controlling most of APC's UPS models on Unix and Windows machines. Apcupsd works with most of APC's Smart-UPS models as well as most simple signalling models such a Back-UPS, and BackUPS-Office. During a power failure, apcupsd will inform the users about the power failure and that a shutdown may occur. If power is not restored, a system shutdown will follow when the battery is exhausted, a timeout (seconds) expires, or runtime expires based on internal APC calculations determined by power consumption rates. Apcupsd is licensed under the GPL version 2.  
   −
The latest version of ''apcupsd'' is 3.14.8-1 (January 2010) and is available from sourceforge in two rpms - one for the UPS daemon and one for the web based monitoring scripts. Neither of these install exactly in line with the ''SME way'', and neither does the older version available on DAG.
+
The latest version of ''apcupsd'' is 3.14.10-1 (2011-10-04) and is available from sourceforge in two rpms - one for the UPS daemon and one for the web based monitoring scripts. Neither of these install exactly in line with the ''SME way'', and neither does the older version available on DAG.
   −
These installation instructions make some additional modifications for SME
+
These installation instructions make some additional modifications for SME. They have been tested on:
{{Note box|SME uses Nut as standard for UPS monitoring and control and works with a more than just APC UPS models. See [[Uninterruptable_Power_Supply]] for details }}
+
- SME 7.5 and an APC SmartUPS 1500i with both a usb and a 940-0024C smart serial cable.
 +
- SME 7.5.1 and an APC BackUPS BR800 with a usb cable.
 +
- AP9617 Network Management Card using both the ''snmp'' and ''pcnet'' UPSTYPE drivers'
 +
 
 +
{{Note box|SME uses Nut as standard for UPS monitoring and control and works with more than just APC UPS models. See [[Uninterruptable_Power_Supply]] for details }}
 
===Download and install===
 
===Download and install===
Get the rpms from sourceforge
+
Get the rpms from [http://sourceforge.net/projects/apcupsd/files/rpms%20-%20Stable/3.14.10/ APCUPSD sourceforge]
 
  −
wget https://sourceforge.net/projects/apcupsd/files/rpms%20-%20Stable/3.14.8/apcupsd-3.14.8-1.el4.i386.rpm/download
  −
wget https://sourceforge.net/projects/apcupsd/files/rpms%20-%20Stable/3.14.8/apcupsd-multimon-3.14.8-1.el4.i386.rpm/download
      +
wget http://sourceforge.net/projects/apcupsd/files/rpms%20-%20Stable/3.14.10/apcupsd-3.14.10-1.el5.x86_64.rpm/download
 +
wget http://sourceforge.net/projects/apcupsd/files/rpms%20-%20Stable/3.14.10/apcupsd-multimon-3.14.10-1.el5.x86_64.rpm/download
 +
 
Install with yum
 
Install with yum
  yum localinstall apcupsd-3.14.8-1.el4.i386.rpm apcupsd-multimon-3.14.8-1.el4.i386.rpm
+
  yum localinstall apcupsd-3.14.10-1.el5.x86_64.rpm apcupsd-multimon-3.14.10-1.el5.x86_64.rpm
    
===Configure apcupsd===
 
===Configure apcupsd===
 +
====General====
 
Link the startup file and enable the service
 
Link the startup file and enable the service
 
  ln -s /etc/init.d/e-smith-service /etc/rc.d/rc7.d/S38apcupsd
 
  ln -s /etc/init.d/e-smith-service /etc/rc.d/rc7.d/S38apcupsd
Line 23: Line 30:  
  cp /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf.orig
 
  cp /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf.orig
   −
Edit ''/etc/apcupsd/apcupsd.conf'' file and make relevant changes for your UPS and requirements. The file is reasonably well documented and as a minimum you will probably want to set  
+
Edit the ''/etc/apcupsd/apcupsd.conf'' file and make relevant changes for your UPS and requirements. The file is reasonably well documented and as a minimum you will probably want to set  
 
  UPSNAME  
 
  UPSNAME  
 
  UPSCABLE
 
  UPSCABLE
Line 31: Line 38:  
  MINUTES
 
  MINUTES
 
  TIMEOUT
 
  TIMEOUT
 +
{{Tip box|msg=See the section below on Network Management Cards for specific settings and notes relating to using the UPS with a NMC such as AP9617 across the network}}
 +
You may also consider some additional security by only listening for connections on the localhost for monitoring and incoming events (assuming you have only one UPS directly connected). In this instance set
 +
NISIP 127.0.0.1
    
Now make sure ''Nut'' isn't running and start the service
 
Now make sure ''Nut'' isn't running and start the service
Line 36: Line 46:  
  /etc/init.d/nut stop
 
  /etc/init.d/nut stop
 
  /etc/rc.d/rc7.d/S38apcupsd start
 
  /etc/rc.d/rc7.d/S38apcupsd start
 +
 +
To check its running and view status information (you may need to wait 30 seconds to ensure initialisation and communications have completed)
 +
/etc/init.d/apcupsd status
 +
{{Note box| If you are using ''UPSCABLE usb'' and ''UPSTYPE usb'', and you get a status messages such as
 +
apcupsd (pid 14420) is running...
 +
Error contacting apcupsd @ localhost:3551: Connection refused
 +
then this may be due to Nut. Make sure Nut is stopped and disabled as above. You may also need to disconnect and reconnect the USB cable after Nut has been stopped}}
 +
====Network Management Cards====
 +
If you have a Network Management Card installed in the UPS such as the AP9617 card, you can use ''snmp'' or ''pcnet'' for UPSTYPE with the following configurations
 +
=====NMC Setup=====
 +
The NMC default configuration searches for an IP address using BOOTP and DHCP. It expects a device specific cookie to be returned with the DHCP response, so even if you create a local hostname in ''Server-manager - Hostnames and Addresses'', initial install will fail. Use the APC ''Device IP Configuration Wizard'' to discover the UPS and assign IP/Subnet/Gateway settings. You can then access the UPS configuration in a browser using the IP given.
 +
 +
The network TCP/IP settings will be set to ''manual'' with the values provided in the wizard above. To use DHCP in future goto the ''Administration - Network Tab'' and under TCP/IP select ''DHCP'' for configuration and press ''Next''. On the following page deselect the tick box against ''Require vendor specific cookie to accept DHCP Address'' and ''Apply''. DHCP configuration via the Hostnames and addresses panel in Server-manager should now work.
 +
 +
Make any other settings you require via the web browser interface.
 +
{{Note box|msg=The /sbin/apctest utility will not work across the network using the ''snmp'' or ''pcnet'' UPSTYPE as it does not have write access. You will therefore need to make the necessary configuration settings via the APC UPS web browser interface}}
 +
=====UPSTYPE snmp=====
 +
For this UPSTYPE to work you will need to make some changes to the NMC via the web browser interface first
 +
 +
Under the ''Administration'' and ''Notification'' tabs goto ''SNMP Trap Receivers'' and press ''Add Trap Reciever''. On the next page add the IP address of your SME server that will be monitoring the UPS and ensure ''SNMP v1'' is selected, ''Community'' is ''public'' and ''Authenticate traps'' is ''enabled''. Now press ''Apply''.
 +
 +
Edit /etc/apcupsd/apcupsd.conf and set the following
 +
UPSCABLE ether
 +
UPSTYPE snmp
 +
DEVICE ''ipaddress'':161:APC:public
 +
{{Note box|msg=''ipaddress'' is the IP address assigned to the UPS. The default port is ''161'', default vendor is ''APC'' and default community is ''public''}}
 +
Make any other changes required and save the file.
 +
 +
Continue as above in the ''Configure apcupsd'' section - but note the requirements in the ''snmp and pcnet Killpower'' section below.
 +
=====UPSTYPE pcnet=====
 +
For this UPSTYPE to work you will need to make some changes to the NMC via the web browser interface first
 +
 +
Under the ''UPS'' tab, goto ''PowerChute - Configuration''. Enter an ''Authentication Phrase'' (This must be at least 15 characters long to be valid)
 +
such as
 +
My hidden auth phrase
 +
and ''Apply''
 +
 +
Now under ''PowerChute - Clients'' press ''Add Clients''. On the subsequent page add the IP address of your SME server that will be monitoring the UPS and ''Apply''
 +
 +
Edit /etc/apcupsd/apcupsd.conf and set the following
 +
UPSCABLE ether
 +
UPSTYPE pcnet
 +
DEVICE ''ipaddress'':apc:''AuthPhrase''
 +
{{Note box|msg=''ipaddress'' is the IP address assigned to the UPS. The default user is ''apc'' (and apparently can't be changed), and the ''AuthPhrase'' is the Authentication Phrase as set above}}
 +
Make any other changes required and save the file.
 +
 +
Continue as above in the ''Configure apcupsd'' section - but note the requirements in the ''snmp and pcnet Killpower'' section below.
 +
=====snmp and pcnet Killpower=====
 +
The standard rpm install copies the ''/etc/init.d/halt'' script to ''/etc/init.d/halt.old'' and then inserts the following code fragment near the end just after the file systems are remounted read only.
 +
# See if this is a powerfail situation.                              # ***apcupsd***
 +
if [ -f /etc/apcupsd/powerfail ]; then                                # ***apcupsd***
 +
    echo                                                              # ***apcupsd***
 +
    echo "APCUPSD will now power off the UPS"                          # ***apcupsd***
 +
    echo                                                              # ***apcupsd***
 +
    /etc/apcupsd/apccontrol killpower                                  # ***apcupsd***
 +
    echo                                                              # ***apcupsd***
 +
    echo "Please ensure that the UPS has powered off before rebooting" # ***apcupsd***
 +
    echo "Otherwise, the UPS may cut the power during the reboot!!!"  # ***apcupsd***
 +
    echo                                                              # ***apcupsd***
 +
fi                                                                    # ***apcupsd***
 +
 +
Thus for normal operation with a USB or serial cable, a killpower instruction is sent to the UPS just before the server powers down. The UPS then waits for the DSHUTD (Delayed shutdown) period (usually 60 or 90 seconds) and powers off, by which time the final server shutdown and power off should be complete.
 +
 +
With the ''snmp'' and ''pcnet'' UPSTYPE however, communication is across the network and the ''/etc/init.d/halt'' script will have killed the network service before the above code instructs the UPS to power down. In order for the UPS to receive a ''killpower'' signal therefore it is necessary to edit ''/etc/init.d/halt'' and move the code fragment shown above to nearer the beginning of the script, inserting it as below.
 +
case "$1" in
 +
    *start)
 +
        ;;
 +
    *)
 +
        echo $"Usage: $0 {start}"
 +
        exit 1
 +
        ;;
 +
esac
 +
 +
# See if this is a powerfail situation.                              # ***apcupsd***
 +
if [ -f /etc/apcupsd/powerfail ]; then                                # ***apcupsd***
 +
    echo                                                              # ***apcupsd***
 +
    echo "APCUPSD will now power off the UPS"                          # ***apcupsd***
 +
    echo                                                              # ***apcupsd***
 +
    /etc/apcupsd/apccontrol killpower                                  # ***apcupsd***
 +
    echo                                                              # ***apcupsd***
 +
    echo "Please ensure that the UPS has powered off before rebooting" # ***apcupsd***
 +
    echo "Otherwise, the UPS may cut the power during the reboot!!!"  # ***apcupsd***
 +
    echo                                                              # ***apcupsd***
 +
fi                                                                    # ***apcupsd***
 +
 +
# Kill all processes.
 +
[ "${BASH+bash}" = bash ] && enable kill
 +
 +
runcmd $"Sending all processes the TERM signal..." /sbin/killall5 -15
 +
sleep 5
 +
runcmd $"Sending all processes the KILL signal..."  /sbin/killall5 -9
 +
 +
The UPS will therefore be instructed to power down before the network service is terminated.
 +
 +
This is much earlier in the server shutdown process however and it is important to set the shutdown delay to at least 180 seconds i.e. greater than the time it actually takes your SME server to shutdown following a halt signal. Therefore via the NMC web browser interface goto the ''UPS'' tab and under ''Configuration - Shutdown'' select the appropriate value for ''Shutdown Delay'' of 180 seconds or greater.
 +
===Usage of apcupsd===
 +
The file ''/etc/apcupsd/apcupsd.conf'' controls the configuration of the apcupsd daemon and is well documented. In addition to this ''/etc/apcupsd/apccontrol'' is called by the daemon whenever a UPS event occurs, and determines the standard action taken. User configurable actions can be taken by creating/editing files in /etc/apcupsd with names corresponding to relevant events, and these are called first by ''apccontrol''. For example, a file called ''onbattery'' will be called by ''apccontrol'' whenever an ON BATTERY event occurs, and if ''onbattery'' returns an exit code of 99, then ''apccontrol'' will not take its own default action.
 +
 +
To view the UPS status of settings and monitored values you can use
 +
/sbin/apcaccess
 +
 +
To configure the UPS EEPROM values you can use
 +
/etc/init.d/apcupsd stop
 +
/sbin/apctest
 +
 +
Follow the command line menu to make selections and set UPS configuration vales. The menu varies depending upon if you are using usb or serial communications, but generally allows for querying the UPS status, running a battery calibration, programming the EEPROM values and communicating directly with the UPS in TTY mode.
 +
 +
Don't forget to restart the daemon when you are finished with apctest
 +
/etc/init.d/apcupsd start
 +
 +
See the [http://www.apcupsd.com/manual/manual.html documentation] for further details
 +
{{Note box|The UPS EEPROM value for RETPCT (Return Percentage - battery charge required before UPS powers up/on after failure) should be greater than the value of BATTERYLEVEL (battery charge level that initiates a shutdown) in ''/etc/apcupsd/apcupsd.conf''}}
    
===Configure Multimon etc Scripts===
 
===Configure Multimon etc Scripts===
Line 56: Line 178:  
     my $pass = '0';
 
     my $pass = '0';
 
     my $satisfy = 'all';
 
     my $satisfy = 'all';
     my $name = $apcupsd{'Name'} || 'apcupsd UPS Monitor';
+
     my $name = $apcupsd{'Name'} || 'APC UPS Daemon Monitoring';
 
   
 
   
 
     for ('exit-if-none')
 
     for ('exit-if-none')
Line 99: Line 221:  
   
 
   
 
       $OUT .= "#------------------------------------------------------------\n";
 
       $OUT .= "#------------------------------------------------------------\n";
       $OUT .= "# apcupsd - $name\n";
+
       $OUT .= "# apcupsd multimon - $name\n";
 
       $OUT .= "#------------------------------------------------------------\n";
 
       $OUT .= "#------------------------------------------------------------\n";
 
   
 
   
 
       {
 
       {
         if ((exists $apcupsd{'URL'}) && ($apcupsd{'URL'} ne ''))
+
         if ((exists $apcupsd{'URL'}) && ($apcupsd{'URL'} ne <nowiki>''</nowiki>)) {
        { $OUT .= "Alias  /$apcupsd{'URL'}  /opt/apcupsd\n";
+
          $OUT .= "Alias  /$apcupsd{'URL'}  /opt/apcupsd\n";  
          $OUT .= "ScriptAlias  /$apcupsd{'URL'/opt/apcupsd\n"; }
+
        }   
 
       }
 
       }
 
   
 
   
Line 129: Line 251:  
  }
 
  }
   −
Configure and expand the template
+
Configure databases and expand the template
 +
db accounts set apcupsd reserved
 
  config setprop apcupsd PublicAccess local
 
  config setprop apcupsd PublicAccess local
 
  /sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf
 
  /sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf
Line 141: Line 264:     
By editing /etc/apcupsd/hosts.conf and adding additional network UPS details, multimon.cgi can be used to monitor more than one UPS. By default only the localhost is monitored.
 
By editing /etc/apcupsd/hosts.conf and adding additional network UPS details, multimon.cgi can be used to monitor more than one UPS. By default only the localhost is monitored.
 +
 +
===Uninstall===
 +
Use the following commands to stop apcupsd and remove/uninstall it
 +
 +
/etc/init.d/apcupsd stop
 +
config delete apcupsd
 +
db accounts delete apcupsd
 +
rm /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/92apcupsdmon
 +
expand-template /etc/httpd/conf/httpd.conf
 +
sv t httpd-e-smith
 +
rm -fr /opt/apcupsd
 +
rm /etc/rc.d/rc7.d/S38apcupsd
 +
yum remove apcupsd apcupsd-multimon
 +
rm -fr /etc/apcupsd
    
===References===
 
===References===
Line 156: Line 293:  
====Setup the DAG repository====
 
====Setup the DAG repository====
   −
{{Repository|Dag}}
+
You need to activate the [[Dag]] reposity before installing this contrib.<br />
 +
 
 +
see [[dag|dag repository]] <br />
    
====Installation====
 
====Installation====
Line 163: Line 302:     
Copy original ''conf'' file
 
Copy original ''conf'' file
  cp apcupsd.conf apcupsd.conf.orig
+
  cp /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf.orig
    
Copy ''CGI'' files
 
Copy ''CGI'' files
22

edits

Navigation menu