
Terminal - Commands using vmstat - 8 results
This is sample output - yours may be different.
while (true); do clear; uname -n; echo ""; df -h /; echo ""; tail -5 /var/log/auth.log; echo ""; vmstat 1 5; sleep 15; done
This is sample output - yours may be different.
hostname
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 182G 32G 141G 19% /
Aug 22 23:17:01 hostname CRON[27580]: pam_unix(cron:session): session closed for user root
Aug 22 23:25:01 hostname CRON[27584]: pam_unix(cron:session): session opened for user root by (uid=0)
Aug 22 23:25:01 hostname CRON[27584]: pam_unix(cron:session): session closed for user root
Aug 22 23:35:01 hostname CRON[27768]: pam_unix(cron:session): session opened for user root by (uid=0)
Aug 22 23:35:01 hostname CRON[27768]: pam_unix(cron:session): session closed for user root
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 428 1382640 70536 252300 0 0 7 3 10 3 0 1 99 0
0 0 428 1382632 70536 252388 0 0 0 0 181 152 0 0 100 0
0 0 428 1382632 70536 252388 0 0 0 0 171 129 0 0 100 0
0 0 428 1382632 70536 252388 0 0 0 0 176 153 0 1 99 0
0 0 428 1382632 70536 252388 0 0 0 0 163 128 0 0 100 0
You can use this one-liner for a quick and dirty (more customizable) alternative to the watch command. The keys to making this work: everything exists in an infinite loop; the loop starts with a clear; the loop ends with a sleep. Enter whatever you'd like to keep an eye on in the middle.
This is sample output - yours may be different.
Every 2,0s: vmstat -sSM Fri Dec 4 23:32:13 2009
1482 M total memory
194 M used memory
109 M active memory
59 M inactive memory
288 M free memory
13 M buffer memory
68 M swap cache
Monitor with watch command and vmstat, memory usage
(echo "set terminal png;plot '-' u 1:2 t 'cpu' w linespoints;"; sudo vmstat 2 10 | awk 'NR > 2 {print NR, $13}') | gnuplot > plot.png
This is sample output - yours may be different.
vmstat 2 10 | awk 'NR > 2 {print NR, $13}' | gnuplot -e "set terminal png;set output 'v.png';plot '-' u 1:2 t 'cpu' w linespoints;"
This is sample output - yours may be different.
draw `vmstat ` data using gnuplot
vmstat 1 | awk '{now=strftime("%Y-%m-%d %T "); print now $0}'
This is sample output - yours may be different.
2009-07-17 15:36:17 procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
2009-07-17 15:36:17 r b swpd free buff cache si so bi bo in cs us sy id wa
2009-07-17 15:36:17 1 0 256 91276 226008 6461180 0 0 278 640 1 3 8 2 83 7
2009-07-17 15:36:18 0 0 256 74252 226524 6478072 0 0 5108 17316 5477 4731 12 3 78 7
2009-07-17 15:36:19 0 1 256 68228 226984 6483120 0 0 5580 1556 3236 5477 6 2 81 11
2009-07-17 15:36:20 1 1 256 57708 227680 6491604 0 0 5428 8384 3927 6805 7 6 76 12
Also useful with iostat, or pretty much anything else you want timestamped.
vmstat 1 10 | /usr/xpg4/bin/awk -f ph-vmstat.awk
This is sample output - yours may be different.
kthr memory page disk faults cpu
r b w swap free re mf pi po fr de sr cd cd cd s0 in sy cs us sy id
0 0 0 775.21M 42.10M 0 2 0 8 16 0 23 0 2 2 -0 448 703 988 2 1 98
0 0 44 35.09M 31.94M 20 540 147 302 302 0 0 311 111 107 0 1.89K 931 960 0 10 90
0 0 44 33.50M 27.88M 21 862 133 318 318 0 0 336 85 117 0 2.48K 1.16K 980 1 14 85
0 0 44 34.36M 27.76M 0 779 100 143 143 0 0 389 130 109 0 2.65K 1.05K 1.25K 0 15 84
0 0 44 33.95M 26.61M 33 830 144 444 444 0 0 434 138 115 0 3.38K 1.53K 1.42K 0 17 82
0 0 44 36.61M 26.18M 15 721 234 246 246 0 0 378 113 96 0 2.10K 1.01K 1.03K 0 11 89
0 0 44 34.71M 26.60M 6 717 186 182 182 0 0 326 93 133 0 2.43K 809 1.05K 0 15 85
0 0 44 35.71M 30.82M 43 763 159 565 565 0 0 422 112 119 0 2.46K 1.57K 1.09K 0 15 85
0 0 44 35.36M 29.56M 5 741 145 174 174 0 0 435 116 121 0 2.54K 834 1.18K 0 15 85
0 0 44 35.09M 30.14M 15 897 139 273 273 0 0 452 115 134 0 2.55K 1.15K 1.12K 0 17 82
% cat ph-vmstat.awk
# Return human readable numbers
function hrnum(a) {
b = a ;
if (a > 1000000) { b = sprintf("%2.2fM", a/1000000) ; }
else if (a > 1000) { b = sprintf("%2.2fK", a/1000) ; }
return(b) ;
}
# Return human readable storage
function hrstorage(a) {
b = a ;
if (a > 1024000) { b = sprintf("%2.2fG", a/1024/1024) ; }
else if (a > 1024) { b = sprintf("%2.2fM", a/1024) ; }
return(b) ;
}
OFS=" " ;
$1 !~ /[0-9].*/ {print}
$1 ~ /[0-9].*/ {
$4 = hrstorage($4) ;
$5 = hrstorage($5) ;
$9 = hrnum($9) ;
$10 = hrnum($10) ;
$17 = hrnum($17) ;
$18 = hrnum($18) ;
$19 = hrnum($19) ;
print ;
}
while [ 1 ]; do echo -n "`date +%F_%T`" ; vmstat 1 2 | tail -1 ; sleep 4; done
This is sample output - yours may be different.
2009-03-26_15:13:49 0 0 536 27724 4236 699064 0 0 0 0 1306 413 2 1 98 0
2009-03-26_15:13:54 0 0 536 27212 4244 699576 0 0 0 0 1182 266 1 0 99 0
2009-03-26_15:13:59 0 0 536 26764 4252 699828 0 0 0 0 1229 330 1 0 98 0
2009-03-26_15:14:04 0 0 536 26508 4260 700080 0 0 0 0 1307 465 2 1 98 0
See man vmstat for information about the statistics.
This does the same thing without the timestamp:
vmstat 5