#!/bin/bash
# sys/h4 - Host management helper
set -e
source "/home/zwelch/src/mcf/mcsh/install/share/mcsh/mcsh.sh"
######
# Native dependencies
h4_client_packages=( iotop iftop )
######
# Host Monitoring CLI
h4_monitor() { cmd_dispatch "$@"; }
h4_monitor_usage() {
cat <<USAGE
<cmd>
Host Monitoring Commands:
all Monitors users, disk, and tasks
users Monitors users
disk Monitors disk space
tasks Monitors processes
Resource Monitoring Commands:
cpu ... Monitors CPU usage
io ... Monitors I/O usage
net ... Monitors network usage
USAGE
}
h4_monitor_users() { run watch 'w'; }
h4_monitor_disk() { run watch 'df -h'; }
h4_monitor_tasks() { run watch 'pstree -u'; }
h4_monitor_all() { run watch 'w; echo; df -h; echo; pstree -u'; }
h4_monitor_cpu() { run top "$@"; }
h4_monitor_io() { run iotop "$@"; }
h4_monitor_net() { run iftop "$@"; }
######
# Host CLI
h4_host() { cmd_dispatch "$@"; }
h4_host_usage() {
cat <<USAGE
<cmd> ...
Host Commands:
upgrade Performs a host-wide upgrade
run ... Run each tool with the given args
Host Command Groups:
client ... Runs client command with each tool
server ... Runs server command with each tool
backup ... Run backup on all tools
restore ... Run restore for all tools
USAGE
}
h4_host_run() { run_each_tool "$@"; }
h4_host_upgrade() {
lib_load 'sys/tool/apt'
apt_upgrade
}
h4_host_client() {
lib_load 'sys/client'
cmd_dispatch "$@"
}
h4_host_client_deps() { host_class_deps client; }
h4_host_client_install() { host_class_install client; }
h4_host_server() {
lib_load 'sys/server'
cmd_dispatch "$@"
}
h4_host_server_deps() { host_class_deps server; }
h4_host_server_install() { host_class_install server; }
######
# Backup CLI
h4_host_backup() {
lib_load 'sys/backup'
cmd_dispatch "$@"
}
h4_host_backup_usage() {
cat <<USAGE
<cmd>
Host Backup Commands:
full ... Run backup on all tools
USAGE
}
h4_host_backup_full() { backup_host full; }
h4_host_restore() {
lib_load 'sys/backup'
cmd_dispatch "$@"
}
h4_host_restore_usage() {
cat <<USAGE
<cmd>
Host Restore Commands:
full ... Run full restore on all tools
USAGE
}
h4_host_restore_full() { restore_host full; }
######
# Main
h4_desc() { echo "Host management helper"; }
h4_usage() {
cat <<USAGE
<cmd> ...
Host Command Groups:
host ... Host management commands
monitor ... Host monitoring commands
USAGE
}
app_run "$@"
Generated on Tue Apr 25 21:19:54 PDT 2017 by mcsh i7 v0.18.0.