#!/bin/sh
POKEMON_NAME=$(hostname)

UPTIME_RAW=$(uptime)
UPTIME=$(echo "$UPTIME_RAW" | sed -n 's/.*up \([^,]*\),\s*[0-9]\+ user.*/\1/p')

if [ -z "$UPTIME" ]; then
    UPTIME=$(echo "$UPTIME_RAW" | awk -F'up ' '{print $2}' | awk -F',' '{print $1}')
fi

MEMORY=$(free | awk '/^Mem:/ {printf "%.0fM/%.0fM", $3/1024, $2/1024}')

DISK=$(df -h / | awk 'NR==2 {print $5}')

LOAD=$(echo "$UPTIME_RAW" | awk -F'load average:' '{print $2}' | sed 's/^ *//')

MESSAGE="$(cat <<EOF
🌟 Status Report 🌟
━━━━━━━━━━━━━━━━━━━━━━━━━━
⏰ Uptime: $UPTIME
🧠 Memory: $MEMORY
💾 Disk: $DISK used
⚡ Load: $LOAD
EOF
)"

echo "$MESSAGE" | pokesay -n "$POKEMON_NAME" -u -w 50
