*** empty log message ***
This commit is contained in:
@@ -7,6 +7,20 @@
|
|||||||
#define NR_TASKS 512
|
#define NR_TASKS 512
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TABLE_KERN_PROC_ALL 0 /* all processes */
|
||||||
|
#define TABLE_KERN_PROC_PID 1
|
||||||
|
#define TABLE_KERN_PROC_PGRP 2
|
||||||
|
#define TABLE_KERN_PROC_SESSION 3
|
||||||
|
#define TABLE_KERN_PROC_TTY 4
|
||||||
|
#define TABLE_KERN_PROC_UID 5
|
||||||
|
#define TABLE_KERN_PROC_RUID 6
|
||||||
|
|
||||||
|
#define TABLE_KERN_PROC_MASK 15
|
||||||
|
|
||||||
|
#define TABLE_EXCLUDE_IDLE 0x1000
|
||||||
|
#define TABLE_EXCLUDE_SYSTEM 0x2000
|
||||||
|
#define TABLE_EXCLUDE_NOTTY 0x4000
|
||||||
|
|
||||||
#define TABLE_VERSION 0
|
#define TABLE_VERSION 0
|
||||||
#define TABLE_CPU 1
|
#define TABLE_CPU 1
|
||||||
#define TABLE_MEM 2
|
#define TABLE_MEM 2
|
||||||
@@ -77,6 +91,11 @@ struct table_uptime
|
|||||||
|
|
||||||
/* Process list. */
|
/* Process list. */
|
||||||
|
|
||||||
|
struct proclist_args
|
||||||
|
{
|
||||||
|
int which, arg;
|
||||||
|
};
|
||||||
|
|
||||||
struct table_proclist
|
struct table_proclist
|
||||||
{
|
{
|
||||||
int nr_running, nr_tasks, last_pid;
|
int nr_running, nr_tasks, last_pid;
|
||||||
@@ -90,6 +109,7 @@ struct table_proc_state
|
|||||||
long state;
|
long state;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
char comm[16];
|
char comm[16];
|
||||||
|
int uid, gid;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct table_proc_uid
|
struct table_proc_uid
|
||||||
|
@@ -189,6 +189,9 @@ sys_table (int type, union table *buf, const void *param)
|
|||||||
union table tbl;
|
union table tbl;
|
||||||
struct sysinfo i;
|
struct sysinfo i;
|
||||||
struct task_struct *tsk = NULL;
|
struct task_struct *tsk = NULL;
|
||||||
|
struct ip_chain *chain;
|
||||||
|
struct ip_fwkernel *rule;
|
||||||
|
char devname [9];
|
||||||
int index, err;
|
int index, err;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
@@ -219,6 +222,14 @@ sys_table (int type, union table *buf, const void *param)
|
|||||||
if (tsk == NULL)
|
if (tsk == NULL)
|
||||||
return -ESRCH;
|
return -ESRCH;
|
||||||
break;
|
break;
|
||||||
|
case TABLE_NETACCT:
|
||||||
|
err = verify_area (VERIFY_READ, param, 5);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
copy_from_user (devname, param, 5);
|
||||||
|
devname [5] = 0;
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Main function dispatcher */
|
/* Main function dispatcher */
|
||||||
@@ -426,6 +437,24 @@ sys_table (int type, union table *buf, const void *param)
|
|||||||
|
|
||||||
tbl.proc_kernel.wchan = get_wchan (tsk);
|
tbl.proc_kernel.wchan = get_wchan (tsk);
|
||||||
break;
|
break;
|
||||||
|
case TABLE_NETACCT:
|
||||||
|
for (chain = ip_fw_chains; chain; chain = chain->next) {
|
||||||
|
for (rule = chain->chain; rule; rule = rule->next) {
|
||||||
|
const char *name = rule->ipfw.fw_vianame;
|
||||||
|
int k;
|
||||||
|
|
||||||
|
if (name [0] && !strncmp (param, name, 5))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (k = 0; k < NUM_SLOTS; k++) {
|
||||||
|
tbl.netacct.packets +=
|
||||||
|
rule->counters[k].pcnt;
|
||||||
|
tbl.netacct.bytes +=
|
||||||
|
rule->counters[k].bcnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@@ -304,8 +304,9 @@ table_fkt (int type, union table *buf, const void *param)
|
|||||||
union table tbl;
|
union table tbl;
|
||||||
struct sysinfo i;
|
struct sysinfo i;
|
||||||
struct task_struct *tsk = NULL;
|
struct task_struct *tsk = NULL;
|
||||||
|
struct proclist_args plistargs;
|
||||||
|
int index, tindex, err, tty;
|
||||||
sigset_t sigign, sigcatch;
|
sigset_t sigign, sigcatch;
|
||||||
int index, tindex, err;
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
if (type == TABLE_VERSION)
|
if (type == TABLE_VERSION)
|
||||||
@@ -339,6 +340,14 @@ table_fkt (int type, union table *buf, const void *param)
|
|||||||
if (tsk == NULL)
|
if (tsk == NULL)
|
||||||
return -ESRCH;
|
return -ESRCH;
|
||||||
break;
|
break;
|
||||||
|
case TABLE_PROCLIST:
|
||||||
|
err = verify_area (VERIFY_READ, param,
|
||||||
|
sizeof (struct proclist_args));
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
copy_from_user (&plistargs, param,
|
||||||
|
sizeof (struct proclist_args));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Main function dispatcher */
|
/* Main function dispatcher */
|
||||||
@@ -347,10 +356,40 @@ table_fkt (int type, union table *buf, const void *param)
|
|||||||
case TABLE_PROCLIST:
|
case TABLE_PROCLIST:
|
||||||
tsk = task [0];
|
tsk = task [0];
|
||||||
read_lock (&tasklist_lock);
|
read_lock (&tasklist_lock);
|
||||||
for (index = tindex = 0; index < nr_tasks; index++) {
|
for (index = tindex = 0; index < nr_tasks;
|
||||||
if (tsk->pid)
|
index++, tsk = tsk->next_task) {
|
||||||
|
if (tsk->pid == 0) continue;
|
||||||
|
switch (plistargs.which & TABLE_KERN_PROC_MASK) {
|
||||||
|
case TABLE_KERN_PROC_PID:
|
||||||
|
if (tsk->pid != plistargs.arg) continue;
|
||||||
|
break;
|
||||||
|
case TABLE_KERN_PROC_PGRP:
|
||||||
|
if (tsk->pgrp != plistargs.arg) continue;
|
||||||
|
break;
|
||||||
|
case TABLE_KERN_PROC_SESSION:
|
||||||
|
if (tsk->session != plistargs.arg) continue;
|
||||||
|
case TABLE_KERN_PROC_TTY:
|
||||||
|
tty = tsk->tty ?
|
||||||
|
kdev_t_to_nr (tsk->tty->device) : 0;
|
||||||
|
if (tty != plistargs.arg) continue;
|
||||||
|
break;
|
||||||
|
case TABLE_KERN_PROC_UID:
|
||||||
|
if (tsk->uid != plistargs.arg) continue;
|
||||||
|
break;
|
||||||
|
case TABLE_KERN_PROC_RUID:
|
||||||
|
if (tsk->euid != plistargs.arg) continue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((plistargs.which & TABLE_EXCLUDE_IDLE) &&
|
||||||
|
(tsk->state != 0))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ((plistargs.which & TABLE_EXCLUDE_NOTTY) &&
|
||||||
|
(tsk->tty == NULL))
|
||||||
|
continue;
|
||||||
|
|
||||||
tbl.proclist.pids [tindex++] = tsk->pid;
|
tbl.proclist.pids [tindex++] = tsk->pid;
|
||||||
tsk = tsk->next_task;
|
|
||||||
}
|
}
|
||||||
tbl.proclist.nr_running = nr_running;
|
tbl.proclist.nr_running = nr_running;
|
||||||
tbl.proclist.last_pid = last_pid;
|
tbl.proclist.last_pid = last_pid;
|
||||||
@@ -395,6 +434,8 @@ table_fkt (int type, union table *buf, const void *param)
|
|||||||
task[0]->times.tms_stime;
|
task[0]->times.tms_stime;
|
||||||
break;
|
break;
|
||||||
case TABLE_PROC_STATE:
|
case TABLE_PROC_STATE:
|
||||||
|
tbl.proc_state.uid = tsk->uid;
|
||||||
|
tbl.proc_state.gid = tsk->gid;
|
||||||
tbl.proc_state.state = tsk->state;
|
tbl.proc_state.state = tsk->state;
|
||||||
tbl.proc_state.flags = tsk->flags;
|
tbl.proc_state.flags = tsk->flags;
|
||||||
memcpy (tbl.proc_state.comm, tsk->comm,
|
memcpy (tbl.proc_state.comm, tsk->comm,
|
||||||
|
1
kernel/version.h
Normal file
1
kernel/version.h
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#define _TABLE_VERSION 1
|
@@ -59,12 +59,16 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
|
|||||||
{
|
{
|
||||||
union table tbl;
|
union table tbl;
|
||||||
unsigned *pids_chain;
|
unsigned *pids_chain;
|
||||||
|
struct proclist_args args;
|
||||||
|
|
||||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROCLIST, 0);
|
glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROCLIST, 0);
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_proclist));
|
memset (buf, 0, sizeof (glibtop_proclist));
|
||||||
|
|
||||||
if (table (TABLE_PROCLIST, &tbl, NULL))
|
args.which = which;
|
||||||
|
args.arg = arg;
|
||||||
|
|
||||||
|
if (table (TABLE_PROCLIST, &tbl, &args))
|
||||||
glibtop_error_io_r (server, "table(TABLE_PROCLIST)");
|
glibtop_error_io_r (server, "table(TABLE_PROCLIST)");
|
||||||
|
|
||||||
buf->size = sizeof (unsigned);
|
buf->size = sizeof (unsigned);
|
||||||
|
@@ -26,7 +26,8 @@
|
|||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
|
||||||
static const unsigned long _glibtop_sysdeps_proc_state =
|
static const unsigned long _glibtop_sysdeps_proc_state =
|
||||||
(1 << GLIBTOP_PROC_STATE_CMD) + (1 << GLIBTOP_PROC_STATE_STATE);
|
(1 << GLIBTOP_PROC_STATE_CMD) + (1 << GLIBTOP_PROC_STATE_STATE) +
|
||||||
|
(1 << GLIBTOP_PROC_STATE_UID) + (1 << GLIBTOP_PROC_STATE_GID);
|
||||||
|
|
||||||
/* Init function. */
|
/* Init function. */
|
||||||
|
|
||||||
@@ -60,6 +61,9 @@ glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf,
|
|||||||
|
|
||||||
memcpy (buf->cmd, tbl.proc_state.comm, sizeof (tbl.proc_state.comm));
|
memcpy (buf->cmd, tbl.proc_state.comm, sizeof (tbl.proc_state.comm));
|
||||||
|
|
||||||
|
buf->uid = tbl.proc_state.uid;
|
||||||
|
buf->gid = tbl.proc_state.state;
|
||||||
|
|
||||||
state = (unsigned) tbl.proc_state.state;
|
state = (unsigned) tbl.proc_state.state;
|
||||||
|
|
||||||
if (state >= NR_STATES)
|
if (state >= NR_STATES)
|
||||||
|
Reference in New Issue
Block a user