Skip to main content

Claude Prompt for a Disk Space Monitoring Alert System

Create a disk space monitoring script with predictive full-date alerts, automated cleanup actions, inode tracking, and capacity trend reporting.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
Write a Bash disk monitoring system for a production application server running Docker server with / (50GB), /var (200GB), /data (1TB), /tmp (20GB). The system should: 1) Check all mounted filesystems every 15 minutes and alert when usage exceeds 80% (warning) or 90% (critical) via PagerDuty for critical, Slack for warning. 2) Calculate disk usage growth rate over the past 14 days and predict when each filesystem will reach 100% — alert if predicted full date is within 7 days. 3) Identify the top 15 largest directories and files consuming space on filesystems above warning threshold using du with depth limiting to avoid performance impact. 4) Implement automated cleanup actions at critical threshold: remove files matching *.log.gz older than 30 days, core dumps, temp files older than 7 days, truncate old logs, clear package manager caches, and remove old Docker images if applicable. 5) Track inode usage alongside disk space — many small files can exhaust inodes before filling disk. 6) Generate a weekly capacity report in HTML format showing per-filesystem usage trends, growth rates, and predicted capacity dates. 7) Integrate with Prometheus node_exporter textfile collector by outputting metrics in the expected format for dashboard visualization.

What this prompt does

This prompt writes a Bash disk monitoring system for a [server_role] server with [filesystem_layout]. It checks mounted filesystems every [check_interval] minutes, alerts at [warning_threshold]% and [critical_threshold]% via [alert_method], calculates growth over [trend_window] days to predict the full date and warn if within [prediction_alert_days] days, lists the top [top_n] largest directories and files using depth-limited du, runs guarded cleanup of [cleanup_patterns] at critical, tracks inode usage, generates a weekly HTML capacity report, and emits metrics for [monitoring_system].

The variables tune sensitivity and safety. [warning_threshold] and [critical_threshold] set the alert tiers, [trend_window] and [prediction_alert_days] drive the predictive full-date warning, and [cleanup_patterns] defines exactly what automated cleanup may delete. The inode tracking matters because many small files can exhaust inodes before the disk itself fills, a case plain usage graphs miss.

When to use it

  • You want to avoid the avoidable outage of a server filling its disk at 3am
  • Predicting when a filesystem will hit 100% rather than only reacting at full
  • Tracking inode usage alongside disk space for small-file-heavy workloads
  • Reporting the top [top_n] largest directories on filesystems over threshold
  • Adding guarded automated cleanup at the critical threshold
  • Emitting capacity metrics into [monitoring_system] for dashboards

Example output

You get a Bash script that checks each mount in [filesystem_layout], sends tiered alerts via [alert_method], computes growth rate and a predicted full date, lists the largest items with depth-limited du, performs guarded cleanup of [cleanup_patterns] only at critical, reports inode usage, writes a weekly HTML capacity report, and outputs metrics in the format [monitoring_system] expects.

Pro tips

  • Define [cleanup_patterns] conservatively; automated deletion of the wrong pattern is worse than a full disk, so scope it to clearly safe files
  • Set [warning_threshold] low enough to give lead time before [critical_threshold] triggers disruptive cleanup
  • Trust the inode tracking — a filesystem can show plenty of free space yet refuse new files because inodes are exhausted
  • Tune [trend_window] to your workload; too short a window makes the predicted full date jumpy, too long smooths over a sudden spike
  • Keep du depth-limited as the prompt specifies, or scanning a large [filesystem_layout] can itself add I/O load during an incident
  • Route critical alerts through [alert_method] to a channel that pages someone; a warning in a quiet Slack channel will not save a 3am disk-full
  • Schedule the weekly HTML capacity report somewhere people actually read it; trend and growth-rate data only prevents outages if someone acts on it before the predicted full date arrives
  • Set [check_interval] against how fast [filesystem_layout] can fill; a busy /data partition may need tighter checks than /, since a fifteen-minute gap can be too coarse for a fast-growing mount

Frequently Asked Questions

How does it predict when a disk will fill up?
It calculates each filesystem's usage growth rate over the past `[trend_window]` days and extrapolates to estimate when usage reaches 100%. If the predicted full date falls within `[prediction_alert_days]` days, it alerts you, giving lead time to act before the disk actually fills.
Why track inodes separately from disk space?
A filesystem can have free space yet still fail to create files because it has run out of inodes, which happens with workloads that create many tiny files. Tracking inode usage alongside disk space catches this case, which usage-percentage graphs alone completely miss.
Is the automated cleanup safe?
It only runs at the critical threshold and deletes files matching the `[cleanup_patterns]` you define, so safety depends on scoping those patterns conservatively. Deleting the wrong pattern can be worse than a full disk, so the cleanup is meant to target clearly disposable files like old compressed logs and temp files.
Can it feed an existing monitoring stack?
Yes. It outputs metrics in the format your `[monitoring_system]` expects, such as a Prometheus node_exporter textfile collector. This lets the disk data appear on your existing dashboards alongside other host metrics rather than living only in standalone alerts.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Linux & Shell Scripting Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support