# Before a disk fills up.

> Get a push when CPU, RAM, or disk crosses a threshold. Run a quick shell check or forward a Grafana alert and catch a full disk before the server gives out.

<!-- source: https://pocketalert.app/use-cases/resource-usage-alerts -->

Run a small threshold check with df, free, or top, or forward an alert from Grafana or Netdata. When CPU, memory, or disk passes your limit, a push notification arrives on your phone carrying the current value.

## Three steps to resource alerts

1. **Get the CLI or URL** — Install the Pocket Alert CLI, or grab your webhook URL for a curl-based check.
2. **Set a threshold** — Add a threshold check to cron, or forward an alert from your monitoring tool.
3. **Act with runway** — Usage passes the line and your phone buzzes with the value, while you still have runway.

## Warned before the box runs dry

A disk that fills at 3am drags everything down with it. Warn yourself at 85 percent and you still have time to act.

- **One shell check** — A two-line check with df, free, or top pushes when usage passes your limit. Nothing to install.
- **Or your existing tools** — Or forward threshold alerts from Grafana, Netdata, Zabbix, and Prometheus.
- **Usage in the alert** — The message carries the current value and threshold, so you know the urgency and the location.
- **Early thresholds** — Warn at 85% disk or 90% memory and the alert reaches you with time to act.
- **Catch it early** — A full disk or pegged CPU can drop services with no warning. This catches it while time remains.
- **Instant warning** — When a threshold trips, the push arrives. No dashboard to keep open.

## Alert on resource usage

### 1. Install the CLI and authenticate

Download the `pocketalert` binary, drop it on your PATH, and authenticate once with your API key from the dashboard.

```
sudo mv pocketalert /usr/local/bin/ && chmod +x /usr/local/bin/pocketalert
pocketalert auth YOUR_API_KEY
```

### 2. Disk threshold (cron)

Read disk usage with `df` and push only when it crosses 85%.

```
USAGE=$(df / | awk 'NR==2{print $5}' | tr -d %)
[ "$USAGE" -gt 85 ] && pocketalert send \
  -t "Disk ${USAGE}% on /" -m "Free space running low on $(hostname)"
```

### 3. Memory and CPU thresholds

The same pattern works for RAM with `free` and CPU load with `top`.

```
MEM=$(free | awk '/Mem/{printf "%d", $3/$2*100}')
[ "$MEM" -gt 90 ] && pocketalert send -t "Memory ${MEM}% on $(hostname)" -m "High memory pressure"

CPU=$(top -bn1 | awk '/Cpu\(s\)/{printf "%d", 100 - $8}')
[ "$CPU" -gt 90 ] && pocketalert send -t "CPU ${CPU}% on $(hostname)" -m "Sustained high CPU"
```

### 4. Schedule it

Add the script to cron so it runs every five minutes.

```
*/5 * * * * /usr/local/bin/check-resources.sh
```

No CLI? Swap `pocketalert send` for a `curl` POST to the messages API.

```
curl -X POST 'https://api.pocketalert.app/v1/messages' \
  -H 'Token: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"title":"Disk full","message":"Disk over 85% on db-1","level":"critical"}'
```

Already run a monitoring tool? Point a Grafana or Netdata threshold alert at a Pocket Alert webhook instead. The [docs](https://info.pocketalert.app/getting-started.html) cover the rest.

## FAQ

### How do I get resource usage alerts?

Schedule a small check, or forward a threshold alert from Grafana, Netdata, or Zabbix that POSTs to Pocket Alert when CPU, memory, or disk passes a limit. The warning reaches your phone with time to react.

### Can I do this without a monitoring tool?

Yes. A two-line shell check with df, free, or top compares usage against a threshold and pushes only when it trips. No monitoring platform needed.

### Can I see the actual usage?

Put the current value and the threshold in the message, like "Disk 92% on /var". You learn how urgent it is and which mount or process caused it.

### Tooling or a plain script?

Both work. Forward threshold alerts from Grafana, Netdata, Zabbix, or Prometheus, or run a tiny cron check on the box. Pocket Alert takes the push either way.

### How early should I be warned?

Set the threshold below the danger zone, around 85% disk and 90% memory. That leaves enough time to clear space or scale up.

### Can a disk-full alert get through Do Not Disturb?

Yes. Add level=critical to the check that must wake you, say a 95% disk threshold, and Android posts it on a channel that bypasses Do Not Disturb while iPhone shows it as a time-sensitive notification that breaks through Focus. Keep the early 85% warning at the default level so it stays polite.
