1statgrab(3)                Library Functions Manual                statgrab(3)
2
3
4

NAME

6       statgrab - get system statistics
7

SYNOPSIS

9       #include <statgrab.h>
10
11
12       int sg_init(void);
13
14       int sg_drop_privileges(void);
15
16       sg_error sg_get_error(void);
17
18       const char *sg_get_error_arg(void);
19
20       intsg_get_error_errno(void);
21
22       const char *sg_str_error(sg_error code);
23
24       sg_cpu_stats *sg_get_cpu_stats(void);
25
26       sg_cpu_stats *sg_get_cpu_stats_diff(void);
27
28       sg_cpu_percents *sg_get_cpu_percents(void);
29
30       sg_disk_io_stats *sg_get_disk_io_stats(int *entries);
31
32       sg_disk_io_stats *sg_get_disk_io_stats_diff(int *entries);
33
34       sg_fs_stats *sg_get_fs_stats(void);
35
36       sg_host_info *sg_get_host_info(void);
37
38       sg_load_stats *sg_get_load_stats(void);
39
40       sg_mem_stats *sg_get_mem_stats(void);
41
42       sg_swap_stats *sg_get_swap_stats(void);
43
44       sg_network_io_stats *sg_get_network_io_stats(int *entries);
45
46       sg_network_io_stats *sg_get_network_io_stats_diff(int *entries);
47
48       sg_network_iface_stats *sg_get_network_iface_stats(int *entries);
49
50       sg_page_stats *sg_get_page_stats(void);
51
52       sg_page_stats *sg_get_page_stats_diff(void);
53
54       sg_process_count *sg_get_process_stats(void);
55
56       sg_user_stats *sg_get_user_stats(void);
57

DESCRIPTION

59       The  statgrab  library  provides  a cross-platform interface to getting
60       system statistics. Each of the function calls returns a structure  con‐
61       taining  statistics.  See  the manual page for each individual function
62       for more details on usage.
63
64       sg_init must be the first function you call before  you  start  to  use
65       libstatgrab;  it  performs  all  the one-time initialisation operations
66       that need setuid/setgid privileges. For instance, on *BSD  it  opens  a
67       descriptor  to  be  able  to  read  kernel  structures later on, and on
68       Solaris it reads the device mappings that in some cases are only acces‐
69       sible  by root (machines with a /dev/osa). Once this has run, the other
70       libstatgrab functions no longer need elevated privileges. It is  there‐
71       fore  a good idea to call sg_drop_privileges, which discards setuid and
72       setgid privileges, immediately after  you  call  sg_init,  unless  your
73       application has another reason for needing setuid or setgid privileges.
74
75       sg_init  and  sg_drop_privileges  return  0 on success, and non-zero on
76       failure.
77
78       There are three functions relating to error reporting  in  libstatgrab.
79       The  first,  sg_get_error returns an sg_error code which relates to the
80       last error generated by libstatgrab. This can be converted to a  string
81       by  calling  sg_str_error  giving  the sg_error code as an argument. An
82       optional argument may be set when the error was generated. This can  be
83       accessed by calling sg_get_error_arg; NULL will be returned if no argu‐
84       ment has been set. Some errors will also record the value of the system
85       errno  variable when the error occurred; this can be retrieved by call‐
86       ing sg_get_error_errno, which will return 0 if no valid errno has  been
87       recorded.
88
89       It  is  the  intended  practice that whenever a libstatgrab function is
90       called and subsequently fails that an appropriate error will be set.
91
92       The library was originally written to support the i-scream central mon‐
93       itoring  system, but has since become a standalone package. It has been
94       ported to work on  Linux,  NetBSD,  FreeBSD,  OpenBSD,  DragonFly  BSD,
95       Solaris, HP-UX and Cygwin.
96

SEE ALSO

98       sg_get_cpu_percents(3)    sg_get_disk_io_stats(3)    sg_get_fs_stats(3)
99       sg_get_host_info(3)      sg_get_load_stats(3)       sg_get_mem_stats(3)
100       sg_get_network_io_stats(3)                sg_get_network_iface_stats(3)
101       sg_get_page_stats(3) sg_get_process_stats(3) sg_get_user_stats(3)
102

WEBSITE

104       http://www.i-scream.org/libstatgrab/
105
106
107
108i-scream                 $Date: 2005/04/25 11:25:45 $              statgrab(3)
Impressum