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
@@ -0,0 +1,157 @@
1
+ /*
2
+ * Copyright (c) 2004-2005 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
+ /* ====================================================================
18
+ * The Apache Software License, Version 1.1
19
+ *
20
+ * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
21
+ * reserved.
22
+ *
23
+ * Redistribution and use in source and binary forms, with or without
24
+ * modification, are permitted provided that the following conditions
25
+ * are met:
26
+ *
27
+ * 1. Redistributions of source code must retain the above copyright
28
+ * notice, this list of conditions and the following disclaimer.
29
+ *
30
+ * 2. Redistributions in binary form must reproduce the above copyright
31
+ * notice, this list of conditions and the following disclaimer in
32
+ * the documentation and/or other materials provided with the
33
+ * distribution.
34
+ *
35
+ * 3. The end-user documentation included with the redistribution,
36
+ * if any, must include the following acknowledgment:
37
+ * "This product includes software developed by the
38
+ * Apache Software Foundation (http://www.apache.org/)."
39
+ * Alternately, this acknowledgment may appear in the software itself,
40
+ * if and wherever such third-party acknowledgments normally appear.
41
+ *
42
+ * 4. The names "Apache" and "Apache Software Foundation" must
43
+ * not be used to endorse or promote products derived from this
44
+ * software without prior written permission. For written
45
+ * permission, please contact apache@apache.org.
46
+ *
47
+ * 5. Products derived from this software may not be called "Apache",
48
+ * nor may "Apache" appear in their name, without prior written
49
+ * permission of the Apache Software Foundation.
50
+ *
51
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
52
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
53
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
54
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
55
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
56
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
57
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
58
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
59
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
60
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
61
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62
+ * SUCH DAMAGE.
63
+ * ====================================================================
64
+ *
65
+ * This software consists of voluntary contributions made by many
66
+ * individuals on behalf of the Apache Software Foundation. For more
67
+ * information on the Apache Software Foundation, please see
68
+ * <http://www.apache.org/>.
69
+ */
70
+
71
+ #include "sigar.h"
72
+
73
+ typedef enum {
74
+ SIGAR_FILETYPE_NOFILE = 0, /**< no file type determined */
75
+ SIGAR_FILETYPE_REG, /**< a regular file */
76
+ SIGAR_FILETYPE_DIR, /**< a directory */
77
+ SIGAR_FILETYPE_CHR, /**< a character device */
78
+ SIGAR_FILETYPE_BLK, /**< a block device */
79
+ SIGAR_FILETYPE_PIPE, /**< a FIFO / pipe */
80
+ SIGAR_FILETYPE_LNK, /**< a symbolic link */
81
+ SIGAR_FILETYPE_SOCK, /**< a [unix domain] socket */
82
+ SIGAR_FILETYPE_UNKFILE /**< a file of some other unknown type */
83
+ } sigar_file_type_e;
84
+
85
+ #define SIGAR_UREAD 0x0400 /**< Read by user */
86
+ #define SIGAR_UWRITE 0x0200 /**< Write by user */
87
+ #define SIGAR_UEXECUTE 0x0100 /**< Execute by user */
88
+
89
+ #define SIGAR_GREAD 0x0040 /**< Read by group */
90
+ #define SIGAR_GWRITE 0x0020 /**< Write by group */
91
+ #define SIGAR_GEXECUTE 0x0010 /**< Execute by group */
92
+
93
+ #define SIGAR_WREAD 0x0004 /**< Read by others */
94
+ #define SIGAR_WWRITE 0x0002 /**< Write by others */
95
+ #define SIGAR_WEXECUTE 0x0001 /**< Execute by others */
96
+
97
+ typedef struct {
98
+ /** The access permissions of the file. Mimics Unix access rights. */
99
+ sigar_uint64_t permissions;
100
+ sigar_file_type_e type;
101
+ /** The user id that owns the file */
102
+ sigar_uid_t uid;
103
+ /** The group id that owns the file */
104
+ sigar_gid_t gid;
105
+ /** The inode of the file. */
106
+ sigar_uint64_t inode;
107
+ /** The id of the device the file is on. */
108
+ sigar_uint64_t device;
109
+ /** The number of hard links to the file. */
110
+ sigar_uint64_t nlink;
111
+ /** The size of the file */
112
+ sigar_uint64_t size;
113
+ /** The time the file was last accessed */
114
+ sigar_uint64_t atime;
115
+ /** The time the file was last modified */
116
+ sigar_uint64_t mtime;
117
+ /** The time the file was last changed */
118
+ sigar_uint64_t ctime;
119
+ } sigar_file_attrs_t;
120
+
121
+ typedef struct {
122
+ sigar_uint64_t total;
123
+ sigar_uint64_t files;
124
+ sigar_uint64_t subdirs;
125
+ sigar_uint64_t symlinks;
126
+ sigar_uint64_t chrdevs;
127
+ sigar_uint64_t blkdevs;
128
+ sigar_uint64_t sockets;
129
+ sigar_uint64_t disk_usage;
130
+ } sigar_dir_stat_t;
131
+
132
+ typedef sigar_dir_stat_t sigar_dir_usage_t;
133
+
134
+ SIGAR_DECLARE(const char *)
135
+ sigar_file_attrs_type_string_get(sigar_file_type_e type);
136
+
137
+ SIGAR_DECLARE(int) sigar_file_attrs_get(sigar_t *sigar,
138
+ const char *file,
139
+ sigar_file_attrs_t *fileattrs);
140
+
141
+ SIGAR_DECLARE(int) sigar_link_attrs_get(sigar_t *sigar,
142
+ const char *file,
143
+ sigar_file_attrs_t *fileattrs);
144
+
145
+ SIGAR_DECLARE(int)sigar_file_attrs_mode_get(sigar_uint64_t permissions);
146
+
147
+ SIGAR_DECLARE(char *)
148
+ sigar_file_attrs_permissions_string_get(sigar_uint64_t permissions,
149
+ char *str);
150
+
151
+ SIGAR_DECLARE(int) sigar_dir_stat_get(sigar_t *sigar,
152
+ const char *dir,
153
+ sigar_dir_stat_t *dirstats);
154
+
155
+ SIGAR_DECLARE(int) sigar_dir_usage_get(sigar_t *sigar,
156
+ const char *dir,
157
+ sigar_dir_usage_t *dirusage);
@@ -0,0 +1,65 @@
1
+ /*
2
+ * Copyright (c) 2007-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_FORMAT_H
19
+ #define SIGAR_FORMAT_H
20
+
21
+ typedef struct {
22
+ double user;
23
+ double sys;
24
+ double nice;
25
+ double idle;
26
+ double wait;
27
+ double irq;
28
+ double soft_irq;
29
+ double stolen;
30
+ double combined;
31
+ } sigar_cpu_perc_t;
32
+
33
+ SIGAR_DECLARE(int) sigar_cpu_perc_calculate(sigar_cpu_t *prev,
34
+ sigar_cpu_t *curr,
35
+ sigar_cpu_perc_t *perc);
36
+
37
+ SIGAR_DECLARE(int) sigar_uptime_string(sigar_t *sigar,
38
+ sigar_uptime_t *uptime,
39
+ char *buffer,
40
+ int buflen);
41
+
42
+ SIGAR_DECLARE(char *) sigar_format_size(sigar_uint64_t size, char *buf);
43
+
44
+ SIGAR_DECLARE(int) sigar_net_address_equals(sigar_net_address_t *addr1,
45
+ sigar_net_address_t *addr2);
46
+
47
+ SIGAR_DECLARE(int) sigar_net_address_to_string(sigar_t *sigar,
48
+ sigar_net_address_t *address,
49
+ char *addr_str);
50
+
51
+ SIGAR_DECLARE(const char *)sigar_net_scope_to_string(int type);
52
+
53
+ SIGAR_DECLARE(sigar_uint32_t) sigar_net_address_hash(sigar_net_address_t *address);
54
+
55
+ SIGAR_DECLARE(const char *)sigar_net_connection_type_get(int type);
56
+
57
+ SIGAR_DECLARE(const char *)sigar_net_connection_state_get(int state);
58
+
59
+ SIGAR_DECLARE(char *) sigar_net_interface_flags_to_string(sigar_uint64_t flags, char *buf);
60
+
61
+ SIGAR_DECLARE(char *)sigar_net_services_name_get(sigar_t *sigar,
62
+ int protocol, unsigned long port);
63
+
64
+ #endif
65
+
@@ -0,0 +1,18 @@
1
+ #ifndef SIGAR_GETLINE_H
2
+ #define SIGAR_GETLINE_H
3
+
4
+ #include "sigar.h"
5
+
6
+ typedef int (*sigar_getline_completer_t)(char *, int, int *);
7
+
8
+ SIGAR_DECLARE(char *) sigar_getline(char *prompt);
9
+ SIGAR_DECLARE(void) sigar_getline_setwidth(int width);
10
+ SIGAR_DECLARE(void) sigar_getline_redraw(void);
11
+ SIGAR_DECLARE(void) sigar_getline_reset(void);
12
+ SIGAR_DECLARE(void) sigar_getline_windowchanged();
13
+ SIGAR_DECLARE(void) sigar_getline_histinit(char *file);
14
+ SIGAR_DECLARE(void) sigar_getline_histadd(char *buf);
15
+ SIGAR_DECLARE(int) sigar_getline_eof();
16
+ SIGAR_DECLARE(void) sigar_getline_completer_set(sigar_getline_completer_t func);
17
+
18
+ #endif /* SIGAR_GETLINE_H */
@@ -0,0 +1,80 @@
1
+ /*
2
+ * Copyright (c) 2004, 2006 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_LOG_H
18
+ #define SIGAR_LOG_H
19
+
20
+ #include <stdarg.h>
21
+
22
+ #define SIGAR_LOG_FATAL 0
23
+ #define SIGAR_LOG_ERROR 1
24
+ #define SIGAR_LOG_WARN 2
25
+ #define SIGAR_LOG_INFO 3
26
+ #define SIGAR_LOG_DEBUG 4
27
+ #define SIGAR_LOG_TRACE 5
28
+
29
+ #define SIGAR_LOG_IS_FATAL(sigar) \
30
+ (sigar->log_level >= SIGAR_LOG_FATAL)
31
+
32
+ #define SIGAR_LOG_IS_ERROR(sigar) \
33
+ (sigar->log_level >= SIGAR_LOG_ERROR)
34
+
35
+ #define SIGAR_LOG_IS_WARN(sigar) \
36
+ (sigar->log_level >= SIGAR_LOG_WARN)
37
+
38
+ #define SIGAR_LOG_IS_INFO(sigar) \
39
+ (sigar->log_level >= SIGAR_LOG_INFO)
40
+
41
+ #define SIGAR_LOG_IS_DEBUG(sigar) \
42
+ (sigar->log_level >= SIGAR_LOG_DEBUG)
43
+
44
+ #define SIGAR_LOG_IS_TRACE(sigar) \
45
+ (sigar->log_level >= SIGAR_LOG_TRACE)
46
+
47
+ #define SIGAR_STRINGIFY(n) #n
48
+
49
+ #define SIGAR_LOG_FILELINE \
50
+ __FILE__ ":" SIGAR_STRINGIFY(__LINE__)
51
+
52
+ #if defined(__GNUC__)
53
+ # if (__GNUC__ > 2)
54
+ # define SIGAR_FUNC __func__
55
+ # else
56
+ # define SIGAR_FUNC __FUNCTION__
57
+ # endif
58
+ #else
59
+ # define SIGAR_FUNC SIGAR_LOG_FILELINE
60
+ #endif
61
+
62
+ typedef void (*sigar_log_impl_t)(sigar_t *, void *, int, char *);
63
+
64
+ SIGAR_DECLARE(void) sigar_log_printf(sigar_t *sigar, int level,
65
+ const char *format, ...);
66
+
67
+ SIGAR_DECLARE(void) sigar_log(sigar_t *sigar, int level, char *message);
68
+
69
+ SIGAR_DECLARE(void) sigar_log_impl_set(sigar_t *sigar, void *data,
70
+ sigar_log_impl_t impl);
71
+
72
+ SIGAR_DECLARE(void) sigar_log_impl_file(sigar_t *sigar, void *data,
73
+ int level, char *message);
74
+
75
+ SIGAR_DECLARE(int) sigar_log_level_get(sigar_t *sigar);
76
+
77
+ SIGAR_DECLARE(void) sigar_log_level_set(sigar_t *sigar, int level);
78
+
79
+
80
+ #endif /* SIGAR_LOG_H */