jstatus — Service Monitoring for FreeBSD Bastille Jails

jstatus is a lightweight shell utility that provides an at-a-glance overview of all Bastille jails and their enabled services on a FreeBSD host.

It automatically discovers jails and services without requiring configuration.

Key Features

  • Automatic discovery: Detects all Bastille jails and enabled services dynamically.
  • Zero dependencies: Written in POSIX sh; requires only FreeBSD base utilities and Bastille.
  • Service monitoring: Checks whether enabled daemon services are running.
  • Color-coded status: Quickly identifies healthy, partially failed, and stopped jails.
  • Script integration: Returns exit code 0 for healthy systems and 1 when failures are detected.
  • Flexible filtering: Monitor all jails or select specific ones.

Status Indicators

StatusMeaning
UPJail running; all monitored services healthy.
WARNJail running; one or more services failed.
DOWNJail stopped despite being configured to start.
STOPPEDJail intentionally stopped (boot="off").

Example output:

calendar UP 4/4 services
db UP 3/3 services
llama STOPPED (boot=off)
mail WARN 8/9 services
KO: dovecot
minecraft-bedrock UP 4/4 services
webmail DOWN

Installation and Usage

Install:

install -m 755 jstatus /usr/local/sbin/jstatus

Run as root:

jstatus # Check all jails
jstatus mail db # Check specific jails

Use in automation:

jstatus && echo "all good"

How It Works

  1. Retrieves the jail list using bastille list jail.
  2. Checks jail state using jls.
  3. Identifies enabled services using service -e inside each running jail.
  4. Excludes services marked nojail and most one-shot startup scripts.
  5. Executes each daemon’s status command and evaluates its exit code.
  6. Reports failed services without parsing their output.

Configuration

All configuration is optional.

VariableDefault / Purpose
JSTATUS_IGNOREnewsyslog; services to exclude
JSTATUS_BASTILLE_CONF/usr/local/etc/bastille/bastille.conf
JSTATUS_JAILSDIRRead from Bastille configuration
NO_COLORDisables colored output

Known Limitations

  • Process checks only: Does not verify ports, network connectivity, or application responsiveness.
  • Service detection: May miss daemons without recognized rc-script variables.
  • Status reliability: Depends on the correctness of each service’s status command.
  • One-shot scripts: Some may require manual exclusion.
  • FreeBSD-specific: Does not support Linux-compatibility jails.
  • Bastille dependency: Relies on Bastille’s configuration layout.

Compatibility and License

  • Tested on FreeBSD 14.5 with Bastille.
  • Written entirely in POSIX shell.
  • Licensed under BSD 2-Clause.
  • Repository: Creep29257/jstatus on GitHub.

https://github.com/Creep29257/jstatus

,

Leave a Reply

Discover more from /root

Subscribe now to keep reading and get access to the full archive.

Continue reading