Have you ever looked at your server and felt a little confused about what was going on? I’ve been there before too, and you really don’t need any complicated tools to know whether or not your server is "OK". There is so much you can check much easier for your
server health! Doesn’t that sound nice?!
First things first, CPU Usage
I always start with
CPU usage. When the
CPU is
100% utilization continuously, the server generally feels slow (or not responsive at all). Luckily you can monitor this with a few different commands:
- top - Gives you live CPU usage
- htop - Very similar to top but much easier to read
- mpstat - CPU usage per core in case you want to look at CPU core utilization
When I see my
CPU utilization is in the
90-100% range for a long period of time, it is a good indicator that there is a problem. Have you ever seen your server freeze up for no reason? It was probably due to a maxed-out CPU.
Memory (RAM) Usage
Servers also slow down when
RAM usage hits
100%. To check memory usage, you can use the following commands:
If the
RAM is utilized at
100% and the server is using too much
"swap" to accommodate, the applications are utilizing too much memory. I have ignored this in the past and my server even began lagging so badly, I had to restart it.
Disk Usage
Next, I check the disk. A
full disk may cause your apps to crash. That is the worst surprise.
You can check disk health by using:
- df -h – shows free and used disk
- du -sh foldername – shows folder size
- iostat - shows disk speed and load
Once the disk gets
90% full, I purge logs or old backups. Better safe than sorry, right?
Network Health
Have you ever thought why your site opens slowly? It could be the network.
I check with:
- ping – checks if the server replies
- netstat - shows connection
- iftop - shows bandwidth live
If I see too many odd connections, I know something is fishy.
System Logs
Logs tell you everything, I mean everything. Every time something gets broken, my first place I look is the logs.
You can get your logs from:
- /var/log/syslog
- /var/log/messages
- journalctl
More often than not, the error message is right there waiting for you to see it.