[arch-general] most efficient way to get linux kernel statistics
Andre Schmidt
andre.osku.schmidt at gmail.com
Sun Mar 6 14:23:33 UTC 2016
hello archers,
thought i ask here first, before i try some kernel mailing list.
i'm writing (for fun) a tiny daemon that sends linux usage (cpu, mem, net, etc.) statistics as efficiently as possible to another machine, repeatedly, to get "live" data.
at the moment i'm simply sending /proc files, but they sometimes have too much data. so was wondering if there is a more efficient way to get (only parts of) the data thats available in /proc?
for example, /proc/meminfo has all this info:
MemTotal: 8051660 kB
MemFree: 6046020 kB
MemAvailable: 6843080 kB
Buffers: 109116 kB
Cached: 708336 kB
SwapCached: 0 kB
Active: 1332416 kB
Inactive: 455428 kB
Active(anon): 971040 kB
Inactive(anon): 22340 kB
Active(file): 361376 kB
Inactive(file): 433088 kB
Unevictable: 16 kB
Mlocked: 16 kB
SwapTotal: 1048572 kB
SwapFree: 1048572 kB
Dirty: 16 kB
Writeback: 0 kB
AnonPages: 970412 kB
Mapped: 323384 kB
Shmem: 23008 kB
Slab: 71760 kB
SReclaimable: 44860 kB
SUnreclaim: 26900 kB
KernelStack: 6544 kB
PageTables: 22924 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 5074400 kB
Committed_AS: 3487604 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
HardwareCorrupted: 0 kB
AnonHugePages: 413696 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 168600 kB
DirectMap2M: 8091648 kB
but i only need:
MemTotal: 8051660 kB
MemAvailable: 6843080 kB
Cached: 708336 kB
event better would be if kernel would only tell me:
8051660 6843080 708336
if /proc is the only way to get this info, i wonder if creating a kernel module for this would be more efficient, or even possible?
Cheers
Andre Schmidt
More information about the arch-general
mailing list