Both sides previous revision Previous revision Next revision | Previous revisionLast revisionBoth sides next revision |
home_server:home_server_setup:other_services:nut [2020-12-20 Sun wk51 19:29] – [NUT Key commands and scripts] baumkp | home_server:home_server_setup:other_services:nut [2023-05-13 Sat wk19 08:54] – [NUT Key commands and scripts] baumkp |
---|
{{tag>linux ubuntu nut ups server}} | {{tag>linux debian nut ups server}} |
======NUT (Network UPS Tools) Setup====== | ======NUT (Network UPS Tools) Setup====== |
| I purchased my current main UPS the Powershield Commander RT PSCRT1100 / Voltronic Power Otima II 1.1K in 2014 and setup NUT about this time, including early conversion to systemd scripts. I notice the Techno Tim [[https://docs.technotim.live/posts/NUT-server-guide/|Network UPS Tools (NUT) Ultimate Guide]] late 2022 has a perhaps more modern take on this. |
| |
NUT is an open source network monitoring and control system. I use a Powershield Commander RT PSCRT1100 a 1100VA/880W, line interactive sinewave UPS. It turns out that this is a slightly modified version of the [[http://voltronicpower.com/en-US/Product/Detail/Otima-II-800VA-5KVA|Voltronic Power Otima II 1.1K]]. Presumably the unit has been slightly modified for Powershield for the Australian market, mainly hardware plugs and presumably some firmware/software setup. In fact Voltronic Power, headquartered in Taiwan, even states they are a leading OEM/ODM manurfacturer of UPSs, AVRs and inverters. The software provided with the UPS is both propriety and bloated. I want a simple efficient command line / daemon based utility that can monitor performance, control as necessary and report on abnormal operation. Unfortunately the [[http://networkupstools.org/documentation.html|NUT project documentation]] is not simple to follow. I set this up quite some time ago, so this will not necessarily be up to date. | By the way a couple years ago the UPS battery fail alarm went off. It would seem the UPS batteries failed after about 5-6 years of operation. These battery seems to be common lead-acid gel type 12 VDC at 9.6 AMP-hr (although they look to be the same as 7.2 AMP batteries....) I basically set an forgot them. I understand 5-6 year lift is not unreasonably. In any case I purchased some new batteries and replaced and the UPS has continued to function well. |
| |
| NUT is an open source network monitoring and control system. I use a Powershield Commander RT PSCRT1100 a 1100VA/880W, line interactive sinewave UPS. It turns out that this is a slightly modified version of the [[http://voltronicpower.com/en-US/Product/Detail/Otima-II-800VA-5KVA|Voltronic Power Otima II 1.1K]]. Presumably the unit has been slightly modified for Powershield for the Australian market, mainly hardware plugs and presumably some firmware/software setup. In fact Voltronic Power, headquartered in Taiwan, even states they are a leading OEM/ODM manufacturer of UPSs, AVRs and inverters. The software provided with the UPS is both propriety and bloated. I want a simple efficient command line / daemon based utility that can monitor performance, control as necessary and report on abnormal operation. Unfortunately the [[http://networkupstools.org/documentation.html|NUT project documentation]] is not simple to follow. I set this up quite some time ago, so this will not necessarily be up to date. |
| |
It turns out the ''nutdrv_qx'' driver is usually better suited for Voltronic Power UPSs than the ''Blazer_usb'' one. See NUT [[http://networkupstools.org/protocols/voltronic.html|Voltronic Power UPS Protocol]], it is also list under the Voltronic Power section, (various)USB of the NUT [[http://networkupstools.org/stable-hcl.html|Hardware compatibility list]]. | It turns out the ''nutdrv_qx'' driver is usually better suited for Voltronic Power UPSs than the ''Blazer_usb'' one. See NUT [[http://networkupstools.org/protocols/voltronic.html|Voltronic Power UPS Protocol]], it is also list under the Voltronic Power section, (various)USB of the NUT [[http://networkupstools.org/stable-hcl.html|Hardware compatibility list]]. |
Turn off the existing legacy scripts and systemd handlers, as noted above; ''sudo update-rc.d nut-client disable'', ''sudo update-rc.d nut-server disable'' and ''sudo systemctl disable ups-monitor.service''. You may also need to disable the following systemd services: nut-client.service, nut-monitor.service and nut-server.service. | Turn off the existing legacy scripts and systemd handlers, as noted above; ''sudo update-rc.d nut-client disable'', ''sudo update-rc.d nut-server disable'' and ''sudo systemctl disable ups-monitor.service''. You may also need to disable the following systemd services: nut-client.service, nut-monitor.service and nut-server.service. |
| |
The Kepstin blog gives a good NUT and Systemd discussion [[https://www.kepstin.ca/blog/networkupstoolsnutandsystemd/|Network UPS Tools (nut) and systemd]]. However it is written for Fedora and there are some nuances required to work with Ubuntu. For a general understanding of Systemd see DigitalOcean references: [[https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files|Understanding Systemd Units and Unit Files]], [[https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units|How To Use Systemctl to Manage Systemd Services and Units]], and [[https://www.digitalocean.com/community/tutorials/systemd-essentials-working-with-services-units-and-the-journal|Systemd Essentials: Working with Services, Units, and the Journal]]. | The Kepstin blog gives a good NUT and Systemd discussion [[https://www.kepstin.ca/blog/networkupstoolsnutandsystemd/|Network UPS Tools (nut) and systemd]]. However it is written for Fedora and there are some nuances required to work with Debian/Ubuntu. For a general understanding of Systemd see DigitalOcean references: [[https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files|Understanding Systemd Units and Unit Files]], [[https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units|How To Use Systemctl to Manage Systemd Services and Units]], and [[https://www.digitalocean.com/community/tutorials/systemd-essentials-working-with-services-units-and-the-journal|Systemd Essentials: Working with Services, Units, and the Journal]]. |
| |
First we need to get the NUT driver running, "sudo vim /etc/systemd/system/nut-driver.service" | First we need to get the NUT driver running, "sudo vim /etc/systemd/system/nut-driver.service" |
| |
*List all the UPS device profile variable ''/bin/upsc KPBUPS@localhost 2>/dev/null''. | *List all the UPS device profile variable ''/bin/upsc KPBUPS@localhost 2>/dev/null''. |
*A script file to succinctly log the UPS data, using cron to run script every 10 minutes ''sudo Myscripts/UPSScan.sh 2>/dev/null'',<code>#!/bin/bash | *A script file to succinctly log the UPS data, using cron to run script every 10 minutes ''sudo Myscripts/UPSScan.sh 2>/dev/null'',<code bash>#!/bin/bash |
# Logging output for NUT UPS Monitor output | # Logging output for NUT UPS Monitor output |
| |
printf("\n") }' >>"$strf" | printf("\n") }' >>"$strf" |
</code> | </code> |
*A script file to rotate a log file out to a dated gzip log file, with a new empty log file, the log file with path is the script input ''sudo rotatelog.sh /var/log/UPSLog.Log'', again can be use with cron monthly to rotate a log file. <code> | *A script file to rotate a log file out to a dated gzip log file, with a new empty log file, the log file with path is the script input ''sudo rotatelog.sh /var/log/UPSLog.Log'', again can be use with cron monthly to rotate a log file. <code bash> |
#!/bin/bash | #!/bin/bash |
logfile=$1 | logfile=$1 |
*To list the available UPS commands: "upscmd -l KPBUPS" | *To list the available UPS commands: "upscmd -l KPBUPS" |
*Some other scripts: | *Some other scripts: |
*To email notifications from nut: nut-notify.sh (not tested)<code> | *To email notifications from nut: nut-notify.sh (not tested)<code bash> |
#!/bin/sh | #!/bin/sh |
#echo "$*" | mailx -s "UPS Notice" baumkp@gmail.com | #echo "$*" | mailx -s "UPS Notice" baumkp@gmail.com |
</code> | </code> |
| |
Example to disable the UPS beeper: ''upscmd beeper.disable'' | Example to disable the UPS beeper: ''upscmd KPBUPS@localhost beeper.disable'' it will then prompt for NUT user and password. |
The command will prompt for a user then password. This is a valid user and password define for the NUT installation as defined in the file ''/etc/nut/upsd.users'' as noted above. | The command will prompt for a user then password. This is a valid user and password define for the NUT installation as defined in the file ''/etc/nut/upsd.users'' as noted above. |
| |
<code> | <code> |
T Voltage Battery S | T Voltage Battery S |
---- | ---- |
| |
<- home_server:home_server_setup:other_services:Mosh|Prev ^ home_server:home_server_setup:other_services:index|Start page ^ home_server:home_server_setup:other_services:back-up_server|Next -> | <- home_server:home_server_setup:other_services:nnn|Prev ^ home_server:home_server_setup:other_services:index|Start page ^ home_server:home_server_setup:other_services:back-up_server|Next -> |
| |
| |