ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/statgrab.h
Revision: 1.16
Committed: Mon Nov 10 21:07:04 2003 UTC (20 years, 6 months ago) by tdb
Content type: text/plain
Branch: MAIN
Changes since 1.15: +7 -0 lines
Log Message:
Add support for cygwin. This is a bit limited, there's a few things that
can't be retrieved on cygwin such as load averages, diskio, network io,
and process stats. The package compiles and runs, and both saidar and
statgrab work.

Taken from a patch submitted by Ron Arts <raarts@netland.nl>. Thanks Ron!

File Contents

# Content
1 /*
2 * i-scream central monitoring system
3 * http://www.i-scream.org
4 * Copyright (C) 2000-2003 i-scream
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21 #include <sys/types.h>
22 #ifdef NETBSD
23 #include <limits.h>
24 #endif
25 #ifdef CYGWIN
26 #include <sys/unistd.h>
27 #endif
28
29 typedef struct{
30 long long user;
31 long long kernel;
32 long long idle;
33 long long iowait;
34 long long swap;
35 long long nice;
36 long long total;
37 time_t systime;
38 }cpu_states_t;
39
40 typedef struct{
41 float user;
42 float kernel;
43 float idle;
44 float iowait;
45 float swap;
46 float nice;
47 time_t time_taken;
48 }cpu_percent_t;
49
50 typedef struct{
51 long long total;
52 long long free;
53 long long used;
54 long long cache;
55 }mem_stat_t;
56
57 typedef struct{
58 double min1;
59 double min5;
60 double min15;
61 }load_stat_t;
62
63 #ifdef SOLARIS
64 #define MAX_LOGIN_NAME_SIZE 8
65 #endif
66 #if defined(LINUX) || defined(FREEBSD)
67 #if defined(CYGWIN)
68 #define MAX_LOGIN_NAME_SIZE _SC_LOGIN_NAME_MAX
69 #else
70 #define MAX_LOGIN_NAME_SIZE UT_NAMESIZE
71 #endif
72 #endif
73 #ifdef NETBSD
74 #define MAX_LOGIN_NAME_SIZE _POSIX_LOGIN_NAME_MAX
75 #endif
76
77 typedef struct{
78 char *name_list;
79 int num_entries;
80 }user_stat_t;
81
82 typedef struct{
83 long long total;
84 long long used;
85 long long free;
86 }swap_stat_t;
87
88 typedef struct{
89 char *os_name;
90 char *os_release;
91 char *os_version;
92 char *platform;
93 char *hostname;
94 time_t uptime;
95 }general_stat_t;
96
97 typedef struct {
98 char *device_name;
99 char *fs_type;
100 char *mnt_point;
101 long long size;
102 long long used;
103 long long avail;
104 long long total_inodes;
105 long long used_inodes;
106 long long free_inodes;
107 }disk_stat_t;
108
109 typedef struct{
110 char *disk_name;
111 long long read_bytes;
112 long long write_bytes;
113 time_t systime;
114 }diskio_stat_t;
115
116 typedef struct{
117 int total;
118 int running;
119 int sleeping;
120 int stopped;
121 int zombie;
122 }process_stat_t;
123
124 typedef struct{
125 char *interface_name;
126 long long tx;
127 long long rx;
128 time_t systime;
129 }network_stat_t;
130
131 typedef struct{
132 long long pages_pagein;
133 long long pages_pageout;
134 time_t systime;
135 }page_stat_t;
136
137 cpu_states_t *get_cpu_totals();
138 cpu_states_t *get_cpu_diff();
139 cpu_percent_t *cpu_percent_usage();
140
141 mem_stat_t *get_memory_stats();
142
143 load_stat_t *get_load_stats();
144
145 user_stat_t *get_user_stats();
146
147 swap_stat_t *get_swap_stats();
148
149 general_stat_t *get_general_stats();
150
151 disk_stat_t *get_disk_stats(int *entries);
152 diskio_stat_t *get_diskio_stats(int *entries);
153 diskio_stat_t *get_diskio_stats_diff(int *entries);
154
155 process_stat_t *get_process_stats();
156
157 network_stat_t *get_network_stats(int *entries);
158 network_stat_t *get_network_stats_diff(int *entries);
159
160 page_stat_t *get_page_stats();
161 page_stat_t *get_page_stats_diff();
162
163 int statgrab_init(void);