EnderUNIX Team.

EnderUNIX tips

Mail to My Friend , Home Page

[ C/C++ ]

"Get system related information via sysinfo()" - Metin KAYA - (2008-07-24 20:30:45)   [9359]

It is possible to get the system uptime, shared, buffered, free and total memory, number of processes, total swap space, etc... via sysinfo() system call. For instance:

struct sysinfo s_info;
printf("Uptime = %d seconds\n"
"RAM: total %d / free %d / shared %d\n"
"Memory in buffers = %d\n"
"Swap: total %d / free %d\n"
"Number of processes = %d\n",
s_info.uptime, s_info.totalram,
s_info.freeram, s_info.sharedram,
s_info.bufferram, s_info.totalswap,
s_info.freeswap, s_info.procs);

To be able to use the code above, "linux/unistd.h" must be included in the source file. For detailed information: man sysinfo

Mail to My Friend , Home Page