Linux203Training Module System Mgmt
This presentation will cover the following topics vmstat mpstat lsof uptime uname hostname
vmstat vmstat by default will display the memory usage (including swap). $ vmstat procs -----------memory---------- ---swap-- -----io---- --system-- --- --cpu------ r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 305416 260688 29160 2356920 2 2 4 1 0 0 6 1 92 2 0 vmstat output contains the following fields: Procs – r: Total number of processes waiting to run Procs – b: Total number of busy processes Memory – swpd: Used virtual memory Memory – free: Free virtual memory Memory – buff: Memory used as buffers Memory – cache: Memory used as cache. Swap – si: Memory swapped from disk (for every second) Swap – so: Memory swapped to disk (for every second) IO – bi: Blocks in. i.e blocks received from device (for every second) IO – bo: Blocks out. i.e blocks sent to the device (for every second) System – in: Interrupts per second System – cs: Context switches CPU – us, sy, id, wa, st: CPU user time, system time, idle time, wait time
To execute every 2 seconds for 10 times $ vmstat 2 10 procs -----------memory---------- ---swap-- ----- io---- --system-- -----cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 1 0 0 537144 182736 6789320 0 0 0 0 1 1 0 0 100 0 0 0 0 0 537004 182736 6789320 0 0 0 0 50 32 0 0 100 0 0 ..
mpstat mpstat – Display basic info By default mpstat displays CPU statistics $ mpstat Linux 2.6.35.13-92.CAV14.fc14.x86_64 (cavisson-server-ns1) 11/01/2012 _x86_64_ (4 CPU) 02:14:39 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle 02:14:39 PM all 0.87 0.00 2.73 0.22 0.00 0.01 0.00 0.00 96.17
Option -P ALL, displays all the individual CPUs (or Cores) along with its statistics $ mpstat -P ALL Linux 2.6.32-100.28.5.el6.x86_64 (dev-db) 07/09/2011 _x86_64_ (4 CPU) 10:28:04 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle 10:28:04 PM all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.99 10:28:04 PM 0 0.01 0.00 0.01 0.01 0.00 0.00 0.00 0.00 99.98 10:28:04 PM 1 0.00 0.00 0.01 0.00 0.00 0.00 0.00 0.00 99.98 10:28:04 PM 2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00 10:28:04 PM 3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
lsof List of open files # lsof COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME init 1 root cwd DIR 8,1 4096 2 / init 1 root txt REG 8,1 124704 917562 /sbin/init init 1 root 0u CHR 1,3 0t0 4369 /dev/null
List opened files under a directory # lsof +D /var/log/ COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME rsyslogd 488 syslog 1w REG 8,1 1151 268940 /var/log/syslog rsyslogd 488 syslog 2w REG 8,1 2405 269616 /var/log/auth.log
uptime Displays the total uptime for the computer. $uptime 12:36:49 up 5 days, 21 min, 17 users, load average: 0.00, 0.01, 0.05
uname Print name of current system. $]uname -arv Linux cavisson-server-ns1 2.6.35.13-92.CAV14.fc14.x86_64 #1 SMP Wed Sep 14 20:54:14 IST 2011 x86_64 x86_64 x86_64 GNU/Linux
hostname view system name (hostname) or assign a new name to system using hostname command. $]hostname cavisson-server-ns1