00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <glib.h>
00024
00025
00026 #define PROC_DIR "/proc/"
00027 #define CPU_FILE "/proc/cpuinfo"
00028 #define MEM_FILE "/proc/meminfo"
00029 #define MAX_FIELD_SZ 255
00030 #define FIELD_SZ 10
00031
00032
00038 struct cpu_info
00039 {
00040 char processor[FIELD_SZ];
00041 char vendor_id[2 * FIELD_SZ];
00042 char cpu_family[2 * FIELD_SZ];
00043 char model[FIELD_SZ];
00044 char model_name[5 * FIELD_SZ];
00045 char stepping[FIELD_SZ];
00046 char Mhz[FIELD_SZ];
00047 char cache[FIELD_SZ];
00048 char fpu[FIELD_SZ / 2];
00049 char fpu_exception[FIELD_SZ / 2];
00050 char cpuid_level[FIELD_SZ / 2];
00051 char wp[FIELD_SZ / 2];
00052 char flags[50 * FIELD_SZ];
00053 char bogomips[FIELD_SZ];
00054 };
00055
00060 struct mem_info
00061 {
00062 char total[FIELD_SZ];
00063 char free[FIELD_SZ];
00064 char shared[FIELD_SZ];
00065 char buffers[FIELD_SZ];
00066 char cached[FIELD_SZ];
00067 char swap_cached[FIELD_SZ];
00068 char active[FIELD_SZ];
00069 char inactive[FIELD_SZ];
00070 char dirty[FIELD_SZ];
00071 char high_total[FIELD_SZ];
00072 char high_free[FIELD_SZ];
00073 char low_total[FIELD_SZ];
00074 char low_free[FIELD_SZ];
00075 char swap_total[FIELD_SZ];
00076 char swap_free[FIELD_SZ];
00077 char hugepages_total[FIELD_SZ];
00078 char hugepages_free[FIELD_SZ];
00079 char hugepages_size[FIELD_SZ];
00080 };
00081
00082
00083 void update_cpu ();
00084 void update_mem ();
00085
00086 int get_cpu_info ();
00087 int get_mem_info ();