> For the complete documentation index, see [llms.txt](https://docs.ititanhosting.ro/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ititanhosting.ro/docs/english/vps/linux/how-to-monitor-vps-resources-with-htop-and-netdata.md).

# How to monitor VPS resources with htop and Netdata

Knowing what is happening on your server is the first step to keeping it healthy. Two tools cover this well: htop for quick terminal checks, and Netdata for real-time dashboards in your browser.

htop is what you use when you SSH in and want to see what is eating your CPU. Netdata is what you leave running in the background and check from your phone or laptop.

### Part 1: htop (quick terminal monitoring)

htop is an improved version of the classic `top` command. It shows processes, CPU usage, memory, and more in a color-coded layout.

#### Install htop

```bash
sudo apt update
sudo apt install htop -y
```

#### Run it

```bash
htop
```

You will see a screen divided into sections:

* CPU usage per core (colored bars at the top)
* Memory and swap usage
* A list of running processes

#### What each color means in htop

The CPU bars show different usage types:

* **Green** - normal user processes
* **Blue** - low-priority processes
* **Red** - kernel processes

#### Keyboard shortcuts

Once htop is running, these are the most useful keys:

| Key        | What it does                               |
| ---------- | ------------------------------------------ |
| F6         | Sort processes (by CPU, memory, etc.)      |
| F9         | Kill a selected process                    |
| F10        | Quit htop                                  |
| Arrow keys | Navigate the process list                  |
| Space      | Highlight a specific process               |
| u          | Show processes for a specific user         |
| t          | Tree view (see parent-child relationships) |

#### Understanding the output

If CPU is at 100%, something is working hard. If memory is nearly full, you might be running out of RAM. If the load average (top left) is higher than the number of CPU cores, your server is struggling.

htop does not save history. It shows you the current moment. For trends over time, use Netdata.

### Part 2: Netdata (real-time monitoring dashboard)

Netdata is a monitoring tool that gives you a web dashboard with live metrics. CPU, RAM, disk, network, running services - it tracks everything and updates every second.

#### Install Netdata

The easiest way is the automatic installer:

```bash
bash <(curl -Ss https://my-netdata.io/kickstart.sh)
```

This detects your OS, installs dependencies, and sets up Netdata as a systemd service. Give it a minute to finish.

#### Verify it is running

```bash
sudo systemctl status netdata
```

You should see "active (running)".

#### Access the dashboard

By default, Netdata listens on port 19999. If UFW is active, allow the port:

```bash
sudo ufw allow 19999/tcp
```

Now open your browser and go to:

```
http://your-server-ip:19999
```

You will see a dashboard with dozens of charts showing every aspect of your server's performance.

#### What the dashboard shows

Scroll through the sections:

* **CPU** - usage per core, interrupts, frequency
* **Memory** - RAM, swap, available memory
* **Disk** - read/write speeds, IO operations
* **Network** - bandwidth per interface
* **Applications** - which processes use the most resources

Each chart updates in real time. Hover over a chart to see exact values at a specific moment.

#### Securing the dashboard

Leaving port 19999 open to the internet is not ideal. You have two options:

**Option A: Use a firewall rule to restrict access**

Allow only your IP:

```bash
sudo ufw allow from YOUR_HOME_IP to any port 19999
```

**Option B: Use an SSH tunnel (more secure)**

Do not open port 19999 at all. Instead, connect from your local machine:

```bash
ssh -L 19999:localhost:19999 root@your-server-ip
```

Then open `http://localhost:19999` in your browser. The traffic goes through the encrypted SSH connection.

#### Netdata configuration file

If you want to tweak settings:

```bash
sudo nano /etc/netdata/netdata.conf
```

Common changes include disabling certain collectors or changing data retention periods. Most people never need to touch this.

### Part 3: Bonus - disk usage check

While htop and Netdata handle most things, disk space is worth checking separately:

```bash
df -h
```

This shows mounted filesystems and how full they are. For a breakdown of what is using the space:

```bash
du -sh /* 2>/dev/null | sort -h
```

### When to use each tool

| Situation                           | Tool              |
| ----------------------------------- | ----------------- |
| Server feels slow right now         | htop              |
| Need to check last week's CPU spike | Netdata history   |
| Debugging a specific process        | htop (tree view)  |
| General health check from phone     | Netdata dashboard |
| Quick SSH check before deploying    | htop              |
| Long-term monitoring                | Netdata           |

### Conclusion

htop and Netdata complement each other well. Use htop for quick checks when you are already in the terminal. Keep Netdata running for continuous monitoring and historical data. Together, they give you full visibility into what your VPS is doing at any moment.
