Home

Awesome

Build GitHub release (with filter) AUR version Github All Releases

ttop

System monitoring tool with historical data service, triggers and top-like TUI

image

Install

Arch/AUR

yay -S ttop             # enables systemd.timers automatically

Static binary (x86-64)

curl -LO https://github.com/inv2004/ttop/releases/latest/download/ttop \
&& chmod +x ttop
mv ttop ~/.local/bin/   # add into PATH if necessary
ttop --on               # Optional: enable data collector in user's systemd.timers or crontab

Uninstall

ttop --off
rm ~/.local/bin/ttop

Build from source

curl https://nim-lang.org/choosenim/init.sh -sSf | sh    # Nim setup from nim-lang.org

git clone https://github.com/inv2004/ttop
cd ttop
nimble -d:release build

Triggers / Notifications

From v0.8.1 you can trigger external tool, for example curl, to send notifications

image

Config example

~/.config/ttop/ttop.toml or /etc/ttop.toml

My own server's config

[[trigger]]
cmd = "$HOME/.local/bin/tel.sh"

Config with all parameters described

# light = false            # set true for light term (default = false)

# refresh_timeout = 1000   # TUI refresh timeout

# docker = "/var/run/docker.sock"   # docker's socket path

# [data]
# path = "/var/log/ttop" # custom storage path (default = if exists /var/log/ttop, else ~/.cache/ttop )

# Trigger is any external script or command which receives text from ttop into stdin + some envs
[[trigger]]              # telegram example
on_alert = true          # execute trigger on alert (true if no other on_* provided)
on_info = true           # execute trigger without alert (default = false)
debug = false            # output stdout/err from cmd (default = false)
cmd = '''
read -d '' TEXT
curl -X POST \
  -H 'Content-Type: application/json' \
  -d "{\"chat_id\": $CHAT_ID, \"text\": \"$TEXT\", \"disable_notification\": $TTOP_INFO}" \
  https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage
'''

# cmd receives text from stdin. The following env vars are set:
#   TTOP_ALERT (true|false) - if alert
#   TTOP_INFO  (true|false) - opposite to alert
#   TTOP_TYPE  (alert|info) - trigger type
#   TTOP_HOST               - host name
# you can find your CHAT_ID by send smth to your bot and run:
#    curl https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/getUpdates

[[trigger]]               # smtp example
cmd = '''
read -d '' TEXT
TEXT="Subject: ttop $TTOP_TYPE from $TTOP_HOST

$TEXT"
echo "$TEXT" | curl --ssl-reqd \
  --url 'smtps://smtp.gmail.com:465' \
  --user 'login:password' \
  --mail-from 'from@gmail.com' \
  --mail-rcpt 'to@gmail.com' \
  --upload-file -
'''