1

Is there an easy way to warn an admin on shutdown, reboot, poweroff, halt, ... about:

  • ongoing computations (high load, high disk io)
  • open bash / zsh / ... terminal sessions
  • other logged in users
  • screen / tmux sessions

I'm looking for a solution that will support admins to not accidentally bin a lot of work.

Setting: Co-operative environment (15 users, all know each other). We use a shared server with multiple users and admins. Many users do long calculations in screen / tmux sessions. Even though admins should know better, it happens from time to time that they reboot the machine and accidentally disturb ongoing work of logged in users.

Jörn Hees
  • 123
  • 8
  • Why it is required to reboot server from time to time? Isn't it stable enough? You may need to reboot a server for example when applying a kernel patch. Other software updates and configuration should not mandate server reboot! – Khaled Jan 26 '17 at 14:15
  • we reboot them just for fun ;)... yes, kernel updates, even though one could in theory do them without along the lines of liveupdate, ksplice, kpatch... (offtopic here though) – Jörn Hees Jan 26 '17 at 16:19
  • This does not require a technological solution. I think it's a people issue. Communicate downtime windows and be more judicious about your reboot schedule. – ewwhite Feb 05 '17 at 14:41
  • 1
    i agree... sadly there were constellations where this communication failed :(. Hence, i'm asking for a tech support solution, that will actually make an admin very aware of what he's doing. – Jörn Hees Feb 05 '17 at 14:46

1 Answers1

1

There's a debian package called molly-guard. It asks you to type in the hostname so you don't accidentally shutdown the wrong machine. By default this is only switched on for SSH connections, but you can set ALWAYS_QUERY_HOSTNAME=true in /etc/molly-guard/rc so it always asks.

Also, to make the admin aware of what's going on, we added the following /etc/molly-guard/run.d/20-own-warning file:

#! /bin/bash

echo
echo "current logins: w:"
w
echo
echo "current logins: who:"
who
echo
echo "current open terminals: ps aux | grep -E '(bash)|(zsh)'"
ps aux | grep -E '(bash)|(zsh)'
echo
echo
echo "Before shutdown/reboot, please contact all of the above users!!!"
echo

exit 0
Jörn Hees
  • 123
  • 8
  • 1
    `molly-guard` runs a series of scripts before prompting for the hostname so it would seem like you could add one to check for the things he mentioned without too much work. – chicks Jan 26 '17 at 14:31
  • edited the answer to include our example, thanks for the pointer – Jörn Hees Feb 05 '17 at 14:06