#!/bin/bash

echo "System:"
echo "  Uptime:   $(uptime -p | cut -d' ' -f2-) (up since $(uptime -s))"
echo "  Memory:   $(free -h | grep Mem | perl -pe 's/Mem:\s+([\.\w]+)\s+([\.\w]+)\s+([\.\w]+).*/\1 total,
 \2 used, \3 free/')"
echo "  Swap:     $(free -h | grep Swap | perl -pe 's/Swap:\s+([\.\w]+)\s+([\.\w]+)\s+([\.\w]+).*/\1 tota
l, \2 used, \3 free/')"
echo "  Load Avg: $(cat /proc/loadavg | cut -d' ' -f1-3 | perl -pe 's/([\.\d]+) ([\.\d]+) ([\.\d]+)/\1 (a
vg 1 min), \2 (avg 5 min), \3 (avg 15 min)/')"
users=$(w | tail -n +3 | cut -d' ' -f1 | sort | uniq -c | wc -l)
sessions=$(w | tail -n +3 | wc -l)
echo "  Logins:   $users users with $sessions sessions total"
ip=$(ip -4 addr show wan0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
name=$(host $ip | cut -d' ' -f5)
name=${name%?}
echo "  WAN Addr: $ip (hostname $name)"
echo ""