#!/bin/bash

# ------------------------------------------------------------------------
# --- SETUP AND USAGE ----------------------------------------------------
# Run it manually:
# bash /data/www/cgi-bin/ffmpeg-monitor.sh
# - OR -
# http://media.home.lan/convert.html
# ------------------------------------------------------------------------

echo "Content-type: text/html"
echo "Cache-Control: no-cache, no-store, must-revalidate"
echo "Pragma: no-cache"
echo "Expires: 0"
echo ""

# --- OUTPUT
echo "<html><head><title>FFmpeg Monitor</title>"
echo "<style>"
echo "  body{ font-family:monospace; background:#1E2939; color:#FAFAF9; padding:20px; }"
echo "  a{ text-decoration:none; color:#53EAFD; }"
echo "  .button{ display:inline-block; padding:10px; border: 2px solid #53EAFD; font-weight:bold; text-decoration:none; background:#364153; color:#53EAFD; }"
echo "  .green{ color:#05DF72; }"
echo "  .cyan{ color:#38D5BE; }"
echo "  .orange{ color:#FDC745; }"
echo "  .red{ color:#FB2C36; }"
echo "</style>"

echo "</head><body>"

# CPU usage
echo "<h3>CPU Usage:</h3>"
echo "<pre class='cyan'>"
top -n 1 -b | grep "Cpu"
echo "</pre>"

# Memory usage
echo "<h3>Memory Usage:</h3>"
echo "<pre class='cyan'>"
free -h
echo "</pre>"

# Disk space
echo "<h3>Disk Space Usage:</h3>"
echo "<pre class='cyan'>"
df -h
echo "</pre>"

echo "</body></html>"