Roger Price
2020-Aug-03 09:33 UTC
[Nut-upsuser] Synology NAS is shutting down Ubuntu servers after very brief power outage (fwd)
On Sun, 2 Aug 2020, Todd Benivegna wrote:> How would you write the SHUTDOWNCMD line with multiple commands? I’ve been > looking at the manual and see that you have to escape the internal “ but am > still a little confused on how to do this exactly.This assumes that you use the Bash shell in your default environment. It will need adaption if you use Dash. In .bashrc define function getUPSstatus # Update variable UPSstatus and export to environment # Usage getUPSstatus <myups> function getUPSstatus { export UPSstatus="[$( upsc $1 ups.status 2>/dev/null )]:$( upsc $1 battery.charge 2>/dev/null )" } The SHUTDOWNCMD declaration now simplifies to SHUTDOWNCMD "getUPSstatus <myups> ; logger -t upsmon.conf \"UPS status is $UPSstatus\" ; /sbin/shutdown -h +0" Roger
Todd Benivegna
2020-Aug-04 01:05 UTC
[Nut-upsuser] Synology NAS is shutting down Ubuntu servers after very brief power outage (fwd)
Thank you! Sorry for another bonehead question…. Do I replace <myups> with the IP address of the NUT Server/Synology? I’m assuming I would use this version for use in Dash with Ubuntu, correct? -- Todd Benivegna // todd at benivegna.com On Aug 3, 2020, 5:33 AM -0400, Roger Price <roger at rogerprice.org>, wrote:> On Sun, 2 Aug 2020, Todd Benivegna wrote: > > > How would you write the SHUTDOWNCMD line with multiple commands? I’ve been > > looking at the manual and see that you have to escape the internal “ but am > > still a little confused on how to do this exactly. > > This assumes that you use the Bash shell in your default environment. It will > need adaption if you use Dash. > > In .bashrc define function getUPSstatus > > # Update variable UPSstatus and export to environment > # Usage getUPSstatus <myups> > function getUPSstatus { > export UPSstatus="[$( upsc $1 ups.status 2>/dev/null )]:$( upsc $1 battery.charge 2>/dev/null )" > } > > The SHUTDOWNCMD declaration now simplifies to > > SHUTDOWNCMD "getUPSstatus <myups> ; logger -t upsmon.conf \"UPS status is $UPSstatus\" ; /sbin/shutdown -h +0" > > Roger > _______________________________________________ > Nut-upsuser mailing list > Nut-upsuser at alioth-lists.debian.net > https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://alioth-lists.debian.net/pipermail/nut-upsuser/attachments/20200803/cb165065/attachment.html>
Roger Price
2020-Aug-04 07:13 UTC
[Nut-upsuser] Synology NAS is shutting down Ubuntu servers after very brief power outage (fwd)
On Mon, 3 Aug 2020, Todd Benivegna wrote:> Thank you! Sorry for another bonehead question…. Do I replace <myups> with > the IP address of the NUT Server/Synology? I’m assuming I would use this > version for use in Dash with Ubuntu, correct?Yes, you replace <myups> with the address of your UPS, for example "ups at 192.168.x.y". Are you using Dash or Bash? If it's Dash, the function getUPSstatus probably goes into .profile . Test on the command line before modifying SHUTDOWNCMD by typing the commands getUPSstatus <myups> echo "UPS status is $UPSstatus" You should see "UPS status is [OL]:100". Roger
Apparently Analagous Threads
- Synology NAS is shutting down Ubuntu servers after very brief power outage (fwd)
- Synology NAS is shutting down Ubuntu servers after very brief power outage (fwd)
- Synology NAS is shutting down Ubuntu servers after very brief power outage (fwd)
- Synology NAS is shutting down Ubuntu servers after very brief power outage (fwd)
- Synology NAS is shutting down Ubuntu servers after very brief power outage (fwd)