Monitoring a Linux Virtual Private Server (VPS) is an important part of server maintenance. It helps you keep your server running smoothly, identify security issues, and prevent unexpected downtime.
Without regular monitoring, you may only notice problems when your website becomes unavailable or your applications stop working.
In this article, we'll cover the most important things to monitor on a Linux VPS and the commands you can use to check them.
1. CPU Usage
The CPU runs applications and processes tasks on your server. If CPU usage remains high for a long time, your server may become slow or unresponsive.
What should you monitor?
Overall CPU usage.
CPU usage by individual processes.
CPU steal time.
Server load average.
To check CPU usage and running processes in real time, use the following command:
top
To check the server load average, use:
uptime
This command shows how long your server has been running and its average system load over the last 1, 5, and 15 minutes.
On a VPS, it is also worth checking CPU steal time. High CPU steal time may indicate that other virtual servers on the same physical server are competing for CPU resources.
2. RAM Usage
RAM is used by the operating system, applications, and other running processes. If your server runs out of available RAM, applications may become slower, stop working, or be terminated by the operating system.
What should you monitor?
Used and available RAM.
Swap memory usage.
Memory usage by individual processes.
Out-of-memory (OOM) events.
To check RAM usage, use:
free -h
The -h option makes the displayed information easier to read.
To find the processes that use the most RAM, use:
ps aux --sort=-%mem | head -n 11
Keep in mind that high RAM usage does not always mean there is a problem. Linux uses unused RAM to cache data and improve performance. Therefore, you should pay more attention to available memory than free memory.
3. Disk Space
Over time, files, databases, logs, and backups can take up a large amount of disk space. If your server runs out of disk space, applications may stop working, and you may be unable to install updates or save new files.
What should you monitor?
Used and available disk space.
Disk space used by directories.
Log file growth.
Inode usage.
Disk space used by backups.
To check disk space usage, use:
df -h
To check how much disk space system logs are using, use:
du -sh /var/log
To check inode usage, use:
df -i
Inodes store information about files and directories. If your server runs out of available inodes, you may be unable to create new files, even if there is enough free disk space.
4. Disk Performance
Having enough free disk space does not always mean that your storage is performing well. Slow disk performance can affect websites, databases, and other applications that frequently read or write data.
What should you monitor?
Disk read and write speeds.
Disk input/output (I/O) operations.
Disk latency.
I/O wait time.
This command displays detailed disk performance information and updates it every two seconds.
The iostat command is included in the sysstat package, which may not be installed on your server by default.
5. Network Usage
Monitoring network usage helps you identify connection problems, unusual traffic, and possible security threats.
What should you monitor?
Incoming and outgoing traffic.
Bandwidth usage.
Network latency.
Packet loss.
Unexpected network connections.
To check network interface statistics, use:
ip -s link
To check active TCP and UDP connections, use:
ss -tun
To check network connectivity, latency, and packet loss, use:
ping -c 5 1.1.1.1
An unexpected increase in network traffic may be caused by more website visitors, incorrectly configured applications, or malicious activity.
6. Server Uptime and Availability
It is important to know whether your server and the services running on it are available. Unexpected downtime can affect your website, applications, and customers.
What should you monitor?
Server uptime.
Unexpected server restarts.
Website availability.
Service response times.
Network connectivity.
To check how long your server has been running, use:
uptime -p
To check the recorded server restart history, use:
last reboot
To check whether a website responds to HTTP requests, use:
curl -I https://example.com
Replace example.com with your actual domain name.
It is also recommended to use an external monitoring service. If your VPS goes offline, monitoring tools running on the same server may also become unavailable.
7. Running Processes and Services
Depending on what you host on your VPS, you may have several services running in the background. If one of these services stops working, it can affect your website or application.
What should you monitor?
Web servers.
Database servers.
SSH service.
Failed system services.
Processes using too many server resources.
To check for failed services on Linux distributions using systemd, use:
systemctl --failed
To check the status of a specific service, such as Nginx, use:
systemctl status nginx
To find the processes that use the most CPU resources, use:
ps aux --sort=-%cpu | head -n 11
Regularly checking running services and processes can help you identify problems before they affect your applications.
8. System and Application Logs
Linux and its applications generate logs that contain information about various events. These logs can help you understand why something is not working correctly.
What should you monitor?
System errors.
Application errors.
Authentication logs.
Kernel messages.
Service failures.
To check system errors recorded during the last 24 hours, use:
journalctl -p err --since "24 hours ago"
To view new system log entries in real time, use:
journalctl -f
To check journal logs related to a specific service, such as Nginx, use:
journalctl -u nginx
Checking logs regularly can help you find recurring errors and identify problems early.
9. Security Events
Linux servers connected to the internet are often targeted by automated attacks. Monitoring security events can help you identify suspicious activity and possible unauthorized access.
What should you monitor?
Failed SSH login attempts.
Unexpected successful logins.
Unknown user accounts.
Unexpected open ports.
Firewall activity.
Changes to important system files.
To check the recorded successful login history, use:
last
To check recorded failed login attempts, use:
sudo lastb
To check listening TCP and UDP ports and the processes using them, use:
sudo ss -tulnp
If you notice unfamiliar login activity, unknown processes, or unexpected open ports, you should investigate them further.
10. System Updates
Outdated software may contain security vulnerabilities. Regularly checking for available updates helps keep your server secure and stable.
What should you monitor?
Available security updates.
Outdated software packages.
Operating system end-of-life dates.
Pending system restarts.
On Debian and Ubuntu-based Linux distributions, you can check for available updates using:
sudo apt update
apt list --upgradable
On AlmaLinux, Rocky Linux, and other DNF-based distributions, use:
dnf check-update
These commands allow you to check for available updates without installing them. The apt update command refreshes the local package information.
11. Backups
Creating backups is important, but you should also make sure they are created successfully and can be used when needed.
A failed backup may go unnoticed until you need to recover your data.
What should you monitor?
Backup completion status.
Date of the last successful backup.
Available backup storage space.
Backup restoration test results.
The commands used to check backup status and integrity depend on your backup solution. It is also recommended to test your backups periodically to ensure your data can be restored.
Popular Linux VPS Monitoring Tools
Although you can monitor your Linux VPS manually using various commands, checking everything manually can take a lot of time.
Dedicated monitoring tools can collect information automatically, display historical data, and send notifications when something goes wrong:
top - CPU, RAM, and process monitoring
htop - Interactive server resource monitoring
free - RAM usage monitoring
df - Disk space monitoring
iostat - Disk performance monitoring
journalctl - System log monitoring
Netdata - Real-time server monitoring
Zabbix - Server and infrastructure monitoring
Prometheus - Metrics collection and alerting
Grafana - Monitoring dashboards and data visualization
Conclusion
Regular monitoring is an important part of managing a Linux VPS. It helps you understand how your server is performing and identify potential problems before they become more serious.
While monitoring CPU, RAM, disk space, and network usage is important, don't forget security events, system updates, backups, and running services.
You can use Linux commands to check your server manually or use dedicated monitoring tools to automate the process and receive notifications when problems occur.
It is always better to identify a problem early than to deal with unexpected downtime.
