Files
troupe-standup/wizard-work/spark/disk-check.sh
T

34 lines
999 B
Bash

#!/bin/bash
# Disk usage checker with JSON output
# Verifies actual disk usage via stat
OUTPUT_DIR="/root/.hermes/wizard-outputs/spark"
# Get disk usage
TOTAL=$(df -B1 / | awk 'NR==2 {print $2}')
USED=$(df -B1 / | awk 'NR==2 {print $3}')
FREE=$(df -B1 / | awk 'NR==2 {print $4}')
USED_PCT=$(df -B1 / | awk 'NR==2 {print $5}')
# Get Python version
PY_VER=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}')" 2>/dev/null || echo "python3 not available")
# Get home directory size
HOME_SIZE=$(du -sb $HOME 2>/dev/null | cut -f1 || echo 0)
HOME_SIZE_MB=$(echo "scale=2; $HOME_SIZE / 1048576" | bc 2>/dev/null || echo "0")
# Output JSON
cat <<EOF
{
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"root_disk": {
"total_bytes": $TOTAL,
"used_bytes": $USED,
"free_bytes": $FREE,
"used_percent": "$USED_PCT"
},
"home_size_bytes": $HOME_SIZE,
"python_version": "$PY_VER",
"status": "verified_actual_df_output"
}
EOF