Remix.run Logo
dancek 5 days ago

I wrote a quick and dirty bash script that launches a tmux dashboard for a legacy linux server. The team has been happy with it. It does seem like an evolutionary dead end to be honest, but it was very quick to set up.

Note that the dashboard is read-only and mostly just shows journalctl for different units (we use systemd for process management). And we assume it's only used by a single user at once and everything is stopped on detach.

Here's a simplified sample of setting up a 3x2 layout with some placeholder content:

    #!/bin/sh
    set -e

    SESSION=example
    WINDOW=dashboard

    tmux new-session -d -s $SESSION -n $WINDOW "journalctl -fk"
    tmux set-option -t $SESSION -g mouse on

    tmux split-window -h -t $SESSION:$WINDOW "journalctl -fu nginx"
    tmux split-window -h -t $SESSION:$WINDOW "journalctl -fu postgresql"
    tmux select-layout -E

    tmux split-window -v -t $SESSION:$WINDOW "echo '<Ctrl-b d> to detach' && read"
    tmux select-pane -t $SESSION:$WINDOW.0
    tmux split-window -v -t $SESSION:$WINDOW "watch uptime"
    tmux select-pane -t $SESSION:$WINDOW.2
    tmux split-window -v -t $SESSION:$WINDOW "watch df -h"

    tmux attach-session -t $SESSION
    # after detaching, close session
    tmux kill-session -t $SESSION 2>/dev/null || true