<div dir="auto">Just a left field idea, is there any way to halt the load process on the Rpi until it can see the NAS is up and running? Then proceed once it can connect. <div dir="auto"><br></div><div dir="auto">The only pi I have messed with is the ones you eat and the button on a calculator.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Nov 22, 2020, 5:05 PM Jim Klimov <<a href="mailto:jimklimov@cos.ru">jimklimov@cos.ru</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On November 22, 2020 6:56:28 PM UTC, "Kevin P. Fleming" <<a href="mailto:kevin@km6g.us" target="_blank" rel="noreferrer">kevin@km6g.us</a>> wrote:<br>
>Here's my situation:<br>
><br>
>APC Smart-UPS 750 powering a rack of equipment. Rack includes a NAS<br>
>(Debian-based) which is connected to the USB port of the UPS and is<br>
>happily running NUT. Rack also includes a router, switch, and various<br>
>other devices, including some Raspberry Pi computers which use the NAS<br>
>as their storage (via NFS) and are powered via PoE (from the switch).<br>
><br>
>When NUT tells the UPS to shut down, that of course will remove power<br>
>from everything in the rack. When mains power returns, the UPS will<br>
>apply power to everything in the rack. However, I *don't* want power<br>
>applied to the RPis, because the NAS takes quite some time (60-90<br>
>seconds) to fully boot, and they won't come up properly if they try<br>
>too early.<br>
><br>
>In addition, there is another RPi in another location, not connected<br>
>to this UPS, but which also uses the NAS as its file storage and thus<br>
>must be shut down if the NAS goes down.<br>
><br>
>At this point I have NUT running on all the systems, and they all<br>
>cleanly shut down when the UPS is heading into 'low battery' mode.<br>
>What I would like to additionally do is send commands to my network<br>
>switches to 'turn off the outlets' for the RPis (disable PoE on the<br>
>ports) as each one disconnects from the NUT master. I can do this over<br>
>SSH quite easily, if I can figure out a way to trigger the SSH command<br>
>to be executed.<br>
><br>
>I can also add commands to enable these ports in the NAS startup<br>
>sequence, at a point late enough for it to be safe.<br>
><br>
>So, the question is: is it possible on the NUT master to trigger a<br>
>command to be run when a slave disconnects? If so, I'd check the "FSD"<br>
>flag at that moment, and if the FSD flag is set then that means the<br>
>power is being shut down, so I should disable the PoE port for that<br>
>slave.<br>
><br>
>I'll also need some way to turn the port back on if NUT entered FSD<br>
>mode but then didn't actually shut down (due to mains power returning<br>
>before the shutdown sequence was completed), so that I don't leave the<br>
>RPis shut down.<br>
><br>
>_______________________________________________<br>
>Nut-upsuser mailing list<br>
><a href="mailto:Nut-upsuser@alioth-lists.debian.net" target="_blank" rel="noreferrer">Nut-upsuser@alioth-lists.debian.net</a><br>
><a href="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser" rel="noreferrer noreferrer" target="_blank">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser</a><br>
<br>
>From a NUT perspective, I think it could be interesting to add drivers that abstract a PoE switch as an ePDU (maybe separate facades for SSH or serial-OOB or SNMP with write access, but same core).<br>
<br>
Possibly ports' power and comms can be turned off/on separately at least on some vendors, which may need separate commands on ePDU shim side. Maybe you'd have to save switch config for ports to stay down after reboot. Otherwise it may make sense to put the switch onto a separately manageable outlet group of the UPS so you can turn that one on sone time after total boot by server command or after a delay counted by UPS itself.<br>
<br>
NFS is quite a sturdy protocol, at least was in original Sun implementation; we had it running cross-continent over VPN with systems rebooting sometimes (server should persist state somehow though). On the remote RPi's you may want to play with client mount options like 'nointr' and/or 'hard' effectively so client processes would freeze on I/O requests until server becomes functional again. A common (and maybe default now) setup may be an opposite of that, to allow for timeouts and application-driven fault handling.<br>
<br>
I don't think upsd currently has a way to call detailed shutdown logic, other than what you specify in SHUTDOWN_CMD - which may be a script, that does the complex logic of tracking accessibility and shutdowns for RPi's, and eventually (all clients down, timeout, UPS charge too low, ...) tells the NFS server and UPS to go down.<br>
<br>
Given Debian and systemd, you might define a template to make unit instances (like rpi-power@13.service) that would power on a port named by that instance when started, power off when stopped, and as Pre*Exec methods might check if the client is alive. Maybe some systemd versions have a more explicit health monitoring framework. That is easy to pluck into dependency chains (start after NUT and NFS, stop before them).<br>
<br>
Typical stance for FSD is that it is a "forced shut down" (and often forced externally as a flag raised by UPS by its policy) - once started, you should not abort it leaving systems in undefined midway state. So whatever happens to power, you go down and reboot cleanly. Frameworks like systemd or SMF do take some unpredictability out, but on a distributed rack you'd still have to design very carefully to abort a shutdown (change of runlevel if it is not too late, and maybe make upsd - or even a depleted UPS - believe the state of FSD is no longer relevant so it does not trigger another shutdown) and start all stuff in order.<br>
<br>
Hope this helps,<br>
Jim Klimov<br>
<br>
--<br>
Typos courtesy of K-9 Mail on my Android<br>
<br>
_______________________________________________<br>
Nut-upsuser mailing list<br>
<a href="mailto:Nut-upsuser@alioth-lists.debian.net" target="_blank" rel="noreferrer">Nut-upsuser@alioth-lists.debian.net</a><br>
<a href="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser" rel="noreferrer noreferrer" target="_blank">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser</a></blockquote></div>