#include <stdio.h>#include <string.h>#include <dirent.h>#include <sys/types.h>#include <stdlib.h>#include <glib.h>#include "lininfo.h"#include "others.h"Go to the source code of this file.
| Functions | |
| int | get_cpu_info (struct cpu_info *cpu) | 
| int | get_mem_info (struct mem_info *mem) | 
| End get_cpu_info. | |
| 
 | 
| Collects cpu information 
 
 Definition at line 38 of file lininfo.c. References cpu_info::bogomips, cpu_info::cache, cpu, cpu_info::cpu_family, CPU_FILE, cpu_info::cpuid_level, find_data_for(), cpu_info::flags, cpu_info::fpu, cpu_info::fpu_exception, cpu_info::Mhz, cpu_info::model, cpu_info::model_name, cpu_info::processor, cpu_info::stepping, cpu_info::vendor_id, and cpu_info::wp. 00039 {
00040   gchar* contenido;
00041   char* str;
00042   
00043   if(g_file_get_contents(CPU_FILE,&contenido,NULL,NULL)==FALSE)
00044           //Error accesing file. Stop program 
00045         g_error("Can't read %s file",CPU_FILE);
00046   
00047   str=contenido;
00048   find_data_for("processor : %[^\n]",cpu->processor,str);
00049   find_data_for("vendor_id : %[^\n]",cpu->vendor_id,str);
00050   find_data_for("cpu family : %[^\n]",cpu->cpu_family,str);
00051   find_data_for("model : %[^\n]",cpu->model,str);
00052   find_data_for("model name : %[^\n]",cpu->model_name,str)      ;
00053   find_data_for("stepping : %[^\n]",cpu->stepping,str);
00054   find_data_for("cpu MHz : %[^\n]",cpu->Mhz,str);
00055   find_data_for("cache size : %[^\n]",cpu->cache,str);
00056   find_data_for("fpu : %[^\n]",cpu->fpu,str);
00057   find_data_for("fpu_exception : %[^\n]",cpu->fpu_exception,str);
00058   find_data_for("cpuid level : %[^\n]",cpu->cpuid_level,str);
00059   find_data_for("wp : %[^\n]",cpu->wp,str);
00060   find_data_for("flags : %[^\n]",cpu->flags,str);
00061   find_data_for("bogomips : %[^\n]",cpu->bogomips,str);
00062         
00063 
00064   g_free(contenido);
00065 
00066   return (0);
00067 }                               
 | 
| 
 | 
| End get_cpu_info. Collects memory information 
 
 Definition at line 76 of file lininfo.c. References mem_info::active, mem_info::buffers, mem_info::cached, mem_info::dirty, find_data_for(), mem_info::free, mem_info::high_free, mem_info::high_total, mem_info::hugepages_free, mem_info::hugepages_size, mem_info::hugepages_total, mem_info::inactive, mem_info::low_free, mem_info::low_total, mem, MEM_FILE, mem_info::swap_cached, mem_info::swap_free, mem_info::swap_total, and mem_info::total. 00077 {
00078         gchar* contenido;
00079         
00080         if(g_file_get_contents(MEM_FILE,&contenido,NULL,NULL)==FALSE)
00081                 //Can't read file. Stop program
00082                 g_error("Can't read %s file",MEM_FILE);
00083 
00084   find_data_for ("MemTotal: %[^\n]",mem->total, contenido);
00085   find_data_for ("MemFree: %[^\n]",mem->free, contenido);
00086   find_data_for ("Buffers: %[^\n]",mem->buffers, contenido);
00087   find_data_for ("Cached: %[^\n]",mem->cached, contenido);
00088   find_data_for ("SwapCached: %[^\n]",mem->swap_cached, contenido);
00089   find_data_for ("Active: %[^\n]",mem->active, contenido);
00090   find_data_for ("Inactive: %[^\n]",mem->inactive,contenido);
00091   find_data_for ("Dirty: %[^\n]",mem->dirty, contenido);
00092   find_data_for ("HighTotal: %[^\n]",mem->high_total, contenido);
00093   find_data_for ("HighFree: %[^\n]",mem->high_free, contenido);
00094   find_data_for ("LowTotal: %[^\n]",mem->low_total, contenido);
00095   find_data_for ("LowFree: %[^\n]",mem->low_free, contenido);
00096   find_data_for ("SwapTotal: %[^\n]",mem->swap_total, contenido);
00097   find_data_for ("SwapFree: %[^\n]",mem->swap_free, contenido);
00098   find_data_for ("HugePages_Total: %[^\n]",mem->hugepages_total, contenido);
00099   find_data_for ("HugePages_Free: %[^\n]",mem->hugepages_free, contenido);
00100   find_data_for ("Hugepagesize: %[^\n]",mem->hugepages_size, contenido);
00101 
00102   g_free(contenido);
00103   
00104   return (0);
00105 }                               
 | 
 1.3.9.1
 1.3.9.1