# Resource Usage Monitoring Guide

> 💡 **Why monitor resources?**\
> Monitoring helps you **detect problems early**, optimize performance, and plan for scaling.

***

### Key Metrics to Monitor

| Resource         | Metric Example                      | Why It Matters                       |
| ---------------- | ----------------------------------- | ------------------------------------ |
| **CPU**          | Load average, process utilization   | Detect overload or runaway processes |
| **Memory (RAM)** | Used vs. free memory                | Prevent crashes due to memory leaks  |
| **Disk**         | Space usage, IOPS, read/write speed | Avoid downtime from full disks       |
| **Network**      | Bandwidth, packet loss, latency     | Identify bottlenecks or DDoS attacks |

***

### Step 1: Monitoring CPU Usage

#### Check Load Average

```bash
uptime
```

Output example:

```
16:22:07 up 10 days,  3:44,  2 users,  load average: 0.25, 0.40, 0.35
```

* **1 minute, 5 minutes, 15 minutes average load**
* If load > CPU cores, server may be overloaded.

#### Real-Time CPU Monitoring

```bash
htop
```

Interactive tool showing per-core usage and top processes.

> ⚠️ **Warning**\
> If your CPU usage is consistently above 80%, consider **optimizing applications or upgrading resources**.

***

### Step 2: Monitoring Memory Usage

#### Check Memory Stats

```bash
free -h
```

Output:

```
              total        used        free      shared  buff/cache   available
Mem:           8.0G        2.1G        3.2G        256M        2.7G        5.4G
```

#### Real-Time Memory Usage

```bash
vmstat 2
```

Updates memory and swap usage every 2 seconds.

***

### Step 3: Monitoring Disk Usage

#### Check Disk Space

```bash
df -h
```

Shows available and used space:

```
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       80G   40G   36G  53% /
```

#### Find Large Directories

```bash
du -sh * | sort -h
```

Lists directories by size in current path.

#### Disk I/O Monitoring

```bash
iostat -xz 1
```

Displays read/write performance and bottlenecks.

> 💡 **Tip**\
> Keep at least **20% disk space free** to avoid fragmentation and performance issues.

***

### Step 4: Monitoring Network Usage

#### Check Bandwidth in Real-Time

```bash
iftop
```

Shows incoming and outgoing traffic by IP.

#### Check Network Errors

```bash
netstat -i
```

Displays dropped packets and errors.

#### Advanced Monitoring

```bash
nload
```

Visual interface showing bandwidth usage.

***

### Step 5: Using Monitoring Tools

For ongoing monitoring, install tools for visibility:

| Tool         | Function                       |
| ------------ | ------------------------------ |
| `htop`       | CPU, memory usage in real time |
| `iotop`      | Disk I/O usage                 |
| `iftop`      | Bandwidth monitoring           |
| `glances`    | All-in-one resource monitor    |
| `fastnetmon` | DDoS detection                 |

Example install (Ubuntu/Debian):

```bash
sudo apt install htop iotop iftop glances
```

***

### Step 6: Advanced Monitoring with Prometheus + Grafana

For long-term tracking and visualization:

1. Install **Prometheus** on your server.
2. Use **Node Exporter** to collect metrics.
3. Connect Prometheus to **Grafana**.
4. Create dashboards for CPU, RAM, disk, and network usage.

> 🚀 **Pro Tip**\
> Clouduxe offers **preconfigured Grafana dashboards** for real-time monitoring of your VPS.

***

### Step 7: Setting Alerts

Monitoring is incomplete without alerts.

Use **Prometheus Alertmanager** or third-party tools (like UptimeRobot, PagerDuty) to notify you when thresholds are exceeded.

Example thresholds:

* CPU > 90% for 5 minutes
* Memory usage > 80%
* Disk usage > 85%
* Network packet loss > 5%

***

### Troubleshooting High Resource Usage

| Issue                | Possible Solution                   |
| -------------------- | ----------------------------------- |
| High CPU load        | Check processes with `top` / `htop` |
| Memory leak          | Restart service, optimize code      |
| Disk usage at 100%   | Delete logs, rotate backups         |
| High network traffic | Check for DDoS, use firewall rules  |

***

### Conclusion

Monitoring **resource usage** is a critical part of server management. By regularly checking CPU, memory, disk, and network utilization, you can:

* Detect issues before they become critical
* Optimize server performance
* Plan scaling efficiently
* Protect against attacks

> ✅ **Next Step**\
> Integrate monitoring into your **Clouduxe VPS Hosting** to get proactive alerts and insights.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clouduxe.com/vps-and-dedicated-servers/resource-usage-monitoring-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
