--- projects/libstatgrab/docs/sg_get_process_stats.xml 2004/05/02 17:39:19 1.6 +++ projects/libstatgrab/docs/sg_get_process_stats.xml 2004/05/04 19:28:06 1.7 @@ -3,20 +3,21 @@ - + - $Date: 2004/05/02 17:39:19 $ - $Id: sg_get_process_stats.xml,v 1.6 2004/05/02 17:39:19 tdb Exp $ + $Date: 2004/05/04 19:28:06 $ + $Id: sg_get_process_stats.xml,v 1.7 2004/05/04 19:28:06 tdb Exp $ - sg_get_process_count + sg_get_process_stats 3 i-scream + sg_get_process_stats sg_get_process_count get process statistics @@ -25,6 +26,10 @@ #include <statgrab.h> + sg_process_stats *sg_get_process_stats + int *entries + + sg_process_count *sg_get_process_count @@ -34,12 +39,21 @@ Description + The sg_get_process_stats takes a pointer to + an int, entries, which is filled with the + number of processes the snapshot contains. A pointer to the first + entry, of type sg_process_stats is + returned, and entries can be used to iterate + through to the last entry. + + sg_get_process_count returns a pointer to a static buffer of type sg_process_count. - It provides information on the number of processes and the - system and the different states they're in. + These two functions provide information on the process running + on the system. In the first case lots of detail is provided, and + in the second case a summary of the states of the current processes. @@ -47,7 +61,171 @@ Return Values - The structure returned is of type + The structure returned by sg_get_process_stats is of type + sg_process_stats. + + + +typedef struct { + char *process_name; + char *proctitle; + + pid_t pid; + pid_t parent; /* Parent pid */ + pid_t pgid; /* process id of process group leader */ + + uid_t uid; + uid_t euid; + gid_t gid; + gid_t egid; + + unsigned long long proc_size; /* in bytes */ + unsigned long long proc_resident; /* in bytes */ + time_t time_spent; /* time running in seconds */ + double cpu_percent; + int nice; + sg_process_state state; +} sg_process_stats; + + + +typedef enum { + SG_PROCESS_STATE_RUNNING, + SG_PROCESS_STATE_SLEEPING, + SG_PROCESS_STATE_STOPPED, + SG_PROCESS_STATE_ZOMBIE, + SG_PROCESS_STATE_UNKNOWN +} sg_process_state; + + + + + process_name + + + The name of the command that was run. + + + + + proctitle + + + The command line (the "title") of the process. Take + note - this can be modified by the process, so isn't + guaranteed to be the original command line. + + + + + pid + + + The process ID. + + + + + parent + + + The parent process ID. + + + + + pgid + + + The process ID of the process group leader. + + + + + uid + + + The UID the process is running as. + + + + + euid + + + The effective UID the process is running as. + + + + + gid + + + The GID the process is running as. + + + + + egid + + + The effective GID the process is running as. + + + + + proc_size + + + The size of the process in bytes. + + + + + proc_resident + + + The size of the process that's resident in memory. + + + + + time_spent + + + The number of seconds the process has been running. + + + + + cpu_percent + + + The current percentage of CPU the process is using. + + + + + nice + + + The nice value of the process. + + + + + state + + + The current state of the process. See sg_process_state + for permitted values. + + + + + + + The structure returned by sg_get_process_count is of type sg_process_count.