sigar-test 0.7.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/NOTICE +117 -0
  4. data/README +2 -0
  5. data/Rakefile +105 -0
  6. data/bindings/SigarBuild.pm +301 -0
  7. data/bindings/SigarWrapper.pm +3025 -0
  8. data/bindings/ruby/extconf.rb +131 -0
  9. data/bindings/ruby/rbsigar.c +888 -0
  10. data/include/sigar.h +984 -0
  11. data/include/sigar_fileinfo.h +157 -0
  12. data/include/sigar_format.h +65 -0
  13. data/include/sigar_getline.h +18 -0
  14. data/include/sigar_log.h +80 -0
  15. data/include/sigar_private.h +429 -0
  16. data/include/sigar_ptql.h +53 -0
  17. data/include/sigar_util.h +197 -0
  18. data/src/os/aix/aix_sigar.c +2168 -0
  19. data/src/os/aix/sigar_os.h +73 -0
  20. data/src/os/darwin/Info.plist.in +27 -0
  21. data/src/os/darwin/darwin_sigar.c +3718 -0
  22. data/src/os/darwin/sigar_os.h +80 -0
  23. data/src/os/hpux/hpux_sigar.c +1361 -0
  24. data/src/os/hpux/sigar_os.h +49 -0
  25. data/src/os/linux/linux_sigar.c +2810 -0
  26. data/src/os/linux/sigar_os.h +82 -0
  27. data/src/os/solaris/get_mib2.c +321 -0
  28. data/src/os/solaris/get_mib2.h +127 -0
  29. data/src/os/solaris/kstats.c +181 -0
  30. data/src/os/solaris/procfs.c +97 -0
  31. data/src/os/solaris/sigar_os.h +224 -0
  32. data/src/os/solaris/solaris_sigar.c +2732 -0
  33. data/src/os/win32/peb.c +212 -0
  34. data/src/os/win32/sigar.rc.in +40 -0
  35. data/src/os/win32/sigar_os.h +685 -0
  36. data/src/os/win32/sigar_pdh.h +47 -0
  37. data/src/os/win32/win32_sigar.c +4109 -0
  38. data/src/sigar.c +2444 -0
  39. data/src/sigar_cache.c +253 -0
  40. data/src/sigar_fileinfo.c +815 -0
  41. data/src/sigar_format.c +696 -0
  42. data/src/sigar_getline.c +1849 -0
  43. data/src/sigar_ptql.c +1976 -0
  44. data/src/sigar_signal.c +216 -0
  45. data/src/sigar_util.c +1060 -0
  46. data/src/sigar_version.c.in +22 -0
  47. data/src/sigar_version_autoconf.c.in +22 -0
  48. data/version.properties +11 -0
  49. metadata +91 -0
data/include/sigar.h ADDED
@@ -0,0 +1,984 @@
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_H
20
+ #define SIGAR_H
21
+
22
+ /* System Information Gatherer And Reporter */
23
+
24
+ #include <limits.h>
25
+
26
+ #ifndef MAX_INTERFACE_NAME_LEN
27
+ #define MAX_INTERFACE_NAME_LEN 256
28
+ #endif
29
+
30
+ #ifdef __cplusplus
31
+ extern "C" {
32
+ #endif
33
+
34
+ #if defined(_LP64) || \
35
+ defined(__LP64__) || \
36
+ defined(__64BIT__) || \
37
+ defined(__powerpc64__) || \
38
+ defined(__osf__)
39
+ #define SIGAR_64BIT
40
+ #endif
41
+
42
+ /* for printf sigar_uint64_t */
43
+ #ifdef SIGAR_64BIT
44
+ # define SIGAR_F_U64 "%lu"
45
+ #else
46
+ # define SIGAR_F_U64 "%Lu"
47
+ #endif
48
+
49
+ #if defined(WIN32)
50
+
51
+ typedef unsigned __int32 sigar_uint32_t;
52
+
53
+ typedef unsigned __int64 sigar_uint64_t;
54
+
55
+ typedef __int32 sigar_int32_t;
56
+
57
+ typedef __int64 sigar_int64_t;
58
+
59
+ #elif ULONG_MAX > 4294967295UL
60
+
61
+ typedef unsigned int sigar_uint32_t;
62
+
63
+ typedef unsigned long sigar_uint64_t;
64
+
65
+ typedef int sigar_int32_t;
66
+
67
+ typedef long sigar_int64_t;
68
+
69
+ #else
70
+
71
+ typedef unsigned int sigar_uint32_t;
72
+
73
+ typedef unsigned long long sigar_uint64_t;
74
+
75
+ typedef int sigar_int32_t;
76
+
77
+ typedef long long sigar_int64_t;
78
+
79
+ #endif
80
+
81
+ #define SIGAR_FIELD_NOTIMPL -1
82
+
83
+ #define SIGAR_OK 0
84
+ #define SIGAR_START_ERROR 20000
85
+ #define SIGAR_ENOTIMPL (SIGAR_START_ERROR + 1)
86
+ #define SIGAR_OS_START_ERROR (SIGAR_START_ERROR*2)
87
+
88
+ #ifdef WIN32
89
+ # define SIGAR_ENOENT ERROR_FILE_NOT_FOUND
90
+ # define SIGAR_EACCES ERROR_ACCESS_DENIED
91
+ # define SIGAR_ENXIO ERROR_BAD_DRIVER_LEVEL
92
+ #else
93
+ # define SIGAR_ENOENT ENOENT
94
+ # define SIGAR_EACCES EACCES
95
+ # define SIGAR_ENXIO ENXIO
96
+ #endif
97
+
98
+ #ifdef WIN32
99
+ # define SIGAR_DECLARE(type) \
100
+ __declspec(dllexport) type __stdcall
101
+ #else
102
+ # define SIGAR_DECLARE(type) type
103
+ #endif
104
+
105
+ #if defined(PATH_MAX)
106
+ # define SIGAR_PATH_MAX PATH_MAX
107
+ #elif defined(MAXPATHLEN)
108
+ # define SIGAR_PATH_MAX MAXPATHLEN
109
+ #else
110
+ # define SIGAR_PATH_MAX 4096
111
+ #endif
112
+
113
+ #ifdef WIN32
114
+ typedef sigar_uint64_t sigar_pid_t;
115
+ typedef unsigned long sigar_uid_t;
116
+ typedef unsigned long sigar_gid_t;
117
+ #else
118
+ #include <sys/types.h>
119
+ typedef pid_t sigar_pid_t;
120
+ typedef uid_t sigar_uid_t;
121
+ typedef gid_t sigar_gid_t;
122
+ #endif
123
+
124
+ typedef struct sigar_t sigar_t;
125
+
126
+ SIGAR_DECLARE(int) sigar_open(sigar_t **sigar);
127
+
128
+ SIGAR_DECLARE(int) sigar_close(sigar_t *sigar);
129
+
130
+ SIGAR_DECLARE(sigar_pid_t) sigar_pid_get(sigar_t *sigar);
131
+
132
+ SIGAR_DECLARE(int) sigar_proc_kill(sigar_pid_t pid, int signum);
133
+
134
+ SIGAR_DECLARE(int) sigar_signum_get(char *name);
135
+
136
+ SIGAR_DECLARE(char *) sigar_strerror(sigar_t *sigar, int err);
137
+
138
+ /* system memory info */
139
+
140
+ typedef struct {
141
+ sigar_uint64_t
142
+ ram,
143
+ total,
144
+ used,
145
+ free,
146
+ actual_used,
147
+ actual_free;
148
+ double used_percent;
149
+ double free_percent;
150
+ } sigar_mem_t;
151
+
152
+ SIGAR_DECLARE(int) sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem);
153
+
154
+ typedef struct {
155
+ sigar_uint64_t
156
+ total,
157
+ used,
158
+ free,
159
+ page_in,
160
+ page_out;
161
+ } sigar_swap_t;
162
+
163
+ SIGAR_DECLARE(int) sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap);
164
+
165
+ typedef struct {
166
+ sigar_uint64_t
167
+ user,
168
+ sys,
169
+ nice,
170
+ idle,
171
+ wait,
172
+ irq,
173
+ soft_irq,
174
+ stolen,
175
+ total;
176
+ } sigar_cpu_t;
177
+
178
+ SIGAR_DECLARE(int) sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu);
179
+
180
+ typedef struct {
181
+ unsigned long number;
182
+ unsigned long size;
183
+ sigar_cpu_t *data;
184
+ } sigar_cpu_list_t;
185
+
186
+ SIGAR_DECLARE(int) sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist);
187
+
188
+ SIGAR_DECLARE(int) sigar_cpu_list_destroy(sigar_t *sigar,
189
+ sigar_cpu_list_t *cpulist);
190
+
191
+ typedef struct {
192
+ char vendor[128];
193
+ char model[128];
194
+ int mhz;
195
+ int mhz_max;
196
+ int mhz_min;
197
+ sigar_uint64_t cache_size;
198
+ int total_sockets;
199
+ int total_cores;
200
+ int cores_per_socket;
201
+ } sigar_cpu_info_t;
202
+
203
+ typedef struct {
204
+ unsigned long number;
205
+ unsigned long size;
206
+ sigar_cpu_info_t *data;
207
+ } sigar_cpu_info_list_t;
208
+
209
+ SIGAR_DECLARE(int)
210
+ sigar_cpu_info_list_get(sigar_t *sigar,
211
+ sigar_cpu_info_list_t *cpu_infos);
212
+
213
+ SIGAR_DECLARE(int)
214
+ sigar_cpu_info_list_destroy(sigar_t *sigar,
215
+ sigar_cpu_info_list_t *cpu_infos);
216
+
217
+ typedef struct {
218
+ double uptime;
219
+ } sigar_uptime_t;
220
+
221
+ SIGAR_DECLARE(int) sigar_uptime_get(sigar_t *sigar,
222
+ sigar_uptime_t *uptime);
223
+
224
+ typedef struct {
225
+ double loadavg[3];
226
+ } sigar_loadavg_t;
227
+
228
+ SIGAR_DECLARE(int) sigar_loadavg_get(sigar_t *sigar,
229
+ sigar_loadavg_t *loadavg);
230
+
231
+ typedef struct {
232
+ unsigned long number;
233
+ unsigned long size;
234
+ sigar_pid_t *data;
235
+ } sigar_proc_list_t;
236
+
237
+ typedef struct {
238
+ /* RLIMIT_CPU */
239
+ sigar_uint64_t cpu_cur, cpu_max;
240
+ /* RLIMIT_FSIZE */
241
+ sigar_uint64_t file_size_cur, file_size_max;
242
+ /* PIPE_BUF */
243
+ sigar_uint64_t pipe_size_cur, pipe_size_max;
244
+ /* RLIMIT_DATA */
245
+ sigar_uint64_t data_cur, data_max;
246
+ /* RLIMIT_STACK */
247
+ sigar_uint64_t stack_cur, stack_max;
248
+ /* RLIMIT_CORE */
249
+ sigar_uint64_t core_cur, core_max;
250
+ /* RLIMIT_RSS */
251
+ sigar_uint64_t memory_cur, memory_max;
252
+ /* RLIMIT_NPROC */
253
+ sigar_uint64_t processes_cur, processes_max;
254
+ /* RLIMIT_NOFILE */
255
+ sigar_uint64_t open_files_cur, open_files_max;
256
+ /* RLIMIT_AS */
257
+ sigar_uint64_t virtual_memory_cur, virtual_memory_max;
258
+ } sigar_resource_limit_t;
259
+
260
+ SIGAR_DECLARE(int) sigar_resource_limit_get(sigar_t *sigar,
261
+ sigar_resource_limit_t *rlimit);
262
+
263
+ SIGAR_DECLARE(int) sigar_proc_list_get(sigar_t *sigar,
264
+ sigar_proc_list_t *proclist);
265
+
266
+ SIGAR_DECLARE(int) sigar_proc_list_destroy(sigar_t *sigar,
267
+ sigar_proc_list_t *proclist);
268
+
269
+ typedef struct {
270
+ sigar_uint64_t total;
271
+ sigar_uint64_t sleeping;
272
+ sigar_uint64_t running;
273
+ sigar_uint64_t zombie;
274
+ sigar_uint64_t stopped;
275
+ sigar_uint64_t idle;
276
+ sigar_uint64_t threads;
277
+ } sigar_proc_stat_t;
278
+
279
+ SIGAR_DECLARE(int) sigar_proc_stat_get(sigar_t *sigar,
280
+ sigar_proc_stat_t *procstat);
281
+
282
+ typedef struct {
283
+ sigar_uint64_t
284
+ size,
285
+ resident,
286
+ share,
287
+ minor_faults,
288
+ major_faults,
289
+ page_faults;
290
+ } sigar_proc_mem_t;
291
+
292
+ SIGAR_DECLARE(int) sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid,
293
+ sigar_proc_mem_t *procmem);
294
+
295
+ typedef struct {
296
+ sigar_uint64_t
297
+ bytes_read,
298
+ bytes_written,
299
+ bytes_total;
300
+ } sigar_proc_disk_io_t;
301
+
302
+ SIGAR_DECLARE(int) sigar_proc_disk_io_get(sigar_t *sigar, sigar_pid_t pid,
303
+ sigar_proc_disk_io_t *proc_disk_io);
304
+
305
+ typedef struct {
306
+ sigar_uint64_t
307
+ bytes_read,
308
+ bytes_written,
309
+ bytes_total;
310
+ sigar_uint64_t last_time;
311
+ sigar_uint64_t
312
+ bytes_read_diff,
313
+ bytes_written_diff,
314
+ bytes_total_diff;
315
+ } sigar_cached_proc_disk_io_t;
316
+
317
+
318
+ typedef struct {
319
+ sigar_uint64_t
320
+ bytes_read,
321
+ bytes_written,
322
+ bytes_total;
323
+ } sigar_proc_cumulative_disk_io_t;
324
+
325
+ SIGAR_DECLARE(int) sigar_proc_cumulative_disk_io_get(sigar_t *sigar, sigar_pid_t pid,
326
+ sigar_proc_cumulative_disk_io_t *proc_cumulative_disk_io);
327
+
328
+
329
+ typedef struct {
330
+ sigar_uint64_t dummy;
331
+ }sigar_dump_pid_cache_t;
332
+
333
+ SIGAR_DECLARE(int) sigar_dump_pid_cache_get(sigar_t *sigar, sigar_dump_pid_cache_t *info);
334
+
335
+
336
+ typedef struct {
337
+ sigar_uid_t uid;
338
+ sigar_gid_t gid;
339
+ sigar_uid_t euid;
340
+ sigar_gid_t egid;
341
+ } sigar_proc_cred_t;
342
+
343
+ SIGAR_DECLARE(int) sigar_proc_cred_get(sigar_t *sigar, sigar_pid_t pid,
344
+ sigar_proc_cred_t *proccred);
345
+
346
+ #define SIGAR_CRED_NAME_MAX 512
347
+
348
+ typedef struct {
349
+ char user[SIGAR_CRED_NAME_MAX];
350
+ char group[SIGAR_CRED_NAME_MAX];
351
+ } sigar_proc_cred_name_t;
352
+
353
+ SIGAR_DECLARE(int)
354
+ sigar_proc_cred_name_get(sigar_t *sigar, sigar_pid_t pid,
355
+ sigar_proc_cred_name_t *proccredname);
356
+
357
+ typedef struct {
358
+ sigar_uint64_t
359
+ start_time,
360
+ user,
361
+ sys,
362
+ total;
363
+ } sigar_proc_time_t;
364
+
365
+ SIGAR_DECLARE(int) sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid,
366
+ sigar_proc_time_t *proctime);
367
+
368
+ typedef struct {
369
+ /* must match sigar_proc_time_t fields */
370
+ sigar_uint64_t
371
+ start_time,
372
+ user,
373
+ sys,
374
+ total;
375
+ sigar_uint64_t last_time;
376
+ double percent;
377
+ } sigar_proc_cpu_t;
378
+
379
+ SIGAR_DECLARE(int) sigar_proc_cpu_get(sigar_t *sigar, sigar_pid_t pid,
380
+ sigar_proc_cpu_t *proccpu);
381
+
382
+ #define SIGAR_PROC_STATE_SLEEP 'S'
383
+ #define SIGAR_PROC_STATE_RUN 'R'
384
+ #define SIGAR_PROC_STATE_STOP 'T'
385
+ #define SIGAR_PROC_STATE_ZOMBIE 'Z'
386
+ #define SIGAR_PROC_STATE_IDLE 'D'
387
+
388
+ #define SIGAR_PROC_NAME_LEN 128
389
+
390
+ typedef struct {
391
+ char name[SIGAR_PROC_NAME_LEN];
392
+ char state;
393
+ sigar_pid_t ppid;
394
+ int tty;
395
+ int priority;
396
+ int nice;
397
+ int processor;
398
+ sigar_uint64_t threads;
399
+ } sigar_proc_state_t;
400
+
401
+ SIGAR_DECLARE(int) sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid,
402
+ sigar_proc_state_t *procstate);
403
+
404
+ typedef struct {
405
+ unsigned long number;
406
+ unsigned long size;
407
+ char **data;
408
+ } sigar_proc_args_t;
409
+
410
+ SIGAR_DECLARE(int) sigar_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
411
+ sigar_proc_args_t *procargs);
412
+
413
+ SIGAR_DECLARE(int) sigar_proc_args_destroy(sigar_t *sigar,
414
+ sigar_proc_args_t *procargs);
415
+
416
+ typedef struct {
417
+ void *data; /* user data */
418
+
419
+ enum {
420
+ SIGAR_PROC_ENV_ALL,
421
+ SIGAR_PROC_ENV_KEY
422
+ } type;
423
+
424
+ /* used for SIGAR_PROC_ENV_KEY */
425
+ const char *key;
426
+ int klen;
427
+
428
+ int (*env_getter)(void *, const char *, int, char *, int);
429
+ } sigar_proc_env_t;
430
+
431
+ SIGAR_DECLARE(int) sigar_proc_env_get(sigar_t *sigar, sigar_pid_t pid,
432
+ sigar_proc_env_t *procenv);
433
+
434
+ typedef struct {
435
+ sigar_uint64_t total;
436
+ /* XXX - which are files, sockets, etc. */
437
+ } sigar_proc_fd_t;
438
+
439
+ SIGAR_DECLARE(int) sigar_proc_fd_get(sigar_t *sigar, sigar_pid_t pid,
440
+ sigar_proc_fd_t *procfd);
441
+
442
+ typedef struct {
443
+ char name[SIGAR_PATH_MAX+1];
444
+ char cwd[SIGAR_PATH_MAX+1];
445
+ char root[SIGAR_PATH_MAX+1];
446
+ } sigar_proc_exe_t;
447
+
448
+ SIGAR_DECLARE(int) sigar_proc_exe_get(sigar_t *sigar, sigar_pid_t pid,
449
+ sigar_proc_exe_t *procexe);
450
+
451
+ typedef struct {
452
+ void *data; /* user data */
453
+
454
+ int (*module_getter)(void *, char *, int);
455
+ } sigar_proc_modules_t;
456
+
457
+ SIGAR_DECLARE(int) sigar_proc_modules_get(sigar_t *sigar, sigar_pid_t pid,
458
+ sigar_proc_modules_t *procmods);
459
+
460
+ typedef struct {
461
+ sigar_uint64_t user;
462
+ sigar_uint64_t sys;
463
+ sigar_uint64_t total;
464
+ } sigar_thread_cpu_t;
465
+
466
+ SIGAR_DECLARE(int) sigar_thread_cpu_get(sigar_t *sigar,
467
+ sigar_uint64_t id,
468
+ sigar_thread_cpu_t *cpu);
469
+
470
+ typedef enum {
471
+ SIGAR_FSTYPE_UNKNOWN,
472
+ SIGAR_FSTYPE_NONE,
473
+ SIGAR_FSTYPE_LOCAL_DISK,
474
+ SIGAR_FSTYPE_NETWORK,
475
+ SIGAR_FSTYPE_RAM_DISK,
476
+ SIGAR_FSTYPE_CDROM,
477
+ SIGAR_FSTYPE_SWAP,
478
+ SIGAR_FSTYPE_MAX
479
+ } sigar_file_system_type_e;
480
+
481
+ #define SIGAR_FS_NAME_LEN SIGAR_PATH_MAX
482
+ #define SIGAR_FS_INFO_LEN 256
483
+
484
+ typedef struct {
485
+ char dir_name[SIGAR_FS_NAME_LEN];
486
+ char dev_name[SIGAR_FS_NAME_LEN];
487
+ char type_name[SIGAR_FS_INFO_LEN]; /* e.g. "local" */
488
+ char sys_type_name[SIGAR_FS_INFO_LEN]; /* e.g. "ext3" */
489
+ char options[SIGAR_FS_INFO_LEN];
490
+ sigar_file_system_type_e type;
491
+ unsigned long flags;
492
+ } sigar_file_system_t;
493
+
494
+ typedef struct {
495
+ unsigned long number;
496
+ unsigned long size;
497
+ sigar_file_system_t *data;
498
+ } sigar_file_system_list_t;
499
+
500
+ SIGAR_DECLARE(int)
501
+ sigar_file_system_list_get(sigar_t *sigar,
502
+ sigar_file_system_list_t *fslist);
503
+
504
+ SIGAR_DECLARE(int)
505
+ sigar_file_system_list_destroy(sigar_t *sigar,
506
+ sigar_file_system_list_t *fslist);
507
+
508
+ typedef struct {
509
+ sigar_uint64_t reads;
510
+ sigar_uint64_t writes;
511
+ sigar_uint64_t write_bytes;
512
+ sigar_uint64_t read_bytes;
513
+ sigar_uint64_t rtime;
514
+ sigar_uint64_t wtime;
515
+ sigar_uint64_t qtime;
516
+ sigar_uint64_t time;
517
+ sigar_uint64_t snaptime;
518
+ double service_time;
519
+ double queue;
520
+ } sigar_disk_usage_t;
521
+
522
+ /* XXX for sigar_file_system_usage_t compat */
523
+ #define disk_reads disk.reads
524
+ #define disk_writes disk.writes
525
+ #define disk_write_bytes disk.write_bytes
526
+ #define disk_read_bytes disk.read_bytes
527
+ #define disk_queue disk.queue
528
+ #define disk_service_time disk.service_time
529
+
530
+ typedef struct {
531
+ sigar_disk_usage_t disk;
532
+ double use_percent;
533
+ sigar_uint64_t total;
534
+ sigar_uint64_t free;
535
+ sigar_uint64_t used;
536
+ sigar_uint64_t avail;
537
+ sigar_uint64_t files;
538
+ sigar_uint64_t free_files;
539
+ } sigar_file_system_usage_t;
540
+
541
+ #undef SIGAR_DISK_USAGE_T
542
+
543
+ SIGAR_DECLARE(int)
544
+ sigar_file_system_usage_get(sigar_t *sigar,
545
+ const char *dirname,
546
+ sigar_file_system_usage_t *fsusage);
547
+
548
+ SIGAR_DECLARE(int) sigar_disk_usage_get(sigar_t *sigar,
549
+ const char *name,
550
+ sigar_disk_usage_t *disk);
551
+
552
+ SIGAR_DECLARE(int)
553
+ sigar_file_system_ping(sigar_t *sigar,
554
+ sigar_file_system_t *fs);
555
+
556
+ typedef struct {
557
+ enum {
558
+ SIGAR_AF_UNSPEC,
559
+ SIGAR_AF_INET,
560
+ SIGAR_AF_INET6,
561
+ SIGAR_AF_LINK
562
+ } family;
563
+ union {
564
+ sigar_uint32_t in;
565
+ sigar_uint32_t in6[4];
566
+ unsigned char mac[8];
567
+ } addr;
568
+ } sigar_net_address_t;
569
+
570
+ #define SIGAR_INET6_ADDRSTRLEN 46
571
+
572
+ #define SIGAR_MAXDOMAINNAMELEN 256
573
+ #define SIGAR_MAXHOSTNAMELEN 256
574
+
575
+ typedef struct {
576
+ char default_gateway[SIGAR_INET6_ADDRSTRLEN];
577
+ char default_gateway_interface[MAX_INTERFACE_NAME_LEN];
578
+ char host_name[SIGAR_MAXHOSTNAMELEN];
579
+ char domain_name[SIGAR_MAXDOMAINNAMELEN];
580
+ char primary_dns[SIGAR_INET6_ADDRSTRLEN];
581
+ char secondary_dns[SIGAR_INET6_ADDRSTRLEN];
582
+ } sigar_net_info_t;
583
+
584
+ SIGAR_DECLARE(int)
585
+ sigar_net_info_get(sigar_t *sigar,
586
+ sigar_net_info_t *netinfo);
587
+
588
+ #define SIGAR_RTF_UP 0x1
589
+ #define SIGAR_RTF_GATEWAY 0x2
590
+ #define SIGAR_RTF_HOST 0x4
591
+
592
+ typedef struct {
593
+ sigar_net_address_t destination;
594
+ sigar_net_address_t gateway;
595
+ sigar_net_address_t mask;
596
+ sigar_uint64_t
597
+ flags,
598
+ refcnt,
599
+ use,
600
+ metric,
601
+ mtu,
602
+ window,
603
+ irtt;
604
+ char ifname[MAX_INTERFACE_NAME_LEN];
605
+ } sigar_net_route_t;
606
+
607
+ typedef struct {
608
+ unsigned long number;
609
+ unsigned long size;
610
+ sigar_net_route_t *data;
611
+ } sigar_net_route_list_t;
612
+
613
+ SIGAR_DECLARE(int) sigar_net_route_list_get(sigar_t *sigar,
614
+ sigar_net_route_list_t *routelist);
615
+
616
+ SIGAR_DECLARE(int) sigar_net_route_list_destroy(sigar_t *sigar,
617
+ sigar_net_route_list_t *routelist);
618
+
619
+ /*
620
+ * platforms define most of these "standard" flags,
621
+ * but of course, with different values in some cases.
622
+ */
623
+ #define SIGAR_IFF_UP 0x1
624
+ #define SIGAR_IFF_BROADCAST 0x2
625
+ #define SIGAR_IFF_DEBUG 0x4
626
+ #define SIGAR_IFF_LOOPBACK 0x8
627
+ #define SIGAR_IFF_POINTOPOINT 0x10
628
+ #define SIGAR_IFF_NOTRAILERS 0x20
629
+ #define SIGAR_IFF_RUNNING 0x40
630
+ #define SIGAR_IFF_NOARP 0x80
631
+ #define SIGAR_IFF_PROMISC 0x100
632
+ #define SIGAR_IFF_ALLMULTI 0x200
633
+ #define SIGAR_IFF_MULTICAST 0x800
634
+ #define SIGAR_IFF_SLAVE 0x1000
635
+ #define SIGAR_IFF_MASTER 0x2000
636
+ #define SIGAR_IFF_DYNAMIC 0x4000
637
+
638
+ #define SIGAR_NULL_HWADDR "00:00:00:00:00:00"
639
+
640
+ /* scope values from linux-2.6/include/net/ipv6.h */
641
+ #define SIGAR_IPV6_ADDR_ANY 0x0000
642
+ #define SIGAR_IPV6_ADDR_UNICAST 0x0001
643
+ #define SIGAR_IPV6_ADDR_MULTICAST 0x0002
644
+ #define SIGAR_IPV6_ADDR_LOOPBACK 0x0010
645
+ #define SIGAR_IPV6_ADDR_LINKLOCAL 0x0020
646
+ #define SIGAR_IPV6_ADDR_SITELOCAL 0x0040
647
+ #define SIGAR_IPV6_ADDR_COMPATv4 0x0080
648
+
649
+ typedef struct {
650
+ char name[MAX_INTERFACE_NAME_LEN];
651
+ char type[64];
652
+ char description[256];
653
+ sigar_net_address_t hwaddr;
654
+ sigar_net_address_t address;
655
+ sigar_net_address_t destination;
656
+ sigar_net_address_t broadcast;
657
+ sigar_net_address_t netmask;
658
+ sigar_net_address_t address6;
659
+ int prefix6_length;
660
+ int scope6;
661
+ sigar_uint64_t
662
+ flags,
663
+ mtu,
664
+ metric;
665
+ int tx_queue_len;
666
+ } sigar_net_interface_config_t;
667
+
668
+ SIGAR_DECLARE(int)
669
+ sigar_net_interface_config_get(sigar_t *sigar,
670
+ const char *name,
671
+ sigar_net_interface_config_t *ifconfig);
672
+
673
+ SIGAR_DECLARE(int)
674
+ sigar_net_interface_config_primary_get(sigar_t *sigar,
675
+ sigar_net_interface_config_t *ifconfig);
676
+
677
+ typedef struct {
678
+ sigar_uint64_t
679
+ /* received */
680
+ rx_packets,
681
+ rx_bytes,
682
+ rx_errors,
683
+ rx_dropped,
684
+ rx_overruns,
685
+ rx_frame,
686
+ /* transmitted */
687
+ tx_packets,
688
+ tx_bytes,
689
+ tx_errors,
690
+ tx_dropped,
691
+ tx_overruns,
692
+ tx_collisions,
693
+ tx_carrier,
694
+ speed;
695
+ } sigar_net_interface_stat_t;
696
+
697
+ SIGAR_DECLARE(int)
698
+ sigar_net_interface_stat_get(sigar_t *sigar,
699
+ const char *name,
700
+ sigar_net_interface_stat_t *ifstat);
701
+
702
+ typedef struct {
703
+ unsigned long number;
704
+ unsigned long size;
705
+ char **data;
706
+ } sigar_net_interface_list_t;
707
+
708
+ SIGAR_DECLARE(int)
709
+ sigar_net_interface_list_get(sigar_t *sigar,
710
+ sigar_net_interface_list_t *iflist);
711
+
712
+ SIGAR_DECLARE(int)
713
+ sigar_net_interface_list_destroy(sigar_t *sigar,
714
+ sigar_net_interface_list_t *iflist);
715
+
716
+ #define SIGAR_NETCONN_CLIENT 0x01
717
+ #define SIGAR_NETCONN_SERVER 0x02
718
+
719
+ #define SIGAR_NETCONN_TCP 0x10
720
+ #define SIGAR_NETCONN_UDP 0x20
721
+ #define SIGAR_NETCONN_RAW 0x40
722
+ #define SIGAR_NETCONN_UNIX 0x80
723
+
724
+ enum {
725
+ SIGAR_TCP_ESTABLISHED = 1,
726
+ SIGAR_TCP_SYN_SENT,
727
+ SIGAR_TCP_SYN_RECV,
728
+ SIGAR_TCP_FIN_WAIT1,
729
+ SIGAR_TCP_FIN_WAIT2,
730
+ SIGAR_TCP_TIME_WAIT,
731
+ SIGAR_TCP_CLOSE,
732
+ SIGAR_TCP_CLOSE_WAIT,
733
+ SIGAR_TCP_LAST_ACK,
734
+ SIGAR_TCP_LISTEN,
735
+ SIGAR_TCP_CLOSING,
736
+ SIGAR_TCP_IDLE,
737
+ SIGAR_TCP_BOUND,
738
+ SIGAR_TCP_UNKNOWN
739
+ };
740
+
741
+ typedef struct {
742
+ unsigned long local_port;
743
+ sigar_net_address_t local_address;
744
+ unsigned long remote_port;
745
+ sigar_net_address_t remote_address;
746
+ sigar_uid_t uid;
747
+ unsigned long inode;
748
+ int type;
749
+ int state;
750
+ unsigned long send_queue;
751
+ unsigned long receive_queue;
752
+ } sigar_net_connection_t;
753
+
754
+ typedef struct {
755
+ unsigned long number;
756
+ unsigned long size;
757
+ sigar_net_connection_t *data;
758
+ } sigar_net_connection_list_t;
759
+
760
+ SIGAR_DECLARE(int)
761
+ sigar_net_connection_list_get(sigar_t *sigar,
762
+ sigar_net_connection_list_t *connlist,
763
+ int flags);
764
+
765
+ SIGAR_DECLARE(int)
766
+ sigar_net_connection_list_destroy(sigar_t *sigar,
767
+ sigar_net_connection_list_t *connlist);
768
+
769
+ typedef struct sigar_net_connection_walker_t sigar_net_connection_walker_t;
770
+
771
+ /* alternative to sigar_net_connection_list_get */
772
+ struct sigar_net_connection_walker_t {
773
+ sigar_t *sigar;
774
+ int flags;
775
+ void *data; /* user data */
776
+ int (*add_connection)(sigar_net_connection_walker_t *walker,
777
+ sigar_net_connection_t *connection);
778
+ };
779
+
780
+ SIGAR_DECLARE(int)
781
+ sigar_net_connection_walk(sigar_net_connection_walker_t *walker);
782
+
783
+ typedef struct {
784
+ int tcp_states[SIGAR_TCP_UNKNOWN];
785
+ sigar_uint32_t tcp_inbound_total;
786
+ sigar_uint32_t tcp_outbound_total;
787
+ sigar_uint32_t all_inbound_total;
788
+ sigar_uint32_t all_outbound_total;
789
+ } sigar_net_stat_t;
790
+
791
+ SIGAR_DECLARE(int)
792
+ sigar_net_stat_get(sigar_t *sigar,
793
+ sigar_net_stat_t *netstat,
794
+ int flags);
795
+
796
+ SIGAR_DECLARE(int)
797
+ sigar_net_stat_port_get(sigar_t *sigar,
798
+ sigar_net_stat_t *netstat,
799
+ int flags,
800
+ sigar_net_address_t *address,
801
+ unsigned long port);
802
+
803
+ /* TCP-MIB */
804
+ typedef struct {
805
+ sigar_uint64_t active_opens;
806
+ sigar_uint64_t passive_opens;
807
+ sigar_uint64_t attempt_fails;
808
+ sigar_uint64_t estab_resets;
809
+ sigar_uint64_t curr_estab;
810
+ sigar_uint64_t in_segs;
811
+ sigar_uint64_t out_segs;
812
+ sigar_uint64_t retrans_segs;
813
+ sigar_uint64_t in_errs;
814
+ sigar_uint64_t out_rsts;
815
+ } sigar_tcp_t;
816
+
817
+ SIGAR_DECLARE(int)
818
+ sigar_tcp_get(sigar_t *sigar,
819
+ sigar_tcp_t *tcp);
820
+
821
+ typedef struct {
822
+ sigar_uint64_t null;
823
+ sigar_uint64_t getattr;
824
+ sigar_uint64_t setattr;
825
+ sigar_uint64_t root;
826
+ sigar_uint64_t lookup;
827
+ sigar_uint64_t readlink;
828
+ sigar_uint64_t read;
829
+ sigar_uint64_t writecache;
830
+ sigar_uint64_t write;
831
+ sigar_uint64_t create;
832
+ sigar_uint64_t remove;
833
+ sigar_uint64_t rename;
834
+ sigar_uint64_t link;
835
+ sigar_uint64_t symlink;
836
+ sigar_uint64_t mkdir;
837
+ sigar_uint64_t rmdir;
838
+ sigar_uint64_t readdir;
839
+ sigar_uint64_t fsstat;
840
+ } sigar_nfs_v2_t;
841
+
842
+ typedef sigar_nfs_v2_t sigar_nfs_client_v2_t;
843
+ typedef sigar_nfs_v2_t sigar_nfs_server_v2_t;
844
+
845
+ SIGAR_DECLARE(int)
846
+ sigar_nfs_client_v2_get(sigar_t *sigar,
847
+ sigar_nfs_client_v2_t *nfs);
848
+
849
+ SIGAR_DECLARE(int)
850
+ sigar_nfs_server_v2_get(sigar_t *sigar,
851
+ sigar_nfs_server_v2_t *nfs);
852
+
853
+ typedef struct {
854
+ sigar_uint64_t null;
855
+ sigar_uint64_t getattr;
856
+ sigar_uint64_t setattr;
857
+ sigar_uint64_t lookup;
858
+ sigar_uint64_t access;
859
+ sigar_uint64_t readlink;
860
+ sigar_uint64_t read;
861
+ sigar_uint64_t write;
862
+ sigar_uint64_t create;
863
+ sigar_uint64_t mkdir;
864
+ sigar_uint64_t symlink;
865
+ sigar_uint64_t mknod;
866
+ sigar_uint64_t remove;
867
+ sigar_uint64_t rmdir;
868
+ sigar_uint64_t rename;
869
+ sigar_uint64_t link;
870
+ sigar_uint64_t readdir;
871
+ sigar_uint64_t readdirplus;
872
+ sigar_uint64_t fsstat;
873
+ sigar_uint64_t fsinfo;
874
+ sigar_uint64_t pathconf;
875
+ sigar_uint64_t commit;
876
+ } sigar_nfs_v3_t;
877
+
878
+ typedef sigar_nfs_v3_t sigar_nfs_client_v3_t;
879
+ typedef sigar_nfs_v3_t sigar_nfs_server_v3_t;
880
+
881
+ SIGAR_DECLARE(int)
882
+ sigar_nfs_client_v3_get(sigar_t *sigar,
883
+ sigar_nfs_client_v3_t *nfs);
884
+
885
+ SIGAR_DECLARE(int)
886
+ sigar_nfs_server_v3_get(sigar_t *sigar,
887
+ sigar_nfs_server_v3_t *nfs);
888
+
889
+ SIGAR_DECLARE(int)
890
+ sigar_net_listen_address_get(sigar_t *sigar,
891
+ unsigned long port,
892
+ sigar_net_address_t *address);
893
+
894
+ typedef struct {
895
+ char ifname[MAX_INTERFACE_NAME_LEN];
896
+ char type[64];
897
+ sigar_net_address_t hwaddr;
898
+ sigar_net_address_t address;
899
+ sigar_uint64_t flags;
900
+ } sigar_arp_t;
901
+
902
+ typedef struct {
903
+ unsigned long number;
904
+ unsigned long size;
905
+ sigar_arp_t *data;
906
+ } sigar_arp_list_t;
907
+
908
+ SIGAR_DECLARE(int) sigar_arp_list_get(sigar_t *sigar,
909
+ sigar_arp_list_t *arplist);
910
+
911
+ SIGAR_DECLARE(int) sigar_arp_list_destroy(sigar_t *sigar,
912
+ sigar_arp_list_t *arplist);
913
+
914
+ typedef struct {
915
+ char user[32];
916
+ char device[32];
917
+ char host[256];
918
+ sigar_uint64_t time;
919
+ } sigar_who_t;
920
+
921
+ typedef struct {
922
+ unsigned long number;
923
+ unsigned long size;
924
+ sigar_who_t *data;
925
+ } sigar_who_list_t;
926
+
927
+ SIGAR_DECLARE(int) sigar_who_list_get(sigar_t *sigar,
928
+ sigar_who_list_t *wholist);
929
+
930
+ SIGAR_DECLARE(int) sigar_who_list_destroy(sigar_t *sigar,
931
+ sigar_who_list_t *wholist);
932
+
933
+ SIGAR_DECLARE(int) sigar_proc_port_get(sigar_t *sigar,
934
+ int protocol, unsigned long port,
935
+ sigar_pid_t *pid);
936
+
937
+ typedef struct {
938
+ const char *build_date;
939
+ const char *scm_revision;
940
+ const char *version;
941
+ const char *archname;
942
+ const char *archlib;
943
+ const char *binname;
944
+ const char *description;
945
+ int major, minor, maint, build;
946
+ } sigar_version_t;
947
+
948
+ SIGAR_DECLARE(sigar_version_t *) sigar_version_get(void);
949
+
950
+ #define SIGAR_SYS_INFO_LEN SIGAR_MAXHOSTNAMELEN /* more than enough */
951
+
952
+ typedef struct {
953
+ char name[SIGAR_SYS_INFO_LEN]; /* canonicalized sysname */
954
+ char version[SIGAR_SYS_INFO_LEN]; /* utsname.release */
955
+ char arch[SIGAR_SYS_INFO_LEN];
956
+ char machine[SIGAR_SYS_INFO_LEN];
957
+ char description[SIGAR_SYS_INFO_LEN];
958
+ char patch_level[SIGAR_SYS_INFO_LEN];
959
+ char vendor[SIGAR_SYS_INFO_LEN];
960
+ char vendor_version[SIGAR_SYS_INFO_LEN];
961
+ char vendor_name[SIGAR_SYS_INFO_LEN]; /* utsname.sysname */
962
+ char vendor_code_name[SIGAR_SYS_INFO_LEN];
963
+ } sigar_sys_info_t;
964
+
965
+ SIGAR_DECLARE(int) sigar_sys_info_get(sigar_t *sigar, sigar_sys_info_t *sysinfo);
966
+
967
+ #define SIGAR_FQDN_LEN 512
968
+
969
+ SIGAR_DECLARE(int) sigar_fqdn_get(sigar_t *sigar, char *name, int namelen);
970
+
971
+ SIGAR_DECLARE(int) sigar_rpc_ping(char *hostname,
972
+ int protocol,
973
+ unsigned long program,
974
+ unsigned long version);
975
+
976
+ SIGAR_DECLARE(char *) sigar_rpc_strerror(int err);
977
+
978
+ SIGAR_DECLARE(char *) sigar_password_get(const char *prompt);
979
+
980
+ #ifdef __cplusplus
981
+ }
982
+ #endif
983
+
984
+ #endif