1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
libsysinfo -- by Vince Weaver <vince@deater.net>
HISTORY:
This library started off as simply the sysinfo detection part
of the linux_logo program.
Gradually linux_logo was split more and more between the logo
part and the sysinfo part. The connection ended up being
so small that I ended up splitting them for a cleaner interface.
I am debating whether I should release this as a package on its
own, to be used by other programs.
Theory of Operation:
See the respective operating system directories for how the info is
gathered.
The "all" directory holds the common routines used by all os's.
The "configure" file is a c-program used to determine OS/arch. It
is a hack.
INTERFACE:
Include the "sysinfo.h" file to get the proper defines.
Link against libsysinfo
[---]
char *get_sysinfo_version(char *version);
Returns a string with version info, such as "2.3.4". This is
used so programs that use libsysinfo can display what version
they are linked against.
[---]
int get_numeric_sysinfo_version(void);
Returns a numeric version info, like 2003004 or some such.
Useful so you can use a simple "if get_numeric_version() > OUR_VERSION"
type construct to see if a new enough libsysinfo is installed.
[---]
int get_os_info(os_info_t *os_info);
typedef struct {
char os_name[33];
char os_version[33];
char os_revision[65];
} os_info_t;
get_os_info() returns the above struct. On unix-like operating
systems the uname() function fills in most of this info.
[---]
char *get_host_name(char hostname[65],char domain[65]);
Returns the hostname and filles in the domain name. Domain name is not
always guaranteed to return a proper value.
[---]
int get_uptime(void);
Returns the number of seconds the machine has been turned on.
[---]
void get_load_average(float *load_1,float *load_5,float *load_15);
Fills in values for the 1, 5, and 15 minute load averages.
[---]
int get_cpu_info(cpu_info_t *cpu_info);
typedef struct {
int num_cpus;
float megahertz;
float bogomips;
char chip_vendor[33];
char chip_type[64];
} cpu_info_t;
get_cpu_info() returns info on the cpus installed.
On Linux /proc/cpuinfo is querried to obtain this information.
Some "pretty-printing" is done to clean up the results a bit.
[---]
int get_hardware_info(char hardware_string[65]);
Fills in a string with extraneous hardware info.
This might be the machine type, or some other string.
On Linux this is also obtained from /proc/cpuinfo.
It is empty on the ix86 architecture.
[---]
long int get_mem_size(void);
Returns memory size in Megabytes.
May be inaccurate on 32bit systems with >2GB of RAM.
[---]
int set_cpuinfo_file(char *filename);
This is used to set the file used instead of /proc/cpuinfo.
I use this during debugging to point to non-native cpuinfo files.
[---]
void set_pretty_printing(int value);
Set whether to do pretty-printing or not. Currently disables
some, but not all, pretty-printing.
|