Blame doc/reference.texi

Packit d37888
@node Reference Manual, , White Paper, Top
Packit d37888
@chapter LibGTop Reference Manual
Packit d37888
Packit d37888
@menu
Packit d37888
* System Dependent::            System Dependent Functions.
Packit d37888
* Common Functions::            Common Functions.
Packit d37888
* Library Functions::           Library Functions.
Packit d37888
@end menu
Packit d37888
Packit d37888
@node System Dependent, Common Functions, Reference Manual, Reference Manual
Packit d37888
@section System Dependent Functions
Packit d37888
Packit d37888
@menu
Packit d37888
* glibtop_cpu::                 CPU Usage.
Packit d37888
* glibtop_mem::                 Memory Usage.
Packit d37888
* glibtop_swap::                Swap Usage.
Packit d37888
* glibtop_uptime::              System Uptime.
Packit d37888
* glibtop_loadavg::             Load Average.
Packit d37888
* glibtop_proclist::            Process List.
Packit d37888
* glibtop_proc_state::          Process State.
Packit d37888
* glibtop_proc_uid::            Process UID and TTY Information.
Packit d37888
* glibtop_proc_mem::            Process Memory Information.
Packit d37888
* glibtop_proc_time::           Process Time Information.
Packit d37888
* glibtop_proc_signal::         Process Signal Information.
Packit d37888
* glibtop_proc_kernel::         Process Kernel Data Information.
Packit d37888
* glibtop_proc_segment::        Process Segment Information.
Packit d37888
* glibtop_proc_args::           Process Arguments.
Packit d37888
* glibtop_proc_map::            Process Memory Maps.
Packit d37888
* glibtop_netload::             Network Load.
Packit d37888
* glibtop_ppp::                 PPP Usage.
Packit d37888
@end menu
Packit d37888
Packit d37888
@node glibtop_cpu, glibtop_mem, System Dependent, System Dependent
Packit d37888
@subsection CPU Usage
Packit d37888
Packit d37888
Library function @code{glibtop_get_cpu}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
void glibtop_get_cpu (glibtop_cpu *buf);
Packit d37888
void glibtop_get_cpu_l (glibtop *server, glibtop_cpu *buf);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_cpu} in @file{<glibtop/cpu.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_cpu     glibtop_cpu;
Packit d37888
Packit d37888
struct _glibtop_cpu
Packit d37888
@{
Packit d37888
    guint64   flags,
Packit d37888
        total,
Packit d37888
        user,
Packit d37888
        nice,
Packit d37888
        sys,
Packit d37888
        idle,
Packit d37888
        iowait,
Packit d37888
        irq,
Packit d37888
        softirq,
Packit d37888
        frequency,
Packit d37888
        xcpu_total [GLIBTOP_NCPU],
Packit d37888
        xcpu_user [GLIBTOP_NCPU],
Packit d37888
        xcpu_nice [GLIBTOP_NCPU],
Packit d37888
        xcpu_sys  [GLIBTOP_NCPU],
Packit d37888
        xcpu_idle [GLIBTOP_NCPU],
Packit d37888
        xcpu_iowait [GLIBTOP_NCPU],
Packit d37888
        xcpu_irq [GLIBTOP_NCPU],
Packit d37888
        xcpu_softirq [GLIBTOP_NCPU],
Packit d37888
        xcpu_flags;
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
All CPU units are measured in @dfn{jiffies} which are normally 1/100th of a
Packit d37888
second (in which case @code{frequency} equals 100), but can also be in any
Packit d37888
other unit. To get seconds, divide them by @code{frequency}.
Packit d37888
Packit d37888
@table @code
Packit d37888
@item total
Packit d37888
Number of clock ticks since system boot.
Packit d37888
Packit d37888
@item user
Packit d37888
Number of clock ticks the system spent in user mode.
Packit d37888
Packit d37888
@item nice
Packit d37888
Number of clock ticks the system spent in user mode (nice).
Packit d37888
Packit d37888
@item sys
Packit d37888
Number of clock ticks the system spent in system mode.
Packit d37888
Packit d37888
@item idle
Packit d37888
Number of clock ticks the system spent in the idle task.
Packit d37888
Packit d37888
@item iowait
Packit d37888
Number of clock ticks the system spent waiting for I/O to complete.
Packit d37888
Packit d37888
@item irq
Packit d37888
Number of clock ticks the system spent servicing interrupts.
Packit d37888
Packit d37888
@item softirq
Packit d37888
Number of clock ticks the system spent servicing softirqs.
Packit d37888
Packit d37888
@item frequency
Packit d37888
Tick frequency (default is 100).
Packit d37888
Packit d37888
@end table
Packit d37888
Packit d37888
The @samp{xcpu_} values are for SMP systems - they are the same than
Packit d37888
@code{total}, @code{user}, @code{nice}, @code{sys}, @code{idle},
Packit d37888
@code{iowait}, @code{irq} and @code{softirq}
Packit d37888
except that they are arrays of @code{GLIBTOP_NCPU} (defined in
Packit d37888
@file{<glibtop/cpu.h>}) elements and contain one value for each CPU
Packit d37888
in the system.
Packit d37888
Packit d37888
@table @code
Packit d37888
@item xcpu_flags
Packit d37888
This is interpreted as a bit-field: on systems like Solaris, not all CPUs
Packit d37888
need to be running all the time, so we set the corresponding bit for each
Packit d37888
CPU that is currently running.
Packit d37888
@end table
Packit d37888
Packit d37888
Please note that all of the cpu values are absolute values measured in
Packit d37888
certain units (to get seconds, divide them by @code{frequency}) since system
Packit d37888
boot. To get percentual values, you need to call @code{glibtop_cpu}, save the
Packit d37888
result, wait some time and then call it again and divide the differences of
Packit d37888
the two values by the time you have waited.
Packit d37888
Packit d37888
@page
Packit d37888
@node glibtop_mem, glibtop_swap, glibtop_cpu, System Dependent
Packit d37888
@subsection Memory Usage
Packit d37888
Packit d37888
Library function @code{glibtop_get_mem}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
void glibtop_get_mem (glibtop_mem *buf);
Packit d37888
void glibtop_get_mem_l (glibtop *server, glibtop_mem *buf);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_mem} in @file{<glibtop/mem.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_mem     glibtop_mem;
Packit d37888
Packit d37888
struct _glibtop_mem
Packit d37888
@{
Packit d37888
    guint64   flags,
Packit d37888
        total,
Packit d37888
        used,
Packit d37888
        free,
Packit d37888
        shared,
Packit d37888
        buffer,
Packit d37888
        cached,
Packit d37888
        user,
Packit d37888
        locked;
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Unless explicitly stated otherwise, all memory units are in bytes.
Packit d37888
Packit d37888
@table @code
Packit d37888
@item total
Packit d37888
Total physical memory.
Packit d37888
Packit d37888
@item used
Packit d37888
Used memory size.
Packit d37888
Packit d37888
@item free
Packit d37888
Free memory size.
Packit d37888
Packit d37888
@item shared
Packit d37888
Shared memory size.
Packit d37888
Packit d37888
This are both segments that are @code{mmap()}ed with @code{MAP_SHARED} and
Packit d37888
IPC Shared Memory segments.
Packit d37888
Packit d37888
@item buffer
Packit d37888
Size of buffers.
Packit d37888
Packit d37888
@item cached
Packit d37888
Size of cached memory.
Packit d37888
Packit d37888
@item user
Packit d37888
Memory used from user processes.
Packit d37888
Packit d37888
This is normally @code{total - free - shared - buffer - cached}.
Packit d37888
Packit d37888
@item locked
Packit d37888
Memory in locked segments.
Packit d37888
Packit d37888
@end table
Packit d37888
Packit d37888
@page
Packit d37888
@node glibtop_swap, glibtop_uptime, glibtop_mem, System Dependent
Packit d37888
@subsection Swap Usage
Packit d37888
Packit d37888
Library function @code{glibtop_get_swap}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
void glibtop_get_swap (glibtop_swap *buf);
Packit d37888
void glibtop_get_swap_l (glibtop *server, glibtop_swap *buf);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_swap} in @file{<glibtop/swap.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_swap    glibtop_swap;
Packit d37888
Packit d37888
struct _glibtop_swap
Packit d37888
@{
Packit d37888
    guint64   flags,
Packit d37888
        total,
Packit d37888
        used,
Packit d37888
        free,
Packit d37888
        pagein,
Packit d37888
        pageout;
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
The following units are in bytes.
Packit d37888
Packit d37888
@table @code
Packit d37888
@item total
Packit d37888
Total swap space in the system.
Packit d37888
Packit d37888
@item used
Packit d37888
Used swap space.
Packit d37888
Packit d37888
@item free
Packit d37888
Free swap space.
Packit d37888
@end table
Packit d37888
Packit d37888
You can use @code{pagein} and @code{pageout} to get some measure about how
Packit d37888
much the system is swapping at the moment. They're increased each time a page
Packit d37888
is swapped in or out, so you need to save this values, wait a little bit, get
Packit d37888
them again and then compare the two results to find out how much the system
Packit d37888
swapped in the meantime.
Packit d37888
Packit d37888
@table @code
Packit d37888
@item pagein
Packit d37888
Total number of swap pages that have been brought in since system boot
Packit d37888
Packit d37888
@item pageout
Packit d37888
Total number of swap pages that have been brought out since system boot
Packit d37888
Packit d37888
@end table
Packit d37888
Packit d37888
@page
Packit d37888
@node glibtop_uptime, glibtop_loadavg, glibtop_swap, System Dependent
Packit d37888
@subsection Uptime
Packit d37888
Packit d37888
Library function @code{glibtop_get_uptime}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
void glibtop_get_uptime (glibtop_uptime *buf);
Packit d37888
void glibtop_get_uptime_l (glibtop *server, glibtop_uptime *buf);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_uptime} in @file{<glibtop/uptime.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_uptime  glibtop_uptime;
Packit d37888
Packit d37888
struct _glibtop_uptime
Packit d37888
@{
Packit d37888
    guint64 flags;
Packit d37888
    double uptime,
Packit d37888
        idletime;
Packit d37888
    guint64 boot_time;
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
When porting LibGTop to a new system, you only need to implement @code{uptime}
Packit d37888
and @code{idletime} if there's a faster or better way to obtain them as using
Packit d37888
@code{glibtop_cpu} for it. Look at @file{sysdeps/freebsd/uptime.c} for an
Packit d37888
example on how to obtain them using @code{glibtop_cpu}.
Packit d37888
Packit d37888
@table @code
Packit d37888
@item uptime
Packit d37888
Time in seconds since system boot.
Packit d37888
Packit d37888
@item idletime
Packit d37888
Time in seconds the system spent in the idle task since system boot.
Packit d37888
@end table
Packit d37888
Packit d37888
The following one was from a request on the @samp{linux-kernel} mailing list;
Packit d37888
on a laptop with advanced power management @code{glibtop_cpu.total} may not
Packit d37888
reflect the correct boot time of the system if the power was turned off by
Packit d37888
means of APM in the meantime.
Packit d37888
Packit d37888
@table @code
Packit d37888
@item boot_time
Packit d37888
Time of last system boot in seconds since the epoch.
Packit d37888
@end table
Packit d37888
Packit d37888
@page
Packit d37888
@node glibtop_loadavg, glibtop_proclist, glibtop_uptime, System Dependent
Packit d37888
@subsection Load Average
Packit d37888
Packit d37888
Library function @code{glibtop_get_loadavg}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
void glibtop_get_loadavg (glibtop_loadavg *buf);
Packit d37888
void glibtop_get_loadavg_l (glibtop *server, glibtop_loadavg *buf);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_loadavg} in @file{<glibtop/loadavg.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_loadavg glibtop_loadavg;
Packit d37888
Packit d37888
struct _glibtop_loadavg
Packit d37888
@{
Packit d37888
    guint64 flags;
Packit d37888
    double loadavg [3];
Packit d37888
    guint64 nr_running,
Packit d37888
        nr_tasks,
Packit d37888
        last_pid;
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
@table @code
Packit d37888
@item loadavg
Packit d37888
Packit d37888
Number of jobs running simultaneously averaged over 1, 5 and 15 minutes.
Packit d37888
Packit d37888
@end table
Packit d37888
Packit d37888
The following fields are Linux specific and deprecated. You don't need to
Packit d37888
implement them when porting LibGTop to a new system as they may be removed
Packit d37888
in a future version.
Packit d37888
Packit d37888
@table @code
Packit d37888
@item nr_running
Packit d37888
Number of tasks currently running.
Packit d37888
Packit d37888
@item nr_tasks
Packit d37888
Total number of tasks.
Packit d37888
Packit d37888
@item last_pid
Packit d37888
Last PID.
Packit d37888
@end table
Packit d37888
Packit d37888
@page
Packit d37888
@node glibtop_proclist, glibtop_proc_state, glibtop_loadavg, System Dependent
Packit d37888
@subsection Process List
Packit d37888
Packit d37888
Library function @code{glibtop_get_proclist}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
unsigned *
Packit d37888
glibtop_get_proclist (glibtop_proclist *buf,
Packit d37888
                      gint64 which, gint64 arg);
Packit d37888
Packit d37888
unsigned *
Packit d37888
glibtop_get_proclist_l (glibtop *server, glibtop_proclist *buf,
Packit d37888
                        gint64 which, gint64 arg);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Constants for the @code{which} argument:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
#define GLIBTOP_KERN_PROC_ALL           0
Packit d37888
#define GLIBTOP_KERN_PROC_PID           1
Packit d37888
#define GLIBTOP_KERN_PROC_PGRP          2
Packit d37888
#define GLIBTOP_KERN_PROC_SESSION       3
Packit d37888
#define GLIBTOP_KERN_PROC_TTY           4
Packit d37888
#define GLIBTOP_KERN_PROC_UID           5
Packit d37888
#define GLIBTOP_KERN_PROC_RUID          6
Packit d37888
Packit d37888
#define GLIBTOP_KERN_PROC_MASK          15
Packit d37888
Packit d37888
#define GLIBTOP_EXCLUDE_IDLE            0x1000
Packit d37888
#define GLIBTOP_EXCLUDE_SYSTEM          0x2000
Packit d37888
#define GLIBTOP_EXCLUDE_NOTTY           0x4000
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_proclist} in @file{<glibtop/proclist.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_proclist        glibtop_proclist;
Packit d37888
Packit d37888
struct _glibtop_proclist
Packit d37888
@{
Packit d37888
    guint64   flags,
Packit d37888
        number,
Packit d37888
        total,
Packit d37888
        size;
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
This function returns a list of all or a selected subset of all running
Packit d37888
processes. You can use the @code{which} and @code{arg} arguments to
Packit d37888
specify which processes should be returned.
Packit d37888
Packit d37888
You can use the following values for the @code{which} argument:
Packit d37888
Packit d37888
@table @code
Packit d37888
@item GLIBTOP_KERN_PROC_ALL
Packit d37888
Return information about all processes (the @code{arg} argument is ignored).
Packit d37888
Packit d37888
@item GLIBTOP_KERN_PROC_PID
Packit d37888
Return information about all process with the pid @var{PID} which is passed
Packit d37888
in @code{arg}. You can use this to find out whether some process still exists.
Packit d37888
Packit d37888
@item GLIBTOP_KERN_PROC_PGRP
Packit d37888
Return all processes in process group @var{PGRP} which is passed in
Packit d37888
@code{arg}.
Packit d37888
Packit d37888
@item GLIBTOP_KERN_PROC_SESSION
Packit d37888
Return all processes in session @var{SESSION} which is passed in @code{arg}.
Packit d37888
Packit d37888
@item GLIBTOP_KERN_PROC_TTY
Packit d37888
Return all processes which have the controlling tty @var{TTY} which is passed
Packit d37888
in @code{arg} (@var{TTY} is interpreted as device number).
Packit d37888
Packit d37888
@item GLIBTOP_KERN_PROC_UID
Packit d37888
Return all processes with effective uid @var{UID} which is passed in @code{arg}.
Packit d37888
Packit d37888
@item GLIBTOP_KERN_PROC_RUID
Packit d37888
Return all processes with real uid @var{RUID} which is passed in @code{arg}.
Packit d37888
Packit d37888
@end table
Packit d37888
Packit d37888
You can alter the list of returned processes by using a binary OR of
Packit d37888
@code{which} and the following constants:
Packit d37888
Packit d37888
@table @code
Packit d37888
@item GLIBTOP_EXCLUDE_IDLE
Packit d37888
Exclude idle processes.
Packit d37888
@item GLIBTOP_EXCLUDE_SYSTEM
Packit d37888
Exclude system processes.
Packit d37888
@item GLIBTOP_EXCLUDE_NOTTY
Packit d37888
Exclude processes without a controlling terminal.
Packit d37888
@end table
Packit d37888
Packit d37888
The return value of @code{glibtop_get_proclist} is either @code{NULL} on
Packit d37888
error or a @code{unsigned *} list of pids. Additionally, the following fields
Packit d37888
of @code{glibtop_proclist} are set:
Packit d37888
Packit d37888
@table @code
Packit d37888
@item number
Packit d37888
Number of entries in the returned list.
Packit d37888
Packit d37888
@item total
Packit d37888
Total size of the returned list (this equals @code{number * size}).
Packit d37888
Packit d37888
@item size
Packit d37888
Size of a single entry in the returned list
Packit d37888
(this equals @code{sizeof (unsigned)}).
Packit d37888
@end table
Packit d37888
Packit d37888
The returned list is allocated using @code{g_malloc} and must be freed
Packit d37888
using @code{g_free} to avoid a memory leak.
Packit d37888
Packit d37888
@page
Packit d37888
@node glibtop_proc_state, glibtop_proc_uid, glibtop_proclist, System Dependent
Packit d37888
@subsection Process State
Packit d37888
Packit d37888
Library function @code{glibtop_get_proc_state}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
void
Packit d37888
glibtop_get_proc_state (glibtop_proc_state *buf, pid_t pid);
Packit d37888
Packit d37888
void
Packit d37888
glibtop_get_proc_state_l (glibtop *server, glibtop_proc_state *buf,
Packit d37888
                          pid_t pid);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_proc_state} in @file{<glibtop/procstate.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_proc_state      glibtop_proc_state;
Packit d37888
Packit d37888
struct _glibtop_proc_state
Packit d37888
@{
Packit d37888
    guint64 flags;
Packit d37888
    char cmd[40];
Packit d37888
@ifset LIBGTOP-1-1
Packit d37888
    unsigned state;
Packit d37888
@end ifset
Packit d37888
@ifclear LIBGTOP-1-1
Packit d37888
    char state;
Packit d37888
@end ifclear
Packit d37888
    int uid,
Packit d37888
        gid,
Packit d37888
        ruid,
Packit d37888
        rgid;
Packit d37888
    int has_cpu,
Packit d37888
        processor,
Packit d37888
        last_processor;
Packit d37888
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
@table @code
Packit d37888
@item cmd
Packit d37888
Basename of the executable file in the call to @code{exec}.
Packit d37888
@item state
Packit d37888
@ifset LIBGTOP-1-1
Packit d37888
Process state (see the constants defined below).
Packit d37888
@end ifset
Packit d37888
@ifclear LIBGTOP-1-1
Packit d37888
Process state ('R' = running, 'S' = sleeping, 'D' = uninterruptible,
Packit d37888
'Z' = zombie, 'T' = stopped, 'I' = idle).
Packit d37888
Packit d37888
This was changed to an @code{unsigned} bitfield in LibGTop 1.1.x where there
Packit d37888
are also some constants for it.
Packit d37888
@end ifclear
Packit d37888
@end table
Packit d37888
Packit d37888
When porting LibGTop, please @emph{try hard} to implement the following
Packit d37888
fields. For security reasons, it is @strong{very important} that you
Packit d37888
@strong{only} set the @code{flags} bits for those fields if their
Packit d37888
@strong{values are correct}.
Packit d37888
Packit d37888
@table @code
Packit d37888
@item uid
Packit d37888
Effective UID of the process.
Packit d37888
@item gid
Packit d37888
Effective GID of the process.
Packit d37888
@item ruid
Packit d37888
Real UID of the process.
Packit d37888
@item rgid
Packit d37888
Read GID of the process.
Packit d37888
@end table
Packit d37888
Packit d37888
The following fields are for SMP systems:
Packit d37888
Packit d37888
@table @code
Packit d37888
@item has_cpu
Packit d37888
This is either 0 or 1 depending on whether the process currently has a CPU
Packit d37888
or not.
Packit d37888
Packit d37888
@item processor
Packit d37888
This is the processor id of the CPU this process is currently running on
Packit d37888
(which can be used as index in the @samp{xcpu_} fields of @code{glibtop_cpu}
Packit d37888
for instance; since zero is a valid processor id, you must check @code{has_cpu}
Packit d37888
in this case to find out whether the process really has a CPU).
Packit d37888
Packit d37888
@item last_processor
Packit d37888
The is the processor id of the CPU the process was last running on.
Packit d37888
@end table
Packit d37888
Packit d37888
@ifset LIBGTOP-1-1
Packit d37888
There are some constants for the @code{state} field:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
#define GLIBTOP_PROCESS_RUNNING                 1
Packit d37888
#define GLIBTOP_PROCESS_INTERRUPTIBLE           2
Packit d37888
#define GLIBTOP_PROCESS_UNINTERRUPTIBLE         4
Packit d37888
#define GLIBTOP_PROCESS_ZOMBIE                  8
Packit d37888
#define GLIBTOP_PROCESS_STOPPED                 16
Packit d37888
#define GLIBTOP_PROCESS_SWAPPING                32
Packit d37888
#define GLIBTOP_PROCESS_DEAD                    64
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
@end ifset
Packit d37888
Packit d37888
@table @code
Packit d37888
@item GLIBTOP_PROCESS_RUNNING
Packit d37888
The process is currently running.
Packit d37888
@item GLIBTOP_PROCESS_INTERRUPTIBLE
Packit d37888
The process is currently in an interruptible sleep.
Packit d37888
@item GLIBTOP_PROCESS_UNINTERRUPTIBLE
Packit d37888
The process is currently in uninterruptible sleep
Packit d37888
(the so-called @dfn{disk sleep}).
Packit d37888
@item GLIBTOP_PROCESS_ZOMBIE
Packit d37888
The process is a zombie.
Packit d37888
@item GLIBTOP_PROCESS_STOPPED
Packit d37888
The process is currently stopped (received @code{SIGSTOP}
Packit d37888
or attached to a debugger).
Packit d37888
@item GLIBTOP_PROCESS_SWAPPING
Packit d37888
The process is currently swapping.
Packit d37888
@end table
Packit d37888
Packit d37888
@page
Packit d37888
@node glibtop_proc_uid, glibtop_proc_mem, glibtop_proc_state, System Dependent
Packit d37888
@subsection Process UID and TTY information
Packit d37888
Packit d37888
Library function @code{glibtop_get_proc_uid}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
void
Packit d37888
glibtop_get_proc_uid (glibtop_proc_uid *buf, pid_t pid);
Packit d37888
Packit d37888
void
Packit d37888
glibtop_get_proc_uid_l (glibtop *server, glibtop_proc_uid *buf,
Packit d37888
                        pid_t pid);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_proc_uid} in @file{<glibtop/procuid.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_proc_uid        glibtop_proc_uid;
Packit d37888
Packit d37888
struct _glibtop_proc_uid
Packit d37888
@{
Packit d37888
    guint64 flags;
Packit d37888
    int uid,
Packit d37888
        euid,
Packit d37888
        gid,
Packit d37888
        egid,
Packit d37888
        suid,
Packit d37888
        sgid,
Packit d37888
        fsuid,
Packit d37888
        fsgid,
Packit d37888
        pid,
Packit d37888
        ppid,
Packit d37888
        pgrp,
Packit d37888
        session,
Packit d37888
        tty,
Packit d37888
        tpgid,
Packit d37888
        priority,
Packit d37888
        nice,
Packit d37888
        ngroups,
Packit d37888
        groups [GLIBTOP_MAX_GROUPS];
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
@table @code
Packit d37888
@item uid
Packit d37888
User ID
Packit d37888
@item euid
Packit d37888
Effective User ID
Packit d37888
@item gid
Packit d37888
Group ID
Packit d37888
@item egid
Packit d37888
Effective Group ID
Packit d37888
@item pid
Packit d37888
Process ID
Packit d37888
@item ppid
Packit d37888
PID of parent process
Packit d37888
@item pgrp
Packit d37888
Process group ID
Packit d37888
@item session
Packit d37888
Session ID
Packit d37888
@item tty
Packit d37888
Full device number of controlling terminal
Packit d37888
@item tpgid
Packit d37888
Terminal process group ID
Packit d37888
@item priority
Packit d37888
Kernel scheduling priority.
Packit d37888
@item nice
Packit d37888
Standard unix nice level of process.
Packit d37888
@item ngroups
Packit d37888
Number of additional process groups.
Packit d37888
@item groups
Packit d37888
Array of additional process groups@*
Packit d37888
(@code{GLIBTOP_MAX_GROUPS} is defined in @file{<glibtop/procuid.h>}).
Packit d37888
@end table
Packit d37888
Packit d37888
@page
Packit d37888
@node glibtop_proc_mem, glibtop_proc_time, glibtop_proc_uid, System Dependent
Packit d37888
@subsection Process Memory information
Packit d37888
Packit d37888
Library function @code{glibtop_get_proc_mem}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
void
Packit d37888
glibtop_get_proc_mem (glibtop_proc_mem *buf, pid_t pid);
Packit d37888
Packit d37888
void
Packit d37888
glibtop_get_proc_mem_l (glibtop *server, glibtop_proc_mem *buf,
Packit d37888
                        pid_t pid);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_proc_mem} in @file{<glibtop/procmem.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_proc_mem        glibtop_proc_mem;
Packit d37888
Packit d37888
struct _glibtop_proc_mem
Packit d37888
@{
Packit d37888
    guint64   flags,
Packit d37888
        size,
Packit d37888
        vsize,
Packit d37888
        resident,
Packit d37888
        share,
Packit d37888
        rss,
Packit d37888
        rss_rlim;
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
@table @code
Packit d37888
@item size
Packit d37888
Total number of pages of memory.
Packit d37888
@item vsize
Packit d37888
Number of pages of virtual memory.
Packit d37888
@item resident
Packit d37888
Number of residnet set (non-swapped) pages.
Packit d37888
@item share
Packit d37888
Number of pages of shared (mmap\'d) memory.
Packit d37888
@item rss
Packit d37888
Number of pages the process has in real memory, minus 3 for administrative
Packit d37888
purposes.
Packit d37888
Packit d37888
This is just the pages which count towards text, data, or stack space.
Packit d37888
This does not include pages which have not been demand-loaded in, or which
Packit d37888
are swapped out.
Packit d37888
@item rss_rlim
Packit d37888
Current limit in bytes on the rss of the process (usually 2,147,483,647).
Packit d37888
@end table
Packit d37888
Packit d37888
The description above is taken from the manual page of the @file{/proc}
Packit d37888
filesystem under Linux and is a little bit confusing, so I make this clear
Packit d37888
here. 
Packit d37888
Packit d37888
@strong{A word for people porting LibGTop to other systems:}
Packit d37888
Every operating system has its own idea about the memory usage of a process
Packit d37888
and also system utilities like @code{ps} show different things on different
Packit d37888
systems.
Packit d37888
Packit d37888
Nevertheless, we should try to make LibGTop as system independent as possible,
Packit d37888
so I give you some hints here how @code{glibtop_get_proc_mem} should work. 
Packit d37888
Packit d37888
@itemize @bullet
Packit d37888
@item
Packit d37888
When you use @code{mmap} with either @code{MAP_SHARED} or @code{MAP_PRIVATE},
Packit d37888
this should only affect the @code{vsize} of the process and none of its
Packit d37888
@code{size}, @code{resident}, @code{shared} and @code{rss} sizes.
Packit d37888
Packit d37888
@item
Packit d37888
As soon as you read some of the @code{mmap()}ed pages, they will be demand-
Packit d37888
oaded and thus count towards the @code{size} of the process.
Packit d37888
Packit d37888
Also - we assume there is enough free memory - they are resident in memory
Packit d37888
until they get stolen or swapped out and thus increase the @code{resident} and
Packit d37888
@code{rss} sizes of the process.
Packit d37888
Packit d37888
@item
Packit d37888
If the process has used @code{MAP_SHARED} and another process attaches the
Packit d37888
same file also @code{MAP_SHARED}, some of the pages are shared with this
Packit d37888
process and thus increase the @code{shared} sizes of both processes.
Packit d37888
Packit d37888
@item
Packit d37888
If the process has used @code{MAP_PRIVATE} and writes to the @code{mmap()}ed
Packit d37888
pages, the only difference to reading from them is that they get dirty and
Packit d37888
cannot be stolen any longer but will get swapped out.
Packit d37888
Packit d37888
@item
Packit d37888
When memory gets rare, clean pages are normally stolen, which decreases the
Packit d37888
@code{size}, @code{resident}, @code{shared} and @code{rss} sizes of the process.
Packit d37888
Packit d37888
@item
Packit d37888
When dirty pages are swapped out, this will not decrease the @code{size} of the
Packit d37888
process but only its @code{resident} and @code{rss} sizes (dirty pages cannot
Packit d37888
be shared).
Packit d37888
Packit d37888
@item
Packit d37888
The @code{vsize} of a process can @emph{only} be changed by the process
Packit d37888
itself when it requests or frees memory but @emph{never} due to swapping
Packit d37888
activity of the system.
Packit d37888
Packit d37888
@item
Packit d37888
If the @code{shared} size changes, this @emph{only} means that the number of
Packit d37888
pages that are currently shared with other processes has changed; if this
Packit d37888
happens, this will @emph{never} affect any of the other sizes of the process.
Packit d37888
@end itemize
Packit d37888
Packit d37888
The hints above describe how it works under Linux - but we should try to make
Packit d37888
@code{glibtop_get_proc_mem} show the same behavior under every other system.
Packit d37888
Packit d37888
@page
Packit d37888
@node glibtop_proc_time, glibtop_proc_signal, glibtop_proc_mem, System Dependent
Packit d37888
@subsection Process Time information
Packit d37888
Packit d37888
Library function @code{glibtop_get_proc_time}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
void
Packit d37888
glibtop_get_proc_time (glibtop_proc_time *buf, pid_t pid);
Packit d37888
Packit d37888
void
Packit d37888
glibtop_get_proc_time_l (glibtop *server, glibtop_proc_time *buf,
Packit d37888
                         pid_t pid);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_proc_time} in @file{<glibtop/proctime.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_proc_time       glibtop_proc_time;
Packit d37888
Packit d37888
struct _glibtop_proc_time
Packit d37888
@{
Packit d37888
    guint64   flags,
Packit d37888
        start_time,
Packit d37888
        rtime,
Packit d37888
        utime,
Packit d37888
        stime,
Packit d37888
        cutime,
Packit d37888
        cstime,
Packit d37888
        timeout,
Packit d37888
        it_real_value,
Packit d37888
        frequency,
Packit d37888
        xcpu_utime [GLIBTOP_NCPU],
Packit d37888
        xcpu_stime [GLIBTOP_NCPU],
Packit d37888
        xcpu_flags;
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Packit d37888
@table @code
Packit d37888
@item start_time
Packit d37888
Start time of process in seconds since the epoch
Packit d37888
@item rtime
Packit d37888
Real time accumulated by process (should be @code{utime} + @code{stime})
Packit d37888
@item utime
Packit d37888
User-mode CPU time accumulated by process
Packit d37888
@item stime
Packit d37888
Kernel-mode CPU time accumulated by process
Packit d37888
@item cutime
Packit d37888
Cumulative utime of process and reaped children
Packit d37888
@item cstime
Packit d37888
Cumulative stime of process and reaped children
Packit d37888
@item timeout
Packit d37888
The time (in jiffies) of the process's next timeout
Packit d37888
@item it_real_value
Packit d37888
The time (in jiffies) before the next SIGALRM is sent to the process due
Packit d37888
to an interval timer.
Packit d37888
@item frequency
Packit d37888
Tick frequency
Packit d37888
@item xcpu_utime
Packit d37888
SMP user-mode CPU time accumulated by process
Packit d37888
@item xcpu_stime
Packit d37888
SMP kernel-mode CPU time accumulated by process
Packit d37888
@end table
Packit d37888
Packit d37888
Packit d37888
Please note that under Linux, @code{start_time} value may be strange.
Packit d37888
Linux kernel defines @code{INITIAL_JIFFIES} which implies a time
Packit d37888
shift. Because @code{INITIAL_JIFFIES} is not user-space defined, we
Packit d37888
cannot use it to compute accurate @code{start_time}. On Linux2.6,
Packit d37888
@code{INITIAL_JIFFIES} is 300 so @code{start_time} is always 3s
Packit d37888
different from real start time of the given process. You may also get
Packit d37888
shift results if your system clock is not synchronised with your
Packit d37888
hardware clock. See @samp{man hwclock}.
Packit d37888
Packit d37888
Packit d37888
Packit d37888
@page
Packit d37888
@node glibtop_proc_signal, glibtop_proc_kernel, glibtop_proc_time, System Dependent
Packit d37888
@subsection Process Signal information
Packit d37888
Packit d37888
Library function @code{glibtop_get_proc_signal}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
void
Packit d37888
glibtop_get_proc_signal (glibtop_proc_signal *buf, pid_t pid);
Packit d37888
Packit d37888
void
Packit d37888
glibtop_get_proc_signal_l (glibtop *server, glibtop_proc_signal *buf,
Packit d37888
                           pid_t pid);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_proc_signal} in @file{<glibtop/procsignal.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_proc_signal     glibtop_proc_signal;
Packit d37888
Packit d37888
struct _glibtop_proc_signal
Packit d37888
@{
Packit d37888
    guint64   flags,
Packit d37888
        signal [2],
Packit d37888
        blocked [2],
Packit d37888
        sigignore [2],
Packit d37888
        sigcatch [2];
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
@table @code
Packit d37888
@item signal
Packit d37888
Mask of pending signals
Packit d37888
@item blocked
Packit d37888
Mask of blocked signals
Packit d37888
@item sigignore
Packit d37888
Mask of ignored signals
Packit d37888
@item sigcatch
Packit d37888
Mask of caught signals
Packit d37888
@end table
Packit d37888
Packit d37888
All signal masks are interpreted as bit mask; it is an array of two
Packit d37888
@code{guint64}'s so we can save 128 signals there.
Packit d37888
Packit d37888
@page
Packit d37888
@node glibtop_proc_kernel, glibtop_proc_segment, glibtop_proc_signal, System Dependent
Packit d37888
@subsection Process Kernel Data information
Packit d37888
Packit d37888
Library function @code{glibtop_get_proc_kernel}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
void
Packit d37888
glibtop_get_proc_kernel (glibtop_proc_kernel *buf, pid_t pid);
Packit d37888
Packit d37888
void
Packit d37888
glibtop_get_proc_kernel_l (glibtop *server, glibtop_proc_kernel *buf,
Packit d37888
                           pid_t pid);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_proc_kernel} in @file{<glibtop/prockernel.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_proc_kernel     glibtop_proc_kernel;
Packit d37888
Packit d37888
struct _glibtop_proc_kernel
Packit d37888
@{
Packit d37888
    guint64 flags;
Packit d37888
    guint64 k_flags,
Packit d37888
        min_flt,
Packit d37888
        maj_flt,
Packit d37888
        cmin_flt,
Packit d37888
        cmaj_flt,
Packit d37888
        kstk_esp,
Packit d37888
        kstk_eip,
Packit d37888
        nwchan;
Packit d37888
    char wchan [40];
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
@table @code
Packit d37888
@item k_flags
Packit d37888
Kernel flags of the process. See the constants defined below.
Packit d37888
@item min_flt
Packit d37888
The number of minor faults the process has made, those which have not required
Packit d37888
loading a memory page from disk.
Packit d37888
@item maj_flt
Packit d37888
The number of major faults the process has made, those which have required loading
Packit d37888
a memory page from disk.
Packit d37888
@item cmin_flt
Packit d37888
The number of minor faults that the process and its children have made.
Packit d37888
@item cmaj_flt
Packit d37888
The number of major faults that the process and its children have made.
Packit d37888
@item kstk_esp
Packit d37888
The current value of @code{esp} (32-bit stack pointer), as found in the kernel stack
Packit d37888
page for the process.
Packit d37888
@item kstk_eip
Packit d37888
The current @code{eip} (32-bit instruction pointer).
Packit d37888
@item nwchan
Packit d37888
This is the "channel" in which the process is waiting. This is the address of a system
Packit d37888
call, and can be looked up in a namelist if you need a textual name.
Packit d37888
(If you have an up-to-date @file{/etc/psdatabase}, then try @code{ps -l} to see the
Packit d37888
WCHAN field in action).
Packit d37888
@item wchan
Packit d37888
This is the textual name of the @code{nwchan} field.
Packit d37888
@end table
Packit d37888
Packit d37888
There are some constants for the @code{k_flags} field:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
#define GLIBTOP_KFLAGS_STARTING         1
Packit d37888
#define GLIBTOP_KFLAGS_EXITING          2
Packit d37888
#define GLIBTOP_KFLAGS_PTRACED          4
Packit d37888
#define GLIBTOP_KFLAGS_TRACESYS         8
Packit d37888
#define GLIBTOP_KFLAGS_FORKNOEXEC       16
Packit d37888
#define GLIBTOP_KFLAGS_SUPERPRIV        32
Packit d37888
#define GLIBTOP_KFLAGS_DUMPEDCORE       64
Packit d37888
#define GLIBTOP_KFLAGS_SIGNALED         128
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
@table @code
Packit d37888
@item GLIBTOP_KFLAGS_STARTING
Packit d37888
Process is being created.
Packit d37888
@item GLIBTOP_KFLAGS_EXITING
Packit d37888
Process is exiting.
Packit d37888
@item GLIBTOP_KFLAGS_PTRACED
Packit d37888
Process is being traced (via @code{ptrace ()}).
Packit d37888
@item GLIBTOP_KFLAGS_TRACESYS
Packit d37888
Process is tracing system calls.
Packit d37888
@item GLIBTOP_KFLAGS_FORKNOEXEC
Packit d37888
Process @code{fork()}ed, but didn't @code{exec()} yet.
Packit d37888
@item GLIBTOP_KFLAGS_SUPERPRIV
Packit d37888
Process used super-user privileges.
Packit d37888
@item GLIBTOP_KFLAGS_DUMPEDCORE
Packit d37888
Process dumped core.
Packit d37888
@item GLIBTOP_KFLAGS_SIGNALED
Packit d37888
Process was killed by a signal.
Packit d37888
@end table
Packit d37888
Packit d37888
@page
Packit d37888
@node glibtop_proc_segment, glibtop_proc_args, glibtop_proc_kernel, System Dependent
Packit d37888
@subsection Process Segment information
Packit d37888
Packit d37888
Library function @code{glibtop_get_proc_segment}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
void
Packit d37888
glibtop_get_proc_segment (glibtop_proc_segment *buf, pid_t pid);
Packit d37888
Packit d37888
void
Packit d37888
glibtop_get_proc_segment_l (glibtop *server, glibtop_proc_segment *buf,
Packit d37888
                            pid_t pid);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_proc_segment} in @file{<glibtop/procsegment.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_proc_segment    glibtop_proc_segment;
Packit d37888
Packit d37888
struct _glibtop_proc_segment
Packit d37888
@{
Packit d37888
    guint64   flags,
Packit d37888
        text_rss,
Packit d37888
        shlib_rss,
Packit d37888
        data_rss,
Packit d37888
        stack_rss,
Packit d37888
        dirty_size,
Packit d37888
        start_code,
Packit d37888
        end_code,
Packit d37888
        start_stack;
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
@table @code
Packit d37888
@item text_rss
Packit d37888
Text resident set size
Packit d37888
@item shlib_rss
Packit d37888
Shared-Lib resident set size
Packit d37888
@item data_rss
Packit d37888
Data resident set size
Packit d37888
@item stack_rss
Packit d37888
Stack resident set size
Packit d37888
@item dirty_size
Packit d37888
Total size of dirty pages
Packit d37888
@item start_code
Packit d37888
Address of beginning of code segment
Packit d37888
@item end_code
Packit d37888
Address of end of code segment
Packit d37888
@item start_stack
Packit d37888
Address of the bottom of stack segmen
Packit d37888
@end table
Packit d37888
Packit d37888
@page
Packit d37888
@node glibtop_proc_args, glibtop_proc_map, glibtop_proc_segment, System Dependent
Packit d37888
@subsection Process Arguments
Packit d37888
Packit d37888
Library function @code{glibtop_get_proc_args}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
char *
Packit d37888
glibtop_get_proc_args(glibtop_proc_args *buf, pid_t pid,
Packit d37888
                         unsigned max_len);
Packit d37888
Packit d37888
char *
Packit d37888
glibtop_get_proc_args_l (glibtop *server, glibtop_proc_args *buf,
Packit d37888
                         pid_t pid, unsigned max_len);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_proc_args} in @file{<glibtop/procargs.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_proc_args       glibtop_proc_args;
Packit d37888
Packit d37888
struct _glibtop_proc_args
Packit d37888
@{
Packit d37888
    guint64   flags,
Packit d37888
        size;
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Returns a string with all command line arguments of process @code{pid}
Packit d37888
(up to @code{max_len} characters, use zero to get all arguments).
Packit d37888
Packit d37888
The command line arguments in the returned string are separated by zero bytes;
Packit d37888
the lenght of this string is returned in the @code{size} field.
Packit d37888
Packit d37888
Remember to @code{g_free} the returned string to avoid a memory leak.
Packit d37888
Packit d37888
@strong{New functions}
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
char **
Packit d37888
glibtop_get_proc_argv(glibtop_proc_args *buf, pid_t pid,
Packit d37888
                         unsigned max_len);
Packit d37888
Packit d37888
char **
Packit d37888
glibtop_get_proc_argv_l (glibtop *server, glibtop_proc_args *buf,
Packit d37888
                         pid_t pid, unsigned max_len);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Returns a NULL-terminated array of strings with all arguments of
Packit d37888
process @code{pid} (up to @code{max_len} characters, use zero to get
Packit d37888
all arguments). @code{glibtop_get_proc_argv()} and
Packit d37888
@code{glibtop_get_proc_argv_l()} are wrappers to
Packit d37888
@code{glibtop_get_proc_args()} and @code{glibtop_get_proc_args_l()}
Packit d37888
that return process' arguments like the C @code{argv}.
Packit d37888
Packit d37888
Remember to @code{g_strfreev} the returned array to avoid a memory
Packit d37888
leak.
Packit d37888
Packit d37888
@page
Packit d37888
@node glibtop_proc_map, glibtop_netload, glibtop_proc_args, System Dependent
Packit d37888
@subsection Process Memory Maps
Packit d37888
Packit d37888
Library function @code{glibtop_get_proc_map}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
glibtop_map_entry *
Packit d37888
glibtop_get_proc_map (glibtop_proc_map *buf, pid_t pid);
Packit d37888
Packit d37888
glibtop_map_entry *
Packit d37888
glibtop_get_proc_map_l (glibtop *server, glibtop_proc_map *buf,
Packit d37888
                        pid_t pid);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_proc_map} in @file{<glibtop/procmap.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_proc_map        glibtop_proc_map;
Packit d37888
Packit d37888
struct _glibtop_proc_map
Packit d37888
@{
Packit d37888
    guint64   flags,
Packit d37888
        number,
Packit d37888
        total,
Packit d37888
        size;
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Returns a @code{glibtop_map_entry *} list (which needs to be freed with
Packit d37888
@code{g_free}) of memory maps of process @code{pid}.
Packit d37888
Packit d37888
@table @code
Packit d37888
@item number
Packit d37888
Number of entries in the returned list.
Packit d37888
Packit d37888
@item total
Packit d37888
Total size of the returned list (this equals @code{number * size}).
Packit d37888
Packit d37888
@item size
Packit d37888
Size of a single entry in the returned list
Packit d37888
(this equals @code{sizeof (glibtop_map_entry)}).
Packit d37888
@end table
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_map_entry       glibtop_map_entry;
Packit d37888
Packit d37888
struct _glibtop_map_entry
Packit d37888
@{
Packit d37888
    guint64 flags, start, end, offset, perm, inode, device;
Packit d37888
    char filename [GLIBTOP_MAP_FILENAME_LEN+1];
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
The @code{flags} member is a bit field and specifies which of the other
Packit d37888
fields are valid:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
#define GLIBTOP_MAP_ENTRY_START         0
Packit d37888
#define GLIBTOP_MAP_ENTRY_END           1
Packit d37888
#define GLIBTOP_MAP_ENTRY_OFFSET        2
Packit d37888
#define GLIBTOP_MAP_ENTRY_PERM          3
Packit d37888
#define GLIBTOP_MAP_ENTRY_INODE         4
Packit d37888
#define GLIBTOP_MAP_ENTRY_DEVICE        5
Packit d37888
#define GLIBTOP_MAP_ENTRY_FILENAME      6
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Constants for the @code{perm} member:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
#define GLIBTOP_MAP_PERM_READ           1
Packit d37888
#define GLIBTOP_MAP_PERM_WRITE          2
Packit d37888
#define GLIBTOP_MAP_PERM_EXECUTE        4
Packit d37888
#define GLIBTOP_MAP_PERM_SHARED         8
Packit d37888
#define GLIBTOP_MAP_PERM_PRIVATE        16
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
@page
Packit d37888
@node glibtop_netload, glibtop_ppp, glibtop_proc_map, System Dependent
Packit d37888
@subsection Network Load
Packit d37888
Packit d37888
Library function @code{glibtop_get_netload}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
void
Packit d37888
glibtop_get_netload (glibtop_netload *buf, const char *interface);
Packit d37888
Packit d37888
void
Packit d37888
glibtop_get_netload_l (glibtop *server, glibtop_netload *buf,
Packit d37888
                       const char *interface);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_netload} in @file{<glibtop/netload.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_netload glibtop_netload;
Packit d37888
Packit d37888
struct _glibtop_netload
Packit d37888
@{
Packit d37888
    guint64   flags,
Packit d37888
        if_flags,
Packit d37888
        mtu,
Packit d37888
        subnet,
Packit d37888
        address,
Packit d37888
        packets_in,
Packit d37888
        packets_out,
Packit d37888
        packets_total,
Packit d37888
        bytes_in,
Packit d37888
        bytes_out,
Packit d37888
        bytes_total,
Packit d37888
        errors_in,
Packit d37888
        errors_out,
Packit d37888
        errors_total,
Packit d37888
        collisions;
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Returns network statistics for interface @code{interface} (which is the same
Packit d37888
than in @code{ifconfig}).
Packit d37888
Packit d37888
@table @code
Packit d37888
@item if_flags
Packit d37888
Interface flags. See the contants defined below.
Packit d37888
@item mtu
Packit d37888
Maximum Transfer Unit (MTU)
Packit d37888
@item subnet
Packit d37888
Subnet Address
Packit d37888
@item address
Packit d37888
Interface Address
Packit d37888
@item packets_in
Packit d37888
Total number of incoming packets
Packit d37888
@item packets_out
Packit d37888
Total number of outgoing packets
Packit d37888
@item packets_total
Packit d37888
Total number of packets
Packit d37888
@item bytes_in
Packit d37888
Total number of incoming bytes
Packit d37888
@item bytes_out
Packit d37888
Total number of outgoing bytes
Packit d37888
@item bytes_total
Packit d37888
Total number of bytes
Packit d37888
@item errors_in
Packit d37888
Total number of errors in incoming direction
Packit d37888
@item errors_out
Packit d37888
Total number of errors in outgoing direction
Packit d37888
@item errors_total
Packit d37888
Total number of errors
Packit d37888
@item collisions
Packit d37888
Total number of collisions
Packit d37888
@end table
Packit d37888
Packit d37888
Please note that not all operating systems distinguish between incoming/outgoing
Packit d37888
bytes/packets/errors - in this case only the @samp{_total} fields are valid.
Packit d37888
Otherwise, they're just @samp{_in} plus @samp{_out}.
Packit d37888
Packit d37888
Constants for @code{if_flags}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
enum @{
Packit d37888
    GLIBTOP_IF_FLAGS_UP = 1,
Packit d37888
    GLIBTOP_IF_FLAGS_BROADCAST,
Packit d37888
    GLIBTOP_IF_FLAGS_DEBUG,
Packit d37888
    GLIBTOP_IF_FLAGS_LOOPBACK,
Packit d37888
    GLIBTOP_IF_FLAGS_POINTOPOINT,
Packit d37888
    GLIBTOP_IF_FLAGS_RUNNING,
Packit d37888
    GLIBTOP_IF_FLAGS_NOARP,
Packit d37888
    GLIBTOP_IF_FLAGS_PROMISC,
Packit d37888
    GLIBTOP_IF_FLAGS_ALLMULTI,
Packit d37888
    GLIBTOP_IF_FLAGS_OACTIVE,
Packit d37888
    GLIBTOP_IF_FLAGS_SIMPLEX,
Packit d37888
    GLIBTOP_IF_FLAGS_LINK0,
Packit d37888
    GLIBTOP_IF_FLAGS_LINK1,
Packit d37888
    GLIBTOP_IF_FLAGS_LINK2,
Packit d37888
    GLIBTOP_IF_FLAGS_ALTPHYS,
Packit d37888
    GLIBTOP_IF_FLAGS_MULTICAST
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
@page
Packit d37888
@node glibtop_ppp,  , glibtop_netload, System Dependent
Packit d37888
@subsection PPP Statistics
Packit d37888
Packit d37888
Library function @code{glibtop_get_ppp}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
void
Packit d37888
glibtop_get_ppp_l (glibtop *server, glibtop_ppp *buf,
Packit d37888
                   unsigned short device);
Packit d37888
Packit d37888
void
Packit d37888
glibtop_get_ppp (glibtop_ppp *buf, unsigned short device);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_ppp} in @file{<glibtop/ppp.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_ppp     glibtop_ppp;
Packit d37888
Packit d37888
struct _glibtop_ppp
Packit d37888
@{
Packit d37888
    guint64   flags,
Packit d37888
        state,
Packit d37888
        bytes_in,
Packit d37888
        bytes_out;
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
@table @code
Packit d37888
@item bytes_in
Packit d37888
Number of input bytes
Packit d37888
@item bytes_out
Packit d37888
Number of output bytes
Packit d37888
@end table
Packit d37888
Packit d37888
There are some constants for @code{state}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
enum @{
Packit d37888
    GLIBTOP_PPP_STATE_UNKNOWN = 0,
Packit d37888
    GLIBTOP_PPP_STATE_HANGUP,
Packit d37888
    GLIBTOP_PPP_STATE_ONLINE
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
@table @code
Packit d37888
@item GLIBTOP_PPP_STATE_UNKNOWN
Packit d37888
LibGTop was unable to determine the current ppp state.
Packit d37888
@item GLIBTOP_PPP_STATE_HANGUP
Packit d37888
We're currently offline.
Packit d37888
@item GLIBTOP_PPP_STATE_ONLINE
Packit d37888
We're currently online.
Packit d37888
@end table
Packit d37888
Packit d37888
@page
Packit d37888
@node Common Functions, Library Functions, System Dependent, Reference Manual
Packit d37888
@section Common Functions
Packit d37888
Packit d37888
This are functions which a common implementation for all systems; we never
Packit d37888
use the server for them.
Packit d37888
Packit d37888
The file system code is taken from GNU Fileutils.
Packit d37888
Packit d37888
@menu
Packit d37888
* glibtop_mountlist::           Mount List.
Packit d37888
* glibtop_fsusage::             File System Usage.
Packit d37888
@end menu
Packit d37888
Packit d37888
@node glibtop_mountlist, glibtop_fsusage, Common Functions, Common Functions
Packit d37888
@subsection Mount List
Packit d37888
Packit d37888
Library function @code{glibtop_get_mountlist}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
glibtop_mountentry *
Packit d37888
glibtop_get_mountlist_l (glibtop *server, glibtop_mountlist *buf,
Packit d37888
                         int all_fs);
Packit d37888
Packit d37888
glibtop_mountentry *
Packit d37888
glibtop_get_mountlist (glibtop_mountlist *buf, int all_fs);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
The @code{all_fs} parameter specifies whether information about all
Packit d37888
filesystems should be returned; this will include filesystem types like
Packit d37888
@code{autofs} and @code{procfs}. You should not use this in disk usage
Packit d37888
programs, but it can be useful to get a list of all currently mounted
Packit d37888
filesystems.
Packit d37888
Packit d37888
Declaration of @code{glibtop_proc_map} in @file{<glibtop/procmap.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_mountlist       glibtop_mountlist;
Packit d37888
Packit d37888
struct _glibtop_mountlist
Packit d37888
@{
Packit d37888
    guint64   flags,
Packit d37888
        number,
Packit d37888
        total,
Packit d37888
        size;
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Returns a @code{glibtop_mountentry *} list (which needs to be freed with
Packit d37888
@code{g_free}) of mounted filesystems.
Packit d37888
Packit d37888
@table @code
Packit d37888
@item number
Packit d37888
Number of entries in the returned list.
Packit d37888
Packit d37888
@item total
Packit d37888
Total size of the returned list (this equals @code{number * size}).
Packit d37888
Packit d37888
@item size
Packit d37888
Size of a single entry in the returned list
Packit d37888
(this equals @code{sizeof (glibtop_mountentry)}).
Packit d37888
@end table
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_mountentry      glibtop_mountentry;
Packit d37888
Packit d37888
struct _glibtop_mountentry
Packit d37888
@{
Packit d37888
    guint64 dev;
Packit d37888
    char devname [GLIBTOP_MOUNTENTRY_LEN+1];
Packit d37888
    char mountdir [GLIBTOP_MOUNTENTRY_LEN+1];
Packit d37888
    char type [GLIBTOP_MOUNTENTRY_LEN+1];
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
@code{GLIBTOP_MOUNTENTRY_LEN} is defined in @file{<glibtop.h>}.
Packit d37888
Packit d37888
@table @code
Packit d37888
@item devname
Packit d37888
Full pathname (such as @samp{/dev/sdb1} for instance) to the mounted device.
Packit d37888
@item mountdir
Packit d37888
Full pathname of the mountpoint (such as @samp{/usr/local} for instance).
Packit d37888
@item type
Packit d37888
Filesystem type as a textual string (such as @samp{ext2fs}).
Packit d37888
@end table
Packit d37888
Packit d37888
@page
Packit d37888
@node glibtop_fsusage,  , glibtop_mountlist, Common Functions
Packit d37888
@subsection File System Usage
Packit d37888
Packit d37888
Library function @code{glibtop_get_fsusage}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
void
Packit d37888
glibtop_get_fsusage_l (glibtop *server, glibtop_fsusage *buf,
Packit d37888
                       const char *mount_dir);
Packit d37888
Packit d37888
void
Packit d37888
glibtop_get_fsusage (glibtop_fsusage *buf, const char *mount_dir);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_fsusage} in @file{<glibtop/fsusage.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_fsusage         glibtop_fsusage;
Packit d37888
Packit d37888
struct _glibtop_fsusage
Packit d37888
@{
Packit d37888
    guint64   flags,
Packit d37888
        blocks,
Packit d37888
        bfree,
Packit d37888
        bavail,
Packit d37888
        files,
Packit d37888
        ffree;
Packit d37888
    guint32   block_size;
Packit d37888
    guint64 read,
Packit d37888
        write;
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
@table @code
Packit d37888
@item blocks
Packit d37888
Total blocks in the filesystem.
Packit d37888
@item bfree
Packit d37888
Free blocks available to the superuser.
Packit d37888
@item bavail
Packit d37888
Free blocks available to ordinary users.
Packit d37888
@item files
Packit d37888
Total file nodes.
Packit d37888
@item ffree
Packit d37888
Free file nodes.
Packit d37888
@item block_size
Packit d37888
Block size in bytes.
Packit d37888
@item read
Packit d37888
Total blocks read.
Packit d37888
@item write
Packit d37888
Total blocks written.
Packit d37888
@end table
Packit d37888
Packit d37888
@page
Packit d37888
@node Library Functions,  , Common Functions, Reference Manual
Packit d37888
@section Library Functions
Packit d37888
Packit d37888
This are general library functions which can be used to get information
Packit d37888
about the library and to control its behavior.
Packit d37888
Packit d37888
@menu
Packit d37888
* glibtop_init::                Server Initialization.
Packit d37888
* glibtop_sysdeps::             Server Sysdeps.
Packit d37888
* Library Parameters::          Library Parameters.
Packit d37888
@end menu
Packit d37888
Packit d37888
@node glibtop_init, glibtop_sysdeps, Library Functions, Library Functions
Packit d37888
@subsection Server Initialization
Packit d37888
Packit d37888
You do not need to worry about the @code{glibtop *} server structure if
Packit d37888
you don't need - the library exports a @code{glibtop_global_server}
Packit d37888
which you can use everywhere a @code{glibtop *} is expected.
Packit d37888
Packit d37888
Most of the library and all of the sysdeps function also have an alias
Packit d37888
(which is the function name without the @samp{_l}, @samp{_s} or @samp{_r}
Packit d37888
suffix) which don't take a @code{glibtop *} as argument but uses the
Packit d37888
@code{glibtop_global_server} instead.
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
extern glibtop *glibtop_global_server;
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Library function @code{glibtop_init}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
glibtop *
Packit d37888
glibtop_init_r (glibtop **server_ptr, unsigned long features,
Packit d37888
                unsigned flags);
Packit d37888
Packit d37888
void
Packit d37888
glibtop_init (void);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
This function initializes a LibGTop server. It is automatically called
Packit d37888
when you use any of the LibGTop functions and will use the global server
Packit d37888
in this case.
Packit d37888
Packit d37888
However, it's appreciated to call @code{glibtop_init} during the
Packit d37888
initialization of your application.
Packit d37888
Packit d37888
You can for instance use
Packit d37888
Packit d37888
@example
Packit d37888
glibtop_init ();
Packit d37888
@end example
Packit d37888
Packit d37888
@noindent
Packit d37888
which is equivalent to
Packit d37888
Packit d37888
@example
Packit d37888
glibtop_init_r (&glibtop_global_server, 0, 0);
Packit d37888
@end example
Packit d37888
Packit d37888
Please note that the @code{server_ptr} argument is a pointer to a pointer
Packit d37888
(and thus is of type @code{glibtop **}).
Packit d37888
Packit d37888
To control what @code{glibtop_init} should actually do, you can use the
Packit d37888
@code{features} and @code{flags} arguments.
Packit d37888
Packit d37888
The @code{features} argument is a bit-mask (interpreted in the same way
Packit d37888
than @samp{sysdeps.features}) and tells the library which features you're
Packit d37888
interested in. The library will only start the server if this is required
Packit d37888
for any of those features.
Packit d37888
Packit d37888
You can use the following constants for the @code{flags} parameter to
Packit d37888
control the behavior of the library:
Packit d37888
Packit d37888
@table @code
Packit d37888
@item GLIBTOP_INIT_NO_INIT
Packit d37888
Tells the library to do nothing. If the value pointed to by the
Packit d37888
@code{server_ptr} argument is @code{NULL}, it will set it to the
Packit d37888
@code{glibtop_global_server} and then return.
Packit d37888
@item GLIBTOP_INIT_NO_OPEN
Packit d37888
Do the initialization, but do not start the server.
Packit d37888
@end table
Packit d37888
Packit d37888
To modify the way the @code{features} are interpretet, you can use the
Packit d37888
following constants for @code{flags} (as a bit mask):
Packit d37888
Packit d37888
@table @code
Packit d37888
@item GLIBTOP_FEATURES_NO_SERVER
Packit d37888
Never use the server, always call the sysdeps code directly.
Packit d37888
If you require any privileges to get them and you don't have those
Packit d37888
privileges, the this will obviously not work and the library will
Packit d37888
fail to return some or all of the requested values.
Packit d37888
@item GLIBTOP_FEATURES_EXCEPT
Packit d37888
Inverts the matching of the @code{features} parameter, i.e. if you use
Packit d37888
this flag this means that @code{features} are all the features you are
Packit d37888
@emph{not} interested in.
Packit d37888
Might be useful to say something like "I want everything but ppp".
Packit d37888
@end table
Packit d37888
Packit d37888
@node glibtop_sysdeps, Library Parameters, glibtop_init, Library Functions
Packit d37888
@subsection Server Sysdeps
Packit d37888
Packit d37888
Library function @code{glibtop_get_sysdeps}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
void
Packit d37888
glibtop_get_sysdeps_r (glibtop *server, glibtop_sysdeps *buf);
Packit d37888
Packit d37888
void
Packit d37888
glibtop_get_sysdeps (glibtop_sysdeps *buf);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
Declaration of @code{glibtop_sysdeps} in @file{<glibtop/sysdeps.h>}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
typedef struct _glibtop_sysdeps         glibtop_sysdeps;
Packit d37888
Packit d37888
struct _glibtop_sysdeps
Packit d37888
@{
Packit d37888
    guint64 flags,
Packit d37888
        features,
Packit d37888
        pointer_size,
Packit d37888
        cpu,
Packit d37888
        mem,
Packit d37888
        swap,
Packit d37888
        uptime,
Packit d37888
        loadavg,
Packit d37888
        shm_limits,
Packit d37888
        msg_limits,
Packit d37888
        sem_limits,
Packit d37888
        proclist,
Packit d37888
        proc_state,
Packit d37888
        proc_uid,
Packit d37888
        proc_mem,
Packit d37888
        proc_time,
Packit d37888
        proc_signal,
Packit d37888
        proc_kernel,
Packit d37888
        proc_segment,
Packit d37888
        proc_args,
Packit d37888
        proc_map,
Packit d37888
        mountlist,
Packit d37888
        fsusage,
Packit d37888
        netload,
Packit d37888
        ppp;
Packit d37888
@};
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
@table @code
Packit d37888
@item features
Packit d37888
This is a bit field (the so-called @dfn{server features}) stating
Packit d37888
for which features we need to use the server.
Packit d37888
@item pointer_size
Packit d37888
This was added in LibGTop 1.1.0 and tells you the number of bits a
Packit d37888
@code{void*} has in the server (this may be different from the
Packit d37888
size on the client machine if we're talking over the daemon to a
Packit d37888
remove machine).
Packit d37888
@end table
Packit d37888
Packit d37888
The following constants from @file{<glibtop/sysdeps.h>} serve as bit-indices
Packit d37888
for the @code{features} field:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
#define GLIBTOP_SYSDEPS_CPU             0
Packit d37888
#define GLIBTOP_SYSDEPS_MEM             1
Packit d37888
#define GLIBTOP_SYSDEPS_SWAP            2
Packit d37888
#define GLIBTOP_SYSDEPS_UPTIME          3
Packit d37888
#define GLIBTOP_SYSDEPS_LOADAVG         4
Packit d37888
#define GLIBTOP_SYSDEPS_SHM_LIMITS      5
Packit d37888
#define GLIBTOP_SYSDEPS_MSG_LIMITS      6
Packit d37888
#define GLIBTOP_SYSDEPS_SEM_LIMITS      7
Packit d37888
#define GLIBTOP_SYSDEPS_PROCLIST        8
Packit d37888
#define GLIBTOP_SYSDEPS_PROC_STATE      9
Packit d37888
#define GLIBTOP_SYSDEPS_PROC_UID        10
Packit d37888
#define GLIBTOP_SYSDEPS_PROC_MEM        11
Packit d37888
#define GLIBTOP_SYSDEPS_PROC_TIME       12
Packit d37888
#define GLIBTOP_SYSDEPS_PROC_SIGNAL     13
Packit d37888
#define GLIBTOP_SYSDEPS_PROC_KERNEL     14
Packit d37888
#define GLIBTOP_SYSDEPS_PROC_SEGMENT    15
Packit d37888
#define GLIBTOP_SYSDEPS_PROC_ARGS       16
Packit d37888
#define GLIBTOP_SYSDEPS_PROC_MAP        17
Packit d37888
#define GLIBTOP_SYSDEPS_MOUNTLIST       18
Packit d37888
#define GLIBTOP_SYSDEPS_FSUSAGE         19
Packit d37888
#define GLIBTOP_SYSDEPS_NETLOAD         20
Packit d37888
#define GLIBTOP_SYSDEPS_PPP             21
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
@node Library Parameters,  , glibtop_sysdeps, Library Functions
Packit d37888
@subsection Library Parameters
Packit d37888
Packit d37888
Library function @code{glibtop_get_parameter}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
size_t
Packit d37888
glibtop_get_parameter_l (glibtop *server, const unsigned parameter,
Packit d37888
                         void *data_ptr, size_t data_size);
Packit d37888
Packit d37888
size_t
Packit d37888
glibtop_get_parameter (const unsigned parameter, void *data_ptr,
Packit d37888
                       size_t data_size);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
This function is used to retrieve a library parameter (see below for a more
Packit d37888
detailed description). It returns the size of the retrieved parameter on
Packit d37888
success, zero on failure or minus the actual size of the parameter if
Packit d37888
@code{data_size} was too small.
Packit d37888
Packit d37888
You may call this function with @code{data_ptr} set to @code{NULL} to get the
Packit d37888
actual size of a parameter (as a negative value).
Packit d37888
Packit d37888
@table @code
Packit d37888
@item parameter
Packit d37888
The parameter you want to retrieve (see below for constants).
Packit d37888
@item data_ptr
Packit d37888
Pointer to a place where the parameter should be stored.
Packit d37888
@item data_size
Packit d37888
Maximum size of the parameter.
Packit d37888
@end table
Packit d37888
Packit d37888
Library function @code{glibtop_set_parameter}:
Packit d37888
Packit d37888
@example
Packit d37888
@cartouche
Packit d37888
void
Packit d37888
glibtop_set_parameter_l (glibtop *server, const unsigned parameter,
Packit d37888
                         const void *data_ptr, size_t data_size);
Packit d37888
Packit d37888
void
Packit d37888
glibtop_set_parameter (const unsigned parameter, const void *data_ptr,
Packit d37888
                       size_t data_size);
Packit d37888
@end cartouche
Packit d37888
@end example
Packit d37888
Packit d37888
This function is used to modify a library parameter. Please not that you
Packit d37888
may not set all parameters since some of them are read-only.
Packit d37888
Packit d37888
@table @code
Packit d37888
@item parameter
Packit d37888
The parameter you want to modify (see below for constants).
Packit d37888
@item data_ptr
Packit d37888
Pointer to the value which should be set.
Packit d37888
@item data_size
Packit d37888
Size of the new value. For fixed-size parameters, this must match
Packit d37888
the exact size of the parameter or you'll get an error.
Packit d37888
@end table
Packit d37888
Packit d37888
The following parameters are defined in @file{<glibtop/parameter.h>}:
Packit d37888
Packit d37888
@table @code
Packit d37888
@item GLIBTOP_PARAM_FEATURES
Packit d37888
This is a read-only @code{unsigned long} representing the @code{features}
Packit d37888
field of @code{glibtop_sysdeps}.
Packit d37888
@item GLIBTOP_PARAM_REQUIRED
Packit d37888
This is a @code{glibtop_sysdeps} structure specifying which features the
Packit d37888
client requires the library return. If it fails to get any of them, you'll
Packit d37888
get an error.
Packit d37888
@item GLIBTOP_PARAM_ERROR_METHOD
Packit d37888
This is an @code{unsigned} telling the library what to do if it fails to
Packit d37888
get any of the features that are marked as required via the
Packit d37888
@code{GLIBTOP_PARAM_REQUIRED} parameter (see below for constants).
Packit d37888
@end table
Packit d37888
Packit d37888
You can use the following constants for @code{GLIBTOP_PARAM_ERROR_METHOD}
Packit d37888
(defined in @file{<glibtop/open.h>}):
Packit d37888
Packit d37888
@table @code
Packit d37888
@item GLIBTOP_ERROR_METHOD_IGNORE
Packit d37888
Ignore the error condition.
Packit d37888
@item GLIBTOP_ERROR_METHOD_WARN_ONCE
Packit d37888
Warn once about the absense of some of the required features, then modify
Packit d37888
@code{GLIBTOP_PARAM_REQUIRED} so that the missing ones are no longer
Packit d37888
required. This is the prefered value for applications since it'll only
Packit d37888
print out the warning message once and not each time the library tries to
Packit d37888
get one of those features.
Packit d37888
@item GLIBTOP_ERROR_METHOD_WARN
Packit d37888
Warn each time the library fails to get some of the required features.
Packit d37888
@item GLIBTOP_ERROR_METHOD_ABORT
Packit d37888
Abort if the library fails to get some of the required features. This
Packit d37888
should not be used by applications.
Packit d37888
@end table
Packit d37888