Linux server monitoring means collecting a few signals from your server (uptime, CPU, memory, disk, network, services and logs), keeping their history, and sending an alert only when someone needs to act. For a single VPS, an external uptime check plus a small script may be enough; for several servers, an open-source stack such as Prometheus with Grafana, Zabbix or Netdata is easier to live with.
This guide shows what to measure, which commands to use when something looks wrong, how to choose a tool and how to set up alerts on a Linux cloud VPS. The commands assume Ubuntu or Debian with sudo access. If you want a routine of recurring tasks such as patching and access reviews, use our weekly and monthly server management checklist alongside this guide.
What linux server monitoring should cover
Work in layers, because each layer catches problems the others miss.
| Layer | What to watch | Typical failure it catches |
|---|---|---|
| External availability | HTTP status, response time, TLS certificate expiry | Server down, firewall mistake, DNS error, expired certificate |
| Host resources | CPU, memory, swap, disk space, inodes, disk latency, network | Full disk, memory leak, overloaded server |
| Services | Web server, database, application, queue workers | A crashed process on a healthy-looking server |
| Scheduled jobs | Backups, cron jobs, certificate renewal | Work that silently stopped weeks ago |
| Logs and security | Errors, kernel messages, logins, sudo use | Out-of-memory kills, disk errors, unexpected access |
The external layer must run somewhere else. A monitoring script on the same VPS cannot report that the VPS is offline. Run at least one check from a different server or an outside service, preferably with a probe location in India if your users are in India. A probe in Europe or the US adds network distance that visitors in India may not experience.
Core metrics and the commands to read them
Learn to read the server directly; you will need these commands during an incident, despite dashboards.
CPU and load
nproc # number of vCPUs
uptime # load average over 1, 5 and 15 minutes
vmstat 5 5 # run queue, swap activity, I/O wait, steal
top # per-process CPU and memory
On Linux, load average counts processes that are running or waiting to run, plus those in uninterruptible sleep, usually waiting on disk. So a high load with low CPU use often points to storage rather than compute. In vmstat, ignore the first line (it is an average since boot). A high wa value means the CPU is waiting for I/O. A persistently high st (steal) value on a virtual machine means your virtual CPUs are waiting for time on the physical host; record it and raise it with your provider.
Memory and swap
free -h
ps aux --sort=-%mem | head -8
sudo journalctl -k | grep -i "out of memory"
Look at the available column in free, not free. Linux uses spare memory as file cache and gives it back when applications need it, so a small "free" figure is normal. Continuous swap-in and swap-out (the si and so columns in vmstat) is a stronger sign of memory pressure than swap space that is merely occupied. The last command shows whether the kernel has killed a process to recover memory.
Disk space, inodes and latency
df -h # space used per filesystem
df -i # inodes used
sudo apt install sysstat
iostat -xz 5 # latency and utilisation per device
A filesystem can run out of inodes while it still has free space, typically when an application creates millions of small session or cache files. In iostat, watch r_await and w_await, the average time in milliseconds for reads and writes. Compare them with your own normal values instead of a universal threshold. Treat %util with care on NVMe and virtual disks: they handle requests in parallel, so a value near 100% does not by itself prove the device is saturated.
Network and listening services
ss -s # socket summary
sudo ss -tulpn # what is listening, and which process
ip -s link # bytes, errors and drops per interface
systemctl --failed # services that have crashed
Compare this list with what you expect. A database or metrics port bound to 0.0.0.0 is reachable on every interface unless a firewall blocks it.
Recent kernels also report how long tasks waited for CPU, memory or I/O in the files under /proc/pressure/. This helps separate the three causes of delay; the kernel PSI documentation explains the fields.
Keep history with sysstat and journald
Most real questions are about the past: what happened at 3 am, or is memory use higher than last month? The sysstat package records that history with little setup. On Ubuntu and Debian, set ENABLED="true" in /etc/default/sysstat, then start it:
sudo systemctl enable --now sysstat
sar -u # CPU today
sar -r # memory today
sar -q # run queue and load
sar -d -p # disk activity (needs disk statistics collection)
Use sar -f with a file under /var/log/sysstat/ to read an earlier day.
For logs, the systemd journal covers most services:
sudo journalctl -p err -b # errors since last boot
sudo journalctl -u nginx --since "1 hour ago"
journalctl --disk-usage
Make sure the journal is persistent (a /var/log/journal directory with Storage=persistent or auto in journald.conf), otherwise entries are lost at reboot. Set a size limit such as SystemMaxUse= so logs cannot fill the disk.
Linux server monitoring tools compared
Choose by the number of servers, the memory you can spare and who will maintain the tool. Each option can be self-hosted at no licence cost in some form; check current licence terms and paid tiers.
| Tool | Good fit | What you maintain |
|---|---|---|
| Shell script plus cron or systemd timer | One small VPS, a handful of checks | The script; there are no graphs |
| Uptime Kuma | External HTTP, TCP and ping checks with notifications | One small app on a separate server; it does not replace host metrics |
| Netdata | Quick, detailed per-server dashboards | An agent on each server, plus any central or cloud setup you choose |
| Prometheus, node_exporter, Grafana, Alertmanager | Several servers, containers, custom application metrics | Four components, storage retention and rule files |
| Zabbix | Teams that want agents, templates, alerting and inventory in one product | A Zabbix server, web interface, database and agents |
Do not run a heavy monitoring server on the machine it is watching if you can avoid it. It competes for the same memory, and it goes down when the server does. A separate small VPS is cleaner for production.
Hosted monitoring services are another route and save maintenance. Before signing up, check where metrics and logs are stored, whether you are billed in INR or a foreign currency, whether you receive a GST invoice, and how the price changes with each extra host or gigabyte of logs.
Set up node_exporter and Prometheus safely
If you choose the Prometheus stack, node_exporter runs on each server and exposes host metrics, by default on port 9100. On Ubuntu or Debian you can install the packaged version:
sudo apt update
sudo apt install prometheus-node-exporter
curl -s http://localhost:9100/metrics | head
The metrics page reveals details about your system and, in a basic installation, asks for no password. Do not leave it open to the internet. If Prometheus runs on the same machine, bind the exporter to localhost in /etc/default/prometheus-node-exporter:
ARGS="--web.listen-address=127.0.0.1:9100"
Then restart it with sudo systemctl restart prometheus-node-exporter. If Prometheus runs elsewhere, use a private network or VPN, or allow port 9100 only from the monitoring server's address:
sudo ufw allow from 203.0.113.10 to any port 9100 proto tcp
Replace the example address with your own, and confirm that the firewall is enabled with a default deny rule for incoming traffic (allow your SSH port first). Protect Grafana, Prometheus and Netdata web ports too. Our VPS security checklist covers firewall and access auditing in more depth.
On the monitoring server, add each host as a target in prometheus.yml:
scrape_configs:
- job_name: node
static_configs:
- targets: ['10.0.0.11:9100', '10.0.0.12:9100']
The official node_exporter guide covers the basics. Grafana then reads from Prometheus as a data source.
Alerts that people act on
An alert should mean that a person needs to do something. If an alert can safely wait until next week, put it on a dashboard or in a daily summary. Use a duration as well as a threshold, so a two-minute spike during a backup does not wake anyone. These are starting points, not standards; tune them against a few weeks of your own data.
| Condition | Starting point | First action |
|---|---|---|
| Website or API unreachable | Two or more failed external checks in a row | Check from a second network, then the server console |
| Disk space | Warn at 80%, urgent at 90% | Find the largest directories; check logs and old dumps |
| Available memory | Below 10% for 10 minutes | Identify the process; look for OOM messages |
| CPU | Above 85% for 15 minutes | Check traffic, runaway processes and recent deploys |
| CPU steal | Above 10% for 15 minutes | Record graphs and contact the provider |
| TLS certificate | Fewer than 14 days remaining | Test renewal and read its log |
| Backup job | No success signal within its expected window | Run it manually and verify the output |
In Prometheus, rules for a missing target and a filling disk look like this:
groups:
- name: host
rules:
- alert: HostDown
expr: up{job="node"} == 0
for: 3m
- alert: DiskAlmostFull
expr: |
100 * (1 - node_filesystem_avail_bytes{fstype=~"ext4|xfs"}
/ node_filesystem_size_bytes{fstype=~"ext4|xfs"}) > 80
for: 10m
Add the file under rule_files and validate it with promtool check rules. Prometheus evaluates the rules, but you need Alertmanager (or Grafana's alerting) configured with email, chat or another channel before anything reaches you. Send a test alert end to end, and repeat the test after any change to notification settings.
A small alert script for a single VPS
#!/bin/sh
# /usr/local/bin/health-check.sh
DISK=$(df --output=pcent / | tail -1 | tr -dc '0-9')
MEM=$(awk '/MemTotal/ {t=$2} /MemAvailable/ {a=$2} END {printf "%d", a*100/t}' /proc/meminfo)
[ "$DISK" -ge 80 ] && echo "$(hostname): root disk ${DISK}% used"
[ "$MEM" -le 10 ] && echo "$(hostname): only ${MEM}% memory available"
systemctl is-active --quiet nginx || echo "$(hostname): nginx is not active"
exit 0
Make it executable and run it every five minutes from cron. Change nginx to the services you actually run. Cron can email any output if the server has a working mail transfer setup and MAILTO is set; many fresh VPS images do not, so test it, or send the output to a webhook you control. This script has no memory of earlier runs, so it repeats the message until the problem is fixed and does not apply a duration.
Monitor the jobs that fail silently
For backups and other scheduled work, use a heartbeat, sometimes called a dead man's switch: the job contacts a monitoring endpoint only after it succeeds, and the monitor alerts when the signal does not arrive on time. This also catches a disabled cron entry, which an error email never will. A success signal still does not prove the backup can be restored, so schedule restore tests as described in our cloud server backup guide.
To check a certificate from another machine, replace the domain below. The command reports whether the certificate expires within 14 days:
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
| openssl x509 -noout -checkend 1209600
If the connection fails, openssl x509 also returns an error, so treat any non-zero exit status as something to investigate.
Logs, retention and Indian compliance points
Metrics tell you that something changed; logs usually help explain why. Collect authentication, sudo, web server, application and firewall logs, and consider copying them to a second system, because an attacker with root access can alter local files. Keep server clocks synchronised (check with timedatectl) so events from different machines line up.
Two Indian requirements are worth reviewing with whoever handles compliance:
- CERT-In directions of April 2022 include maintaining logs of ICT systems for a rolling 180 days within Indian jurisdiction, and reporting specified cyber incidents within six hours of noticing them. Read the current text and clarifications on the CERT-In website and confirm how they apply to your organisation.
- The Digital Personal Data Protection Act, 2023 requires reasonable security safeguards for personal data. Logs can themselves contain personal data such as IP addresses, email addresses or tokens in URLs. Limit who can read them, avoid logging passwords and secrets, and define how long you keep them. The DPDP Rules add further detail, so check what is in force when you set your policy.
This is general information, not legal advice. Check where your monitoring and log vendor stores data before sending it anything from production.
A rollout plan for a small team
- Day one: add an external uptime and certificate check, and make sure the alert reaches a phone or channel someone watches.
- First week: enable sysstat, make the journal persistent, and add disk, memory and service checks.
- Next: add heartbeats for backups and other important jobs.
- After two to four weeks: review the history, adjust thresholds and remove alerts nobody acted on.
- When you add servers: move to a central tool and give each alert an owner and a short runbook (meaning, how to confirm it, safe first step, whom to call).
How AvertHost can help
AvertHost offers Linux cloud VPS hosting with root access in a Tier-IV data centre in Delhi, with a 99.9% uptime SLA. You can run any of the approaches above on a self-managed VPS. AvertHost also lists a Managed VPS option that includes server setup, security hardening and 24/7 monitoring. Before relying on it, ask for the scope in writing: which metrics and services are checked, who receives alerts, what actions the team takes and whether your application is included. See the Linux VPS page for current plans and contact options.
FAQ
What is the most basic monitoring a Linux VPS needs?
An external uptime check, a certificate expiry check, alerts for disk space and memory, a check that key services are running, and a success signal for backups. Add history with sysstat so you can investigate past problems.
Do I need Prometheus and Grafana for one server?
Usually not. They are useful if you already know them or need application metrics, but for one small server an external check, a script and sysstat are less to maintain. Reconsider when you add servers or need dashboards for a team.
Which commands should I run first when a server is slow?
Start with uptime, vmstat 5 5, free -h, df -h, df -i and systemctl --failed. Then use top for processes, iostat -xz for disk latency and the journal for errors around the time the slowness began.
How often should metrics be collected?
Between 15 seconds and one minute is common for host metrics in central tools. Shorter intervals show spikes better but create more data. Default sysstat sampling is much less frequent, so it can miss brief spikes.