1 | /* $Id: first.c,v 1.1.1.2 2004-10-03 04:59:48 ghudson Exp $ */ |
---|
2 | |
---|
3 | /* Copyright (C) 1998-99 Martin Baulig |
---|
4 | This file is part of LibGTop 1.0. |
---|
5 | |
---|
6 | Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. |
---|
7 | |
---|
8 | LibGTop is free software; you can redistribute it and/or modify it |
---|
9 | under the terms of the GNU General Public License as published by |
---|
10 | the Free Software Foundation; either version 2 of the License, |
---|
11 | or (at your option) any later version. |
---|
12 | |
---|
13 | LibGTop is distributed in the hope that it will be useful, but WITHOUT |
---|
14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
16 | for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with LibGTop; see the file COPYING. If not, write to the |
---|
20 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
21 | Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | #include <locale.h> |
---|
25 | #include <libintl.h> |
---|
26 | #include <stdio.h> |
---|
27 | |
---|
28 | #include <glibtop.h> |
---|
29 | #include <glibtop/open.h> |
---|
30 | #include <glibtop/close.h> |
---|
31 | |
---|
32 | #include <glibtop/parameter.h> |
---|
33 | |
---|
34 | #include <glibtop/union.h> |
---|
35 | #include <glibtop/sysdeps.h> |
---|
36 | |
---|
37 | #include <sys/resource.h> |
---|
38 | |
---|
39 | #ifndef PROFILE_COUNT |
---|
40 | #define PROFILE_COUNT 1 |
---|
41 | #endif |
---|
42 | |
---|
43 | int |
---|
44 | main (int argc, char *argv []) |
---|
45 | { |
---|
46 | glibtop_union data; |
---|
47 | glibtop_sysdeps sysdeps; |
---|
48 | unsigned c, method, count, port, i, *ptr; |
---|
49 | char buffer [BUFSIZ]; |
---|
50 | pid_t pid, ppid; |
---|
51 | char *args; |
---|
52 | |
---|
53 | count = PROFILE_COUNT; |
---|
54 | |
---|
55 | setlocale (LC_ALL, ""); |
---|
56 | bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR); |
---|
57 | textdomain (GETTEXT_PACKAGE); |
---|
58 | |
---|
59 | glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN); |
---|
60 | |
---|
61 | glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method)); |
---|
62 | |
---|
63 | printf ("Method = %d\n", method); |
---|
64 | |
---|
65 | count = glibtop_get_parameter (GLIBTOP_PARAM_COMMAND, buffer, BUFSIZ); |
---|
66 | buffer [count] = 0; |
---|
67 | |
---|
68 | printf ("Command = '%s'\n", buffer); |
---|
69 | |
---|
70 | count = glibtop_get_parameter (GLIBTOP_PARAM_HOST, buffer, BUFSIZ); |
---|
71 | buffer [count] = 0; |
---|
72 | |
---|
73 | glibtop_get_parameter (GLIBTOP_PARAM_PORT, &port, sizeof (port)); |
---|
74 | |
---|
75 | printf ("Host = '%s' - %u\n\n", buffer, port); |
---|
76 | |
---|
77 | glibtop_init_r (&glibtop_global_server, 0, 0); |
---|
78 | |
---|
79 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
80 | glibtop_get_cpu (&data.cpu); |
---|
81 | |
---|
82 | printf ("CPU (0x%08lx): %lu, %lu, %lu, %lu, %lu, %lu\n", |
---|
83 | (unsigned long) data.cpu.flags, |
---|
84 | (unsigned long) data.cpu.total, |
---|
85 | (unsigned long) data.cpu.user, |
---|
86 | (unsigned long) data.cpu.nice, |
---|
87 | (unsigned long) data.cpu.sys, |
---|
88 | (unsigned long) data.cpu.idle, |
---|
89 | (unsigned long) data.cpu.frequency); |
---|
90 | |
---|
91 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
92 | glibtop_get_mem (&data.mem); |
---|
93 | |
---|
94 | printf ("Memory (0x%08lx): " |
---|
95 | "%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n", |
---|
96 | (unsigned long) data.mem.flags, |
---|
97 | (unsigned long) data.mem.total, |
---|
98 | (unsigned long) data.mem.used, |
---|
99 | (unsigned long) data.mem.free, |
---|
100 | (unsigned long) data.mem.shared, |
---|
101 | (unsigned long) data.mem.buffer, |
---|
102 | (unsigned long) data.mem.cached, |
---|
103 | (unsigned long) data.mem.user, |
---|
104 | (unsigned long) data.mem.locked); |
---|
105 | |
---|
106 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
107 | glibtop_get_swap (&data.swap); |
---|
108 | |
---|
109 | printf ("Swap (0x%08lx): %lu, %lu, %lu, %lu, %lu\n", |
---|
110 | (unsigned long) data.swap.flags, |
---|
111 | (unsigned long) data.swap.total, |
---|
112 | (unsigned long) data.swap.used, |
---|
113 | (unsigned long) data.swap.free, |
---|
114 | (unsigned long) data.swap.pagein, |
---|
115 | (unsigned long) data.swap.pageout); |
---|
116 | |
---|
117 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
118 | glibtop_get_uptime (&data.uptime); |
---|
119 | |
---|
120 | printf ("Uptime (0x%08lx): %f, %f\n", |
---|
121 | (unsigned long) data.uptime.flags, |
---|
122 | data.uptime.uptime, data.uptime.idletime); |
---|
123 | |
---|
124 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
125 | glibtop_get_loadavg (&data.loadavg); |
---|
126 | |
---|
127 | printf ("Loadavg (0x%08lx): %f, %f, %f - %lu, %lu, %lu\n", |
---|
128 | (unsigned long) data.loadavg.flags, |
---|
129 | (double) data.loadavg.loadavg [0], |
---|
130 | (double) data.loadavg.loadavg [1], |
---|
131 | (double) data.loadavg.loadavg [2], |
---|
132 | (unsigned long) data.loadavg.nr_running, |
---|
133 | (unsigned long) data.loadavg.nr_tasks, |
---|
134 | (unsigned long) data.loadavg.last_pid); |
---|
135 | |
---|
136 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
137 | glibtop_get_shm_limits (&data.shm_limits); |
---|
138 | |
---|
139 | printf ("Shm Limits (0x%08lx): %lu, %lu, %lu, %lu, %lu\n", |
---|
140 | (unsigned long) data.shm_limits.flags, |
---|
141 | (unsigned long) data.shm_limits.shmmax, |
---|
142 | (unsigned long) data.shm_limits.shmmin, |
---|
143 | (unsigned long) data.shm_limits.shmmni, |
---|
144 | (unsigned long) data.shm_limits.shmseg, |
---|
145 | (unsigned long) data.shm_limits.shmall); |
---|
146 | |
---|
147 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
148 | glibtop_get_msg_limits (&data.msg_limits); |
---|
149 | |
---|
150 | printf ("Msg Limits (0x%08lx): %lu, %lu, %lu, %lu, %lu, %lu, %lu\n", |
---|
151 | (unsigned long) data.msg_limits.flags, |
---|
152 | (unsigned long) data.msg_limits.msgpool, |
---|
153 | (unsigned long) data.msg_limits.msgmap, |
---|
154 | (unsigned long) data.msg_limits.msgmax, |
---|
155 | (unsigned long) data.msg_limits.msgmnb, |
---|
156 | (unsigned long) data.msg_limits.msgmni, |
---|
157 | (unsigned long) data.msg_limits.msgssz, |
---|
158 | (unsigned long) data.msg_limits.msgtql); |
---|
159 | |
---|
160 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
161 | glibtop_get_sem_limits (&data.sem_limits); |
---|
162 | |
---|
163 | printf ("Sem Limits (0x%08lx): " |
---|
164 | "%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n", |
---|
165 | (unsigned long) data.sem_limits.flags, |
---|
166 | (unsigned long) data.sem_limits.semmap, |
---|
167 | (unsigned long) data.sem_limits.semmni, |
---|
168 | (unsigned long) data.sem_limits.semmns, |
---|
169 | (unsigned long) data.sem_limits.semmnu, |
---|
170 | (unsigned long) data.sem_limits.semmsl, |
---|
171 | (unsigned long) data.sem_limits.semopm, |
---|
172 | (unsigned long) data.sem_limits.semume, |
---|
173 | (unsigned long) data.sem_limits.semusz, |
---|
174 | (unsigned long) data.sem_limits.semvmx, |
---|
175 | (unsigned long) data.sem_limits.semaem); |
---|
176 | |
---|
177 | printf ("\n"); |
---|
178 | |
---|
179 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
180 | glibtop_get_ppp (&data.ppp, 0); |
---|
181 | |
---|
182 | printf ("PPP (0x%08lx): %lu, %lu, %lu\n", |
---|
183 | (unsigned long) data.ppp.flags, |
---|
184 | (unsigned long) data.ppp.state, |
---|
185 | (unsigned long) data.ppp.bytes_in, |
---|
186 | (unsigned long) data.ppp.bytes_out); |
---|
187 | |
---|
188 | printf ("\n"); |
---|
189 | |
---|
190 | glibtop_get_sysdeps (&sysdeps); |
---|
191 | |
---|
192 | printf ("Sysdeps (0x%08lx): %lu, %lu, %lu, %lu, %lu, " |
---|
193 | "%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, " |
---|
194 | "%lu, %lu, %lu, %lu, %lu, %lu\n", |
---|
195 | (unsigned long) sysdeps.flags, |
---|
196 | (unsigned long) sysdeps.cpu, |
---|
197 | (unsigned long) sysdeps.mem, |
---|
198 | (unsigned long) sysdeps.swap, |
---|
199 | (unsigned long) sysdeps.uptime, |
---|
200 | (unsigned long) sysdeps.loadavg, |
---|
201 | (unsigned long) sysdeps.shm_limits, |
---|
202 | (unsigned long) sysdeps.msg_limits, |
---|
203 | (unsigned long) sysdeps.sem_limits, |
---|
204 | (unsigned long) sysdeps.proclist, |
---|
205 | (unsigned long) sysdeps.proc_state, |
---|
206 | (unsigned long) sysdeps.proc_uid, |
---|
207 | (unsigned long) sysdeps.proc_mem, |
---|
208 | (unsigned long) sysdeps.proc_time, |
---|
209 | (unsigned long) sysdeps.proc_signal, |
---|
210 | (unsigned long) sysdeps.proc_kernel, |
---|
211 | (unsigned long) sysdeps.proc_segment, |
---|
212 | (unsigned long) sysdeps.proc_args, |
---|
213 | (unsigned long) sysdeps.proc_map, |
---|
214 | (unsigned long) sysdeps.mountlist, |
---|
215 | (unsigned long) sysdeps.fsusage, |
---|
216 | (unsigned long) sysdeps.netload, |
---|
217 | (unsigned long) sysdeps.ppp); |
---|
218 | |
---|
219 | printf ("\n"); |
---|
220 | |
---|
221 | ptr = glibtop_get_proclist (&data.proclist, 0, 0); |
---|
222 | |
---|
223 | printf ("Proclist (0x%08lx): %lu, %lu, %lu\n", |
---|
224 | (unsigned long) data.proclist.flags, |
---|
225 | (unsigned long) data.proclist.number, |
---|
226 | (unsigned long) data.proclist.size, |
---|
227 | (unsigned long) data.proclist.total); |
---|
228 | |
---|
229 | if (ptr) { |
---|
230 | printf ("\nProcess: "); |
---|
231 | for (i = 0; i < data.proclist.number; i++) |
---|
232 | printf ("%s%u", i ? ", " : "", ptr [i]); |
---|
233 | printf ("\n"); |
---|
234 | } |
---|
235 | |
---|
236 | g_free (ptr); |
---|
237 | |
---|
238 | pid = getpid (); |
---|
239 | ppid = getppid (); |
---|
240 | |
---|
241 | printf ("\n"); |
---|
242 | |
---|
243 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
244 | glibtop_get_proc_state (&data.proc_state, pid); |
---|
245 | |
---|
246 | printf ("Proc_State PID %5d (0x%08lx): '%s', %c, %lu, %lu\n", |
---|
247 | (int) pid, (unsigned long) data.proc_state.flags, |
---|
248 | data.proc_state.cmd, data.proc_state.state, |
---|
249 | (unsigned long) data.proc_state.uid, |
---|
250 | (unsigned long) data.proc_state.gid); |
---|
251 | |
---|
252 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
253 | glibtop_get_proc_uid (&data.proc_uid, pid); |
---|
254 | |
---|
255 | printf ("Proc_Uid PID %5d (0x%08lx): " |
---|
256 | "%d %d %d %d %d %d %d %d %d %d %d %d\n", (int) pid, |
---|
257 | (unsigned long) data.proc_uid.flags, |
---|
258 | data.proc_uid.uid, data.proc_uid.euid, |
---|
259 | data.proc_uid.gid, data.proc_uid.egid, |
---|
260 | data.proc_uid.pid, data.proc_uid.ppid, |
---|
261 | data.proc_uid.pgrp, data.proc_uid.session, |
---|
262 | data.proc_uid.tty, data.proc_uid.tpgid, |
---|
263 | data.proc_uid.priority, data.proc_uid.nice); |
---|
264 | |
---|
265 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
266 | glibtop_get_proc_mem (&data.proc_mem, pid); |
---|
267 | |
---|
268 | printf ("Proc_Mem PID %5d (0x%08lx): " |
---|
269 | "%lu %lu %lu %lu %lu %lu\n", (int) pid, |
---|
270 | (unsigned long) data.proc_mem.flags, |
---|
271 | (unsigned long) data.proc_mem.size, |
---|
272 | (unsigned long) data.proc_mem.vsize, |
---|
273 | (unsigned long) data.proc_mem.resident, |
---|
274 | (unsigned long) data.proc_mem.share, |
---|
275 | (unsigned long) data.proc_mem.rss, |
---|
276 | (unsigned long) data.proc_mem.rss_rlim); |
---|
277 | |
---|
278 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
279 | glibtop_get_proc_segment (&data.proc_segment, pid); |
---|
280 | |
---|
281 | printf ("Proc_Segment PID %5d (0x%08lx): " |
---|
282 | "%lu %lu %lu %lu %lu %lu %lu %lu\n", (int) pid, |
---|
283 | (unsigned long) data.proc_segment.flags, |
---|
284 | (unsigned long) data.proc_segment.text_rss, |
---|
285 | (unsigned long) data.proc_segment.shlib_rss, |
---|
286 | (unsigned long) data.proc_segment.data_rss, |
---|
287 | (unsigned long) data.proc_segment.stack_rss, |
---|
288 | (unsigned long) data.proc_segment.dirty_size, |
---|
289 | (unsigned long) data.proc_segment.start_code, |
---|
290 | (unsigned long) data.proc_segment.end_code, |
---|
291 | (unsigned long) data.proc_segment.start_stack); |
---|
292 | |
---|
293 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
294 | glibtop_get_proc_time (&data.proc_time, pid); |
---|
295 | |
---|
296 | printf ("Proc_Time PID %5d (0x%08lx): " |
---|
297 | "%lu %lu %lu %lu %lu %lu %lu %lu %lu\n", (int) pid, |
---|
298 | (unsigned long) data.proc_time.flags, |
---|
299 | (unsigned long) data.proc_time.start_time, |
---|
300 | (unsigned long) data.proc_time.rtime, |
---|
301 | (unsigned long) data.proc_time.utime, |
---|
302 | (unsigned long) data.proc_time.stime, |
---|
303 | (unsigned long) data.proc_time.cutime, |
---|
304 | (unsigned long) data.proc_time.cstime, |
---|
305 | (unsigned long) data.proc_time.timeout, |
---|
306 | (unsigned long) data.proc_time.it_real_value, |
---|
307 | (unsigned long) data.proc_time.frequency); |
---|
308 | |
---|
309 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
310 | glibtop_get_proc_signal (&data.proc_signal, pid); |
---|
311 | |
---|
312 | printf ("Proc_Signal PID %5d (0x%08lx): " |
---|
313 | "%lu %lu %lu %lu\n", (int) pid, |
---|
314 | (unsigned long) data.proc_signal.flags, |
---|
315 | (unsigned long) data.proc_signal.signal, |
---|
316 | (unsigned long) data.proc_signal.blocked, |
---|
317 | (unsigned long) data.proc_signal.sigignore, |
---|
318 | (unsigned long) data.proc_signal.sigcatch); |
---|
319 | |
---|
320 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
321 | glibtop_get_proc_kernel (&data.proc_kernel, pid); |
---|
322 | |
---|
323 | printf ("Proc_Kernel PID %5d (0x%08lx): " |
---|
324 | "%lu %lu %lu %lu %lu 0x%lx 0x%lx 0x%lx (%s)\n", (int) pid, |
---|
325 | (unsigned long) data.proc_kernel.flags, |
---|
326 | (unsigned long) data.proc_kernel.k_flags, |
---|
327 | (unsigned long) data.proc_kernel.min_flt, |
---|
328 | (unsigned long) data.proc_kernel.maj_flt, |
---|
329 | (unsigned long) data.proc_kernel.cmin_flt, |
---|
330 | (unsigned long) data.proc_kernel.cmaj_flt, |
---|
331 | (unsigned long) data.proc_kernel.kstk_esp, |
---|
332 | (unsigned long) data.proc_kernel.kstk_eip, |
---|
333 | (unsigned long) data.proc_kernel.nwchan, |
---|
334 | data.proc_kernel.wchan); |
---|
335 | |
---|
336 | printf ("\n"); |
---|
337 | |
---|
338 | args = glibtop_get_proc_args (&data.proc_args, pid, 0); |
---|
339 | |
---|
340 | for (i = 0; i < data.proc_args.size; i++) { |
---|
341 | if (args [i]) continue; |
---|
342 | args [i] = '|'; |
---|
343 | } |
---|
344 | |
---|
345 | printf ("Proc_Args PID %5d (0x%08lx): %lu - '%s'\n", (int) pid, |
---|
346 | (unsigned long) data.proc_args.flags, |
---|
347 | (unsigned long) data.proc_args.size, |
---|
348 | args ? args : ""); |
---|
349 | |
---|
350 | g_free (args); |
---|
351 | |
---|
352 | printf ("\n"); |
---|
353 | |
---|
354 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
355 | glibtop_get_proc_state (&data.proc_state, ppid); |
---|
356 | |
---|
357 | printf ("Proc_State PPID %5d (0x%08lx): '%s', %c, %lu, %lu\n", |
---|
358 | (int) ppid, (unsigned long) data.proc_state.flags, |
---|
359 | data.proc_state.cmd, data.proc_state.state, |
---|
360 | (unsigned long) data.proc_state.uid, |
---|
361 | (unsigned long) data.proc_state.gid); |
---|
362 | |
---|
363 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
364 | glibtop_get_proc_uid (&data.proc_uid, ppid); |
---|
365 | |
---|
366 | printf ("Proc_Uid PPID %5d (0x%08lx): " |
---|
367 | "%d %d %d %d %d %d %d %d %d %d %d %d\n", (int) ppid, |
---|
368 | (unsigned long) data.proc_uid.flags, |
---|
369 | data.proc_uid.uid, data.proc_uid.euid, |
---|
370 | data.proc_uid.gid, data.proc_uid.egid, |
---|
371 | data.proc_uid.pid, data.proc_uid.ppid, |
---|
372 | data.proc_uid.pgrp, data.proc_uid.session, |
---|
373 | data.proc_uid.tty, data.proc_uid.tpgid, |
---|
374 | data.proc_uid.priority, data.proc_uid.nice); |
---|
375 | |
---|
376 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
377 | glibtop_get_proc_mem (&data.proc_mem, ppid); |
---|
378 | |
---|
379 | printf ("Proc_Mem PPID %5d (0x%08lx): " |
---|
380 | "%lu %lu %lu %lu %lu %lu\n", (int) ppid, |
---|
381 | (unsigned long) data.proc_mem.flags, |
---|
382 | (unsigned long) data.proc_mem.size, |
---|
383 | (unsigned long) data.proc_mem.vsize, |
---|
384 | (unsigned long) data.proc_mem.resident, |
---|
385 | (unsigned long) data.proc_mem.share, |
---|
386 | (unsigned long) data.proc_mem.rss, |
---|
387 | (unsigned long) data.proc_mem.rss_rlim); |
---|
388 | |
---|
389 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
390 | glibtop_get_proc_segment (&data.proc_segment, ppid); |
---|
391 | |
---|
392 | printf ("Proc_Segment PPID %5d (0x%08lx): " |
---|
393 | "%lu %lu %lu %lu %lu %lu %lu %lu\n", (int) ppid, |
---|
394 | (unsigned long) data.proc_segment.flags, |
---|
395 | (unsigned long) data.proc_segment.text_rss, |
---|
396 | (unsigned long) data.proc_segment.shlib_rss, |
---|
397 | (unsigned long) data.proc_segment.data_rss, |
---|
398 | (unsigned long) data.proc_segment.stack_rss, |
---|
399 | (unsigned long) data.proc_segment.dirty_size, |
---|
400 | (unsigned long) data.proc_segment.start_code, |
---|
401 | (unsigned long) data.proc_segment.end_code, |
---|
402 | (unsigned long) data.proc_segment.start_stack); |
---|
403 | |
---|
404 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
405 | glibtop_get_proc_time (&data.proc_time, ppid); |
---|
406 | |
---|
407 | printf ("Proc_Time PPID %5d (0x%08lx): " |
---|
408 | "%lu %lu %lu %lu %lu %lu %lu %lu %lu\n", (int) ppid, |
---|
409 | (unsigned long) data.proc_time.flags, |
---|
410 | (unsigned long) data.proc_time.start_time, |
---|
411 | (unsigned long) data.proc_time.rtime, |
---|
412 | (unsigned long) data.proc_time.utime, |
---|
413 | (unsigned long) data.proc_time.stime, |
---|
414 | (unsigned long) data.proc_time.cutime, |
---|
415 | (unsigned long) data.proc_time.cstime, |
---|
416 | (unsigned long) data.proc_time.timeout, |
---|
417 | (unsigned long) data.proc_time.it_real_value, |
---|
418 | (unsigned long) data.proc_time.frequency); |
---|
419 | |
---|
420 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
421 | glibtop_get_proc_signal (&data.proc_signal, ppid); |
---|
422 | |
---|
423 | printf ("Proc_Signal PPID %5d (0x%08lx): %lu %lu %lu %lu\n", |
---|
424 | (int) ppid, (unsigned long) data.proc_signal.flags, |
---|
425 | (unsigned long) data.proc_signal.signal, |
---|
426 | (unsigned long) data.proc_signal.blocked, |
---|
427 | (unsigned long) data.proc_signal.sigignore, |
---|
428 | (unsigned long) data.proc_signal.sigcatch); |
---|
429 | |
---|
430 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
431 | glibtop_get_proc_kernel (&data.proc_kernel, ppid); |
---|
432 | |
---|
433 | printf ("Proc_Kernel PPID %5d (0x%08lx): " |
---|
434 | "%lu %lu %lu %lu %lu 0x%lx 0x%lx 0x%lx (%s)\n", (int) ppid, |
---|
435 | (unsigned long) data.proc_kernel.flags, |
---|
436 | (unsigned long) data.proc_kernel.k_flags, |
---|
437 | (unsigned long) data.proc_kernel.min_flt, |
---|
438 | (unsigned long) data.proc_kernel.maj_flt, |
---|
439 | (unsigned long) data.proc_kernel.cmin_flt, |
---|
440 | (unsigned long) data.proc_kernel.cmaj_flt, |
---|
441 | (unsigned long) data.proc_kernel.kstk_esp, |
---|
442 | (unsigned long) data.proc_kernel.kstk_eip, |
---|
443 | (unsigned long) data.proc_kernel.nwchan, |
---|
444 | data.proc_kernel.wchan); |
---|
445 | |
---|
446 | printf ("\n"); |
---|
447 | |
---|
448 | args = glibtop_get_proc_args (&data.proc_args, ppid, 0); |
---|
449 | |
---|
450 | for (i = 0; i < data.proc_args.size; i++) { |
---|
451 | if (args [i]) continue; |
---|
452 | args [i] = '|'; |
---|
453 | } |
---|
454 | |
---|
455 | printf ("Proc_Args PID %5d (0x%08lx): %lu - '%s'\n", (int) ppid, |
---|
456 | (unsigned long) data.proc_args.flags, |
---|
457 | (unsigned long) data.proc_args.size, |
---|
458 | args ? args : ""); |
---|
459 | |
---|
460 | g_free (args); |
---|
461 | |
---|
462 | printf ("\n"); |
---|
463 | |
---|
464 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
465 | glibtop_get_proc_state (&data.proc_state, 1); |
---|
466 | |
---|
467 | printf ("Proc_State INIT %5d (0x%08lx): '%s', %c, %lu, %lu\n", 1, |
---|
468 | (unsigned long) data.proc_state.flags, |
---|
469 | data.proc_state.cmd, data.proc_state.state, |
---|
470 | (unsigned long) data.proc_state.uid, |
---|
471 | (unsigned long) data.proc_state.gid); |
---|
472 | |
---|
473 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
474 | glibtop_get_proc_uid (&data.proc_uid, 1); |
---|
475 | |
---|
476 | printf ("Proc_Uid INIT %5d (0x%08lx): " |
---|
477 | "%d %d %d %d %d %d %d %d %d %d %d %d\n", 1, |
---|
478 | (unsigned long) data.proc_uid.flags, |
---|
479 | data.proc_uid.uid, data.proc_uid.euid, |
---|
480 | data.proc_uid.gid, data.proc_uid.egid, |
---|
481 | data.proc_uid.pid, data.proc_uid.ppid, |
---|
482 | data.proc_uid.pgrp, data.proc_uid.session, |
---|
483 | data.proc_uid.tty, data.proc_uid.tpgid, |
---|
484 | data.proc_uid.priority, data.proc_uid.nice); |
---|
485 | |
---|
486 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
487 | glibtop_get_proc_mem (&data.proc_mem, 1); |
---|
488 | |
---|
489 | printf ("Proc_Mem INIT %5d (0x%08lx): " |
---|
490 | "%lu %lu %lu %lu %lu %lu\n", 1, |
---|
491 | (unsigned long) data.proc_mem.flags, |
---|
492 | (unsigned long) data.proc_mem.size, |
---|
493 | (unsigned long) data.proc_mem.vsize, |
---|
494 | (unsigned long) data.proc_mem.resident, |
---|
495 | (unsigned long) data.proc_mem.share, |
---|
496 | (unsigned long) data.proc_mem.rss, |
---|
497 | (unsigned long) data.proc_mem.rss_rlim); |
---|
498 | |
---|
499 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
500 | glibtop_get_proc_segment (&data.proc_segment, 1); |
---|
501 | |
---|
502 | printf ("Proc_Segment INIT %5d (0x%08lx): " |
---|
503 | "%lu %lu %lu %lu %lu %lu %lu %lu\n", 1, |
---|
504 | (unsigned long) data.proc_segment.flags, |
---|
505 | (unsigned long) data.proc_segment.text_rss, |
---|
506 | (unsigned long) data.proc_segment.shlib_rss, |
---|
507 | (unsigned long) data.proc_segment.data_rss, |
---|
508 | (unsigned long) data.proc_segment.stack_rss, |
---|
509 | (unsigned long) data.proc_segment.dirty_size, |
---|
510 | (unsigned long) data.proc_segment.start_code, |
---|
511 | (unsigned long) data.proc_segment.end_code, |
---|
512 | (unsigned long) data.proc_segment.start_stack); |
---|
513 | |
---|
514 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
515 | glibtop_get_proc_time (&data.proc_time, 1); |
---|
516 | |
---|
517 | printf ("Proc_Time INIT %5d (0x%08lx): " |
---|
518 | "%lu %lu %lu %lu %lu %lu %lu %lu %lu\n", 1, |
---|
519 | (unsigned long) data.proc_time.flags, |
---|
520 | (unsigned long) data.proc_time.start_time, |
---|
521 | (unsigned long) data.proc_time.rtime, |
---|
522 | (unsigned long) data.proc_time.utime, |
---|
523 | (unsigned long) data.proc_time.stime, |
---|
524 | (unsigned long) data.proc_time.cutime, |
---|
525 | (unsigned long) data.proc_time.cstime, |
---|
526 | (unsigned long) data.proc_time.timeout, |
---|
527 | (unsigned long) data.proc_time.it_real_value, |
---|
528 | (unsigned long) data.proc_time.frequency); |
---|
529 | |
---|
530 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
531 | glibtop_get_proc_signal (&data.proc_signal, 1); |
---|
532 | |
---|
533 | printf ("Proc_Signal INIT %5d (0x%08lx): " |
---|
534 | "%lu %lu %lu %lu\n", 1, |
---|
535 | (unsigned long) data.proc_signal.flags, |
---|
536 | (unsigned long) data.proc_signal.signal, |
---|
537 | (unsigned long) data.proc_signal.blocked, |
---|
538 | (unsigned long) data.proc_signal.sigignore, |
---|
539 | (unsigned long) data.proc_signal.sigcatch); |
---|
540 | |
---|
541 | for (c = 0; c < PROFILE_COUNT; c++) |
---|
542 | glibtop_get_proc_kernel (&data.proc_kernel, 1); |
---|
543 | |
---|
544 | printf ("Proc_Kernel INIT %5d (0x%08lx): " |
---|
545 | "%lu %lu %lu %lu %lu 0x%lx 0x%lx 0x%lx (%s)\n", 1, |
---|
546 | (unsigned long) data.proc_kernel.flags, |
---|
547 | (unsigned long) data.proc_kernel.k_flags, |
---|
548 | (unsigned long) data.proc_kernel.min_flt, |
---|
549 | (unsigned long) data.proc_kernel.maj_flt, |
---|
550 | (unsigned long) data.proc_kernel.cmin_flt, |
---|
551 | (unsigned long) data.proc_kernel.cmaj_flt, |
---|
552 | (unsigned long) data.proc_kernel.kstk_esp, |
---|
553 | (unsigned long) data.proc_kernel.kstk_eip, |
---|
554 | (unsigned long) data.proc_kernel.nwchan, |
---|
555 | data.proc_kernel.wchan); |
---|
556 | |
---|
557 | printf ("\n"); |
---|
558 | |
---|
559 | args = glibtop_get_proc_args (&data.proc_args, 1, 0); |
---|
560 | |
---|
561 | for (i = 0; i < data.proc_args.size; i++) { |
---|
562 | if (args [i]) continue; |
---|
563 | args [i] = '|'; |
---|
564 | } |
---|
565 | |
---|
566 | printf ("Proc_Args PID %5d (0x%08lx): %lu - '%s'\n", 1, |
---|
567 | (unsigned long) data.proc_args.flags, |
---|
568 | (unsigned long) data.proc_args.size, |
---|
569 | args ? args : ""); |
---|
570 | |
---|
571 | g_free (args); |
---|
572 | |
---|
573 | glibtop_close (); |
---|
574 | |
---|
575 | exit (0); |
---|
576 | } |
---|