{"skill":{"slug":"diskmon","displayName":"Diskmon","summary":"Watch disk space in real time and alert before storage runs low. Use when monitoring usage, finding large dirs, preventing disk-full events.","description":"---\nname: DiskMon\ndescription: \"Watch disk space in real time and alert before storage runs low. Use when monitoring usage, finding large dirs, preventing disk-full events.\"\nversion: \"2.0.0\"\nauthor: \"BytesAgain\"\nhomepage: https://bytesagain.com\nsource: https://github.com/bytesagain/ai-skills\ntags: [\"disk\",\"storage\",\"monitor\",\"space\",\"cleanup\",\"filesystem\",\"admin\",\"devops\"]\ncategories: [\"System Tools\", \"Utility\"]\n---\n\n# DiskMon\n\nA sysops toolkit for scanning, monitoring, reporting, alerting, tracking top usage, checking health, fixing issues, cleaning up, backing up, restoring, logging, benchmarking, and comparing disk-related operations — all from the command line with full history tracking.\n\n## Commands\n\n| Command | Description |\n|---------|-------------|\n| `diskmon scan <input>` | Record and review disk scan entries (run without args to see recent) |\n| `diskmon monitor <input>` | Record and review monitoring entries |\n| `diskmon report <input>` | Record and review report entries |\n| `diskmon alert <input>` | Record and review alert entries |\n| `diskmon top <input>` | Record and review top-usage entries |\n| `diskmon usage <input>` | Record and review usage entries |\n| `diskmon check <input>` | Record and review health check entries |\n| `diskmon fix <input>` | Record and review fix entries |\n| `diskmon cleanup <input>` | Record and review cleanup entries |\n| `diskmon backup <input>` | Record and review backup entries |\n| `diskmon restore <input>` | Record and review restore entries |\n| `diskmon log <input>` | Record and review log entries |\n| `diskmon benchmark <input>` | Record and review benchmark entries |\n| `diskmon compare <input>` | Record and review comparison entries |\n| `diskmon stats` | Show summary statistics across all log files |\n| `diskmon export <fmt>` | Export all data in JSON, CSV, or TXT format |\n| `diskmon search <term>` | Search across all logged entries |\n| `diskmon recent` | Show the 20 most recent activity entries |\n| `diskmon status` | Health check — version, data dir, entry count, disk usage |\n| `diskmon help` | Show usage info and all available commands |\n| `diskmon version` | Print version string |\n\nEach data command (scan, monitor, report, etc.) works in two modes:\n- **With arguments:** Logs the input with a timestamp and saves to the corresponding `.log` file\n- **Without arguments:** Displays the 20 most recent entries from that command's log\n\n## Data Storage\n\nAll data is stored locally in `~/.local/share/diskmon/`. Each command writes to its own log file (e.g., `scan.log`, `monitor.log`, `alert.log`). A unified `history.log` tracks all activity across commands with timestamps.\n\n- Log format: `YYYY-MM-DD HH:MM|<input>`\n- History format: `MM-DD HH:MM <command>: <input>`\n- No external database or network access required\n\n## Requirements\n\n- Bash 4+ (uses `set -euo pipefail`)\n- Standard POSIX utilities: `date`, `wc`, `du`, `head`, `tail`, `grep`, `basename`, `cat`\n- No root privileges needed\n- No API keys or external dependencies\n\n## When to Use\n\n1. **Tracking disk space trends over time** — Use `diskmon monitor` and `diskmon usage` to log periodic disk space readings across servers, building a historical record you can search and export\n2. **Setting up alert documentation** — Use `diskmon alert` to record threshold breaches and disk-full warnings, creating a searchable incident history\n3. **Documenting cleanup and maintenance** — Use `diskmon cleanup` and `diskmon fix` to keep timestamped logs of what was cleaned, freed, or repaired on which systems\n4. **Benchmarking storage performance** — Use `diskmon benchmark` and `diskmon compare` to log I/O test results and compare performance across different disks or configurations\n5. **Generating audit-ready exports** — Use `diskmon export json` to produce a structured file of all logged monitoring activity for capacity planning, compliance reviews, or team handoff\n\n## Examples\n\n### Log a scan and review history\n\n```bash\n# Record a scan result\ndiskmon scan \"/dev/sda1: 78% used, 45GB free\"\n\n# View recent scan entries\ndiskmon scan\n```\n\n### Monitor, alert, and report workflow\n\n```bash\n# Log a monitoring observation\ndiskmon monitor \"web-server-01 /var at 91% — nearing threshold\"\n\n# Log an alert\ndiskmon alert \"CRITICAL: /data at 98% on prod-db-02\"\n\n# Generate a report entry\ndiskmon report \"Weekly disk report: 3 servers above 85% threshold\"\n\n# Search across all entries\ndiskmon search \"prod-db\"\n```\n\n### Cleanup and fix tracking\n\n```bash\n# Log a cleanup action\ndiskmon cleanup \"Purged 15GB of old logs from /var/log on app-server-03\"\n\n# Log a fix\ndiskmon fix \"Extended /home LVM volume by 20GB on dev-server\"\n\n# View recent activity\ndiskmon recent\n```\n\n### Export and statistics\n\n```bash\n# Summary stats across all log files\ndiskmon stats\n\n# Export everything as JSON\ndiskmon export json\n\n# Export as CSV for spreadsheet analysis\ndiskmon export csv\n\n# Health check\ndiskmon status\n```\n\n### Backup, restore, and benchmark\n\n```bash\n# Log a backup\ndiskmon backup \"Snapshot of /data volume taken at 03:00 UTC\"\n\n# Log a restore test\ndiskmon restore \"Verified restore of /etc from snapshot-2025-03-15\"\n\n# Log a benchmark result\ndiskmon benchmark \"Sequential write: 480 MB/s on /dev/nvme0n1\"\n\n# Compare two benchmark runs\ndiskmon compare \"nvme0n1 vs sda: 480 MB/s vs 210 MB/s sequential write\"\n```\n\n## How It Works\n\nDiskMon uses a simple case-dispatch architecture in a single Bash script. Each command maps to a log file under `~/.local/share/diskmon/`. When called with arguments, the input is appended with a timestamp. When called without arguments, the last 20 lines of that log are displayed. The `stats` command aggregates entry counts across all logs, `export` serializes everything into JSON, CSV, or plain text, and `search` greps across all log files for a given term.\n\n## Support\n\n- Website: [bytesagain.com](https://bytesagain.com)\n- Feedback: [bytesagain.com/feedback](https://bytesagain.com/feedback)\n- Email: hello@bytesagain.com\n\n---\n\n*Powered by BytesAgain | bytesagain.com | hello@bytesagain.com*\n","topics":["Disk","Space","Storage","Admin","Cleanup"],"tags":{"latest":"2.0.1"},"stats":{"comments":0,"downloads":729,"installsAllTime":27,"installsCurrent":2,"stars":0,"versions":8},"createdAt":1773530769454,"updatedAt":1778491913988},"latestVersion":{"version":"2.0.1","createdAt":1773830487651,"changelog":"update","license":"MIT-0"},"metadata":{"setup":[],"os":null,"systems":null},"owner":{"handle":"ckchzh","userId":"s1722v35hsq964bw64ecjw43z583fbex","displayName":"BytesAgain2","image":"https://avatars.githubusercontent.com/u/44366898?v=4"},"moderation":null}