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