NAME
Linux::MemInfo - Perl extension for accessing /proc/meminfo
SYNOPSIS
use Linux::MemInfo;
ABSTRACT
This module will allow you to easily extract the fields out of the
/proc/meminfo file. All of the fields are stored in a hash.
DESCRIPTION
%mem = get_mem_info
foreach(sort keys %mem) {
printf("%-20s\t%s\n",$_,$mem{$_});
}
Would yield the following:
Active 371368
ActiveAnon 104980
ActiveAnonUnit kB
ActiveCache 266388
ActiveCacheUnit kB
ActiveUnit kB
Buffers 80968
BuffersUnit kB
Cached 272400
CachedUnit kB
HighFree 0
HighFreeUnit kB
HighTotal 0
HighTotalUnit kB
Inact_clean 9976
Inact_cleanUnit kB
Inact_dirty 0
Inact_dirtyUnit kB
Inact_laundry 75480
Inact_laundryUnit kB
Inact_target 91364
Inact_targetUnit kB
LowFree 11172
LowFreeUnit kB
LowTotal 512540
LowTotalUnit kB
MemFree 11172
MemFreeUnit kB
MemShared 0
MemSharedUnit kB
MemTotal 512540
MemTotalUnit kB
SwapCached 6768
SwapCachedUnit kB
SwapFree 505096
SwapFreeUnit kB
SwapTotal 522072
SwapTotalUnit kB
mem_buffers 82911232
mem_cached 285868032
mem_free 11440128
mem_shared 0
mem_total 524840960
mem_used 513400832
swap_free 517218304
swap_total 534601728
swap_used 17383424
The raw data looks like this: cat /proc/meminfo
total: used: free: shared: buffers: cached:
Mem: 524840960 510504960 14336000 0 81543168 283406336
Swap: 534601728 17448960 517152768
MemTotal: 512540 kB
MemFree: 14000 kB
MemShared: 0 kB
Buffers: 79632 kB
Cached: 269932 kB
SwapCached: 6832 kB
Active: 371352 kB
ActiveAnon: 106300 kB
ActiveCache: 265052 kB
Inact_dirty: 0 kB
Inact_laundry: 73628 kB
Inact_clean: 9296 kB
Inact_target: 90852 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 512540 kB
LowFree: 14000 kB
SwapTotal: 522072 kB
SwapFree: 505032 kB
SEE ALSO
None
AUTHOR
Chad Kerner, <chadkerner@yahoo.com>
COPYRIGHT AND LICENSE
Copyright 2003 by Chad Kerner
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.