verifying a given jail is running
- Reply: Miroslav Lachman : "Re: verifying a given jail is running"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 18 Aug 2021 16:21:28 UTC
Hello, I want a script to verify a given jail is running. I think I have a rather simple solution but I'm presenting what I tried as I went along. I have a Nagios script for monitoring that a given jail is running: https://git.langille.org/dvl/nagios/src/branch/master/check_freebsd_jails I found that via a search, made some improvements, and I'm now using it in production. It seems to be low-overhead: $ time /usr/local/libexec/nagios-custom/check_freebsd_jails freshports Jail freshports (10.55.0.37) is running under JID 156 in /jails/freshports real 0m0.025s user 0m0.011s sys 0m0.017s I could easily invoke that from within my scripts. I then thought: why not jexec? $ time sudo jexec freshports date Wed Aug 18 15:23:25 UTC 2021 real 0m0.029s user 0m0.013s sys 0m0.003s Roughly the same time. Next to try was: $ time jls -j freshports JID IP Address Hostname Path 156 10.55.0.37 freshports /jails/freshports real 0m0.003s user 0m0.000s sys 0m0.005s That's much faster, not that speed is really relevant here. I could use it like this in a shell script. jls -j freshports > /dev/null 2>&1 if [ $? = 0 ] ; then echo jail is running else echo jail is not running fi The main reason I need this: Verifying the jail is running before continuing with a script. Thank you. -- Dan Langille dan@langille.org