sigar-test 0.7.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +201 -0
- data/NOTICE +117 -0
- data/README +2 -0
- data/Rakefile +105 -0
- data/bindings/SigarBuild.pm +301 -0
- data/bindings/SigarWrapper.pm +3025 -0
- data/bindings/ruby/extconf.rb +131 -0
- data/bindings/ruby/rbsigar.c +888 -0
- data/include/sigar.h +984 -0
- data/include/sigar_fileinfo.h +157 -0
- data/include/sigar_format.h +65 -0
- data/include/sigar_getline.h +18 -0
- data/include/sigar_log.h +80 -0
- data/include/sigar_private.h +429 -0
- data/include/sigar_ptql.h +53 -0
- data/include/sigar_util.h +197 -0
- data/src/os/aix/aix_sigar.c +2168 -0
- data/src/os/aix/sigar_os.h +73 -0
- data/src/os/darwin/Info.plist.in +27 -0
- data/src/os/darwin/darwin_sigar.c +3718 -0
- data/src/os/darwin/sigar_os.h +80 -0
- data/src/os/hpux/hpux_sigar.c +1361 -0
- data/src/os/hpux/sigar_os.h +49 -0
- data/src/os/linux/linux_sigar.c +2810 -0
- data/src/os/linux/sigar_os.h +82 -0
- data/src/os/solaris/get_mib2.c +321 -0
- data/src/os/solaris/get_mib2.h +127 -0
- data/src/os/solaris/kstats.c +181 -0
- data/src/os/solaris/procfs.c +97 -0
- data/src/os/solaris/sigar_os.h +224 -0
- data/src/os/solaris/solaris_sigar.c +2732 -0
- data/src/os/win32/peb.c +212 -0
- data/src/os/win32/sigar.rc.in +40 -0
- data/src/os/win32/sigar_os.h +685 -0
- data/src/os/win32/sigar_pdh.h +47 -0
- data/src/os/win32/win32_sigar.c +4109 -0
- data/src/sigar.c +2444 -0
- data/src/sigar_cache.c +253 -0
- data/src/sigar_fileinfo.c +815 -0
- data/src/sigar_format.c +696 -0
- data/src/sigar_getline.c +1849 -0
- data/src/sigar_ptql.c +1976 -0
- data/src/sigar_signal.c +216 -0
- data/src/sigar_util.c +1060 -0
- data/src/sigar_version.c.in +22 -0
- data/src/sigar_version_autoconf.c.in +22 -0
- data/version.properties +11 -0
- metadata +91 -0
@@ -0,0 +1,429 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2004-2008 Hyperic, Inc.
|
3
|
+
* Copyright (c) 2009 SpringSource, Inc.
|
4
|
+
* Copyright (c) 2009-2010 VMware, Inc.
|
5
|
+
*
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
* you may not use this file except in compliance with the License.
|
8
|
+
* You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
* See the License for the specific language governing permissions and
|
16
|
+
* limitations under the License.
|
17
|
+
*/
|
18
|
+
|
19
|
+
#ifndef SIGAR_PRIVATE_DOT_H
|
20
|
+
#define SIGAR_PRIVATE_DOT_H
|
21
|
+
|
22
|
+
#include "sigar_log.h"
|
23
|
+
#include "sigar_ptql.h"
|
24
|
+
|
25
|
+
#include <stdlib.h>
|
26
|
+
#include <string.h>
|
27
|
+
#include <ctype.h>
|
28
|
+
|
29
|
+
#ifndef WIN32
|
30
|
+
#include <unistd.h>
|
31
|
+
#include <stddef.h>
|
32
|
+
#ifndef DARWIN
|
33
|
+
#include <strings.h>
|
34
|
+
#endif
|
35
|
+
#endif
|
36
|
+
|
37
|
+
#ifdef DMALLOC
|
38
|
+
#define _MEMORY_H /* exclude memory.h on solaris */
|
39
|
+
#define DMALLOC_FUNC_CHECK
|
40
|
+
#include <dmalloc.h>
|
41
|
+
#endif
|
42
|
+
|
43
|
+
/* common to all os sigar_t's */
|
44
|
+
/* XXX: this is ugly; but don't want the same stuffs
|
45
|
+
* duplicated on 4 platforms and am too lazy to change
|
46
|
+
* sigar_t to the way it was originally where sigar_t was
|
47
|
+
* common and contained a sigar_os_t.
|
48
|
+
* feel free trav ;-)
|
49
|
+
*/
|
50
|
+
#define SIGAR_T_BASE \
|
51
|
+
int cpu_list_cores; \
|
52
|
+
int log_level; \
|
53
|
+
void *log_data; \
|
54
|
+
sigar_log_impl_t log_impl; \
|
55
|
+
void *ptql_re_data; \
|
56
|
+
sigar_ptql_re_impl_t ptql_re_impl; \
|
57
|
+
unsigned int ncpu; \
|
58
|
+
unsigned long version; \
|
59
|
+
unsigned long boot_time; \
|
60
|
+
int ticks; \
|
61
|
+
sigar_pid_t pid; \
|
62
|
+
char errbuf[256]; \
|
63
|
+
char *ifconf_buf; \
|
64
|
+
int ifconf_len; \
|
65
|
+
char *self_path; \
|
66
|
+
sigar_proc_list_t *pids; \
|
67
|
+
sigar_cache_t *fsdev; \
|
68
|
+
sigar_cache_t *proc_cpu; \
|
69
|
+
sigar_cache_t *net_listen; \
|
70
|
+
sigar_cache_t *net_services_tcp; \
|
71
|
+
sigar_cache_t *net_services_udp;\
|
72
|
+
sigar_cache_t *proc_io
|
73
|
+
|
74
|
+
#if defined(WIN32)
|
75
|
+
# define SIGAR_INLINE __inline
|
76
|
+
#elif defined(__GNUC__)
|
77
|
+
# define SIGAR_INLINE inline
|
78
|
+
#else
|
79
|
+
# define SIGAR_INLINE
|
80
|
+
#endif
|
81
|
+
|
82
|
+
#ifdef DMALLOC
|
83
|
+
/* linux has its own strdup macro, make sure we use dmalloc's */
|
84
|
+
#define sigar_strdup(s) \
|
85
|
+
dmalloc_strndup(__FILE__, __LINE__, (s), -1, 0)
|
86
|
+
#else
|
87
|
+
# ifdef WIN32
|
88
|
+
# define sigar_strdup(s) _strdup(s)
|
89
|
+
# else
|
90
|
+
# define sigar_strdup(s) strdup(s)
|
91
|
+
# endif
|
92
|
+
#endif
|
93
|
+
|
94
|
+
#define SIGAR_ZERO(s) \
|
95
|
+
memset(s, '\0', sizeof(*(s)))
|
96
|
+
|
97
|
+
#define SIGAR_STRNCPY(dest, src, len) \
|
98
|
+
strncpy(dest, src, len); \
|
99
|
+
dest[len-1] = '\0'
|
100
|
+
|
101
|
+
/* we use fixed size buffers pretty much everywhere */
|
102
|
+
/* this is strncpy + ensured \0 terminator */
|
103
|
+
#define SIGAR_SSTRCPY(dest, src) \
|
104
|
+
SIGAR_STRNCPY(dest, src, sizeof(dest))
|
105
|
+
|
106
|
+
#ifndef strEQ
|
107
|
+
#define strEQ(s1, s2) (strcmp(s1, s2) == 0)
|
108
|
+
#endif
|
109
|
+
|
110
|
+
#ifndef strnEQ
|
111
|
+
#define strnEQ(s1, s2, n) (strncmp(s1, s2, n) == 0)
|
112
|
+
#endif
|
113
|
+
|
114
|
+
#ifdef WIN32
|
115
|
+
#define strcasecmp stricmp
|
116
|
+
#define strncasecmp strnicmp
|
117
|
+
#endif
|
118
|
+
|
119
|
+
#ifndef strcaseEQ
|
120
|
+
#define strcaseEQ(s1, s2) (strcasecmp(s1, s2) == 0)
|
121
|
+
#endif
|
122
|
+
|
123
|
+
#ifndef strncaseEQ
|
124
|
+
#define strncaseEQ(s1, s2, n) (strncasecmp(s1, s2, n) == 0)
|
125
|
+
#endif
|
126
|
+
|
127
|
+
#ifdef offsetof
|
128
|
+
#define sigar_offsetof offsetof
|
129
|
+
#else
|
130
|
+
#define sigar_offsetof(type, field) ((size_t)(&((type *)0)->field))
|
131
|
+
#endif
|
132
|
+
|
133
|
+
#define SIGAR_MSEC 1000L
|
134
|
+
#define SIGAR_USEC 1000000L
|
135
|
+
#define SIGAR_NSEC 1000000000L
|
136
|
+
|
137
|
+
#define SIGAR_SEC2NANO(s) \
|
138
|
+
((sigar_uint64_t)(s) * (sigar_uint64_t)SIGAR_NSEC)
|
139
|
+
|
140
|
+
/* cpu ticks to milliseconds */
|
141
|
+
#define SIGAR_TICK2MSEC(s) \
|
142
|
+
((sigar_uint64_t)(s) * ((sigar_uint64_t)SIGAR_MSEC / (double)sigar->ticks))
|
143
|
+
|
144
|
+
#define SIGAR_TICK2NSEC(s) \
|
145
|
+
((sigar_uint64_t)(s) * ((sigar_uint64_t)SIGAR_NSEC / (double)sigar->ticks))
|
146
|
+
|
147
|
+
/* nanoseconds to milliseconds */
|
148
|
+
#define SIGAR_NSEC2MSEC(s) \
|
149
|
+
((sigar_uint64_t)(s) / ((sigar_uint64_t)1000000L))
|
150
|
+
|
151
|
+
#define IFTYPE_LO 2
|
152
|
+
#define IFTYPE_ETH 3
|
153
|
+
|
154
|
+
#define SIGAR_LAST_PROC_EXPIRE 2
|
155
|
+
|
156
|
+
#define SIGAR_BUFFER_EXPIRE 1000
|
157
|
+
|
158
|
+
#define SIGAR_FS_MAX 10
|
159
|
+
|
160
|
+
#define SIGAR_CPU_INFO_MAX 4
|
161
|
+
|
162
|
+
#define SIGAR_CPU_LIST_MAX 4
|
163
|
+
|
164
|
+
#define SIGAR_PROC_LIST_MAX 256
|
165
|
+
|
166
|
+
#define SIGAR_PROC_ARGS_MAX 12
|
167
|
+
|
168
|
+
#define SIGAR_NET_ROUTE_LIST_MAX 6
|
169
|
+
|
170
|
+
#define SIGAR_NET_IFLIST_MAX 20
|
171
|
+
|
172
|
+
#define SIGAR_NET_CONNLIST_MAX 20
|
173
|
+
|
174
|
+
#define SIGAR_ARP_LIST_MAX 12
|
175
|
+
|
176
|
+
#define SIGAR_WHO_LIST_MAX 12
|
177
|
+
|
178
|
+
int sigar_os_open(sigar_t **sigar);
|
179
|
+
|
180
|
+
int sigar_os_close(sigar_t *sigar);
|
181
|
+
|
182
|
+
char *sigar_os_error_string(sigar_t *sigar, int err);
|
183
|
+
|
184
|
+
char *sigar_strerror_get(int err, char *errbuf, int buflen);
|
185
|
+
|
186
|
+
void sigar_strerror_set(sigar_t *sigar, char *msg);
|
187
|
+
|
188
|
+
void sigar_strerror_printf(sigar_t *sigar, const char *format, ...);
|
189
|
+
|
190
|
+
int sigar_sys_info_get_uname(sigar_sys_info_t *sysinfo);
|
191
|
+
|
192
|
+
int sigar_os_sys_info_get(sigar_t *sigar, sigar_sys_info_t *sysinfo);
|
193
|
+
|
194
|
+
int sigar_os_proc_list_get(sigar_t *sigar,
|
195
|
+
sigar_proc_list_t *proclist);
|
196
|
+
|
197
|
+
int sigar_proc_list_create(sigar_proc_list_t *proclist);
|
198
|
+
|
199
|
+
int sigar_proc_list_grow(sigar_proc_list_t *proclist);
|
200
|
+
|
201
|
+
#define SIGAR_PROC_LIST_GROW(proclist) \
|
202
|
+
if (proclist->number >= proclist->size) { \
|
203
|
+
sigar_proc_list_grow(proclist); \
|
204
|
+
}
|
205
|
+
|
206
|
+
int sigar_proc_args_create(sigar_proc_args_t *proclist);
|
207
|
+
|
208
|
+
int sigar_proc_args_grow(sigar_proc_args_t *procargs);
|
209
|
+
|
210
|
+
#define SIGAR_PROC_ARGS_GROW(procargs) \
|
211
|
+
if (procargs->number >= procargs->size) { \
|
212
|
+
sigar_proc_args_grow(procargs); \
|
213
|
+
}
|
214
|
+
|
215
|
+
int sigar_os_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
|
216
|
+
sigar_proc_args_t *procargs);
|
217
|
+
|
218
|
+
int sigar_file_system_list_create(sigar_file_system_list_t *fslist);
|
219
|
+
|
220
|
+
int sigar_file_system_list_grow(sigar_file_system_list_t *fslist);
|
221
|
+
|
222
|
+
#define SIGAR_FILE_SYSTEM_LIST_GROW(fslist) \
|
223
|
+
if (fslist->number >= fslist->size) { \
|
224
|
+
sigar_file_system_list_grow(fslist); \
|
225
|
+
}
|
226
|
+
|
227
|
+
int sigar_os_fs_type_get(sigar_file_system_t *fsp);
|
228
|
+
|
229
|
+
/* os plugins that set fsp->type call fs_type_get directly */
|
230
|
+
#define sigar_fs_type_init(fsp) \
|
231
|
+
fsp->type = SIGAR_FSTYPE_UNKNOWN; \
|
232
|
+
sigar_fs_type_get(fsp)
|
233
|
+
|
234
|
+
void sigar_fs_type_get(sigar_file_system_t *fsp);
|
235
|
+
|
236
|
+
int sigar_cpu_info_list_create(sigar_cpu_info_list_t *cpu_infos);
|
237
|
+
|
238
|
+
int sigar_cpu_info_list_grow(sigar_cpu_info_list_t *cpu_infos);
|
239
|
+
|
240
|
+
#define SIGAR_CPU_INFO_LIST_GROW(cpu_infos) \
|
241
|
+
if (cpu_infos->number >= cpu_infos->size) { \
|
242
|
+
sigar_cpu_info_list_grow(cpu_infos); \
|
243
|
+
}
|
244
|
+
|
245
|
+
int sigar_cpu_list_create(sigar_cpu_list_t *cpulist);
|
246
|
+
|
247
|
+
int sigar_cpu_list_grow(sigar_cpu_list_t *cpulist);
|
248
|
+
|
249
|
+
#define SIGAR_CPU_LIST_GROW(cpulist) \
|
250
|
+
if (cpulist->number >= cpulist->size) { \
|
251
|
+
sigar_cpu_list_grow(cpulist); \
|
252
|
+
}
|
253
|
+
|
254
|
+
int sigar_net_route_list_create(sigar_net_route_list_t *routelist);
|
255
|
+
|
256
|
+
int sigar_net_route_list_grow(sigar_net_route_list_t *net_routelist);
|
257
|
+
|
258
|
+
#define SIGAR_NET_ROUTE_LIST_GROW(routelist) \
|
259
|
+
if (routelist->number >= routelist->size) { \
|
260
|
+
sigar_net_route_list_grow(routelist); \
|
261
|
+
}
|
262
|
+
|
263
|
+
int sigar_net_interface_list_create(sigar_net_interface_list_t *iflist);
|
264
|
+
|
265
|
+
int sigar_net_interface_list_grow(sigar_net_interface_list_t *iflist);
|
266
|
+
|
267
|
+
#define SIGAR_NET_IFLIST_GROW(iflist) \
|
268
|
+
if (iflist->number >= iflist->size) { \
|
269
|
+
sigar_net_interface_list_grow(iflist); \
|
270
|
+
}
|
271
|
+
|
272
|
+
int sigar_net_connection_list_create(sigar_net_connection_list_t *connlist);
|
273
|
+
|
274
|
+
int sigar_net_connection_list_grow(sigar_net_connection_list_t *connlist);
|
275
|
+
|
276
|
+
#define SIGAR_NET_CONNLIST_GROW(connlist) \
|
277
|
+
if (connlist->number >= connlist->size) { \
|
278
|
+
sigar_net_connection_list_grow(connlist); \
|
279
|
+
}
|
280
|
+
|
281
|
+
#define sigar_net_address_set(a, val) \
|
282
|
+
(a).addr.in = val; \
|
283
|
+
(a).family = SIGAR_AF_INET
|
284
|
+
|
285
|
+
#define sigar_net_address6_set(a, val) \
|
286
|
+
memcpy(&((a).addr.in6), val, sizeof((a).addr.in6)); \
|
287
|
+
(a).family = SIGAR_AF_INET6
|
288
|
+
|
289
|
+
#define SIGAR_IFHWADDRLEN 6
|
290
|
+
|
291
|
+
#define sigar_net_address_mac_set(a, val, len) \
|
292
|
+
memcpy(&((a).addr.mac), val, len); \
|
293
|
+
(a).family = SIGAR_AF_LINK
|
294
|
+
|
295
|
+
#define sigar_hwaddr_set_null(ifconfig) \
|
296
|
+
SIGAR_ZERO(&ifconfig->hwaddr.addr.mac); \
|
297
|
+
ifconfig->hwaddr.family = SIGAR_AF_LINK
|
298
|
+
|
299
|
+
int sigar_net_interface_ipv6_config_get(sigar_t *sigar, const char *name,
|
300
|
+
sigar_net_interface_config_t *ifconfig);
|
301
|
+
|
302
|
+
#define sigar_net_interface_ipv6_config_init(ifconfig) \
|
303
|
+
ifconfig->address6.family = SIGAR_AF_INET6; \
|
304
|
+
ifconfig->prefix6_length = 0; \
|
305
|
+
ifconfig->scope6 = 0
|
306
|
+
|
307
|
+
#define SIGAR_SIN6(s) ((struct sockaddr_in6 *)(s))
|
308
|
+
|
309
|
+
#define SIGAR_SIN6_ADDR(s) &SIGAR_SIN6(s)->sin6_addr
|
310
|
+
|
311
|
+
#define sigar_net_interface_scope6_set(ifconfig, addr) \
|
312
|
+
if (IN6_IS_ADDR_LINKLOCAL(addr)) \
|
313
|
+
ifconfig->scope6 = SIGAR_IPV6_ADDR_LINKLOCAL; \
|
314
|
+
else if (IN6_IS_ADDR_SITELOCAL(addr)) \
|
315
|
+
ifconfig->scope6 = SIGAR_IPV6_ADDR_SITELOCAL; \
|
316
|
+
else if (IN6_IS_ADDR_V4COMPAT(addr)) \
|
317
|
+
ifconfig->scope6 = SIGAR_IPV6_ADDR_COMPATv4; \
|
318
|
+
else if (IN6_IS_ADDR_LOOPBACK(addr)) \
|
319
|
+
ifconfig->scope6 = SIGAR_IPV6_ADDR_LOOPBACK; \
|
320
|
+
else \
|
321
|
+
ifconfig->scope6 = SIGAR_IPV6_ADDR_ANY
|
322
|
+
|
323
|
+
int sigar_tcp_curr_estab(sigar_t *sigar, sigar_tcp_t *tcp);
|
324
|
+
|
325
|
+
int sigar_arp_list_create(sigar_arp_list_t *arplist);
|
326
|
+
|
327
|
+
int sigar_arp_list_grow(sigar_arp_list_t *arplist);
|
328
|
+
|
329
|
+
#define SIGAR_ARP_LIST_GROW(arplist) \
|
330
|
+
if (arplist->number >= arplist->size) { \
|
331
|
+
sigar_arp_list_grow(arplist); \
|
332
|
+
}
|
333
|
+
|
334
|
+
int sigar_who_list_create(sigar_who_list_t *wholist);
|
335
|
+
|
336
|
+
int sigar_who_list_grow(sigar_who_list_t *wholist);
|
337
|
+
|
338
|
+
#define SIGAR_WHO_LIST_GROW(wholist) \
|
339
|
+
if (wholist->number >= wholist->size) { \
|
340
|
+
sigar_who_list_grow(wholist); \
|
341
|
+
}
|
342
|
+
|
343
|
+
int sigar_user_id_get(sigar_t *sigar, const char *name, int *uid);
|
344
|
+
|
345
|
+
int sigar_user_name_get(sigar_t *sigar, int uid, char *buf, int buflen);
|
346
|
+
|
347
|
+
int sigar_group_name_get(sigar_t *sigar, int gid, char *buf, int buflen);
|
348
|
+
|
349
|
+
#define SIGAR_PROC_ENV_KEY_LOOKUP() \
|
350
|
+
if ((procenv->type == SIGAR_PROC_ENV_KEY) && \
|
351
|
+
(pid == sigar->pid)) \
|
352
|
+
{ \
|
353
|
+
char *value = getenv(procenv->key); \
|
354
|
+
if (value != NULL) { \
|
355
|
+
procenv->env_getter(procenv->data, \
|
356
|
+
procenv->key, \
|
357
|
+
procenv->klen, \
|
358
|
+
value, strlen(value)); \
|
359
|
+
} \
|
360
|
+
return SIGAR_OK; \
|
361
|
+
}
|
362
|
+
|
363
|
+
#define SIGAR_DISK_STATS_INIT(disk) \
|
364
|
+
(disk)->reads = (disk)->writes = \
|
365
|
+
(disk)->read_bytes = (disk)->write_bytes = \
|
366
|
+
(disk)->rtime = (disk)->wtime = (disk)->qtime = (disk)->time = \
|
367
|
+
(disk)->queue = (disk)->service_time = SIGAR_FIELD_NOTIMPL; \
|
368
|
+
(disk)->snaptime = 0
|
369
|
+
|
370
|
+
/* key used for filesystem (/) -> device (/dev/hda1) mapping */
|
371
|
+
/* and disk_usage cache for service_time */
|
372
|
+
#define SIGAR_FSDEV_ID(sb) \
|
373
|
+
(S_ISBLK((sb).st_mode) ? (sb).st_rdev : ((sb).st_ino + (sb).st_dev))
|
374
|
+
|
375
|
+
#if defined(WIN32) || defined(NETWARE)
|
376
|
+
int sigar_get_iftype(const char *name, int *type, int *inst);
|
377
|
+
#endif
|
378
|
+
|
379
|
+
#define SIGAR_NIC_LOOPBACK "Local Loopback"
|
380
|
+
#define SIGAR_NIC_UNSPEC "UNSPEC"
|
381
|
+
#define SIGAR_NIC_SLIP "Serial Line IP"
|
382
|
+
#define SIGAR_NIC_CSLIP "VJ Serial Line IP"
|
383
|
+
#define SIGAR_NIC_SLIP6 "6-bit Serial Line IP"
|
384
|
+
#define SIGAR_NIC_CSLIP6 "VJ 6-bit Serial Line IP"
|
385
|
+
#define SIGAR_NIC_ADAPTIVE "Adaptive Serial Line IP"
|
386
|
+
#define SIGAR_NIC_ETHERNET "Ethernet"
|
387
|
+
#define SIGAR_NIC_ASH "Ash"
|
388
|
+
#define SIGAR_NIC_FDDI "Fiber Distributed Data Interface"
|
389
|
+
#define SIGAR_NIC_HIPPI "HIPPI"
|
390
|
+
#define SIGAR_NIC_AX25 "AMPR AX.25"
|
391
|
+
#define SIGAR_NIC_ROSE "AMPR ROSE"
|
392
|
+
#define SIGAR_NIC_NETROM "AMPR NET/ROM"
|
393
|
+
#define SIGAR_NIC_X25 "generic X.25"
|
394
|
+
#define SIGAR_NIC_TUNNEL "IPIP Tunnel"
|
395
|
+
#define SIGAR_NIC_PPP "Point-to-Point Protocol"
|
396
|
+
#define SIGAR_NIC_HDLC "(Cisco)-HDLC"
|
397
|
+
#define SIGAR_NIC_LAPB "LAPB"
|
398
|
+
#define SIGAR_NIC_ARCNET "ARCnet"
|
399
|
+
#define SIGAR_NIC_DLCI "Frame Relay DLCI"
|
400
|
+
#define SIGAR_NIC_FRAD "Frame Relay Access Device"
|
401
|
+
#define SIGAR_NIC_SIT "IPv6-in-IPv4"
|
402
|
+
#define SIGAR_NIC_IRDA "IrLAP"
|
403
|
+
#define SIGAR_NIC_EC "Econet"
|
404
|
+
#define PID_CACHE_CLEANUP_PERIOD 1000*60*10 /* 10 minutes */
|
405
|
+
#define PID_CACHE_ENTRY_EXPIRE_PERIOD 1000*60*20 /* 20 minutes */
|
406
|
+
#ifndef WIN32
|
407
|
+
#include <netdb.h>
|
408
|
+
#endif
|
409
|
+
|
410
|
+
#define PROC_PID_CPU_CACHE 1
|
411
|
+
#define PROC_PID_IO_CACHE 2
|
412
|
+
|
413
|
+
#define SIGAR_HOSTENT_LEN 1024
|
414
|
+
#if defined(_AIX)
|
415
|
+
#define SIGAR_HAS_HOSTENT_DATA
|
416
|
+
#endif
|
417
|
+
|
418
|
+
typedef struct {
|
419
|
+
char buffer[SIGAR_HOSTENT_LEN];
|
420
|
+
int error;
|
421
|
+
#ifndef WIN32
|
422
|
+
struct hostent hs;
|
423
|
+
#endif
|
424
|
+
#ifdef SIGAR_HAS_HOSTENT_DATA
|
425
|
+
struct hostent_data hd;
|
426
|
+
#endif
|
427
|
+
} sigar_hostent_t;
|
428
|
+
|
429
|
+
#endif
|
@@ -0,0 +1,53 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2006-2007 Hyperic, Inc.
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
#ifndef SIGAR_PTQL_H
|
18
|
+
#define SIGAR_PTQL_H
|
19
|
+
|
20
|
+
#define SIGAR_PTQL_MALFORMED_QUERY -1
|
21
|
+
|
22
|
+
typedef struct sigar_ptql_query_t sigar_ptql_query_t;
|
23
|
+
|
24
|
+
#define SIGAR_PTQL_ERRMSG_SIZE 1024
|
25
|
+
|
26
|
+
typedef struct {
|
27
|
+
char message[SIGAR_PTQL_ERRMSG_SIZE];
|
28
|
+
} sigar_ptql_error_t;
|
29
|
+
|
30
|
+
typedef int (*sigar_ptql_re_impl_t)(void *, char *, char *);
|
31
|
+
|
32
|
+
SIGAR_DECLARE(void) sigar_ptql_re_impl_set(sigar_t *sigar, void *data,
|
33
|
+
sigar_ptql_re_impl_t impl);
|
34
|
+
|
35
|
+
SIGAR_DECLARE(int) sigar_ptql_query_create(sigar_ptql_query_t **query,
|
36
|
+
char *ptql,
|
37
|
+
sigar_ptql_error_t *error);
|
38
|
+
|
39
|
+
SIGAR_DECLARE(int) sigar_ptql_query_match(sigar_t *sigar,
|
40
|
+
sigar_ptql_query_t *query,
|
41
|
+
sigar_pid_t pid);
|
42
|
+
|
43
|
+
SIGAR_DECLARE(int) sigar_ptql_query_destroy(sigar_ptql_query_t *query);
|
44
|
+
|
45
|
+
SIGAR_DECLARE(int) sigar_ptql_query_find_process(sigar_t *sigar,
|
46
|
+
sigar_ptql_query_t *query,
|
47
|
+
sigar_pid_t *pid);
|
48
|
+
|
49
|
+
SIGAR_DECLARE(int) sigar_ptql_query_find(sigar_t *sigar,
|
50
|
+
sigar_ptql_query_t *query,
|
51
|
+
sigar_proc_list_t *proclist);
|
52
|
+
|
53
|
+
#endif /*SIGAR_PTQL_H*/
|
@@ -0,0 +1,197 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2004-2008 Hyperic, Inc.
|
3
|
+
* Copyright (c) 2009 SpringSource, Inc.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
|
18
|
+
#ifndef SIGAR_UTIL_H
|
19
|
+
#define SIGAR_UTIL_H
|
20
|
+
|
21
|
+
/* most of this is crap for dealing with linux /proc */
|
22
|
+
#define UITOA_BUFFER_SIZE \
|
23
|
+
(sizeof(int) * 3 + 1)
|
24
|
+
|
25
|
+
#define SSTRLEN(s) \
|
26
|
+
(sizeof(s)-1)
|
27
|
+
|
28
|
+
#define sigar_strtoul(ptr) \
|
29
|
+
strtoul(ptr, &ptr, 10)
|
30
|
+
|
31
|
+
#define sigar_strtoull(ptr) \
|
32
|
+
strtoull(ptr, &ptr, 10)
|
33
|
+
|
34
|
+
#define sigar_isspace(c) \
|
35
|
+
(isspace(((unsigned char)(c))))
|
36
|
+
|
37
|
+
#define sigar_isdigit(c) \
|
38
|
+
(isdigit(((unsigned char)(c))))
|
39
|
+
|
40
|
+
#define sigar_isalpha(c) \
|
41
|
+
(isalpha(((unsigned char)(c))))
|
42
|
+
|
43
|
+
#define sigar_isupper(c) \
|
44
|
+
(isupper(((unsigned char)(c))))
|
45
|
+
|
46
|
+
#define sigar_tolower(c) \
|
47
|
+
(tolower(((unsigned char)(c))))
|
48
|
+
|
49
|
+
#ifdef WIN32
|
50
|
+
#define sigar_fileno _fileno
|
51
|
+
#define sigar_isatty _isatty
|
52
|
+
#define sigar_write _write
|
53
|
+
#else
|
54
|
+
#define sigar_fileno fileno
|
55
|
+
#define sigar_isatty isatty
|
56
|
+
#define sigar_write write
|
57
|
+
#endif
|
58
|
+
|
59
|
+
#ifndef PROC_FS_ROOT
|
60
|
+
#define PROC_FS_ROOT "/proc/"
|
61
|
+
#endif
|
62
|
+
|
63
|
+
#ifndef PROCP_FS_ROOT
|
64
|
+
#define PROCP_FS_ROOT "/proc/"
|
65
|
+
#endif
|
66
|
+
|
67
|
+
sigar_int64_t sigar_time_now_millis(void);
|
68
|
+
|
69
|
+
char *sigar_uitoa(char *buf, unsigned int n, int *len);
|
70
|
+
|
71
|
+
int sigar_inet_ntoa(sigar_t *sigar,
|
72
|
+
sigar_uint32_t address,
|
73
|
+
char *addr_str);
|
74
|
+
|
75
|
+
struct hostent *sigar_gethostbyname(const char *name,
|
76
|
+
sigar_hostent_t *data);
|
77
|
+
|
78
|
+
SIGAR_INLINE char *sigar_skip_line(char *buffer, int buflen);
|
79
|
+
|
80
|
+
SIGAR_INLINE char *sigar_skip_token(char *p);
|
81
|
+
|
82
|
+
SIGAR_INLINE char *sigar_skip_multiple_token(char *p, int count);
|
83
|
+
|
84
|
+
char *sigar_getword(char **line, char stop);
|
85
|
+
|
86
|
+
char *sigar_strcasestr(const char *s1, const char *s2);
|
87
|
+
|
88
|
+
int sigar_file2str(const char *fname, char *buffer, int buflen);
|
89
|
+
|
90
|
+
int sigar_proc_file2str(char *buffer, int buflen,
|
91
|
+
sigar_pid_t pid,
|
92
|
+
const char *fname,
|
93
|
+
int fname_len);
|
94
|
+
|
95
|
+
#define SIGAR_PROC_FILE2STR(buffer, pid, fname) \
|
96
|
+
sigar_proc_file2str(buffer, sizeof(buffer), \
|
97
|
+
pid, fname, SSTRLEN(fname))
|
98
|
+
|
99
|
+
#define SIGAR_PROC_FILENAME(buffer, pid, fname) \
|
100
|
+
sigar_proc_filename(buffer, sizeof(buffer), \
|
101
|
+
pid, fname, SSTRLEN(fname))
|
102
|
+
|
103
|
+
#define SIGAR_SKIP_SPACE(ptr) \
|
104
|
+
while (sigar_isspace(*ptr)) ++ptr
|
105
|
+
|
106
|
+
char *sigar_proc_filename(char *buffer, int buflen,
|
107
|
+
sigar_pid_t pid,
|
108
|
+
const char *fname, int fname_len);
|
109
|
+
|
110
|
+
int sigar_proc_list_procfs_get(sigar_t *sigar,
|
111
|
+
sigar_proc_list_t *proclist);
|
112
|
+
|
113
|
+
int sigar_proc_fd_count(sigar_t *sigar, sigar_pid_t pid,
|
114
|
+
sigar_uint64_t *total);
|
115
|
+
|
116
|
+
/* linux + freebsd */
|
117
|
+
int sigar_procfs_args_get(sigar_t *sigar, sigar_pid_t pid,
|
118
|
+
sigar_proc_args_t *procargs);
|
119
|
+
|
120
|
+
int sigar_mem_calc_ram(sigar_t *sigar, sigar_mem_t *mem);
|
121
|
+
|
122
|
+
int sigar_statvfs(sigar_t *sigar,
|
123
|
+
const char *dirname,
|
124
|
+
sigar_file_system_usage_t *fsusage);
|
125
|
+
|
126
|
+
double sigar_file_system_usage_calc_used(sigar_t *sigar,
|
127
|
+
sigar_file_system_usage_t *fs);
|
128
|
+
|
129
|
+
#define SIGAR_DEV_PREFIX "/dev/"
|
130
|
+
|
131
|
+
#define SIGAR_NAME_IS_DEV(dev) \
|
132
|
+
strnEQ(dev, SIGAR_DEV_PREFIX, SSTRLEN(SIGAR_DEV_PREFIX))
|
133
|
+
|
134
|
+
typedef struct {
|
135
|
+
char name[256];
|
136
|
+
int is_partition;
|
137
|
+
sigar_disk_usage_t disk;
|
138
|
+
} sigar_iodev_t;
|
139
|
+
|
140
|
+
sigar_iodev_t *sigar_iodev_get(sigar_t *sigar,
|
141
|
+
const char *dirname);
|
142
|
+
|
143
|
+
int sigar_cpu_core_count(sigar_t *sigar);
|
144
|
+
|
145
|
+
/* e.g. VM guest may have 1 virtual ncpu on multicore hosts */
|
146
|
+
#define sigar_cpu_socket_count(sigar) \
|
147
|
+
(sigar->ncpu < sigar->lcpu) ? sigar->ncpu : \
|
148
|
+
(sigar->ncpu / sigar->lcpu)
|
149
|
+
|
150
|
+
int sigar_cpu_core_rollup(sigar_t *sigar);
|
151
|
+
|
152
|
+
void sigar_cpu_model_adjust(sigar_t *sigar, sigar_cpu_info_t *info);
|
153
|
+
|
154
|
+
int sigar_cpu_mhz_from_model(char *model);
|
155
|
+
|
156
|
+
char *sigar_get_self_path(sigar_t *sigar);
|
157
|
+
|
158
|
+
#if defined(__sun) || defined(__FreeBSD__)
|
159
|
+
|
160
|
+
#define SIGAR_HAS_DLINFO_MODULES
|
161
|
+
#include <dlfcn.h>
|
162
|
+
#include <link.h>
|
163
|
+
|
164
|
+
int sigar_dlinfo_modules(sigar_t *sigar, sigar_proc_modules_t *procmods);
|
165
|
+
#endif
|
166
|
+
|
167
|
+
typedef struct sigar_cache_entry_t sigar_cache_entry_t;
|
168
|
+
|
169
|
+
struct sigar_cache_entry_t {
|
170
|
+
sigar_cache_entry_t *next;
|
171
|
+
sigar_uint64_t id;
|
172
|
+
void *value;
|
173
|
+
sigar_uint64_t last_access_time;
|
174
|
+
};
|
175
|
+
|
176
|
+
typedef struct {
|
177
|
+
sigar_cache_entry_t **entries;
|
178
|
+
unsigned int count, size;
|
179
|
+
void (*free_value)(void *ptr);
|
180
|
+
sigar_uint64_t entry_expire_period;
|
181
|
+
sigar_uint64_t cleanup_period_millis;
|
182
|
+
sigar_uint64_t last_cleanup_time;
|
183
|
+
} sigar_cache_t;
|
184
|
+
|
185
|
+
sigar_cache_t *sigar_cache_new(int size);
|
186
|
+
sigar_cache_t *sigar_expired_cache_new(int size, sigar_uint64_t cleanup_period_millis, sigar_uint64_t entry_expire_period);
|
187
|
+
void sigar_cache_dump(sigar_cache_t *table);
|
188
|
+
|
189
|
+
sigar_cache_entry_t *sigar_cache_get(sigar_cache_t *table,
|
190
|
+
sigar_uint64_t key);
|
191
|
+
|
192
|
+
sigar_cache_entry_t *sigar_cache_find(sigar_cache_t *table,
|
193
|
+
sigar_uint64_t key);
|
194
|
+
|
195
|
+
void sigar_cache_destroy(sigar_cache_t *table);
|
196
|
+
|
197
|
+
#endif /* SIGAR_UTIL_H */
|