📄 reference.texi
字号:
@node Reference Manual, , White Paper, Top@chapter LibGTop Reference Manual@menu* System Dependent:: System Dependent Functions.* Common Functions:: Common Functions.* Library Functions:: Library Functions.@end menu@node System Dependent, Common Functions, Reference Manual, Reference Manual@section System Dependent Functions@menu* glibtop_cpu:: CPU Usage.* glibtop_mem:: Memory Usage.* glibtop_swap:: Swap Usage.* glibtop_uptime:: System Uptime.* glibtop_loadavg:: Load Average.* glibtop_proclist:: Process List.* glibtop_proc_state:: Process State.* glibtop_proc_uid:: Process UID and TTY Information.* glibtop_proc_mem:: Process Memory Information.* glibtop_proc_time:: Process Time Information.* glibtop_proc_signal:: Process Signal Information.* glibtop_proc_kernel:: Process Kernel Data Information.* glibtop_proc_segment:: Process Segment Information.* glibtop_proc_args:: Process Arguments.* glibtop_proc_map:: Process Memory Maps.* glibtop_netload:: Network Load.* glibtop_ppp:: PPP Usage.@end menu@node glibtop_cpu, glibtop_mem, System Dependent, System Dependent@subsection CPU UsageLibrary function @code{glibtop_get_cpu}:@example@cartouchevoid glibtop_get_cpu (glibtop_cpu *buf);void glibtop_get_cpu_l (glibtop *server, glibtop_cpu *buf);@end cartouche@end exampleDeclaration of @code{glibtop_cpu} in @file{<glibtop/cpu.h>}:@example@cartouchetypedef struct _glibtop_cpu glibtop_cpu;struct _glibtop_cpu@{ guint64 flags, total, user, nice, sys, idle, frequency, xcpu_total [GLIBTOP_NCPU], xcpu_user [GLIBTOP_NCPU], xcpu_nice [GLIBTOP_NCPU], xcpu_sys [GLIBTOP_NCPU],@ifset LIBGTOP-1-1 xcpu_idle [GLIBTOP_NCPU], xcpu_flags;@end ifset@ifclear LIBGTOP-1-1 xcpu_idle [GLIBTOP_NCPU];@end ifclear@};@end cartouche@end exampleAll CPU units are measured in @dfn{jiffies} which are normally 1/100th of asecond (in which case @code{frequency} equals 100), but can also be in anyother unit. To get seconds, divide them by @code{frequency}.@table @code@item totalNumber of clock ticks since system boot.@item userNumber of clock ticks the system spent in user mode.@item niceNumber of clock ticks the system spent in user mode (nice).@item sysNumber of clock ticks the system spent in system mode.@item idleNumber of clock ticks the system spent in the idle task.@item frequencyTick frequency (default is 100).@end tableThe @samp{xcpu_} values are for SMP systems - they are the same than@code{total}, @code{user}, @code{nice}, @code{sys} and @code{idle}except that they are arrays of @code{GLIBTOP_NCPU} (defined in@file{<glibtop/limits.h>}) elements and contain one value for each CPUin the system.@ifset LIBGTOP-1-1@table @code@item xcpu_flagsThis is interpreted as a bit-field: on systems like Solaris, not all CPUsneed to be running all the time, so we set the corresponding bit for eachCPU that is currently running.@end table@end ifsetPlease note that all of the cpu values are absolute values measured incertain units (to get seconds, divide them by @code{frequency}) since systemboot. To get percentual values, you need to call @code{glibtop_cpu}, save theresult, wait some time and then call it again and divide the differences ofthe two values by the time you have waited.@page@node glibtop_mem, glibtop_swap, glibtop_cpu, System Dependent@subsection Memory UsageLibrary function @code{glibtop_get_mem}:@example@cartouchevoid glibtop_get_mem (glibtop_mem *buf);void glibtop_get_mem_l (glibtop *server, glibtop_mem *buf);@end cartouche@end exampleDeclaration of @code{glibtop_mem} in @file{<glibtop/mem.h>}:@example@cartouchetypedef struct _glibtop_mem glibtop_mem;struct _glibtop_mem@{ guint64 flags, total, used, free, shared, buffer, cached, user, locked;@};@end cartouche@end exampleUnless explicitly stated otherwise, all memory units are in bytes.@table @code@item totalTotal physical memory.@item usedUsed memory size.@item freeFree memory size.@item sharedShared memory size.This are both segments that are @code{mmap()}ed with @code{MAP_SHARED} andIPC Shared Memory segments.@item bufferSize of buffers.@item cachedSize of cached memory.@item userMemory used from user processes.This is normally @code{total - free - shared - buffer - cached}.@item lockedMemory in locked segments.@end table@page@node glibtop_swap, glibtop_uptime, glibtop_mem, System Dependent@subsection Swap UsageLibrary function @code{glibtop_get_swap}:@example@cartouchevoid glibtop_get_swap (glibtop_swap *buf);void glibtop_get_swap_l (glibtop *server, glibtop_swap *buf);@end cartouche@end exampleDeclaration of @code{glibtop_swap} in @file{<glibtop/swap.h>}:@example@cartouchetypedef struct _glibtop_swap glibtop_swap;struct _glibtop_swap@{ guint64 flags, total, used, free, pagein, pageout;@};@end cartouche@end exampleThe following units are in bytes.@table @code@item totalTotal swap space in the system.@item usedUsed swap space.@item freeFree swap space.@end tableYou can use @code{pagein} and @code{pageout} to get some measure about howmuch the system is swapping at the moment. They're increased each time a pageis swapped in or out, so you need to save this values, wait a little bit, getthem again and then compare the two results to find out how much the systemswapped in the meantime.@table @code@item pageinTotal number of swap pages that have been brought in since system boot@item pageoutTotal number of swap pages that have been brought out since system boot@end table@page@node glibtop_uptime, glibtop_loadavg, glibtop_swap, System Dependent@subsection UptimeLibrary function @code{glibtop_get_uptime}:@example@cartouchevoid glibtop_get_uptime (glibtop_uptime *buf);void glibtop_get_uptime_l (glibtop *server, glibtop_uptime *buf);@end cartouche@end exampleDeclaration of @code{glibtop_uptime} in @file{<glibtop/uptime.h>}:@example@cartouchetypedef struct _glibtop_uptime glibtop_uptime;struct _glibtop_uptime@{ guint64 flags; double uptime, idletime; guint64 boot_time;@};@end cartouche@end exampleWhen porting LibGTop to a new system, you only need to implement @code{uptime}and @code{idletime} if there's a faster or better way to obtain them as using@code{glibtop_cpu} for it. Look at @file{sysdeps/freebsd/uptime.c} for anexample on how to obtain them using @code{glibtop_cpu}.@table @code@item uptimeTime in seconds since system boot.@item idletimeTime in seconds the system spent in the idle task since system boot.@end tableThe following one was from a request on the @samp{linux-kernel} mailing list;on a laptop with advanced power management @code{glibtop_cpu.total} may notreflect the correct boot time of the system if the power was turned off bymeans of APM in the meantime.@table @code@item boot_timeTime of last system boot in seconds since the epoch.@end table@page@node glibtop_loadavg, glibtop_proclist, glibtop_uptime, System Dependent@subsection Load AverageLibrary function @code{glibtop_get_loadavg}:@example@cartouchevoid glibtop_get_loadavg (glibtop_loadavg *buf);void glibtop_get_loadavg_l (glibtop *server, glibtop_loadavg *buf);@end cartouche@end exampleDeclaration of @code{glibtop_loadavg} in @file{<glibtop/loadavg.h>}:@example@cartouchetypedef struct _glibtop_loadavg glibtop_loadavg;struct _glibtop_loadavg@{ guint64 flags; double loadavg [3]; guint64 nr_running, nr_tasks, last_pid;@};@end cartouche@end example@table @code@item loadavgNumber of jobs running simultaneously averaged over 1, 5 and 15 minutes.@end tableThe following fields are Linux specific and deprecated. You don't need toimplement them when porting LibGTop to a new system as they may be removedin a future version.@table @code@item nr_runningNumber of tasks currently running.@item nr_tasksTotal number of tasks.@item last_pidLast PID.@end table@page@node glibtop_proclist, glibtop_proc_state, glibtop_loadavg, System Dependent@subsection Process ListLibrary function @code{glibtop_get_proclist}:@example@cartoucheunsigned *glibtop_get_proclist (glibtop_proclist *buf, int64_t which, int64_t arg);unsigned *glibtop_get_proclist_l (glibtop *server, glibtop_proclist *buf, int64_t which, int64_t arg);@end cartouche@end exampleConstants for the @code{which} argument:@example@cartouche#define GLIBTOP_KERN_PROC_ALL 0#define GLIBTOP_KERN_PROC_PID 1#define GLIBTOP_KERN_PROC_PGRP 2#define GLIBTOP_KERN_PROC_SESSION 3#define GLIBTOP_KERN_PROC_TTY 4#define GLIBTOP_KERN_PROC_UID 5#define GLIBTOP_KERN_PROC_RUID 6#define GLIBTOP_KERN_PROC_MASK 15#define GLIBTOP_EXCLUDE_IDLE 0x1000#define GLIBTOP_EXCLUDE_SYSTEM 0x2000#define GLIBTOP_EXCLUDE_NOTTY 0x4000@end cartouche@end exampleDeclaration of @code{glibtop_proclist} in @file{<glibtop/proclist.h>}:@example@cartouchetypedef struct _glibtop_proclist glibtop_proclist;struct _glibtop_proclist@{ guint64 flags, number, total, size;@};@end cartouche@end exampleThis function returns a list of all or a selected subset of all runningprocesses. You can use the @code{which} and @code{arg} arguments tospecify which processes should be returned.You can use the following values for the @code{which} argument:@table @code@item GLIBTOP_KERN_PROC_ALLReturn information about all processes (the @code{arg} argument is ignored).@item GLIBTOP_KERN_PROC_PIDReturn information about all process with the pid @var{PID} which is passedin @code{arg}. You can use this to find out whether some process still exists.@item GLIBTOP_KERN_PROC_PGRPReturn all processes in process group @var{PGRP} which is passed in@code{arg}.@item GLIBTOP_KERN_PROC_SESSIONReturn all processes in session @var{SESSION} which is passed in @code{arg}.@item GLIBTOP_KERN_PROC_TTYReturn all processes which have the controlling tty @var{TTY} which is passedin @code{arg} (@var{TTY} is interpreted as device number).@item GLIBTOP_KERN_PROC_UIDReturn all processes with effective uid @var{UID} which is passed in @code{arg}.@item GLIBTOP_KERN_PROC_RUIDReturn all processes with real uid @var{RUID} which is passed in @code{arg}.@end tableYou can alter the list of returned processes by using a binary OR of@code{which} and the following constants:@table @code@item GLIBTOP_EXCLUDE_IDLEExclude idle processes.@item GLIBTOP_EXCLUDE_SYSTEMExclude system processes.@item GLIBTOP_EXCLUDE_NOTTYExclude processes without a controlling terminal.@end tableThe return value of @code{glibtop_get_proclist} is either @code{NULL} onerror or a @code{unsigned *} list of pids. Additionally, the following fields
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -