Process, Memory, IO and Network monitoring in Linux

Process monitoring utilities:

  • ps  (procps: Detailed information about process)
    • ps -ef; ps aux
    • ps -eo pid,ppid,cmd,lstart,%cpu,%mem –sort=-%cpu 
    • ps -u user1
    • ps -C httpd
    • ps -p 1234
    • ps –ppid 1234
    • Shows top 5 process using cpu & memory:
      • ps aux –sort=-pcpu,+pmem | head -5
    • Find out process started date/time:
      • ps -eo lstart,cmd | grep java
      • ls -ld /proc/pid
  • pgrep  (procps: List process info based upon name) 
    • pgrep -l bash
    • pgrep -lu user              (List all user processes)
  • top  (procps: Process activity, dynamically updated)
    • top
    • top -p pid
    • top -u user
  • uptime  (procps: How long the system is running and average load)
    • uptime
    • uptime -s
  • w: Show overall system load, and who is logged on and what they are doing
  • pstree  (psmisc or pstree: A tree of process and their connections)
    • pstree
    • pstree -aAp 1234
    • ls -l /proc/pid/task
  • mpstat  (sysstat: Multiple process usage)
    • mpstat
    • mpstat -P ALL 2 5      (Show all process at 2 secs interval and total 5 reports)
  • jobs/fg/bg:
    • jobs -l                                      (List status of jobs)
    • bg %1; kill -SIGCONT %1    (Move job to background or resume it)
    • fg %1                     (Move job to the foreground; ctr+z to stop it)
    • ctr+z | kill -SIGSTOP %1     (Stops a process)
    • ctr+c | kill -SIGTERM %1    (Terminate a process)
  • kill: (kill processes)
    • kill -9 $(pgrep java)    (Kill -SIGTERM|-SIGSTOP|-SIGCONT  pid)
    • killall httpd
    • pkill java                       (Kills all process using process name)
    • pkill -9 -u user java     (Kill all java process of user)
    • pkill -9 -t tty2                (Kill user session, run w cmd to find TTY)
  • nice/renice(Min: -19; Max: 19)
    • nice -n 10 bash          
    • renice -n 15 -p 1234    (Change nice value of a process ) 
    • ps -o ni,pid,cmd,user   
    • renice -n –9 -u user    (Change nice value of all process of the user)
  • numastat: (numactl: Information about Non-Uniform Memory Architecture)
  • strace (strace): Information about all system calls a process makes

Memory monitoring utilities:

  •  free: (procps: Brief summary of memory usage)
    • free -mh
    • cat /proc/meminfo
  • vmstat (procps: Detailed virtual memory statistics and block IO)
    • vmstat
    • vmstat -s                     (-s: Summary of event counter statistics)
    • vmstat -S M  2   5       (-S: Unit; -M: MB;  2: interval in secs; 5: reports)
  • dstat (Dstat is a versatile replacement for vmstat, iostat and ifstat)
    • dstat 5 10       (Default -cdngy, 5:  secs delay, 10: reports)
    • dstat -n 2 5    (-c: cpu, -d: disk, -n: network, -g: page, -s: system, -m: memory)
  • pmap (procps: Process memory map)
    • pmap 1234

IO monitoring utilities:

  • iostat (sysstat: CPU utilization and I/O statistics)
    • iostat
    • iostat  -xm                               (-x: extended; -m: MB)
    • iostat  -xmd   /dev/sda   2 5   (-d: device; 2: interval secs; 5: reports)
  • iotop   (iotop: Shows IO activity dynamically like process top utility)
    • iotop
    • iotop -o            (o-> show only active process doing IO)
  • vmstat (procps: Detailed virtual memory statistics and block I/O)
    • vmstat -d                        (-d: disk statistics)
    • vmstat -p /dev/sda1      (-p: partition)
    • vmstat -d 2 5                  (2: interval secs; 5: reports)
  • sar (sysstat: Display and collect information about system activity)
    • sar
    • sar -A 
    • sar 1 3     (1: sec; 3: reports)

Network Monitoring utilities:

  • ss (Another utility to investigate sockets)
    • ss -lpt | grep httpd        (Show process and pid)
    • ss -s                (Show open, closed, establish and orphaned TCP processes)
    • ss -l                 (List listening sockets)
    • ss -t4 state established   (Show established connections)
    • ss -tupae | grep httpd
    • ss -tupan | grep 80
  • netstat (Print network connections, routing tables, interface statistics)
    • netstat -tupae |grep httpd    (e-> Extended)
    • netstat -tupan | grep 80        (n-> Show in numeric format)
  • tcpdump (dump traffic on a network)
    • tcpdump -i lo proto ICMP
  • nmap (Network exploration tool and security / port scanner)
    • namp -A localhost
    • namp -A -sS localhost
  • iptraf – real-time network traffic analyzer
    • iptraf-ng

CPU, Memory, and IO bench-marking utilities:

  • fs_mark  (A file system benchmark tool)
    • fs_mark -d /tmp -n 1000 -s 10240
  • bonnie  (A file system benchmark tool to test disk performance)
    • time bonnie++ -n 0 -u 0 -r 100 -f -b -d /mnt
  • stress: (impose load on stress test systems)
    • stress -c 8 -i 4 -m 6 -t 30s

 

 

 

 

Advertisements

About Ishtiaque

I am IBM Certified Infrastructure Systems Architect, Linux Foundation Certified System Administrator, Oracle Certified Programmer in Java and Web Component Developer, and TOGAF 9 certified with over 10 years of support and development experience in IBM middleware software and Java. Additionally, have a sound grip in databases and OpenStack administration. I hold the following certifications: IBM Certified Infrastructure Systems Architect Linux Foundation Certified System Administrator (LFCS) TOGAF 9 Certified Oracle Certified Expert, Java EE6 Web Component Developer Oracle Certified Professional – Java 6 Programmer ITIL v3 Foundation Certified IBM Certified Solution Architect – Cloud Computing Infrastructure V1 IBM Certified System Administrator – WebSphere Portal V8, V7, V6.1, V6 IBM Certified System Administrator – WebSphere Application Server V7, V6.1 IBM Certified System Administrator – AIX V7 IBM Certified System Administrator – WebSphere MQ V7 IBM Certified Deployment Professional – Business Process Manager Advanced V7.5 IBM Certified Solution Advisor – Cloud Computing Architecture V3 IBM Certified Solution Developer – WebSphere Portal V5.1
This entry was posted in LFCE, LFCS, Linux and tagged . Bookmark the permalink.