Monitoring commands



Does anyone have any monitoring commands they like to use? I currently use top -s to monitor what's currently happening and occasionally sar -q to see if the server had any high loads at certain points.



Great question. In my experience, you have 4 main things that you have to stay on top of.

1) CPU
2) Memory
3) Disk
4) Network

`top -c` will give you a good indication of CPU & Memory, but it won't tell you much about Disk or Network. For a quick snapshot of disk i/o, I prefer using `iotop`, and to get a quick look at network I usually look at `netstat -tuna`. Also, we like to run `vnstat` on our servers so that it tracks the historical usage of network as well as the current usage. We have some fancy nagios scripts that pull and parse vnstat data out and alert us if things start getting crazy.

Great question. Glad you asked.


[email protected] [~]# vnstat
bash: vnstat: command not found


[email protected] [~]# iotop
bash: iotop: command not found


By the looks of it, I won't be testing out either of them any time soon. :(


Check for applications like vmstat, iostat, mpstat. Also don't forget trusty ps aux --sort pcpu.

RHEL editions usually have a tool called dstat as well.


By the looks of it, I won't be testing out either of them any time soon. :(
Don't give up so soon! It's easy to install them, e.g. if you're on fedora the package names are the same as the program names, so just find them in Add/Remove Software (or do yum install vnstat iostat).

I love the simple things. In addition to the things mentioned, I like a good ps or lsof command. Instructive examples:
• ps axru
  # shows running processes with extra info
• ps -FC httpd
  # shows httpd processes with extra info
• ps -eo pcpu,rss,pid,comm --sort=-rss | head
  # shows most ram-heavy processes
• lsof /var/log/messages
• lsof +d /var/log
• lsof +D /var/log
• lsof -c bas
  #info on what cmd starting with 'bas' in its name has open
• lsof -p 20628
  #info on what PID has open
• lsof -u ryran -c fire
  #all ryran's procs + all fire.* procs as well
• lsof -c httpd -a +D /var/www/html
  #all processes that have open files in /var/www/html and are named httpd.*
• lsof -i
  #list internet files (open ports & established connections)
• lsof -i tcp:ssh,80
• lsof -i tcp -a -u ryran

Members online

Latest posts