45 lines
970 B
C
45 lines
970 B
C
|
|
/* retoor <retoor@molodetz.nl> */
|
||
|
|
#ifndef PROCESS_H
|
||
|
|
#define PROCESS_H
|
||
|
|
|
||
|
|
#define MAX_PROCESSES 4096
|
||
|
|
#define MAX_CMD_LEN 256
|
||
|
|
#define MAX_USER_LEN 64
|
||
|
|
|
||
|
|
typedef struct {
|
||
|
|
int pid;
|
||
|
|
int ppid;
|
||
|
|
int uid;
|
||
|
|
char user[MAX_USER_LEN];
|
||
|
|
char state;
|
||
|
|
char cmd[MAX_CMD_LEN];
|
||
|
|
int threads;
|
||
|
|
int priority;
|
||
|
|
int nice;
|
||
|
|
unsigned long vsize;
|
||
|
|
unsigned long rss;
|
||
|
|
unsigned long utime;
|
||
|
|
unsigned long stime;
|
||
|
|
unsigned long prev_utime;
|
||
|
|
unsigned long prev_stime;
|
||
|
|
double cpu_percent;
|
||
|
|
double mem_percent;
|
||
|
|
} ProcessInfo;
|
||
|
|
|
||
|
|
typedef struct {
|
||
|
|
int total;
|
||
|
|
int running;
|
||
|
|
int sleeping;
|
||
|
|
int stopped;
|
||
|
|
int zombie;
|
||
|
|
int count;
|
||
|
|
ProcessInfo processes[MAX_PROCESSES];
|
||
|
|
} ProcessList;
|
||
|
|
|
||
|
|
int process_list_init(ProcessList *list);
|
||
|
|
int process_list_update(ProcessList *list, unsigned long total_mem, double interval, int num_cpus);
|
||
|
|
void process_list_sort_by_cpu(ProcessList *list);
|
||
|
|
void process_list_sort_by_mem(ProcessList *list);
|
||
|
|
|
||
|
|
#endif
|