sigar-test 0.7.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,212 @@
1
+ /*
2
+ * Copyright (c) 2004, 2006-2008 Hyperic, Inc.
3
+ * Copyright (c) 2009 SpringSource, Inc.
4
+ * Copyright (c) 2009 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
+ /*
20
+ * functions for getting info from the Process Environment Block
21
+ */
22
+ #define UNICODE
23
+ #define _UNICODE
24
+
25
+ #include "sigar.h"
26
+ #include "sigar_private.h"
27
+ #include "sigar_os.h"
28
+ #include <shellapi.h>
29
+
30
+ void dllmod_init_ntdll(sigar_t *sigar);
31
+
32
+ #define sigar_NtQueryInformationProcess \
33
+ sigar->ntdll.query_proc_info.func
34
+
35
+ static int sigar_pbi_get(sigar_t *sigar, HANDLE proc, PEB *peb)
36
+ {
37
+ int status;
38
+ PROCESS_BASIC_INFORMATION pbi;
39
+ DWORD size=sizeof(pbi);
40
+
41
+ dllmod_init_ntdll(sigar);
42
+
43
+ if (!sigar_NtQueryInformationProcess) {
44
+ return SIGAR_ENOTIMPL;
45
+ }
46
+
47
+ SIGAR_ZERO(&pbi);
48
+ status =
49
+ sigar_NtQueryInformationProcess(proc,
50
+ ProcessBasicInformation,
51
+ &pbi,
52
+ size, NULL);
53
+ if (status != ERROR_SUCCESS) {
54
+ return status;
55
+ }
56
+
57
+ if (!pbi.PebBaseAddress) {
58
+ /* likely we are 32-bit, pid process is 64-bit */
59
+ return ERROR_DATATYPE_MISMATCH;
60
+ }
61
+
62
+ size = sizeof(*peb);
63
+
64
+ if (ReadProcessMemory(proc, pbi.PebBaseAddress, peb, size, NULL)) {
65
+ return SIGAR_OK;
66
+ }
67
+ else {
68
+ return GetLastError();
69
+ }
70
+ }
71
+
72
+ static int sigar_rtl_get(sigar_t *sigar, HANDLE proc,
73
+ RTL_USER_PROCESS_PARAMETERS *rtl)
74
+ {
75
+ PEB peb;
76
+ int status = sigar_pbi_get(sigar, proc, &peb);
77
+ DWORD size=sizeof(*rtl);
78
+
79
+ if (status != SIGAR_OK) {
80
+ return status;
81
+ }
82
+
83
+ if (ReadProcessMemory(proc, peb.ProcessParameters, rtl, size, NULL)) {
84
+ return SIGAR_OK;
85
+ }
86
+ else {
87
+ return GetLastError();
88
+ }
89
+ }
90
+
91
+ #define rtl_bufsize(buf, uc) \
92
+ ((sizeof(buf) < uc.Length) ? sizeof(buf) : uc.Length)
93
+
94
+ int sigar_proc_exe_peb_get(sigar_t *sigar, HANDLE proc,
95
+ sigar_proc_exe_t *procexe)
96
+ {
97
+ int status;
98
+ WCHAR buf[MAX_PATH+1];
99
+ RTL_USER_PROCESS_PARAMETERS rtl;
100
+ DWORD size;
101
+
102
+ procexe->name[0] = '\0';
103
+ procexe->cwd[0] = '\0';
104
+
105
+ if ((status = sigar_rtl_get(sigar, proc, &rtl)) != SIGAR_OK) {
106
+ return status;
107
+ }
108
+
109
+ size = rtl_bufsize(buf, rtl.ImagePathName);
110
+ memset(buf, '\0', sizeof(buf));
111
+
112
+ if ((size > 0) &&
113
+ ReadProcessMemory(proc, rtl.ImagePathName.Buffer, buf, size, NULL))
114
+ {
115
+ SIGAR_W2A(buf, procexe->name, sizeof(procexe->name));
116
+ }
117
+
118
+ size = rtl_bufsize(buf, rtl.CurrentDirectoryName);
119
+ memset(buf, '\0', sizeof(buf));
120
+
121
+ if ((size > 0) &&
122
+ ReadProcessMemory(proc, rtl.CurrentDirectoryName.Buffer, buf, size, NULL))
123
+ {
124
+ SIGAR_W2A(buf, procexe->cwd, sizeof(procexe->cwd));
125
+ }
126
+
127
+ return SIGAR_OK;
128
+ }
129
+
130
+ int sigar_parse_proc_args(sigar_t *sigar, WCHAR *buf,
131
+ sigar_proc_args_t *procargs)
132
+ {
133
+ char arg[SIGAR_CMDLINE_MAX];
134
+ LPWSTR *args;
135
+ int num, i;
136
+
137
+ if (!buf) {
138
+ buf = GetCommandLine();
139
+ }
140
+
141
+ args = CommandLineToArgvW(buf, &num);
142
+
143
+ if (args == NULL) {
144
+ return SIGAR_OK;
145
+ }
146
+
147
+ for (i=0; i<num; i++) {
148
+ SIGAR_W2A(args[i], arg, SIGAR_CMDLINE_MAX);
149
+ SIGAR_PROC_ARGS_GROW(procargs);
150
+ procargs->data[procargs->number++] = sigar_strdup(arg);
151
+ }
152
+
153
+ GlobalFree(args);
154
+
155
+ return SIGAR_OK;
156
+ }
157
+
158
+ int sigar_proc_args_peb_get(sigar_t *sigar, HANDLE proc,
159
+ sigar_proc_args_t *procargs)
160
+ {
161
+ int status;
162
+ WCHAR buf[SIGAR_CMDLINE_MAX];
163
+ RTL_USER_PROCESS_PARAMETERS rtl;
164
+ DWORD size;
165
+
166
+ if ((status = sigar_rtl_get(sigar, proc, &rtl)) != SIGAR_OK) {
167
+ return status;
168
+ }
169
+
170
+ size = rtl_bufsize(buf, rtl.CommandLine);
171
+ if (size <= 0) {
172
+ return ERROR_DATATYPE_MISMATCH; /* fallback to wmi */
173
+ }
174
+ memset(buf, '\0', sizeof(buf));
175
+
176
+ if (ReadProcessMemory(proc, rtl.CommandLine.Buffer, buf, size, NULL)) {
177
+ return sigar_parse_proc_args(sigar, buf, procargs);
178
+ }
179
+ else {
180
+ return GetLastError();
181
+ }
182
+ }
183
+
184
+ int sigar_proc_env_peb_get(sigar_t *sigar, HANDLE proc,
185
+ WCHAR *buf, DWORD size)
186
+ {
187
+ int status;
188
+ RTL_USER_PROCESS_PARAMETERS rtl;
189
+ MEMORY_BASIC_INFORMATION info;
190
+
191
+ if ((status = sigar_rtl_get(sigar, proc, &rtl)) != SIGAR_OK) {
192
+ return status;
193
+ }
194
+
195
+ memset(buf, '\0', size);
196
+ /* -2 to ensure \0\0 terminator */
197
+ size -= 2;
198
+
199
+ if (VirtualQueryEx(proc, rtl.Environment, &info, sizeof(info))) {
200
+ if (size > info.RegionSize) {
201
+ /* ReadProcessMemory beyond region would fail */
202
+ size = info.RegionSize;
203
+ }
204
+ }
205
+
206
+ if (ReadProcessMemory(proc, rtl.Environment, buf, size, NULL)) {
207
+ return SIGAR_OK;
208
+ }
209
+ else {
210
+ return GetLastError();
211
+ }
212
+ }
@@ -0,0 +1,40 @@
1
+ #define SIGAR_VERSION_CSV \
2
+ @@VERSION_MAJOR@@,@@VERSION_MINOR@@,@@VERSION_MAINT@@,@@VERSION_BUILD@@
3
+ #define SIGAR_VERSION_STR \
4
+ "@@VERSION_MAJOR@@.@@VERSION_MINOR@@.@@VERSION_MAINT@@.@@VERSION_BUILD@@"
5
+
6
+ #define SIGAR_ARCHLIB "@@ARCHLIB@@"
7
+
8
+ 1 VERSIONINFO
9
+ FILEVERSION SIGAR_VERSION_CSV
10
+ PRODUCTVERSION SIGAR_VERSION_CSV
11
+ FILEFLAGSMASK 0x3fL
12
+ FILEFLAGS 0x00L
13
+ #if defined(WINNT) || defined(WIN64)
14
+ FILEOS 0x40004L
15
+ #else
16
+ FILEOS 0x4L
17
+ #endif
18
+ FILETYPE 0x2L
19
+ FILESUBTYPE 0x0L
20
+ BEGIN
21
+ BLOCK "StringFileInfo"
22
+ BEGIN
23
+ BLOCK "040904b0"
24
+ BEGIN
25
+ VALUE "Comments", "http://sigar.hyperic.com/\0"
26
+ VALUE "CompanyName", "Hyperic, Inc.\0"
27
+ VALUE "FileDescription", "System Information Gatherer And Reporter DLL\0"
28
+ VALUE "FileVersion", SIGAR_VERSION_STR "\0"
29
+ VALUE "InternalName", "sigar.dll\0"
30
+ VALUE "LegalCopyright", "Copyright [@@COPYRIGHT_YEAR@@], Hyperic, Inc.\0"
31
+ VALUE "OriginalFilename", SIGAR_ARCHLIB "\0"
32
+ VALUE "ProductName", "Hyperic SIGAR\0"
33
+ VALUE "ProductVersion", SIGAR_VERSION_STR "\0"
34
+ END
35
+ END
36
+ BLOCK "VarFileInfo"
37
+ BEGIN
38
+ VALUE "Translation", 0x409, 1200
39
+ END
40
+ END