1 | This is libgtop2.info, produced by makeinfo version 4.0 from |
---|
2 | libgtop2.texi. |
---|
3 | |
---|
4 | This is the LibGTop Reference Manual version 2.0.0 (last modified |
---|
5 | 10 June 2002). |
---|
6 | |
---|
7 | Copyright 1999 Free Software Foundation, Inc. |
---|
8 | |
---|
9 | Permission is granted to make and distribute verbatim copies of this |
---|
10 | manual provided the copyright notice and this permission notice are |
---|
11 | preserved on all copies. |
---|
12 | |
---|
13 | Permission is granted to copy and distribute modified versions of |
---|
14 | this manual under the conditions for verbatim copying, provided also |
---|
15 | that the sections entitled "Copying" and "GNU General Public License" |
---|
16 | are included exactly as in the original, and provided that the entire |
---|
17 | resulting derived work is distributed under the terms of a permission |
---|
18 | notice identical to this one. |
---|
19 | |
---|
20 | Permission is granted to copy and distribute translations of this |
---|
21 | manual into another language, under the above conditions for modified |
---|
22 | versions, except that this permission notice may be stated in a |
---|
23 | translation approved by the Free Software Foundation. |
---|
24 | |
---|
25 | INFO-DIR-SECTION Libraries: |
---|
26 | START-INFO-DIR-ENTRY |
---|
27 | * LibGTop2: (libgtop2). Library to get system specific data |
---|
28 | such as cpu and memory usage, active |
---|
29 | processes |
---|
30 | END-INFO-DIR-ENTRY |
---|
31 | |
---|
32 | |
---|
33 | File: libgtop2.info, Node: Top, Next: About, Prev: (dir), Up: (dir) |
---|
34 | |
---|
35 | * Menu: |
---|
36 | |
---|
37 | * About:: About LibGTop |
---|
38 | * White Paper:: LibGTop White Paper |
---|
39 | * Reference Manual:: LibGTop Reference Manual |
---|
40 | |
---|
41 | --- The Detailed Node Listing --- |
---|
42 | |
---|
43 | About LibGTop |
---|
44 | |
---|
45 | * Availability:: Where to get LibGTop |
---|
46 | * Supported Platforms:: Supported Platforms |
---|
47 | * Mailing List:: Helping with LibGTop development |
---|
48 | * Thanks:: People who contributed to LibGTop |
---|
49 | |
---|
50 | LibGTop White Paper |
---|
51 | |
---|
52 | * Introduction:: Introduction |
---|
53 | * Overview:: Overview |
---|
54 | |
---|
55 | Overview |
---|
56 | |
---|
57 | * Interface Design:: Things that need to be considered |
---|
58 | * Server Implementation:: The LibGTop "server" |
---|
59 | |
---|
60 | LibGTop Reference Manual |
---|
61 | |
---|
62 | * System Dependent:: System Dependent Functions. |
---|
63 | * Common Functions:: Common Functions. |
---|
64 | * Library Functions:: Library Functions. |
---|
65 | |
---|
66 | System Dependent Functions |
---|
67 | |
---|
68 | * glibtop_cpu:: CPU Usage. |
---|
69 | * glibtop_mem:: Memory Usage. |
---|
70 | * glibtop_swap:: Swap Usage. |
---|
71 | * glibtop_uptime:: System Uptime. |
---|
72 | * glibtop_loadavg:: Load Average. |
---|
73 | * glibtop_proclist:: Process List. |
---|
74 | * glibtop_proc_state:: Process State. |
---|
75 | * glibtop_proc_uid:: Process UID and TTY Information. |
---|
76 | * glibtop_proc_mem:: Process Memory Information. |
---|
77 | * glibtop_proc_time:: Process Time Information. |
---|
78 | * glibtop_proc_signal:: Process Signal Information. |
---|
79 | * glibtop_proc_kernel:: Process Kernel Data Information. |
---|
80 | * glibtop_proc_segment:: Process Segment Information. |
---|
81 | * glibtop_proc_args:: Process Arguments. |
---|
82 | * glibtop_proc_map:: Process Memory Maps. |
---|
83 | * glibtop_netload:: Network Load. |
---|
84 | * glibtop_ppp:: PPP Usage. |
---|
85 | |
---|
86 | Common Functions |
---|
87 | |
---|
88 | * glibtop_mountlist:: Mount List. |
---|
89 | * glibtop_fsusage:: File System Usage. |
---|
90 | |
---|
91 | Library Functions |
---|
92 | |
---|
93 | * glibtop_init:: Server Initialization. |
---|
94 | * glibtop_sysdeps:: Server Sysdeps. |
---|
95 | * Library Parameters:: Library Parameters. |
---|
96 | |
---|
97 | |
---|
98 | File: libgtop2.info, Node: About, Next: White Paper, Prev: Top, Up: Top |
---|
99 | |
---|
100 | About LibGTop |
---|
101 | ************* |
---|
102 | |
---|
103 | LibGTop is a library to get system specific data such as CPU and |
---|
104 | Memory Usage and information about running Processes. |
---|
105 | |
---|
106 | On Systems like Solaris or Digital Unix where you need special |
---|
107 | privileges to get those data, it uses a setuid/setgid server to do so. |
---|
108 | |
---|
109 | Even if LibGTop is a part of the GNOME desktop environment |
---|
110 | (`http://www.gnome.org'), the main interface of LibGTop is totally |
---|
111 | independent from any particular desktop environment, so you can also |
---|
112 | use it as a standalone library in any piece of GPLed software. |
---|
113 | |
---|
114 | * Menu: |
---|
115 | |
---|
116 | * Availability:: Where to get LibGTop |
---|
117 | * Supported Platforms:: Supported Platforms |
---|
118 | * Mailing List:: Helping with LibGTop development |
---|
119 | * Thanks:: People who contributed to LibGTop |
---|
120 | |
---|
121 | |
---|
122 | File: libgtop2.info, Node: Availability, Next: Supported Platforms, Prev: About, Up: About |
---|
123 | |
---|
124 | Availability |
---|
125 | ============ |
---|
126 | |
---|
127 | The master source of LibGTop is the GNOME CVS tree (see |
---|
128 | `http://www.gnome.org' for details), but you can also get the latest |
---|
129 | release tarballs from |
---|
130 | |
---|
131 | `ftp://ftp.gnome.org/pub/GNOME/sources/libgtop/' |
---|
132 | |
---|
133 | or any of its mirror sites. |
---|
134 | |
---|
135 | The latest stable version of LibGTop is 1.0.12 which is also the one |
---|
136 | that comes together with GNOME 1.0. It belongs to `LIBGTOP_STABLE_1_0' |
---|
137 | branch in CVS. Actual development occurs in the |
---|
138 | `libgtop-GNOME-2-0-port' which is currently versioned 1.90.0. |
---|
139 | |
---|
140 | |
---|
141 | File: libgtop2.info, Node: Supported Platforms, Next: Mailing List, Prev: Availability, Up: About |
---|
142 | |
---|
143 | Supported Platforms |
---|
144 | =================== |
---|
145 | |
---|
146 | The stable branch currently supports the following platforms: |
---|
147 | |
---|
148 | * All versions of Linux |
---|
149 | |
---|
150 | LibGTop was tested under Linux 2.0.x and 2.2.x on the ix86 and the |
---|
151 | alpha, but it should also work without problems on SparcLinux or |
---|
152 | Linux 2.4.x. |
---|
153 | |
---|
154 | Note: I'm speaking of the Linux kernel here, not the GNU/Linux |
---|
155 | operating system. |
---|
156 | |
---|
157 | * FreeBSD, NetBSD and OpenBSD |
---|
158 | |
---|
159 | LibGTop was tested under FreeBSD 2.2.6 and 3.0, NetBSD 1.3.2 and |
---|
160 | OpenBSD 2.4. Support for NetBSD 1.4 was added in LibGTop 1.0.2. |
---|
161 | |
---|
162 | |
---|
163 | The platforms listed above are known to be stable and working. |
---|
164 | However, if you're using the latest development version, you can use it |
---|
165 | on the following platforms as well: |
---|
166 | |
---|
167 | * BSD/OS |
---|
168 | |
---|
169 | There is a port for BSD/OS (aka BSDI) 2.x and 3.x from Timur |
---|
170 | Bakeyev which should also work with 4.x. This isn't tested very |
---|
171 | well, but it should be working. |
---|
172 | |
---|
173 | * Digital Unix |
---|
174 | |
---|
175 | There is some basic support for Digital Unix (formerly DEC OSF/1) |
---|
176 | V3.2C, but this may still be a bit unstable. I'm currently working |
---|
177 | on this port as time permits so it should be fully supported soon. |
---|
178 | |
---|
179 | * Solaris |
---|
180 | |
---|
181 | The Solaris port currently works on Solaris 7 and maybe also on |
---|
182 | other releases. Thanks a lot to Drazen Kacar and everyone who |
---|
183 | helped working on this port. They have really done excellent work |
---|
184 | here and I'm pretty sure that this port will be fully functional |
---|
185 | on most Solaris versions in near future. |
---|
186 | |
---|
187 | |
---|
188 | |
---|
189 | File: libgtop2.info, Node: Mailing List, Next: Thanks, Prev: Supported Platforms, Up: About |
---|
190 | |
---|
191 | Mailing List |
---|
192 | ============ |
---|
193 | |
---|
194 | There is a <libgtop-devel-list@egroups.com> mailing list for people |
---|
195 | who want to help with the development of LibGTop. |
---|
196 | |
---|
197 | It is meant as a low-traffic, but high content-list where we can |
---|
198 | discuss technical details such as adding new sysdeps ports etc. |
---|
199 | |
---|
200 | Especially, I'd like to see people with a deeper knowledge of |
---|
201 | operating systems internals joining my list so we can discuss technical |
---|
202 | details of the sysdeps code. |
---|
203 | |
---|
204 | It is *not* for users that want to know how to compile LibGTop etc. |
---|
205 | |
---|
206 | You can subscribe to this mailing list and view the mailing list |
---|
207 | archives on the LibGTop Page at |
---|
208 | `http://www.home-of-linux.org/gnome/libgtop'. |
---|
209 | |
---|
210 | |
---|
211 | File: libgtop2.info, Node: Thanks, Prev: Mailing List, Up: About |
---|
212 | |
---|
213 | Thanks |
---|
214 | ====== |
---|
215 | |
---|
216 | At the place I'd like to thank the following people who contributed |
---|
217 | to LibGTop (listed in chronological order): |
---|
218 | |
---|
219 | * Sebastian Wilhelmi who had the initial idea of LibGTop and helped |
---|
220 | me a lot in the early beginning. |
---|
221 | |
---|
222 | * Josh Sled for the initial FreeBSD port. |
---|
223 | |
---|
224 | * Jeremy Lea for his BSD patches. |
---|
225 | |
---|
226 | * Timur Bakeyev for the BSDI port. |
---|
227 | |
---|
228 | * Drazen Kacar and the other people on the LibGTop development |
---|
229 | mailing list for the Solaris port. |
---|
230 | |
---|
231 | * Kevin Vandersloot for the effort to port to GNOME 2.0. |
---|
232 | |
---|
233 | * All people sending me patches, having good ideas, ... |
---|
234 | |
---|
235 | * Everyone I have forgotten in this list ... |
---|
236 | |
---|
237 | |
---|
238 | File: libgtop2.info, Node: White Paper, Next: Reference Manual, Prev: About, Up: Top |
---|
239 | |
---|
240 | LibGTop White Paper |
---|
241 | ******************* |
---|
242 | |
---|
243 | * Menu: |
---|
244 | |
---|
245 | * Introduction:: Introduction |
---|
246 | * Overview:: Overview |
---|
247 | |
---|
248 | |
---|
249 | File: libgtop2.info, Node: Introduction, Next: Overview, Prev: White Paper, Up: White Paper |
---|
250 | |
---|
251 | Introduction |
---|
252 | ============ |
---|
253 | |
---|
254 | Many modern UNIX systems like Solaris, BSD or Digitial Unix only |
---|
255 | allow priviledged processes to read information like CPU and Memory |
---|
256 | Usage or information about running processes. |
---|
257 | |
---|
258 | * BSD, for instance, doesn't have any other way to get those data |
---|
259 | than reading directly from `/dev/kmem' and you need to be in the |
---|
260 | `kmem' group to be able to read this. |
---|
261 | |
---|
262 | * Other systems, like Digital Unix, allow all users to get things |
---|
263 | like CPU and Memory statistics, but only root may read information |
---|
264 | about any process other than the current one (you may not even get |
---|
265 | information about your own processes if you're not root). |
---|
266 | |
---|
267 | * Linux has a very nice `/proc' filesystem, but reading and parsing |
---|
268 | `/proc' is very slow and inefficient. |
---|
269 | |
---|
270 | * Solaris is a bit better, but you still need to be in the `sys' |
---|
271 | group or even root to get some data. |
---|
272 | |
---|
273 | Because of this system utilities like `ps', `uptime' or `top' often |
---|
274 | are setgid kmem or setuid root. Usually, they're also very specific to |
---|
275 | the system they're written for and not easily portable to other systems |
---|
276 | without a lot of work. |
---|
277 | |
---|
278 | This, of cause, becomes a problem for graphical tools like `gtop' - |
---|
279 | making a GTK+ program setgid or even setuid would be a security hole as |
---|
280 | big as you can drive the entire X11 source code through. For the GNOME |
---|
281 | project, we also needed some kind of library which provides all the |
---|
282 | required information in a portable since there's more than just one |
---|
283 | single program that wants to use them - for instance `gtop' and the |
---|
284 | `multiload', `cpumemusage' and `netload' panel applets. |
---|
285 | |
---|
286 | |
---|
287 | File: libgtop2.info, Node: Overview, Prev: Introduction, Up: White Paper |
---|
288 | |
---|
289 | Overview |
---|
290 | ======== |
---|
291 | |
---|
292 | This section should give you a short overview on how LibGTop was |
---|
293 | developed, which things needed to be considered and how it works. |
---|
294 | |
---|
295 | * Menu: |
---|
296 | |
---|
297 | * Interface Design:: Things that need to be considered |
---|
298 | * Server Implementation:: The LibGTop "server" |
---|
299 | |
---|
300 | |
---|
301 | File: libgtop2.info, Node: Interface Design, Next: Server Implementation, Prev: Overview, Up: Overview |
---|
302 | |
---|
303 | Interface Design |
---|
304 | ---------------- |
---|
305 | |
---|
306 | At the very beginning, it was necessary to collect all the data the |
---|
307 | library part should provide and put them into some C structures. This |
---|
308 | was not that easiy as it might sound since LibGTop should be portable |
---|
309 | to any modern UNIX system with a common library part on all those |
---|
310 | systems, but the data that should be returned vary from system to |
---|
311 | system. For instance some systems support shared memory, but some others |
---|
312 | may not. |
---|
313 | |
---|
314 | The header files where we define these C structures (which are |
---|
315 | system-independent) are shared between client and server. This way we |
---|
316 | can call the system dependent code directly where we do not need any |
---|
317 | special privileges to do so. |
---|
318 | |
---|
319 | All of those structures contain a `flags' member which is |
---|
320 | interpreted as a bit mask and tells the caller of the library functions |
---|
321 | which of the fields in the returned structure are valid and which are |
---|
322 | not. |
---|
323 | |
---|
324 | |
---|
325 | File: libgtop2.info, Node: Server Implementation, Prev: Interface Design, Up: Overview |
---|
326 | |
---|
327 | Server Implementation |
---|
328 | --------------------- |
---|
329 | |
---|
330 | The LibGTop "server" is a setgid/setuid binary which contains all |
---|
331 | the system dependent code which needs special privileges. It is only |
---|
332 | build if it's required on the current system (for instance, the Linux |
---|
333 | kernel provides all the required data via its `/proc' filesystem so we |
---|
334 | do not need the server at all) and it only contains the "features" |
---|
335 | which need privileges. |
---|
336 | |
---|
337 | Whenever we do not need any privileges to get all the data for some |
---|
338 | of the requested structures (here called "features") the library calls |
---|
339 | the sysdeps code directly rather than using the server. |
---|
340 | |
---|
341 | |
---|
342 | File: libgtop2.info, Node: Reference Manual, Prev: White Paper, Up: Top |
---|
343 | |
---|
344 | LibGTop Reference Manual |
---|
345 | ************************ |
---|
346 | |
---|
347 | * Menu: |
---|
348 | |
---|
349 | * System Dependent:: System Dependent Functions. |
---|
350 | * Common Functions:: Common Functions. |
---|
351 | * Library Functions:: Library Functions. |
---|
352 | |
---|
353 | |
---|
354 | File: libgtop2.info, Node: System Dependent, Next: Common Functions, Prev: Reference Manual, Up: Reference Manual |
---|
355 | |
---|
356 | System Dependent Functions |
---|
357 | ========================== |
---|
358 | |
---|
359 | * Menu: |
---|
360 | |
---|
361 | * glibtop_cpu:: CPU Usage. |
---|
362 | * glibtop_mem:: Memory Usage. |
---|
363 | * glibtop_swap:: Swap Usage. |
---|
364 | * glibtop_uptime:: System Uptime. |
---|
365 | * glibtop_loadavg:: Load Average. |
---|
366 | * glibtop_proclist:: Process List. |
---|
367 | * glibtop_proc_state:: Process State. |
---|
368 | * glibtop_proc_uid:: Process UID and TTY Information. |
---|
369 | * glibtop_proc_mem:: Process Memory Information. |
---|
370 | * glibtop_proc_time:: Process Time Information. |
---|
371 | * glibtop_proc_signal:: Process Signal Information. |
---|
372 | * glibtop_proc_kernel:: Process Kernel Data Information. |
---|
373 | * glibtop_proc_segment:: Process Segment Information. |
---|
374 | * glibtop_proc_args:: Process Arguments. |
---|
375 | * glibtop_proc_map:: Process Memory Maps. |
---|
376 | * glibtop_netload:: Network Load. |
---|
377 | * glibtop_ppp:: PPP Usage. |
---|
378 | |
---|
379 | |
---|
380 | File: libgtop2.info, Node: glibtop_cpu, Next: glibtop_mem, Prev: System Dependent, Up: System Dependent |
---|
381 | |
---|
382 | CPU Usage |
---|
383 | --------- |
---|
384 | |
---|
385 | Library function `glibtop_get_cpu': |
---|
386 | |
---|
387 | void glibtop_get_cpu (glibtop_cpu *buf); |
---|
388 | void glibtop_get_cpu_l (glibtop *server, glibtop_cpu *buf); |
---|
389 | |
---|
390 | Declaration of `glibtop_cpu' in `<glibtop/cpu.h>': |
---|
391 | |
---|
392 | typedef struct _glibtop_cpu glibtop_cpu; |
---|
393 | |
---|
394 | struct _glibtop_cpu |
---|
395 | { |
---|
396 | u_int64_t flags, |
---|
397 | total, |
---|
398 | user, |
---|
399 | nice, |
---|
400 | sys, |
---|
401 | idle, |
---|
402 | frequency, |
---|
403 | xcpu_total [GLIBTOP_NCPU], |
---|
404 | xcpu_user [GLIBTOP_NCPU], |
---|
405 | xcpu_nice [GLIBTOP_NCPU], |
---|
406 | xcpu_sys [GLIBTOP_NCPU], |
---|
407 | xcpu_idle [GLIBTOP_NCPU], |
---|
408 | xcpu_flags; |
---|
409 | }; |
---|
410 | |
---|
411 | All CPU units are measured in "jiffies" which are normally 1/100th |
---|
412 | of a second (in which case `frequency' equals 100), but can also be in |
---|
413 | any other unit. To get seconds, divide them by `frequency'. |
---|
414 | |
---|
415 | `total' |
---|
416 | Number of clock ticks since system boot. |
---|
417 | |
---|
418 | `user' |
---|
419 | Number of clock ticks the system spent in user mode. |
---|
420 | |
---|
421 | `nice' |
---|
422 | Number of clock ticks the system spent in user mode (nice). |
---|
423 | |
---|
424 | `sys' |
---|
425 | Number of clock ticks the system spent in system mode. |
---|
426 | |
---|
427 | `idle' |
---|
428 | Number of clock ticks the system spent in the idle task. |
---|
429 | |
---|
430 | `frequency' |
---|
431 | Tick frequency (default is 100). |
---|
432 | |
---|
433 | The `xcpu_' values are for SMP systems - they are the same than |
---|
434 | `total', `user', `nice', `sys' and `idle' except that they are arrays |
---|
435 | of `GLIBTOP_NCPU' (defined in `<glibtop/limits.h>') elements and |
---|
436 | contain one value for each CPU in the system. |
---|
437 | |
---|
438 | `xcpu_flags' |
---|
439 | This is interpreted as a bit-field: on systems like Solaris, not |
---|
440 | all CPUs need to be running all the time, so we set the |
---|
441 | corresponding bit for each CPU that is currently running. |
---|
442 | |
---|
443 | Please note that all of the cpu values are absolute values measured |
---|
444 | in certain units (to get seconds, divide them by `frequency') since |
---|
445 | system boot. To get percentual values, you need to call `glibtop_cpu', |
---|
446 | save the result, wait some time and then call it again and divide the |
---|
447 | differences of the two values by the time you have waited. |
---|
448 | |
---|
449 | |
---|
450 | File: libgtop2.info, Node: glibtop_mem, Next: glibtop_swap, Prev: glibtop_cpu, Up: System Dependent |
---|
451 | |
---|
452 | Memory Usage |
---|
453 | ------------ |
---|
454 | |
---|
455 | Library function `glibtop_get_mem': |
---|
456 | |
---|
457 | void glibtop_get_mem (glibtop_mem *buf); |
---|
458 | void glibtop_get_mem_l (glibtop *server, glibtop_mem *buf); |
---|
459 | |
---|
460 | Declaration of `glibtop_mem' in `<glibtop/mem.h>': |
---|
461 | |
---|
462 | typedef struct _glibtop_mem glibtop_mem; |
---|
463 | |
---|
464 | struct _glibtop_mem |
---|
465 | { |
---|
466 | u_int64_t flags, |
---|
467 | total, |
---|
468 | used, |
---|
469 | free, |
---|
470 | shared, |
---|
471 | buffer, |
---|
472 | cached, |
---|
473 | user, |
---|
474 | locked; |
---|
475 | }; |
---|
476 | |
---|
477 | Unless explicitly stated otherwise, all memory units are in bytes. |
---|
478 | |
---|
479 | `total' |
---|
480 | Total physical memory. |
---|
481 | |
---|
482 | `used' |
---|
483 | Used memory size. |
---|
484 | |
---|
485 | `free' |
---|
486 | Free memory size. |
---|
487 | |
---|
488 | `shared' |
---|
489 | Shared memory size. |
---|
490 | |
---|
491 | This are both segments that are `mmap()'ed with `MAP_SHARED' and |
---|
492 | IPC Shared Memory segments. |
---|
493 | |
---|
494 | `buffer' |
---|
495 | Size of buffers. |
---|
496 | |
---|
497 | `cached' |
---|
498 | Size of cached memory. |
---|
499 | |
---|
500 | `user' |
---|
501 | Memory used from user processes. |
---|
502 | |
---|
503 | This is normally `total - free - shared - buffer - cached'. |
---|
504 | |
---|
505 | `locked' |
---|
506 | Memory in locked segments. |
---|
507 | |
---|
508 | |
---|
509 | File: libgtop2.info, Node: glibtop_swap, Next: glibtop_uptime, Prev: glibtop_mem, Up: System Dependent |
---|
510 | |
---|
511 | Swap Usage |
---|
512 | ---------- |
---|
513 | |
---|
514 | Library function `glibtop_get_swap': |
---|
515 | |
---|
516 | void glibtop_get_swap (glibtop_swap *buf); |
---|
517 | void glibtop_get_swap_l (glibtop *server, glibtop_swap *buf); |
---|
518 | |
---|
519 | Declaration of `glibtop_swap' in `<glibtop/swap.h>': |
---|
520 | |
---|
521 | typedef struct _glibtop_swap glibtop_swap; |
---|
522 | |
---|
523 | struct _glibtop_swap |
---|
524 | { |
---|
525 | u_int64_t flags, |
---|
526 | total, |
---|
527 | used, |
---|
528 | free, |
---|
529 | pagein, |
---|
530 | pageout; |
---|
531 | }; |
---|
532 | |
---|
533 | The following units are in bytes. |
---|
534 | |
---|
535 | `total' |
---|
536 | Total swap space in the system. |
---|
537 | |
---|
538 | `used' |
---|
539 | Used swap space. |
---|
540 | |
---|
541 | `free' |
---|
542 | Free swap space. |
---|
543 | |
---|
544 | You can use `pagein' and `pageout' to get some measure about how |
---|
545 | much the system is swapping at the moment. They're increased each time |
---|
546 | a page is swapped in or out, so you need to save this values, wait a |
---|
547 | little bit, get them again and then compare the two results to find out |
---|
548 | how much the system swapped in the meantime. |
---|
549 | |
---|
550 | `pagein' |
---|
551 | Total number of swap pages that have been brought in since system |
---|
552 | boot |
---|
553 | |
---|
554 | `pageout' |
---|
555 | Total number of swap pages that have been brought out since system |
---|
556 | boot |
---|
557 | |
---|
558 | |
---|
559 | File: libgtop2.info, Node: glibtop_uptime, Next: glibtop_loadavg, Prev: glibtop_swap, Up: System Dependent |
---|
560 | |
---|
561 | Uptime |
---|
562 | ------ |
---|
563 | |
---|
564 | Library function `glibtop_get_uptime': |
---|
565 | |
---|
566 | void glibtop_get_uptime (glibtop_uptime *buf); |
---|
567 | void glibtop_get_uptime_l (glibtop *server, glibtop_uptime *buf); |
---|
568 | |
---|
569 | Declaration of `glibtop_uptime' in `<glibtop/uptime.h>': |
---|
570 | |
---|
571 | typedef struct _glibtop_uptime glibtop_uptime; |
---|
572 | |
---|
573 | struct _glibtop_uptime |
---|
574 | { |
---|
575 | u_int64_t flags; |
---|
576 | double uptime, |
---|
577 | idletime; |
---|
578 | u_int64_t boot_time; |
---|
579 | }; |
---|
580 | |
---|
581 | When porting LibGTop to a new system, you only need to implement |
---|
582 | `uptime' and `idletime' if there's a faster or better way to obtain |
---|
583 | them as using `glibtop_cpu' for it. Look at `sysdeps/freebsd/uptime.c' |
---|
584 | for an example on how to obtain them using `glibtop_cpu'. |
---|
585 | |
---|
586 | `uptime' |
---|
587 | Time in seconds since system boot. |
---|
588 | |
---|
589 | `idletime' |
---|
590 | Time in seconds the system spent in the idle task since system |
---|
591 | boot. |
---|
592 | |
---|
593 | The following one was from a request on the `linux-kernel' mailing |
---|
594 | list; on a laptop with advanced power management `glibtop_cpu.total' |
---|
595 | may not reflect the correct boot time of the system if the power was |
---|
596 | turned off by means of APM in the meantime. |
---|
597 | |
---|
598 | `boot_time' |
---|
599 | Time of last system boot in seconds since the epoch. |
---|
600 | |
---|
601 | |
---|
602 | File: libgtop2.info, Node: glibtop_loadavg, Next: glibtop_proclist, Prev: glibtop_uptime, Up: System Dependent |
---|
603 | |
---|
604 | Load Average |
---|
605 | ------------ |
---|
606 | |
---|
607 | Library function `glibtop_get_loadavg': |
---|
608 | |
---|
609 | void glibtop_get_loadavg (glibtop_loadavg *buf); |
---|
610 | void glibtop_get_loadavg_l (glibtop *server, glibtop_loadavg *buf); |
---|
611 | |
---|
612 | Declaration of `glibtop_loadavg' in `<glibtop/loadavg.h>': |
---|
613 | |
---|
614 | typedef struct _glibtop_loadavg glibtop_loadavg; |
---|
615 | |
---|
616 | struct _glibtop_loadavg |
---|
617 | { |
---|
618 | u_int64_t flags; |
---|
619 | double loadavg [3]; |
---|
620 | u_int64_t nr_running, |
---|
621 | nr_tasks, |
---|
622 | last_pid; |
---|
623 | }; |
---|
624 | |
---|
625 | `loadavg' |
---|
626 | Number of jobs running simultaneously averaged over 1, 5 and 15 |
---|
627 | minutes. |
---|
628 | |
---|
629 | The following fields are Linux specific and deprecated. You don't |
---|
630 | need to implement them when porting LibGTop to a new system as they may |
---|
631 | be removed in a future version. |
---|
632 | |
---|
633 | `nr_running' |
---|
634 | Number of tasks currently running. |
---|
635 | |
---|
636 | `nr_tasks' |
---|
637 | Total number of tasks. |
---|
638 | |
---|
639 | `last_pid' |
---|
640 | Last PID. |
---|
641 | |
---|
642 | |
---|
643 | File: libgtop2.info, Node: glibtop_proclist, Next: glibtop_proc_state, Prev: glibtop_loadavg, Up: System Dependent |
---|
644 | |
---|
645 | Process List |
---|
646 | ------------ |
---|
647 | |
---|
648 | Library function `glibtop_get_proclist': |
---|
649 | |
---|
650 | unsigned * |
---|
651 | glibtop_get_proclist (glibtop_proclist *buf, |
---|
652 | int64_t which, int64_t arg); |
---|
653 | |
---|
654 | unsigned * |
---|
655 | glibtop_get_proclist_l (glibtop *server, glibtop_proclist *buf, |
---|
656 | int64_t which, int64_t arg); |
---|
657 | |
---|
658 | Constants for the `which' argument: |
---|
659 | |
---|
660 | #define GLIBTOP_KERN_PROC_ALL 0 |
---|
661 | #define GLIBTOP_KERN_PROC_PID 1 |
---|
662 | #define GLIBTOP_KERN_PROC_PGRP 2 |
---|
663 | #define GLIBTOP_KERN_PROC_SESSION 3 |
---|
664 | #define GLIBTOP_KERN_PROC_TTY 4 |
---|
665 | #define GLIBTOP_KERN_PROC_UID 5 |
---|
666 | #define GLIBTOP_KERN_PROC_RUID 6 |
---|
667 | |
---|
668 | #define GLIBTOP_KERN_PROC_MASK 15 |
---|
669 | |
---|
670 | #define GLIBTOP_EXCLUDE_IDLE 0x1000 |
---|
671 | #define GLIBTOP_EXCLUDE_SYSTEM 0x2000 |
---|
672 | #define GLIBTOP_EXCLUDE_NOTTY 0x4000 |
---|
673 | |
---|
674 | Declaration of `glibtop_proclist' in `<glibtop/proclist.h>': |
---|
675 | |
---|
676 | typedef struct _glibtop_proclist glibtop_proclist; |
---|
677 | |
---|
678 | struct _glibtop_proclist |
---|
679 | { |
---|
680 | u_int64_t flags, |
---|
681 | number, |
---|
682 | total, |
---|
683 | size; |
---|
684 | }; |
---|
685 | |
---|
686 | This function returns a list of all or a selected subset of all |
---|
687 | running processes. You can use the `which' and `arg' arguments to |
---|
688 | specify which processes should be returned. |
---|
689 | |
---|
690 | You can use the following values for the `which' argument: |
---|
691 | |
---|
692 | `GLIBTOP_KERN_PROC_ALL' |
---|
693 | Return information about all processes (the `arg' argument is |
---|
694 | ignored). |
---|
695 | |
---|
696 | `GLIBTOP_KERN_PROC_PID' |
---|
697 | Return information about all process with the pid PID which is |
---|
698 | passed in `arg'. You can use this to find out whether some process |
---|
699 | still exists. |
---|
700 | |
---|
701 | `GLIBTOP_KERN_PROC_PGRP' |
---|
702 | Return all processes in process group PGRP which is passed in |
---|
703 | `arg'. |
---|
704 | |
---|
705 | `GLIBTOP_KERN_PROC_SESSION' |
---|
706 | Return all processes in session SESSION which is passed in `arg'. |
---|
707 | |
---|
708 | `GLIBTOP_KERN_PROC_TTY' |
---|
709 | Return all processes which have the controlling tty TTY which is |
---|
710 | passed in `arg' (TTY is interpreted as device number). |
---|
711 | |
---|
712 | `GLIBTOP_KERN_PROC_UID' |
---|
713 | Return all processes with effective uid UID which is passed in |
---|
714 | `arg'. |
---|
715 | |
---|
716 | `GLIBTOP_KERN_PROC_RUID' |
---|
717 | Return all processes with real uid RUID which is passed in `arg'. |
---|
718 | |
---|
719 | You can alter the list of returned processes by using a binary OR of |
---|
720 | `which' and the following constants: |
---|
721 | |
---|
722 | `GLIBTOP_EXCLUDE_IDLE' |
---|
723 | Exclude idle processes. |
---|
724 | |
---|
725 | `GLIBTOP_EXCLUDE_SYSTEM' |
---|
726 | Exclude system processes. |
---|
727 | |
---|
728 | `GLIBTOP_EXCLUDE_NOTTY' |
---|
729 | Exclude processes without a controlling terminal. |
---|
730 | |
---|
731 | The return value of `glibtop_get_proclist' is either `NULL' on error |
---|
732 | or a `unsigned *' list of pids. Additionally, the following fields of |
---|
733 | `glibtop_proclist' are set: |
---|
734 | |
---|
735 | `number' |
---|
736 | Number of entries in the returned list. |
---|
737 | |
---|
738 | `total' |
---|
739 | Total size of the returned list (this equals `number * size'). |
---|
740 | |
---|
741 | `size' |
---|
742 | Size of a single entry in the returned list (this equals `sizeof |
---|
743 | (unsigned)'). |
---|
744 | |
---|
745 | The returned list is allocated using `glibtop_malloc' and must be |
---|
746 | freed using `glibtop_free' to avoid a memory leak. |
---|
747 | |
---|
748 | |
---|
749 | File: libgtop2.info, Node: glibtop_proc_state, Next: glibtop_proc_uid, Prev: glibtop_proclist, Up: System Dependent |
---|
750 | |
---|
751 | Process State |
---|
752 | ------------- |
---|
753 | |
---|
754 | Library function `glibtop_get_proc_state': |
---|
755 | |
---|
756 | void |
---|
757 | glibtop_get_proc_state (glibtop_proc_state *buf, pid_t pid); |
---|
758 | |
---|
759 | void |
---|
760 | glibtop_get_proc_state_l (glibtop *server, glibtop_proc_state *buf, |
---|
761 | pid_t pid); |
---|
762 | |
---|
763 | Declaration of `glibtop_proc_state' in `<glibtop/proc_state.h>': |
---|
764 | |
---|
765 | typedef struct _glibtop_proc_state glibtop_proc_state; |
---|
766 | |
---|
767 | struct _glibtop_proc_state |
---|
768 | { |
---|
769 | u_int64_t flags; |
---|
770 | char cmd[40]; |
---|
771 | unsigned state; |
---|
772 | int uid, |
---|
773 | gid, |
---|
774 | ruid, |
---|
775 | rgid; |
---|
776 | int has_cpu, |
---|
777 | processor, |
---|
778 | last_processor; |
---|
779 | |
---|
780 | }; |
---|
781 | |
---|
782 | `cmd' |
---|
783 | Basename of the executable file in the call to `exec'. |
---|
784 | |
---|
785 | `state' |
---|
786 | Process state (see the constants defined below). |
---|
787 | |
---|
788 | When porting LibGTop, please _try hard_ to implement the following |
---|
789 | fields. For security reasons, it is *very important* that you *only* |
---|
790 | set the `flags' bits for those fields if their *values are correct*. |
---|
791 | |
---|
792 | `uid' |
---|
793 | Effective UID of the process. |
---|
794 | |
---|
795 | `gid' |
---|
796 | Effective GID of the process. |
---|
797 | |
---|
798 | `ruid' |
---|
799 | Real UID of the process. |
---|
800 | |
---|
801 | `rgid' |
---|
802 | Read GID of the process. |
---|
803 | |
---|
804 | The following fields are for SMP systems: |
---|
805 | |
---|
806 | `has_cpu' |
---|
807 | This is either 0 or 1 depending on whether the process currently |
---|
808 | has a CPU or not. |
---|
809 | |
---|
810 | `processor' |
---|
811 | This is the processor id of the CPU this process is currently |
---|
812 | running on (which can be used as index in the `xcpu_' fields of |
---|
813 | `glibtop_cpu' for instance; since zero is a valid processor id, |
---|
814 | you must check `has_cpu' in this case to find out whether the |
---|
815 | process really has a CPU). |
---|
816 | |
---|
817 | `last_processor' |
---|
818 | The is the processor id of the CPU the process was last running on. |
---|
819 | |
---|
820 | There are some constants for the `state' field: |
---|
821 | |
---|
822 | #define GLIBTOP_PROCESS_RUNNING 1 |
---|
823 | #define GLIBTOP_PROCESS_INTERRUPTIBLE 2 |
---|
824 | #define GLIBTOP_PROCESS_UNINTERRUPTIBLE 4 |
---|
825 | #define GLIBTOP_PROCESS_ZOMBIE 8 |
---|
826 | #define GLIBTOP_PROCESS_STOPPED 16 |
---|
827 | #define GLIBTOP_PROCESS_SWAPPING 32 |
---|
828 | |
---|
829 | `GLIBTOP_PROCESS_RUNNING' |
---|
830 | The process is currently running. |
---|
831 | |
---|
832 | `GLIBTOP_PROCESS_INTERRUPTIBLE' |
---|
833 | The process is currently in an interruptible sleep. |
---|
834 | |
---|
835 | `GLIBTOP_PROCESS_UNINTERRUPTIBLE' |
---|
836 | The process is currently in uninterruptible sleep (the so-called |
---|
837 | "disk sleep"). |
---|
838 | |
---|
839 | `GLIBTOP_PROCESS_ZOMBIE' |
---|
840 | The process is a zombie. |
---|
841 | |
---|
842 | `GLIBTOP_PROCESS_STOPPED' |
---|
843 | The process is currently stopped (received `SIGSTOP' or attached |
---|
844 | to a debugger). |
---|
845 | |
---|
846 | `GLIBTOP_PROCESS_SWAPPING' |
---|
847 | The process is currently swapping. |
---|
848 | |
---|
849 | |
---|
850 | File: libgtop2.info, Node: glibtop_proc_uid, Next: glibtop_proc_mem, Prev: glibtop_proc_state, Up: System Dependent |
---|
851 | |
---|
852 | Process UID and TTY information |
---|
853 | ------------------------------- |
---|
854 | |
---|
855 | Library function `glibtop_get_proc_uid': |
---|
856 | |
---|
857 | void |
---|
858 | glibtop_get_proc_uid (glibtop_proc_uid *buf, pid_t pid); |
---|
859 | |
---|
860 | void |
---|
861 | glibtop_get_proc_uid_l (glibtop *server, glibtop_proc_uid *buf, |
---|
862 | pid_t pid); |
---|
863 | |
---|
864 | Declaration of `glibtop_proc_uid' in `<glibtop/procuid.h>': |
---|
865 | |
---|
866 | typedef struct _glibtop_proc_uid glibtop_proc_uid; |
---|
867 | |
---|
868 | struct _glibtop_proc_uid |
---|
869 | { |
---|
870 | u_int64_t flags; |
---|
871 | int uid, |
---|
872 | euid, |
---|
873 | gid, |
---|
874 | egid, |
---|
875 | suid, |
---|
876 | sgid, |
---|
877 | fsuid, |
---|
878 | fsgid, |
---|
879 | pid, |
---|
880 | ppid, |
---|
881 | pgrp, |
---|
882 | session, |
---|
883 | tty, |
---|
884 | tpgid, |
---|
885 | priority, |
---|
886 | nice, |
---|
887 | ngroups, |
---|
888 | groups [GLIBTOP_MAX_GROUPS]; |
---|
889 | }; |
---|
890 | |
---|
891 | `uid' |
---|
892 | User ID |
---|
893 | |
---|
894 | `euid' |
---|
895 | Effective User ID |
---|
896 | |
---|
897 | `gid' |
---|
898 | Group ID |
---|
899 | |
---|
900 | `egid' |
---|
901 | Effective Group ID |
---|
902 | |
---|
903 | `pid' |
---|
904 | Process ID |
---|
905 | |
---|
906 | `ppid' |
---|
907 | PID of parent process |
---|
908 | |
---|
909 | `pgrp' |
---|
910 | Process group ID |
---|
911 | |
---|
912 | `session' |
---|
913 | Session ID |
---|
914 | |
---|
915 | `tty' |
---|
916 | Full device number of controlling terminal |
---|
917 | |
---|
918 | `tpgid' |
---|
919 | Terminal process group ID |
---|
920 | |
---|
921 | `priority' |
---|
922 | Kernel scheduling priority. |
---|
923 | |
---|
924 | `nice' |
---|
925 | Standard unix nice level of process. |
---|
926 | |
---|
927 | `ngroups' |
---|
928 | Number of additional process groups. |
---|
929 | |
---|
930 | `groups' |
---|
931 | Array of additional process groups |
---|
932 | (`GLIBTOP_MAX_GROUPS' is defined in `<glibtop/limits.h>'). |
---|
933 | |
---|
934 | |
---|
935 | File: libgtop2.info, Node: glibtop_proc_mem, Next: glibtop_proc_time, Prev: glibtop_proc_uid, Up: System Dependent |
---|
936 | |
---|
937 | Process Memory information |
---|
938 | -------------------------- |
---|
939 | |
---|
940 | Library function `glibtop_get_proc_mem': |
---|
941 | |
---|
942 | void |
---|
943 | glibtop_get_proc_mem (glibtop_proc_mem *buf, pid_t pid); |
---|
944 | |
---|
945 | void |
---|
946 | glibtop_get_proc_mem_l (glibtop *server, glibtop_proc_mem *buf, |
---|
947 | pid_t pid); |
---|
948 | |
---|
949 | Declaration of `glibtop_proc_mem' in `<glibtop/procmem.h>': |
---|
950 | |
---|
951 | typedef struct _glibtop_proc_mem glibtop_proc_mem; |
---|
952 | |
---|
953 | struct _glibtop_proc_mem |
---|
954 | { |
---|
955 | u_int64_t flags, |
---|
956 | size, |
---|
957 | vsize, |
---|
958 | resident, |
---|
959 | share, |
---|
960 | rss, |
---|
961 | rss_rlim; |
---|
962 | }; |
---|
963 | |
---|
964 | `size' |
---|
965 | Total number of pages of memory. |
---|
966 | |
---|
967 | `vsize' |
---|
968 | Number of pages of virtual memory. |
---|
969 | |
---|
970 | `resident' |
---|
971 | Number of residnet set (non-swapped) pages. |
---|
972 | |
---|
973 | `share' |
---|
974 | Number of pages of shared (mmap'd) memory. |
---|
975 | |
---|
976 | `rss' |
---|
977 | Number of pages the process has in real memory, minus 3 for |
---|
978 | administrative purposes. |
---|
979 | |
---|
980 | This is just the pages which count towards text, data, or stack |
---|
981 | space. This does not include pages which have not been |
---|
982 | demand-loaded in, or which are swapped out. |
---|
983 | |
---|
984 | `rss_rlim' |
---|
985 | Current limit in bytes on the rss of the process (usually |
---|
986 | 2,147,483,647). |
---|
987 | |
---|
988 | The description above is taken from the manual page of the `/proc' |
---|
989 | filesystem under Linux and is a little bit confusing, so I make this |
---|
990 | clear here. |
---|
991 | |
---|
992 | *Note for people porting LibGTop to other systems:* Every operating |
---|
993 | system has its own idea about the memory usage of a process and also |
---|
994 | system utilities like `ps' show different things on different systems. |
---|
995 | |
---|
996 | Nevertheless, we should try to make LibGTop as system independent as |
---|
997 | possible, so I give you some hints here how `glibtop_get_proc_mem' |
---|
998 | should work. |
---|
999 | |
---|
1000 | * When you use `mmap' with either `MAP_SHARED' or `MAP_PRIVATE', |
---|
1001 | this should only affect the `vsize' of the process and none of its |
---|
1002 | `size', `resident', `shared' and `rss' sizes. |
---|
1003 | |
---|
1004 | * As soon as you read some of the `mmap()'ed pages, they will be |
---|
1005 | demand- oaded and thus count towards the `size' of the process. |
---|
1006 | |
---|
1007 | Also - we assume there is enough free memory - they are resident |
---|
1008 | in memory until they get stolen or swapped out and thus increase |
---|
1009 | the `resident' and `rss' sizes of the process. |
---|
1010 | |
---|
1011 | * If the process has used `MAP_SHARED' and another process attaches |
---|
1012 | the same file also `MAP_SHARED', some of the pages are shared with |
---|
1013 | this process and thus increase the `shared' sizes of both |
---|
1014 | processes. |
---|
1015 | |
---|
1016 | * If the process has used `MAP_PRIVATE' and writes to the `mmap()'ed |
---|
1017 | pages, the only difference to reading from them is that they get |
---|
1018 | dirty and cannot be stolen any longer but will get swapped out. |
---|
1019 | |
---|
1020 | * When memory gets rare, clean pages are normally stolen, which |
---|
1021 | decreases the `size', `resident', `shared' and `rss' sizes of the |
---|
1022 | process. |
---|
1023 | |
---|
1024 | * When dirty pages are swapped out, this will not decrease the |
---|
1025 | `size' of the process but only its `resident' and `rss' sizes |
---|
1026 | (dirty pages cannot be shared). |
---|
1027 | |
---|
1028 | * The `vsize' of a process can _only_ be changed by the process |
---|
1029 | itself when it requests or frees memory but _never_ due to swapping |
---|
1030 | activity of the system. |
---|
1031 | |
---|
1032 | * If the `shared' size changes, this _only_ means that the number of |
---|
1033 | pages that are currently shared with other processes has changed; |
---|
1034 | if this happens, this will _never_ affect any of the other sizes |
---|
1035 | of the process. |
---|
1036 | |
---|
1037 | The hints above describe how it works under Linux - but we should |
---|
1038 | try to make `glibtop_get_proc_mem' show the same behavior under every |
---|
1039 | other system. |
---|
1040 | |
---|
1041 | |
---|
1042 | File: libgtop2.info, Node: glibtop_proc_time, Next: glibtop_proc_signal, Prev: glibtop_proc_mem, Up: System Dependent |
---|
1043 | |
---|
1044 | Process Time information |
---|
1045 | ------------------------ |
---|
1046 | |
---|
1047 | Library function `glibtop_get_proc_time': |
---|
1048 | |
---|
1049 | void |
---|
1050 | glibtop_get_proc_time (glibtop_proc_time *buf, pid_t pid); |
---|
1051 | |
---|
1052 | void |
---|
1053 | glibtop_get_proc_time_l (glibtop *server, glibtop_proc_time *buf, |
---|
1054 | pid_t pid); |
---|
1055 | |
---|
1056 | Declaration of `glibtop_proc_time' in `<glibtop/proctime.h>': |
---|
1057 | |
---|
1058 | typedef struct _glibtop_proc_time glibtop_proc_time; |
---|
1059 | |
---|
1060 | struct _glibtop_proc_time |
---|
1061 | { |
---|
1062 | u_int64_t flags, |
---|
1063 | start_time, |
---|
1064 | rtime, |
---|
1065 | utime, |
---|
1066 | stime, |
---|
1067 | cutime, |
---|
1068 | cstime, |
---|
1069 | timeout, |
---|
1070 | it_real_value, |
---|
1071 | frequency, |
---|
1072 | xcpu_utime [GLIBTOP_NCPU], |
---|
1073 | xcpu_stime [GLIBTOP_NCPU], |
---|
1074 | xcpu_flags; |
---|
1075 | }; |
---|
1076 | |
---|
1077 | `start_time' |
---|
1078 | Start time of process in seconds since the epoch |
---|
1079 | |
---|
1080 | `rtime' |
---|
1081 | Real time accumulated by process (should be `utime' + `stime') |
---|
1082 | |
---|
1083 | `utime' |
---|
1084 | User-mode CPU time accumulated by process |
---|
1085 | |
---|
1086 | `stime' |
---|
1087 | Kernel-mode CPU time accumulated by process |
---|
1088 | |
---|
1089 | `cutime' |
---|
1090 | Cumulative utime of process and reaped children |
---|
1091 | |
---|
1092 | `cstime' |
---|
1093 | Cumulative stime of process and reaped children |
---|
1094 | |
---|
1095 | `timeout' |
---|
1096 | The time (in jiffies) of the process's next timeout |
---|
1097 | |
---|
1098 | `it_real_value' |
---|
1099 | The time (in jiffies) before the next SIGALRM is sent to the |
---|
1100 | process due to an interval timer. |
---|
1101 | |
---|
1102 | `frequency' |
---|
1103 | Tick frequency |
---|
1104 | |
---|
1105 | `xcpu_utime' |
---|
1106 | SMP user-mode CPU time accumulated by process |
---|
1107 | |
---|
1108 | `xcpu_stime' |
---|
1109 | SMP kernel-mode CPU time accumulated by process |
---|
1110 | |
---|
1111 | |
---|
1112 | File: libgtop2.info, Node: glibtop_proc_signal, Next: glibtop_proc_kernel, Prev: glibtop_proc_time, Up: System Dependent |
---|
1113 | |
---|
1114 | Process Signal information |
---|
1115 | -------------------------- |
---|
1116 | |
---|
1117 | Library function `glibtop_get_proc_signal': |
---|
1118 | |
---|
1119 | void |
---|
1120 | glibtop_get_proc_signal (glibtop_proc_signal *buf, pid_t pid); |
---|
1121 | |
---|
1122 | void |
---|
1123 | glibtop_get_proc_signal_l (glibtop *server, glibtop_proc_signal *buf, |
---|
1124 | pid_t pid); |
---|
1125 | |
---|
1126 | Declaration of `glibtop_proc_signal' in `<glibtop/procsignal.h>': |
---|
1127 | |
---|
1128 | typedef struct _glibtop_proc_signal glibtop_proc_signal; |
---|
1129 | |
---|
1130 | struct _glibtop_proc_signal |
---|
1131 | { |
---|
1132 | u_int64_t flags, |
---|
1133 | signal [2], |
---|
1134 | blocked [2], |
---|
1135 | sigignore [2], |
---|
1136 | sigcatch [2]; |
---|
1137 | }; |
---|
1138 | |
---|
1139 | `signal' |
---|
1140 | Mask of pending signals |
---|
1141 | |
---|
1142 | `blocked' |
---|
1143 | Mask of blocked signals |
---|
1144 | |
---|
1145 | `sigignore' |
---|
1146 | Mask of ignored signals |
---|
1147 | |
---|
1148 | `sigcatch' |
---|
1149 | Mask of caught signals |
---|
1150 | |
---|
1151 | All signal masks are interpreted as bit mask; it is an array of two |
---|
1152 | `u_int64_t''s so we can save 128 signals there. |
---|
1153 | |
---|
1154 | |
---|
1155 | File: libgtop2.info, Node: glibtop_proc_kernel, Next: glibtop_proc_segment, Prev: glibtop_proc_signal, Up: System Dependent |
---|
1156 | |
---|
1157 | Process Kernel Data information |
---|
1158 | ------------------------------- |
---|
1159 | |
---|
1160 | Library function `glibtop_get_proc_kernel': |
---|
1161 | |
---|
1162 | void |
---|
1163 | glibtop_get_proc_kernel (glibtop_proc_kernel *buf, pid_t pid); |
---|
1164 | |
---|
1165 | void |
---|
1166 | glibtop_get_proc_kernel_l (glibtop *server, glibtop_proc_kernel *buf, |
---|
1167 | pid_t pid); |
---|
1168 | |
---|
1169 | Declaration of `glibtop_proc_kernel' in `<glibtop/prockernel.h>': |
---|
1170 | |
---|
1171 | typedef struct _glibtop_proc_kernel glibtop_proc_kernel; |
---|
1172 | |
---|
1173 | struct _glibtop_proc_kernel |
---|
1174 | { |
---|
1175 | u_int64_t flags; |
---|
1176 | u_int64_t k_flags, |
---|
1177 | min_flt, |
---|
1178 | maj_flt, |
---|
1179 | cmin_flt, |
---|
1180 | cmaj_flt, |
---|
1181 | kstk_esp, |
---|
1182 | kstk_eip, |
---|
1183 | nwchan; |
---|
1184 | char wchan [40]; |
---|
1185 | }; |
---|
1186 | |
---|
1187 | `k_flags' |
---|
1188 | Kernel flags of the process. See the constants defined below. |
---|
1189 | |
---|
1190 | `min_flt' |
---|
1191 | The number of minor faults the process has made, those which have |
---|
1192 | not required loading a memory page from disk. |
---|
1193 | |
---|
1194 | `maj_flt' |
---|
1195 | The number of major faults the process has made, those which have |
---|
1196 | required loading a memory page from disk. |
---|
1197 | |
---|
1198 | `cmin_flt' |
---|
1199 | The number of minor faults that the process and its children have |
---|
1200 | made. |
---|
1201 | |
---|
1202 | `cmaj_flt' |
---|
1203 | The number of major faults that the process and its children have |
---|
1204 | made. |
---|
1205 | |
---|
1206 | `kstk_esp' |
---|
1207 | The current value of `esp' (32-bit stack pointer), as found in the |
---|
1208 | kernel stack page for the process. |
---|
1209 | |
---|
1210 | `kstk_eip' |
---|
1211 | The current `eip' (32-bit instruction pointer). |
---|
1212 | |
---|
1213 | `nwchan' |
---|
1214 | This is the "channel" in which the process is waiting. This is the |
---|
1215 | address of a system call, and can be looked up in a namelist if |
---|
1216 | you need a textual name. (If you have an up-to-date |
---|
1217 | `/etc/psdatabase', then try `ps -l' to see the WCHAN field in |
---|
1218 | action). |
---|
1219 | |
---|
1220 | `wchan' |
---|
1221 | This is the textual name of the `nwchan' field. |
---|
1222 | |
---|
1223 | There are some constants for the `k_flags' field: |
---|
1224 | |
---|
1225 | #define GLIBTOP_KFLAGS_STARTING 1 |
---|
1226 | #define GLIBTOP_KFLAGS_EXITING 2 |
---|
1227 | #define GLIBTOP_KFLAGS_PTRACED 4 |
---|
1228 | #define GLIBTOP_KFLAGS_TRACESYS 8 |
---|
1229 | #define GLIBTOP_KFLAGS_FORKNOEXEC 16 |
---|
1230 | #define GLIBTOP_KFLAGS_SUPERPRIV 32 |
---|
1231 | #define GLIBTOP_KFLAGS_DUMPEDCORE 64 |
---|
1232 | #define GLIBTOP_KFLAGS_SIGNALED 128 |
---|
1233 | |
---|
1234 | `GLIBTOP_KFLAGS_STARTING' |
---|
1235 | Process is being created. |
---|
1236 | |
---|
1237 | `GLIBTOP_KFLAGS_EXITING' |
---|
1238 | Process is exiting. |
---|
1239 | |
---|
1240 | `GLIBTOP_KFLAGS_PTRACED' |
---|
1241 | Process is being traced (via `ptrace ()'). |
---|
1242 | |
---|
1243 | `GLIBTOP_KFLAGS_TRACESYS' |
---|
1244 | Process is tracing system calls. |
---|
1245 | |
---|
1246 | `GLIBTOP_KFLAGS_FORKNOEXEC' |
---|
1247 | Process `fork()'ed, but didn't `exec()' yet. |
---|
1248 | |
---|
1249 | `GLIBTOP_KFLAGS_SUPERPRIV' |
---|
1250 | Process used super-user privileges. |
---|
1251 | |
---|
1252 | `GLIBTOP_KFLAGS_DUMPEDCORE' |
---|
1253 | Process dumped core. |
---|
1254 | |
---|
1255 | `GLIBTOP_KFLAGS_SIGNALED' |
---|
1256 | Process was killed by a signal. |
---|
1257 | |
---|
1258 | |
---|
1259 | File: libgtop2.info, Node: glibtop_proc_segment, Next: glibtop_proc_args, Prev: glibtop_proc_kernel, Up: System Dependent |
---|
1260 | |
---|
1261 | Process Segment information |
---|
1262 | --------------------------- |
---|
1263 | |
---|
1264 | Library function `glibtop_get_proc_segment': |
---|
1265 | |
---|
1266 | void |
---|
1267 | glibtop_get_proc_segment (glibtop_proc_segment *buf, pid_t pid); |
---|
1268 | |
---|
1269 | void |
---|
1270 | glibtop_get_proc_segment_l (glibtop *server, glibtop_proc_segment *buf, |
---|
1271 | pid_t pid); |
---|
1272 | |
---|
1273 | Declaration of `glibtop_proc_segment' in `<glibtop/procsegment.h>': |
---|
1274 | |
---|
1275 | typedef struct _glibtop_proc_segment glibtop_proc_segment; |
---|
1276 | |
---|
1277 | struct _glibtop_proc_segment |
---|
1278 | { |
---|
1279 | u_int64_t flags, |
---|
1280 | text_rss, |
---|
1281 | shlib_rss, |
---|
1282 | data_rss, |
---|
1283 | stack_rss, |
---|
1284 | dirty_size, |
---|
1285 | start_code, |
---|
1286 | end_code, |
---|
1287 | start_data, |
---|
1288 | end_data, |
---|
1289 | start_brk, |
---|
1290 | end_brk, |
---|
1291 | start_stack, |
---|
1292 | start_mmap, |
---|
1293 | arg_start, |
---|
1294 | arg_end, |
---|
1295 | env_start, |
---|
1296 | env_end; |
---|
1297 | }; |
---|
1298 | |
---|
1299 | `text_rss' |
---|
1300 | Text resident set size |
---|
1301 | |
---|
1302 | `shlib_rss' |
---|
1303 | Shared-Lib resident set size |
---|
1304 | |
---|
1305 | `data_rss' |
---|
1306 | Data resident set size |
---|
1307 | |
---|
1308 | `stack_rss' |
---|
1309 | Stack resident set size |
---|
1310 | |
---|
1311 | `dirty_size' |
---|
1312 | Total size of dirty pages |
---|
1313 | |
---|
1314 | `start_code' |
---|
1315 | Address of beginning of code segment |
---|
1316 | |
---|
1317 | `end_code' |
---|
1318 | Address of end of code segment |
---|
1319 | |
---|
1320 | `start_stack' |
---|
1321 | Address of the bottom of stack segmen |
---|
1322 | |
---|
1323 | |
---|
1324 | File: libgtop2.info, Node: glibtop_proc_args, Next: glibtop_proc_map, Prev: glibtop_proc_segment, Up: System Dependent |
---|
1325 | |
---|
1326 | Process Arguments |
---|
1327 | ----------------- |
---|
1328 | |
---|
1329 | Library function `glibtop_get_proc_args': |
---|
1330 | |
---|
1331 | char * |
---|
1332 | glibtop_get_proc_args_l (glibtop_proc_args *buf, pid_t pid, |
---|
1333 | unsigned max_len); |
---|
1334 | |
---|
1335 | char * |
---|
1336 | glibtop_get_proc_args_l (glibtop *server, glibtop_proc_args *buf, |
---|
1337 | pid_t pid, unsigned max_len); |
---|
1338 | |
---|
1339 | Declaration of `glibtop_proc_args' in `<glibtop/procargs.h>': |
---|
1340 | |
---|
1341 | typedef struct _glibtop_proc_args glibtop_proc_args; |
---|
1342 | |
---|
1343 | struct _glibtop_proc_args |
---|
1344 | { |
---|
1345 | u_int64_t flags, |
---|
1346 | size; |
---|
1347 | }; |
---|
1348 | |
---|
1349 | Returns a string with all command line arguments of process `pid' |
---|
1350 | (up to `max_len' characters, use zero to get all arguments). |
---|
1351 | |
---|
1352 | The command line arguments in the returned string are separated by |
---|
1353 | zero bytes; the lenght of this string is returned in the `size' field. |
---|
1354 | |
---|
1355 | Remember to `glibtop_free' the returned string to avoid a memory |
---|
1356 | leak. |
---|
1357 | |
---|
1358 | |
---|
1359 | File: libgtop2.info, Node: glibtop_proc_map, Next: glibtop_netload, Prev: glibtop_proc_args, Up: System Dependent |
---|
1360 | |
---|
1361 | Process Memory Maps |
---|
1362 | ------------------- |
---|
1363 | |
---|
1364 | Library function `glibtop_get_proc_map': |
---|
1365 | |
---|
1366 | glibtop_map_entry * |
---|
1367 | glibtop_get_proc_map (glibtop_proc_map *buf, pid_t pid); |
---|
1368 | |
---|
1369 | glibtop_map_entry * |
---|
1370 | glibtop_get_proc_map_l (glibtop *server, glibtop_proc_map *buf, |
---|
1371 | pid_t pid); |
---|
1372 | |
---|
1373 | Declaration of `glibtop_proc_map' in `<glibtop/procmap.h>': |
---|
1374 | |
---|
1375 | typedef struct _glibtop_proc_map glibtop_proc_map; |
---|
1376 | |
---|
1377 | struct _glibtop_proc_map |
---|
1378 | { |
---|
1379 | u_int64_t flags, |
---|
1380 | number, |
---|
1381 | total, |
---|
1382 | size; |
---|
1383 | }; |
---|
1384 | |
---|
1385 | Returns a `glibtop_map_entry *' list (which needs to be freed with |
---|
1386 | `glibtop_free') of memory maps of process `pid'. |
---|
1387 | |
---|
1388 | `number' |
---|
1389 | Number of entries in the returned list. |
---|
1390 | |
---|
1391 | `total' |
---|
1392 | Total size of the returned list (this equals `number * size'). |
---|
1393 | |
---|
1394 | `size' |
---|
1395 | Size of a single entry in the returned list (this equals `sizeof |
---|
1396 | (glibtop_map_entry)'). |
---|
1397 | |
---|
1398 | typedef struct _glibtop_map_entry glibtop_map_entry; |
---|
1399 | |
---|
1400 | struct _glibtop_map_entry |
---|
1401 | { |
---|
1402 | u_int64_t flags, start, end, offset, perm, inode, device; |
---|
1403 | char filename [GLIBTOP_MAP_FILENAME_LEN+1]; |
---|
1404 | }; |
---|
1405 | |
---|
1406 | The `flags' member is a bit field and specifies which of the other |
---|
1407 | fields are valid: |
---|
1408 | |
---|
1409 | #define GLIBTOP_MAP_ENTRY_START 1 |
---|
1410 | #define GLIBTOP_MAP_ENTRY_END 2 |
---|
1411 | #define GLIBTOP_MAP_ENTRY_OFFSET 3 |
---|
1412 | #define GLIBTOP_MAP_ENTRY_PERM 4 |
---|
1413 | #define GLIBTOP_MAP_ENTRY_INODE 5 |
---|
1414 | #define GLIBTOP_MAP_ENTRY_DEVICE 6 |
---|
1415 | #define GLIBTOP_MAP_ENTRY_FILENAME 7 |
---|
1416 | |
---|
1417 | Constants for the `perm' member: |
---|
1418 | |
---|
1419 | #define GLIBTOP_MAP_PERM_READ 1 |
---|
1420 | #define GLIBTOP_MAP_PERM_WRITE 2 |
---|
1421 | #define GLIBTOP_MAP_PERM_EXECUTE 4 |
---|
1422 | #define GLIBTOP_MAP_PERM_SHARED 8 |
---|
1423 | #define GLIBTOP_MAP_PERM_PRIVATE 16 |
---|
1424 | |
---|
1425 | |
---|
1426 | File: libgtop2.info, Node: glibtop_netload, Next: glibtop_ppp, Prev: glibtop_proc_map, Up: System Dependent |
---|
1427 | |
---|
1428 | Network Load |
---|
1429 | ------------ |
---|
1430 | |
---|
1431 | Library function `glibtop_get_netload': |
---|
1432 | |
---|
1433 | void |
---|
1434 | glibtop_get_netload (glibtop_netload *buf, const char *interface); |
---|
1435 | |
---|
1436 | void |
---|
1437 | glibtop_get_netload_l (glibtop *server, glibtop_netload *buf, |
---|
1438 | const char *interface); |
---|
1439 | |
---|
1440 | Declaration of `glibtop_netload' in `<glibtop/netload.h>': |
---|
1441 | |
---|
1442 | typedef struct _glibtop_netload glibtop_netload; |
---|
1443 | |
---|
1444 | struct _glibtop_netload |
---|
1445 | { |
---|
1446 | u_int64_t flags, |
---|
1447 | if_flags, |
---|
1448 | mtu, |
---|
1449 | subnet, |
---|
1450 | address, |
---|
1451 | packets_in, |
---|
1452 | packets_out, |
---|
1453 | packets_total, |
---|
1454 | bytes_in, |
---|
1455 | bytes_out, |
---|
1456 | bytes_total, |
---|
1457 | errors_in, |
---|
1458 | errors_out, |
---|
1459 | errors_total, |
---|
1460 | collisions; |
---|
1461 | }; |
---|
1462 | |
---|
1463 | Returns network statistics for interface `interface' (which is the |
---|
1464 | same than in `ifconfig'). |
---|
1465 | |
---|
1466 | `if_flags' |
---|
1467 | Interface flags. See the contants defined below. |
---|
1468 | |
---|
1469 | `mtu' |
---|
1470 | Maximum Transfer Unit (MTU) |
---|
1471 | |
---|
1472 | `subnet' |
---|
1473 | Subnet Address |
---|
1474 | |
---|
1475 | `address' |
---|
1476 | Interface Address |
---|
1477 | |
---|
1478 | `packets_in' |
---|
1479 | Total number of incoming packets |
---|
1480 | |
---|
1481 | `packets_out' |
---|
1482 | Total number of outgoing packets |
---|
1483 | |
---|
1484 | `packets_total' |
---|
1485 | Total number of packets |
---|
1486 | |
---|
1487 | `bytes_in' |
---|
1488 | Total number of incoming bytes |
---|
1489 | |
---|
1490 | `bytes_out' |
---|
1491 | Total number of outgoing bytes |
---|
1492 | |
---|
1493 | `bytes_total' |
---|
1494 | Total number of bytes |
---|
1495 | |
---|
1496 | `errors_in' |
---|
1497 | Total number of errors in incoming direction |
---|
1498 | |
---|
1499 | `errors_out' |
---|
1500 | Total number of errors in outgoing direction |
---|
1501 | |
---|
1502 | `errors_total' |
---|
1503 | Total number of errors |
---|
1504 | |
---|
1505 | `collisions' |
---|
1506 | Total number of collisions |
---|
1507 | |
---|
1508 | Please note that not all operating systems distinguish between |
---|
1509 | incoming/outgoing bytes/packets/errors - in this case only the `_total' |
---|
1510 | fields are valid. Otherwise, they're just `_in' plus `_out'. |
---|
1511 | |
---|
1512 | Constants for `if_flags': |
---|
1513 | |
---|
1514 | enum { |
---|
1515 | GLIBTOP_IF_FLAGS_UP = 1, |
---|
1516 | GLIBTOP_IF_FLAGS_BROADCAST, |
---|
1517 | GLIBTOP_IF_FLAGS_DEBUG, |
---|
1518 | GLIBTOP_IF_FLAGS_LOOPBACK, |
---|
1519 | GLIBTOP_IF_FLAGS_POINTOPOINT, |
---|
1520 | GLIBTOP_IF_FLAGS_RUNNING, |
---|
1521 | GLIBTOP_IF_FLAGS_NOARP, |
---|
1522 | GLIBTOP_IF_FLAGS_PROMISC, |
---|
1523 | GLIBTOP_IF_FLAGS_ALLMULTI, |
---|
1524 | GLIBTOP_IF_FLAGS_OACTIVE, |
---|
1525 | GLIBTOP_IF_FLAGS_SIMPLEX, |
---|
1526 | GLIBTOP_IF_FLAGS_LINK0, |
---|
1527 | GLIBTOP_IF_FLAGS_LINK1, |
---|
1528 | GLIBTOP_IF_FLAGS_LINK2, |
---|
1529 | GLIBTOP_IF_FLAGS_ALTPHYS, |
---|
1530 | GLIBTOP_IF_FLAGS_MULTICAST |
---|
1531 | }; |
---|
1532 | |
---|
1533 | |
---|
1534 | File: libgtop2.info, Node: glibtop_ppp, Prev: glibtop_netload, Up: System Dependent |
---|
1535 | |
---|
1536 | PPP Statistics |
---|
1537 | -------------- |
---|
1538 | |
---|
1539 | Library function `glibtop_get_ppp': |
---|
1540 | |
---|
1541 | void |
---|
1542 | glibtop_get_ppp_l (glibtop *server, glibtop_ppp *buf, |
---|
1543 | unsigned short device); |
---|
1544 | |
---|
1545 | void |
---|
1546 | glibtop_get_ppp (glibtop_ppp *buf, unsigned short device); |
---|
1547 | |
---|
1548 | Declaration of `glibtop_ppp' in `<glibtop/ppp.h>': |
---|
1549 | |
---|
1550 | typedef struct _glibtop_ppp glibtop_ppp; |
---|
1551 | |
---|
1552 | struct _glibtop_ppp |
---|
1553 | { |
---|
1554 | u_int64_t flags, |
---|
1555 | state, |
---|
1556 | bytes_in, |
---|
1557 | bytes_out; |
---|
1558 | }; |
---|
1559 | |
---|
1560 | `bytes_in' |
---|
1561 | Number of input bytes |
---|
1562 | |
---|
1563 | `bytes_out' |
---|
1564 | Number of output bytes |
---|
1565 | |
---|
1566 | There are some constants for `state': |
---|
1567 | |
---|
1568 | enum { |
---|
1569 | GLIBTOP_PPP_STATE_UNKNOWN = 0, |
---|
1570 | GLIBTOP_PPP_STATE_HANGUP, |
---|
1571 | GLIBTOP_PPP_STATE_ONLINE |
---|
1572 | }; |
---|
1573 | |
---|
1574 | `GLIBTOP_PPP_STATE_UNKNOWN' |
---|
1575 | LibGTop was unable to determine the current ppp state. |
---|
1576 | |
---|
1577 | `GLIBTOP_PPP_STATE_HANGUP' |
---|
1578 | We're currently offline. |
---|
1579 | |
---|
1580 | `GLIBTOP_PPP_STATE_ONLINE' |
---|
1581 | We're currently online. |
---|
1582 | |
---|
1583 | |
---|
1584 | File: libgtop2.info, Node: Common Functions, Next: Library Functions, Prev: System Dependent, Up: Reference Manual |
---|
1585 | |
---|
1586 | Common Functions |
---|
1587 | ================ |
---|
1588 | |
---|
1589 | This are functions which a common implementation for all systems; we |
---|
1590 | never use the server for them. |
---|
1591 | |
---|
1592 | The file system code is taken from GNU Fileutils. |
---|
1593 | |
---|
1594 | * Menu: |
---|
1595 | |
---|
1596 | * glibtop_mountlist:: Mount List. |
---|
1597 | * glibtop_fsusage:: File System Usage. |
---|
1598 | |
---|
1599 | |
---|
1600 | File: libgtop2.info, Node: glibtop_mountlist, Next: glibtop_fsusage, Prev: Common Functions, Up: Common Functions |
---|
1601 | |
---|
1602 | Mount List |
---|
1603 | ---------- |
---|
1604 | |
---|
1605 | Library function `glibtop_get_mountlist': |
---|
1606 | |
---|
1607 | glibtop_mountentry * |
---|
1608 | glibtop_get_mountlist_l (glibtop *server, glibtop_mountlist *buf, |
---|
1609 | int all_fs); |
---|
1610 | |
---|
1611 | glibtop_mountentry * |
---|
1612 | glibtop_get_mountlist (glibtop_mountlist *buf, int all_fs); |
---|
1613 | |
---|
1614 | The `all_fs' parameter specifies whether information about all |
---|
1615 | filesystems should be returned; this will include filesystem types like |
---|
1616 | `autofs' and `procfs'. You should not use this in disk usage programs, |
---|
1617 | but it can be useful to get a list of all currently mounted filesystems. |
---|
1618 | |
---|
1619 | Declaration of `glibtop_proc_map' in `<glibtop/procmap.h>': |
---|
1620 | |
---|
1621 | typedef struct _glibtop_mountlist glibtop_mountlist; |
---|
1622 | |
---|
1623 | struct _glibtop_mountlist |
---|
1624 | { |
---|
1625 | u_int64_t flags, |
---|
1626 | number, |
---|
1627 | total, |
---|
1628 | size; |
---|
1629 | }; |
---|
1630 | |
---|
1631 | Returns a `glibtop_mountentry *' list (which needs to be freed with |
---|
1632 | `glibtop_free') of mounted filesystems. |
---|
1633 | |
---|
1634 | `number' |
---|
1635 | Number of entries in the returned list. |
---|
1636 | |
---|
1637 | `total' |
---|
1638 | Total size of the returned list (this equals `number * size'). |
---|
1639 | |
---|
1640 | `size' |
---|
1641 | Size of a single entry in the returned list (this equals `sizeof |
---|
1642 | (glibtop_mountentry)'). |
---|
1643 | |
---|
1644 | typedef struct _glibtop_mountentry glibtop_mountentry; |
---|
1645 | |
---|
1646 | struct _glibtop_mountentry |
---|
1647 | { |
---|
1648 | u_int64_t dev; |
---|
1649 | char devname [GLIBTOP_MOUNTENTRY_LEN+1]; |
---|
1650 | char mountdir [GLIBTOP_MOUNTENTRY_LEN+1]; |
---|
1651 | char type [GLIBTOP_MOUNTENTRY_LEN+1]; |
---|
1652 | }; |
---|
1653 | |
---|
1654 | `GLIBTOP_MOUNTENTRY_LEN' is defined in `<glibtop/limits.h>'. |
---|
1655 | |
---|
1656 | `devname' |
---|
1657 | Full pathname (such as `/dev/sdb1' for instance) to the mounted |
---|
1658 | device. |
---|
1659 | |
---|
1660 | `mountdir' |
---|
1661 | Full pathname of the mountpoint (such as `/usr/local' for |
---|
1662 | instance). |
---|
1663 | |
---|
1664 | `type' |
---|
1665 | Filesystem type as a textual string (such as `ext2fs'). |
---|
1666 | |
---|
1667 | |
---|
1668 | File: libgtop2.info, Node: glibtop_fsusage, Prev: glibtop_mountlist, Up: Common Functions |
---|
1669 | |
---|
1670 | File System Usage |
---|
1671 | ----------------- |
---|
1672 | |
---|
1673 | Library function `glibtop_get_fsusage': |
---|
1674 | |
---|
1675 | void |
---|
1676 | glibtop_get_fsusage_l (glibtop *server, glibtop_fsusage *buf, |
---|
1677 | const char *mount_dir); |
---|
1678 | |
---|
1679 | void |
---|
1680 | glibtop_get_fsusage (glibtop_fsusage *buf, const char *mount_dir); |
---|
1681 | |
---|
1682 | Declaration of `glibtop_fsusage' in `<glibtop/fsusage.h>': |
---|
1683 | |
---|
1684 | typedef struct _glibtop_fsusage glibtop_fsusage; |
---|
1685 | |
---|
1686 | struct _glibtop_fsusage |
---|
1687 | { |
---|
1688 | u_int64_t flags, |
---|
1689 | blocks, |
---|
1690 | bfree, |
---|
1691 | bavail, |
---|
1692 | files, |
---|
1693 | ffree; |
---|
1694 | }; |
---|
1695 | |
---|
1696 | `blocks' |
---|
1697 | Total blocks in the filesystem. |
---|
1698 | |
---|
1699 | `bfree' |
---|
1700 | Free blocks available to the superuser. |
---|
1701 | |
---|
1702 | `bavail' |
---|
1703 | Free blocks available to ordinary users. |
---|
1704 | |
---|
1705 | `files' |
---|
1706 | Total file nodes. |
---|
1707 | |
---|
1708 | `ffree' |
---|
1709 | Free file nodes. |
---|
1710 | |
---|
1711 | Blocks are usually 512 bytes. |
---|
1712 | |
---|
1713 | |
---|
1714 | File: libgtop2.info, Node: Library Functions, Prev: Common Functions, Up: Reference Manual |
---|
1715 | |
---|
1716 | Library Functions |
---|
1717 | ================= |
---|
1718 | |
---|
1719 | This are general library functions which can be used to get |
---|
1720 | information about the library and to control its behavior. |
---|
1721 | |
---|
1722 | * Menu: |
---|
1723 | |
---|
1724 | * glibtop_init:: Server Initialization. |
---|
1725 | * glibtop_sysdeps:: Server Sysdeps. |
---|
1726 | * Library Parameters:: Library Parameters. |
---|
1727 | |
---|
1728 | |
---|
1729 | File: libgtop2.info, Node: glibtop_init, Next: glibtop_sysdeps, Prev: Library Functions, Up: Library Functions |
---|
1730 | |
---|
1731 | Server Initialization |
---|
1732 | --------------------- |
---|
1733 | |
---|
1734 | You do not need to worry about the `glibtop *' server structure if |
---|
1735 | you don't need - the library exports a `glibtop_global_server' which |
---|
1736 | you can use everywhere a `glibtop *' is expected. |
---|
1737 | |
---|
1738 | Most of the library and all of the sysdeps function also have an |
---|
1739 | alias (which is the function name without the `_l', `_s' or `_r' |
---|
1740 | suffix) which don't take a `glibtop *' as argument but uses the |
---|
1741 | `glibtop_global_server' instead. |
---|
1742 | |
---|
1743 | extern glibtop *glibtop_global_server; |
---|
1744 | |
---|
1745 | Library function `glibtop_init': |
---|
1746 | |
---|
1747 | glibtop * |
---|
1748 | glibtop_init_r (glibtop **server_ptr, unsigned long features, |
---|
1749 | unsigned flags); |
---|
1750 | |
---|
1751 | void |
---|
1752 | glibtop_init (void); |
---|
1753 | |
---|
1754 | This function initializes a LibGTop server. It is automatically |
---|
1755 | called when you use any of the LibGTop functions and will use the |
---|
1756 | global server in this case. |
---|
1757 | |
---|
1758 | However, it's appreciated to call `glibtop_init' during the |
---|
1759 | initialization of your application. |
---|
1760 | |
---|
1761 | You can for instance use |
---|
1762 | |
---|
1763 | glibtop_init (); |
---|
1764 | |
---|
1765 | which is equivalent to |
---|
1766 | |
---|
1767 | glibtop_init_r (&glibtop_global_server, 0, 0); |
---|
1768 | |
---|
1769 | Please note that the `server_ptr' argument is a pointer to a pointer |
---|
1770 | (and thus is of type `glibtop **'). |
---|
1771 | |
---|
1772 | To control what `glibtop_init' should actually do, you can use the |
---|
1773 | `features' and `flags' arguments. |
---|
1774 | |
---|
1775 | The `features' argument is a bit-mask (interpreted in the same way |
---|
1776 | than `sysdeps.features') and tells the library which features you're |
---|
1777 | interested in. The library will only start the server if this is |
---|
1778 | required for any of those features. |
---|
1779 | |
---|
1780 | You can use the following constants for the `flags' parameter to |
---|
1781 | control the behavior of the library: |
---|
1782 | |
---|
1783 | `GLIBTOP_INIT_NO_INIT' |
---|
1784 | Tells the library to do nothing. If the value pointed to by the |
---|
1785 | `server_ptr' argument is `NULL', it will set it to the |
---|
1786 | `glibtop_global_server' and then return. |
---|
1787 | |
---|
1788 | `GLIBTOP_INIT_NO_OPEN' |
---|
1789 | Do the initialization, but do not start the server. |
---|
1790 | |
---|
1791 | To modify the way the `features' are interpretet, you can use the |
---|
1792 | following constants for `flags' (as a bit mask): |
---|
1793 | |
---|
1794 | `GLIBTOP_FEATURES_NO_SERVER' |
---|
1795 | Never use the server, always call the sysdeps code directly. If |
---|
1796 | you require any privileges to get them and you don't have those |
---|
1797 | privileges, the this will obviously not work and the library will |
---|
1798 | fail to return some or all of the requested values. |
---|
1799 | |
---|
1800 | `GLIBTOP_FEATURES_EXCEPT' |
---|
1801 | Inverts the matching of the `features' parameter, i.e. if you use |
---|
1802 | this flag this means that `features' are all the features you are |
---|
1803 | _not_ interested in. Might be useful to say something like "I |
---|
1804 | want everything but ppp". |
---|
1805 | |
---|
1806 | |
---|
1807 | File: libgtop2.info, Node: glibtop_sysdeps, Next: Library Parameters, Prev: glibtop_init, Up: Library Functions |
---|
1808 | |
---|
1809 | Server Sysdeps |
---|
1810 | -------------- |
---|
1811 | |
---|
1812 | Library function `glibtop_get_sysdeps': |
---|
1813 | |
---|
1814 | void |
---|
1815 | glibtop_get_sysdeps_r (glibtop *server, glibtop_sysdeps *buf); |
---|
1816 | |
---|
1817 | void |
---|
1818 | glibtop_get_sysdeps (glibtop_sysdeps *buf); |
---|
1819 | |
---|
1820 | Declaration of `glibtop_sysdeps' in `<glibtop/sysdeps.h>': |
---|
1821 | |
---|
1822 | typedef struct _glibtop_sysdeps glibtop_sysdeps; |
---|
1823 | |
---|
1824 | struct _glibtop_sysdeps |
---|
1825 | { |
---|
1826 | u_int64_t flags, |
---|
1827 | features, |
---|
1828 | pointer_size, |
---|
1829 | cpu, |
---|
1830 | mem, |
---|
1831 | swap, |
---|
1832 | uptime, |
---|
1833 | loadavg, |
---|
1834 | shm_limits, |
---|
1835 | msg_limits, |
---|
1836 | sem_limits, |
---|
1837 | proclist, |
---|
1838 | proc_state, |
---|
1839 | proc_uid, |
---|
1840 | proc_mem, |
---|
1841 | proc_time, |
---|
1842 | proc_signal, |
---|
1843 | proc_kernel, |
---|
1844 | proc_segment, |
---|
1845 | proc_args, |
---|
1846 | proc_map, |
---|
1847 | mountlist, |
---|
1848 | fsusage, |
---|
1849 | netload, |
---|
1850 | ppp; |
---|
1851 | }; |
---|
1852 | |
---|
1853 | `features' |
---|
1854 | This is a bit field (the so-called "server features") stating for |
---|
1855 | which features we need to use the server. |
---|
1856 | |
---|
1857 | `pointer_size' |
---|
1858 | This was added in LibGTop 1.1.0 and tells you the number of bits a |
---|
1859 | `void*' has in the server (this may be different from the size on |
---|
1860 | the client machine if we're talking over the daemon to a remove |
---|
1861 | machine). |
---|
1862 | |
---|
1863 | The following constants from `<glibtop/sysdeps.h>' serve as |
---|
1864 | bit-indices for the `features' field: |
---|
1865 | |
---|
1866 | #define GLIBTOP_SYSDEPS_CPU 0 |
---|
1867 | #define GLIBTOP_SYSDEPS_MEM 1 |
---|
1868 | #define GLIBTOP_SYSDEPS_SWAP 2 |
---|
1869 | #define GLIBTOP_SYSDEPS_UPTIME 3 |
---|
1870 | #define GLIBTOP_SYSDEPS_LOADAVG 4 |
---|
1871 | #define GLIBTOP_SYSDEPS_SHM_LIMITS 5 |
---|
1872 | #define GLIBTOP_SYSDEPS_MSG_LIMITS 6 |
---|
1873 | #define GLIBTOP_SYSDEPS_SEM_LIMITS 7 |
---|
1874 | #define GLIBTOP_SYSDEPS_PROCLIST 8 |
---|
1875 | #define GLIBTOP_SYSDEPS_PROC_STATE 9 |
---|
1876 | #define GLIBTOP_SYSDEPS_PROC_UID 10 |
---|
1877 | #define GLIBTOP_SYSDEPS_PROC_MEM 11 |
---|
1878 | #define GLIBTOP_SYSDEPS_PROC_TIME 12 |
---|
1879 | #define GLIBTOP_SYSDEPS_PROC_SIGNAL 13 |
---|
1880 | #define GLIBTOP_SYSDEPS_PROC_KERNEL 14 |
---|
1881 | #define GLIBTOP_SYSDEPS_PROC_SEGMENT 15 |
---|
1882 | #define GLIBTOP_SYSDEPS_PROC_ARGS 16 |
---|
1883 | #define GLIBTOP_SYSDEPS_PROC_MAP 17 |
---|
1884 | #define GLIBTOP_SYSDEPS_MOUNTLIST 18 |
---|
1885 | #define GLIBTOP_SYSDEPS_FSUSAGE 19 |
---|
1886 | #define GLIBTOP_SYSDEPS_NETLOAD 20 |
---|
1887 | #define GLIBTOP_SYSDEPS_PPP 21 |
---|
1888 | |
---|
1889 | |
---|
1890 | File: libgtop2.info, Node: Library Parameters, Prev: glibtop_sysdeps, Up: Library Functions |
---|
1891 | |
---|
1892 | Library Parameters |
---|
1893 | ------------------ |
---|
1894 | |
---|
1895 | Library function `glibtop_get_parameter': |
---|
1896 | |
---|
1897 | size_t |
---|
1898 | glibtop_get_parameter_l (glibtop *server, const unsigned parameter, |
---|
1899 | void *data_ptr, size_t data_size); |
---|
1900 | |
---|
1901 | size_t |
---|
1902 | glibtop_get_parameter (const unsigned parameter, void *data_ptr, |
---|
1903 | size_t data_size); |
---|
1904 | |
---|
1905 | This function is used to retrieve a library parameter (see below for |
---|
1906 | a more detailed description). It returns the size of the retrieved |
---|
1907 | parameter on success, zero on failure or minus the actual size of the |
---|
1908 | parameter if `data_size' was too small. |
---|
1909 | |
---|
1910 | You may call this function with `data_ptr' set to `NULL' to get the |
---|
1911 | actual size of a parameter (as a negative value). |
---|
1912 | |
---|
1913 | `parameter' |
---|
1914 | The parameter you want to retrieve (see below for constants). |
---|
1915 | |
---|
1916 | `data_ptr' |
---|
1917 | Pointer to a place where the parameter should be stored. |
---|
1918 | |
---|
1919 | `data_size' |
---|
1920 | Maximum size of the parameter. |
---|
1921 | |
---|
1922 | Library function `glibtop_set_parameter': |
---|
1923 | |
---|
1924 | void |
---|
1925 | glibtop_set_parameter_l (glibtop *server, const unsigned parameter, |
---|
1926 | const void *data_ptr, size_t data_size); |
---|
1927 | |
---|
1928 | void |
---|
1929 | glibtop_set_parameter (const unsigned parameter, const void *data_ptr, |
---|
1930 | size_t data_size); |
---|
1931 | |
---|
1932 | This function is used to modify a library parameter. Please not that |
---|
1933 | you may not set all parameters since some of them are read-only. |
---|
1934 | |
---|
1935 | `parameter' |
---|
1936 | The parameter you want to modify (see below for constants). |
---|
1937 | |
---|
1938 | `data_ptr' |
---|
1939 | Pointer to the value which should be set. |
---|
1940 | |
---|
1941 | `data_size' |
---|
1942 | Size of the new value. For fixed-size parameters, this must match |
---|
1943 | the exact size of the parameter or you'll get an error. |
---|
1944 | |
---|
1945 | The following parameters are defined in `<glibtop/parameter.h>': |
---|
1946 | |
---|
1947 | `GLIBTOP_PARAM_FEATURES' |
---|
1948 | This is a read-only `unsigned long' representing the `features' |
---|
1949 | field of `glibtop_sysdeps'. |
---|
1950 | |
---|
1951 | `GLIBTOP_PARAM_REQUIRED' |
---|
1952 | This is a `glibtop_sysdeps' structure specifying which features the |
---|
1953 | client requires the library return. If it fails to get any of |
---|
1954 | them, you'll get an error. |
---|
1955 | |
---|
1956 | `GLIBTOP_PARAM_ERROR_METHOD' |
---|
1957 | This is an `unsigned' telling the library what to do if it fails to |
---|
1958 | get any of the features that are marked as required via the |
---|
1959 | `GLIBTOP_PARAM_REQUIRED' parameter (see below for constants). |
---|
1960 | |
---|
1961 | You can use the following constants for `GLIBTOP_PARAM_ERROR_METHOD' |
---|
1962 | (defined in `<glibtop/open.h>'): |
---|
1963 | |
---|
1964 | `GLIBTOP_ERROR_METHOD_IGNORE' |
---|
1965 | Ignore the error condition. |
---|
1966 | |
---|
1967 | `GLIBTOP_ERROR_METHOD_WARN_ONCE' |
---|
1968 | Warn once about the absense of some of the required features, then |
---|
1969 | modify `GLIBTOP_PARAM_REQUIRED' so that the missing ones are no |
---|
1970 | longer required. This is the prefered value for applications since |
---|
1971 | it'll only print out the warning message once and not each time |
---|
1972 | the library tries to get one of those features. |
---|
1973 | |
---|
1974 | `GLIBTOP_ERROR_METHOD_WARN' |
---|
1975 | Warn each time the library fails to get some of the required |
---|
1976 | features. |
---|
1977 | |
---|
1978 | `GLIBTOP_ERROR_METHOD_ABORT' |
---|
1979 | Abort if the library fails to get some of the required features. |
---|
1980 | This should not be used by applications. |
---|
1981 | |
---|
1982 | |
---|
1983 | |
---|
1984 | Tag Table: |
---|
1985 | Node: Top1203 |
---|
1986 | Node: About3356 |
---|
1987 | Node: Availability4233 |
---|
1988 | Node: Supported Platforms4848 |
---|
1989 | Node: Mailing List6453 |
---|
1990 | Node: Thanks7220 |
---|
1991 | Node: White Paper7932 |
---|
1992 | Node: Introduction8161 |
---|
1993 | Node: Overview9869 |
---|
1994 | Node: Interface Design10231 |
---|
1995 | Node: Server Implementation11246 |
---|
1996 | Node: Reference Manual11953 |
---|
1997 | Node: System Dependent12253 |
---|
1998 | Node: glibtop_cpu13320 |
---|
1999 | Node: glibtop_mem15505 |
---|
2000 | Node: glibtop_swap16665 |
---|
2001 | Node: glibtop_uptime17894 |
---|
2002 | Node: glibtop_loadavg19188 |
---|
2003 | Node: glibtop_proclist20194 |
---|
2004 | Node: glibtop_proc_state23429 |
---|
2005 | Node: glibtop_proc_uid26219 |
---|
2006 | Node: glibtop_proc_mem27806 |
---|
2007 | Node: glibtop_proc_time31506 |
---|
2008 | Node: glibtop_proc_signal33189 |
---|
2009 | Node: glibtop_proc_kernel34240 |
---|
2010 | Node: glibtop_proc_segment37146 |
---|
2011 | Node: glibtop_proc_args38603 |
---|
2012 | Node: glibtop_proc_map39666 |
---|
2013 | Node: glibtop_netload41657 |
---|
2014 | Node: glibtop_ppp44178 |
---|
2015 | Node: Common Functions45240 |
---|
2016 | Node: glibtop_mountlist45660 |
---|
2017 | Node: glibtop_fsusage47600 |
---|
2018 | Node: Library Functions48555 |
---|
2019 | Node: glibtop_init48977 |
---|
2020 | Node: glibtop_sysdeps51722 |
---|
2021 | Node: Library Parameters54337 |
---|
2022 | |
---|
2023 | End Tag Table |
---|