Monitoring commands

Discussion in 'Command Line' started by MustangV10, Nov 11, 2011.

  1. MustangV10

    MustangV10 New Member

    Joined:
    Nov 11, 2011
    Messages:
    87
    Likes Received:
    3
    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.

     
  2. gcawood

    gcawood Administrator Staff Member

    Joined:
    Oct 28, 2011
    Messages:
    49
    Likes Received:
    19
    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.
     
  3. MustangV10

    MustangV10 New Member

    Joined:
    Nov 11, 2011
    Messages:
    87
    Likes Received:
    3
    root@clients [~]# vnstat
    bash: vnstat: command not found

    =================================

    root@clients [~]# iotop
    bash: iotop: command not found

    =================================

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

    majcherek2048 New Member

    Joined:
    Nov 16, 2011
    Messages:
    4
    Likes Received:
    1
    Which distro are you running? (Debian, RedHat, SuSE, Ubuntu, etc...)
     
  5. grim76

    grim76 Active Member Staff Writer

    Joined:
    Nov 21, 2011
    Messages:
    177
    Likes Received:
    48
    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.
     
  6. ryran

    ryran New Member

    Joined:
    Nov 28, 2011
    Messages:
    10
    Likes Received:
    4
    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:
    Code:
    • 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
     
    Rob likes this.

Share This Page