version 1.6, 2002/07/15 17:20:36 |
version 1.7, 2003/06/13 21:52:25 |
|
|
/* $OpenBSD$ */ |
/* $OpenBSD$ */ |
|
|
/* |
/* |
* Top users/processes display for Unix |
* Top users/processes display for Unix |
|
|
/* |
/* |
* the statics struct is filled in by machine_init |
* the statics struct is filled in by machine_init |
*/ |
*/ |
struct statics |
struct statics { |
{ |
char **procstate_names; |
char **procstate_names; |
char **cpustate_names; |
char **cpustate_names; |
char **memory_names; |
char **memory_names; |
char **order_names; |
#ifdef ORDER |
|
char **order_names; |
|
#endif |
|
}; |
}; |
|
|
/* |
/* |
* the system_info struct is filled in by a machine dependent routine. |
* the system_info struct is filled in by a machine dependent routine. |
*/ |
*/ |
|
|
struct system_info |
struct system_info { |
{ |
pid_t last_pid; |
pid_t last_pid; |
double load_avg[NUM_AVERAGES]; |
double load_avg[NUM_AVERAGES]; |
int p_total; |
int p_total; |
int p_active; /* number of procs considered |
int p_active; /* number of procs considered "active" */ |
* "active" */ |
int *procstates; |
int *procstates; |
int *cpustates; |
int *cpustates; |
int *memory; |
int *memory; |
}; |
}; |
|
|
/* cpu_states is an array of percentages * 10. For example, |
/* |
the (integer) value 105 is 10.5% (or .105). |
* cpu_states is an array of percentages * 10. For example, the (integer) |
|
* value 105 is 10.5% (or .105). |
*/ |
*/ |
|
|
/* |
/* |
|
|
* are interested in seeing |
* are interested in seeing |
*/ |
*/ |
|
|
struct process_select |
struct process_select { |
{ |
int idle; /* show idle processes */ |
int idle; /* show idle processes */ |
int system; /* show system processes */ |
int system; /* show system processes */ |
int uid; /* only this uid (unless uid == -1) */ |
int uid; /* only this uid (unless uid == -1) */ |
char *command;/* only this command (unless == NULL) */ |
char *command; /* only this command (unless == NULL) */ |
|
}; |
}; |
|
|
/* prototypes */ |
/* prototypes */ |
extern int display_init(struct statics *); |
extern int display_init(struct statics *); |
|
|
/* machine.c */ |
/* machine.c */ |
extern int machine_init(struct statics *); |
extern int machine_init(struct statics *); |
extern char *format_header(char *); |
extern char *format_header(char *); |
extern void get_system_info(struct system_info *); |
extern void get_system_info(struct system_info *); |
extern caddr_t get_process_info(struct system_info *, struct process_select *, |
extern caddr_t |
int (*)(const void *, const void *)); |
get_process_info(struct system_info *, struct process_select *, |
extern char *format_next_process(caddr_t, char *(*)()); |
int (*) (const void *, const void *)); |
extern int proc_compate(const void *, const void *); |
extern char *format_next_process(caddr_t, char *(*) ()); |
extern int proc_owner(pid_t); |
extern int proc_compate(const void *, const void *); |
|
extern int proc_owner(pid_t); |