$def with (machine, ssh, ls)
$var breadcrumbs = ("machines", "Machines")
$var title: $machine["name"]
$machine["ip_address"]
$ d = machine["details"]
$def render(cmd):
$ output = ssh(cmd).stdout
$if "\n" not in output:
$ output += "\n"
$output.rpartition("\n")[0]
Application
$:render("/home/gaea/runinenv /home/gaea/app python -V")
$:render("du -sh /home/gaea/app")
$:render("ls -lthr /home/gaea/app/run | cut -d' ' -f5-")
Supervisor
$:render("supervisorctl status")
$def render_status(cmd):
$ status = {}
$for line in ssh(cmd).stdout.rpartition("\n")[0].splitlines():
$ key, _, value = line.partition("=")
$ status[key] = value
$status["ActiveState"]
Nginx
$:render_status("systemctl --no-pager show nginx")
Tmux
$:render("tmux list-sessions")
$:render("tmux list-windows -t 0")
System
$:render("df -ht ext4")
$:render("grep 'Invalid user' /var/log/auth.log | cut -d' ' -f8 | sort | uniq -c | sort -r | head")
$# Last updated: $d.get("updated")
$#
$#
$# $if d.get("supervisor"):
$# Supervisor: $d["supervisor"]
$# $else:
$#
$#
$# $if d.get("nginx"):
$# Nginx: $d["nginx"]
$# $else:
$#
$#
$# $if d.get("tor"):
$# Tor: $d["tor"]
$# $else:
$#
$#
$# $if d.get("python"):
$# Python: $d["python"]
$# $else:
$#
$#
$#
$#
$# $if d.get("canopy"):
$# Canopy: $d["canopy"]
$# Identities
$# $#
$# $# $for domain in domains:
$# $# - $domain["name"]
$# $# $domain
$# $#
$#
$# $else:
$#