Skip to content

Instantly share code, notes, and snippets.

@kmwenja
Last active December 17, 2022 14:58
Show Gist options
  • Save kmwenja/8bd5907d8cba9c3e830ae483968b7f06 to your computer and use it in GitHub Desktop.
Save kmwenja/8bd5907d8cba9c3e830ae483968b7f06 to your computer and use it in GitHub Desktop.
Tmux script for active server monitoring
Tmux Script for Active Server Monitoring

Tmux Script for Active Server Monitoring

Starts a tmux session that bootstraps htop, iotop and vmstat.

In detail, starts a tmux session with 4 panes that contain:

  1. htop sorted by PERCENT_CPU
  2. htop sorted by PERCENT_MEM
  3. iotop
  4. vmstat 1

Can reattach to a similarly named session.

Requires

  1. tmux
  2. htop
  3. iotop
  4. sudo powers for iotop

Usage

sh monitor.sh <session name>

#!/bin/sh
tmux new-session -d -A -s $1
tmux split-window -v
tmux select-pane -t 0
tmux split-window -h
tmux select-pane -t 2
tmux split-window -h
tmux select-pane -t 0
tmux send-keys "htop --sort PERCENT_CPU" C-m
tmux select-pane -t 1
tmux send-keys "htop --sort PERCENT_MEM" C-m
tmux select-pane -t 2
tmux send-keys "sudo iotop" C-m
tmux select-pane -t 3
tmux send-keys "vmstat 1" C-m
tmux -2 attach-session -t $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment