Difference between revisions of "Configuring UPS"
(Created page with "If you have an uninterrupted power supply device from APC corporation, you can automate your system startup and shutdown when running on batteries using the open source tool call...") |
|||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| − | If you have an uninterrupted power supply device from APC corporation, you can automate your system startup and shutdown when running on batteries using the open source tool called | + | If you have an uninterrupted power supply device from APC corporation, you can automate your system startup and shutdown when running on batteries using the open source tool called ''apcupsd''. |
| + | '''$''' sudo emerge -av apcupsd | ||
| + | Have a look at the possible USE flags for the package and put an entry in your ''/etc/portage/package.use/sys-power'' if desired. The '''cgi''' flag is recommended for the web configuration below. Afterward, emerge the package. | ||
| + | |||
| + | Once emerged, edit the configuration file to suit your needs. | ||
| + | '''$''' sudo nano -w /etc/apcupsd/apcupsd.conf | ||
| + | Edit the '''hosts.conf''' file to enable cgi web monitoring. | ||
| + | '''$''' sudo nano -w /etc/apcupsd/hosts.conf | ||
| + | Add your email address and particulars to the files '''changeme''','''onbattery''' and '''offbattery''' if you want notifications when the power goes out. Note that notifications may not work unless you change the APCUPSD_MAIL directive from '''/bin/mail''' to '''/usr/bin/sendmail'''. | ||
| + | |||
| + | Next, set apcupsd to start with the system. | ||
| + | '''$''' sudo rc-update add apcupsd default | ||
| + | Start the service. | ||
| + | '''$''' sudo /etc/init.d/apcupsd start | ||
| + | To view your UPS's statistics once the service has started, | ||
| + | '''$''' sudo apcaccess status | ||
| + | ===CGI Web Monitoring=== | ||
| + | This feature used to be provided by the installer using the webapp-config command, but support for this was removed some time ago. | ||
| + | |||
| + | To enable CGI web monitoring, you'll need to create a symbolic link from your primary web folder to the apcupsd script directory. Assuming you aren't using apache vhosts, | ||
| + | '''$''' sudo -u apache ln -s /usr/libexec/apcupsd/cgi-bin /var/www/localhost/htdocs/apcupsd | ||
| + | You'll then need to make an addition to your apache configuration. | ||
| + | '''$''' sudo nano -w /etc/apache2/httpd.conf | ||
| + | Add the following to the bottom of the file: | ||
| + | <Directory /var/www/localhost/htdocs/apcupsd> | ||
| + | # * The cgi-bin directory for apcupsd is /usr/libexec/apcupsd/cgi-bin. | ||
| + | # * Set up your ScriptAlias or symbolic links accordingly. | ||
| + | Options ExecCGI | ||
| + | SetHandler cgi-script | ||
| + | </Directory> | ||
| + | Restart the apache server. | ||
| + | '''$''' sudo /etc/init.d/apache2 restart | ||
| + | You should now be able to see the statistic from a browser by visiting ''http://localhost/apcupsd/multimon.cgi''. | ||
Latest revision as of 16:52, 24 November 2016
If you have an uninterrupted power supply device from APC corporation, you can automate your system startup and shutdown when running on batteries using the open source tool called apcupsd.
$ sudo emerge -av apcupsd
Have a look at the possible USE flags for the package and put an entry in your /etc/portage/package.use/sys-power if desired. The cgi flag is recommended for the web configuration below. Afterward, emerge the package.
Once emerged, edit the configuration file to suit your needs.
$ sudo nano -w /etc/apcupsd/apcupsd.conf
Edit the hosts.conf file to enable cgi web monitoring.
$ sudo nano -w /etc/apcupsd/hosts.conf
Add your email address and particulars to the files changeme,onbattery and offbattery if you want notifications when the power goes out. Note that notifications may not work unless you change the APCUPSD_MAIL directive from /bin/mail to /usr/bin/sendmail.
Next, set apcupsd to start with the system.
$ sudo rc-update add apcupsd default
Start the service.
$ sudo /etc/init.d/apcupsd start
To view your UPS's statistics once the service has started,
$ sudo apcaccess status
CGI Web Monitoring
This feature used to be provided by the installer using the webapp-config command, but support for this was removed some time ago.
To enable CGI web monitoring, you'll need to create a symbolic link from your primary web folder to the apcupsd script directory. Assuming you aren't using apache vhosts,
$ sudo -u apache ln -s /usr/libexec/apcupsd/cgi-bin /var/www/localhost/htdocs/apcupsd
You'll then need to make an addition to your apache configuration.
$ sudo nano -w /etc/apache2/httpd.conf
Add the following to the bottom of the file:
<Directory /var/www/localhost/htdocs/apcupsd>
# * The cgi-bin directory for apcupsd is /usr/libexec/apcupsd/cgi-bin.
# * Set up your ScriptAlias or symbolic links accordingly.
Options ExecCGI
SetHandler cgi-script
</Directory>
Restart the apache server.
$ sudo /etc/init.d/apache2 restart
You should now be able to see the statistic from a browser by visiting http://localhost/apcupsd/multimon.cgi.