Difference between revisions of "NUT"
Jump to navigation
Jump to search
Michael.mast (talk | contribs) (Created page with "WORK IN PROGRESS ==Configure NUT== First edit the /etc/ups/ups.conf file by appending the battery info. You can find this information by running nut-scanner<br> Example: <pre...") |
Michael.mast (talk | contribs) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
WORK IN PROGRESS | WORK IN PROGRESS | ||
+ | ==APC Specific== | ||
+ | <ref>https://www.cyberciti.biz/faq/debian-ubuntu-centos-rhel-install-apcups/</ref> | ||
+ | |||
+ | <pre> | ||
+ | dnf install apcupsd | ||
+ | systemctl enable --now apcupsd | ||
+ | apcaccess | ||
+ | </pre> | ||
==Configure NUT== | ==Configure NUT== | ||
− | First edit the /etc/ups/ups.conf file by appending the battery info. You can find this information by running nut-scanner<br> | + | *First edit the /etc/ups/ups.conf file by appending the battery info. You can find this information by running nut-scanner<br> |
− | |||
<pre> | <pre> | ||
[root@dronetest ~]# nut-scanner -U | [root@dronetest ~]# nut-scanner -U | ||
Line 19: | Line 26: | ||
</pre> | </pre> | ||
<br> | <br> | ||
+ | *With the information above, append the following to /etc/ups/ups.conf | ||
+ | <pre> | ||
+ | [nutdev1] | ||
+ | driver = usbhid-ups | ||
+ | port = auto | ||
+ | </pre> | ||
+ | *For basic email alerting, create the following script and associated cronjob.<br> | ||
+ | <b>NOTE :</b> This is a work in progress. This script would send you a ton of emails and is not smart enough to everything it needs to. | ||
+ | <pre> | ||
+ | #!/bin/bash | ||
+ | branch='location name' | ||
+ | nutdevcount='1' | ||
+ | nutdevlist='nutdev1' | ||
+ | support='support@yourcompany.com' | ||
+ | for i in $nutdevlist; do | ||
+ | upsstatus=$(upsc $i@localhost ups.status) | ||
+ | upsload=$(upsc $i@localhost ups.load) | ||
+ | [ ! -z $upsstatus ] && [ ! -z $upsload ] && | ||
+ | if [ "$upsstatus" = "OL" ]; then | ||
+ | echo "Battery Online" > /dev/null | ||
+ | elif [ "$upsstatus" == "OB DISCHRG" ]; then | ||
+ | echo -e "Subject:$branch UPS has lost AC Power" | /usr/sbin/sendmail "$support" | ||
+ | elif [ "$upsstatus" = "OL CHRG" ]; then | ||
+ | echo "Charging" > /dev/null | ||
+ | else | ||
+ | echo "Status Unknown" > /dev/null | ||
+ | fi | ||
+ | if [ "$upsload" -ge "70" ] | ||
+ | then echo -e "Subject:$branch UPS Load=$upsload" | /usr/sbin/sendmail "$support" | ||
+ | fi | ||
+ | done | ||
+ | </pre> | ||
+ | |||
==Start NUT service Layers== | ==Start NUT service Layers== | ||
+ | <pre> | ||
+ | systemctl enable --now nut-server | ||
+ | </pre> | ||
+ | ==Old Startup Type== | ||
+ | The following was used before I ran across the systemd unit files that came with the package. The other issue is that I am now getting the following error that makes this setup no longer usable in it's current state. | ||
+ | <pre> | ||
+ | [/etc/systemd/system/nutstart.service:6] Failed to parse service type, ignoring: Simple | ||
+ | </pre> | ||
+ | <s> | ||
Have the following shell script in place | Have the following shell script in place | ||
<pre> | <pre> | ||
Line 40: | Line 89: | ||
</pre> | </pre> | ||
Then enable the service | Then enable the service | ||
− | + | </s> | |
− | |||
− | |||
− | < | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 12:11, 5 March 2021
WORK IN PROGRESS
APC Specific
dnf install apcupsd systemctl enable --now apcupsd apcaccess
Configure NUT
- First edit the /etc/ups/ups.conf file by appending the battery info. You can find this information by running nut-scanner
[root@dronetest ~]# nut-scanner -U Cannot load XML library (libneon.so.27) : file not found. XML search disabled. Scanning USB bus. [nutdev1] driver = "usbhid-ups" port = "auto" vendorid = "0764" productid = "0601" product = "OR1500PFCLCD" serial = "GXIFS2000130" vendor = "CPS" bus = "001"
- With the information above, append the following to /etc/ups/ups.conf
[nutdev1] driver = usbhid-ups port = auto
- For basic email alerting, create the following script and associated cronjob.
NOTE : This is a work in progress. This script would send you a ton of emails and is not smart enough to everything it needs to.
#!/bin/bash branch='location name' nutdevcount='1' nutdevlist='nutdev1' support='support@yourcompany.com' for i in $nutdevlist; do upsstatus=$(upsc $i@localhost ups.status) upsload=$(upsc $i@localhost ups.load) [ ! -z $upsstatus ] && [ ! -z $upsload ] && if [ "$upsstatus" = "OL" ]; then echo "Battery Online" > /dev/null elif [ "$upsstatus" == "OB DISCHRG" ]; then echo -e "Subject:$branch UPS has lost AC Power" | /usr/sbin/sendmail "$support" elif [ "$upsstatus" = "OL CHRG" ]; then echo "Charging" > /dev/null else echo "Status Unknown" > /dev/null fi if [ "$upsload" -ge "70" ] then echo -e "Subject:$branch UPS Load=$upsload" | /usr/sbin/sendmail "$support" fi done
Start NUT service Layers
systemctl enable --now nut-server
Old Startup Type
The following was used before I ran across the systemd unit files that came with the package. The other issue is that I am now getting the following error that makes this setup no longer usable in it's current state.
[/etc/systemd/system/nutstart.service:6] Failed to parse service type, ignoring: Simple
Have the following shell script in place
#!/bin/bash sudo usbhid-ups -uroot -a nutdev1 sudo upsd -uroot
Then create the systemd unit file /etc/systemd/system/nutstart.service with the following
[Unit] Description=Start NUT services After=network.target [Service] Type=Simple ExecStart=/root/nutstart.sh [Install] WantedBy=default.target
Then enable the service