vmstat command shows Virtual Memory Statistics.
Sample outputs of the command are shown below.
$ vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 507912 6016 5216 61768 0 0 1 5 3 3 1 0 98 0
With -s option (this prints the vm table)
$ vmstat -s
515420 total memory
510060 used memory
340984 active memory
18404 inactive memory
5360 free memory
5580 buffer memory
62024 swap cache
1024088 total swap
507896 used swap
516192 free swap
5159612 non-nice user cpu ticks
284811 nice user cpu ticks
1343974 system cpu ticks
441240715 idle cpu ticks
1061329 IO-wait cpu ticks
266848 IRQ cpu ticks
130451 softirq cpu ticks
135296968 pages paged in
21489954 pages paged out
402670 pages swapped in
414068 pages swapped out
402061903 interrupts
401831289 CPU context switches
1157798489 boot time
185206 forks
To get just one number say that of free memory, you have to pipe this command to a awk (or perl or some other) that does filtering.
$ vmstat -s | awk '/free memory/{print $1}'
5360
awk is sometimes handier than grep :-)
Tuesday, October 31, 2006
Sunday, October 29, 2006
PHP : variable names by form fields
Here's a quick way to make form fields accessible just by appending a $ sign as in old php3.
Notice the two $ signs.
foreach ($_POST as $key=>$val)
{
$$key=$val;
}
Notice the two $ signs.
foreach ($_POST as $key=>$val)
{
$$key=$val;
}
Sunday, October 08, 2006
Linux : Finding unique types of files
Here's a quick way to figure out what different file-types (based on extension) you have. The following example checks the working directory. A hash of extensions is used in the perl code that appears in single quotes.
find . -name "*.*" | perl -e 'while(<>){$ext{$1}++ if(/\.([\w]+)$/);} $,="\n"; print sort keys %ext;'
Do you find this useful ?
find . -name "*.*" | perl -e 'while(<>){$ext{$1}++ if(/\.([\w]+)$/);} $,="\n"; print sort keys %ext;'
Do you find this useful ?
Subscribe to:
Posts (Atom)