*** empty log message ***

This commit is contained in:
Martin Baulig
1999-03-22 14:34:34 +00:00
parent 33021311b2
commit ec9aedea0b
9 changed files with 188 additions and 14 deletions

1
kernel/sysctl/.cvsignore Normal file
View File

@@ -0,0 +1 @@
*.flags

View File

@@ -38,6 +38,13 @@ BEGIN_LIBGTOP_DECLS
int glibtop_get_proc_data_stat_s (glibtop *server, libgtop_stat_t *stat);
int glibtop_get_proc_data_mem_s (glibtop *server, libgtop_mem_t *mem);
int glibtop_get_proc_data_swap_s (glibtop *server, libgtop_swap_t *swap);
int glibtop_get_proc_data_proclist_s (glibtop *server,
libgtop_proclist_t *proclist,
u_int64_t which, u_int64_t arg);
int glibtop_get_proc_data_proc_state_s (glibtop *server,
libgtop_proc_state_t *proc_state,
pid_t pid);
END_LIBGTOP_DECLS

View File

@@ -65,3 +65,36 @@ glibtop_get_proc_data_swap_s (glibtop *server, libgtop_swap_t *swap)
return 0;
}
int
glibtop_get_proc_data_proclist_s (glibtop *server,
libgtop_proclist_t *proclist,
u_int64_t which, u_int64_t arg)
{
int name [4] = { CTL_LIBGTOP, LIBGTOP_PROCLIST, which, arg };
size_t size = sizeof (libgtop_proclist_t);
if (sysctl (name, 4, proclist, &size, NULL, 0)) {
glibtop_warn_io_r (server, "sysctl (libgtop/proclist)");
return -1;
}
return 0;
}
int
glibtop_get_proc_data_proc_state_s (glibtop *server,
libgtop_proc_state_t *proc_state,
pid_t pid)
{
int name [3] = { CTL_LIBGTOP, LIBGTOP_PROC_STATE, pid };
size_t size = sizeof (libgtop_proc_state_t);
if (sysctl (name, 3, proc_state, &size, NULL, 0)) {
glibtop_warn_io_r (server, "sysctl (libgtop/proc_state)");
return -1;
}
return 0;
}

View File

@@ -24,14 +24,22 @@
#include <glibtop.h>
#include <glibtop/prockernel.h>
static const unsigned long _glibtop_sysdeps_proc_kernel = 0;
#include <glibtop_private.h>
static const unsigned long _glibtop_sysdeps_proc_kernel =
(1 << GLIBTOP_PROC_KERNEL_MIN_FLT) +
(1 << GLIBTOP_PROC_KERNEL_MAJ_FLT) +
(1 << GLIBTOP_PROC_KERNEL_CMIN_FLT) +
(1 << GLIBTOP_PROC_KERNEL_CMAJ_FLT) +
(1 << GLIBTOP_PROC_KERNEL_KSTK_ESP) +
(1 << GLIBTOP_PROC_KERNEL_KSTK_EIP);
/* Init function. */
void
glibtop_init_proc_kernel_s (glibtop *server)
{
server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel;
server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel;
}
/* Provides detailed information about a process. */
@@ -40,5 +48,19 @@ void
glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf,
pid_t pid)
{
memset (buf, 0, sizeof (glibtop_proc_kernel));
libgtop_proc_state_t proc_state;
memset (buf, 0, sizeof (glibtop_proc_kernel));
if (glibtop_get_proc_data_proc_state_s (server, &proc_state, pid))
return;
buf->min_flt = proc_state.min_flt;
buf->maj_flt = proc_state.maj_flt;
buf->cmin_flt = proc_state.cmin_flt;
buf->cmaj_flt = proc_state.cmaj_flt;
buf->kstk_esp = proc_state.kesp;
buf->kstk_eip = proc_state.keip;
buf->flags = _glibtop_sysdeps_proc_kernel;
}

View File

@@ -22,8 +22,11 @@
*/
#include <glibtop.h>
#include <glibtop/xmalloc.h>
#include <glibtop/proclist.h>
#include <glibtop_private.h>
#define GLIBTOP_PROCLIST_FLAGS 3
static const unsigned long _glibtop_sysdeps_proclist = 0;
@@ -33,7 +36,7 @@ static const unsigned long _glibtop_sysdeps_proclist = 0;
void
glibtop_init_proclist_s (glibtop *server)
{
server->sysdeps.proclist = _glibtop_sysdeps_proclist;
server->sysdeps.proclist = _glibtop_sysdeps_proclist;
}
/* Fetch list of currently running processes.
@@ -47,6 +50,23 @@ unsigned *
glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
int64_t which, int64_t arg)
{
memset (buf, 0, sizeof (glibtop_proclist));
libgtop_proclist_t proclist;
unsigned *ret;
int i;
memset (buf, 0, sizeof (glibtop_proclist));
if (glibtop_get_proc_data_proclist_s (server, &proclist, which, arg))
return NULL;
ret = glibtop_calloc_r (server, proclist.count, sizeof (unsigned));
buf->number = proclist.count;
buf->size = sizeof (unsigned);
buf->total = proclist.count * sizeof (unsigned);
for (i = 0; i < proclist.count; i++)
ret [i] = proclist.pids [i];
return ret;
}

View File

@@ -24,14 +24,18 @@
#include <glibtop.h>
#include <glibtop/procstate.h>
static const unsigned long _glibtop_sysdeps_proc_state = 0;
#include <glibtop_private.h>
static const unsigned long _glibtop_sysdeps_proc_state =
(1 << GLIBTOP_PROC_STATE_UID) + (1 << GLIBTOP_PROC_STATE_GID) +
(1 << GLIBTOP_PROC_STATE_CMD);
/* Init function. */
void
glibtop_init_proc_state_s (glibtop *server)
{
server->sysdeps.proc_state = _glibtop_sysdeps_proc_state;
server->sysdeps.proc_state = _glibtop_sysdeps_proc_state;
}
/* Provides detailed information about a process. */
@@ -40,5 +44,16 @@ void
glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf,
pid_t pid)
{
memset (buf, 0, sizeof (glibtop_proc_state));
libgtop_proc_state_t proc_state;
memset (buf, 0, sizeof (glibtop_proc_state));
if (glibtop_get_proc_data_proc_state_s (server, &proc_state, pid))
return;
memcpy (buf->cmd, proc_state.comm, sizeof (buf->cmd));
buf->uid = proc_state.uid;
buf->gid = proc_state.gid;
buf->flags = _glibtop_sysdeps_proc_state;
}

View File

@@ -24,14 +24,25 @@
#include <glibtop.h>
#include <glibtop/proctime.h>
static const unsigned long _glibtop_sysdeps_proc_time = 0;
#include <glibtop_private.h>
static const unsigned long _glibtop_sysdeps_proc_time =
(1 << GLIBTOP_PROC_TIME_UTIME) + (1 << GLIBTOP_PROC_TIME_STIME) +
(1 << GLIBTOP_PROC_TIME_CUTIME) + (1 << GLIBTOP_PROC_TIME_CSTIME) +
(1 << GLIBTOP_PROC_TIME_START_TIME) + (1 << GLIBTOP_PROC_TIME_FREQUENCY);
static const unsigned long _glibtop_sysdeps_proc_time_smp =
(1 << GLIBTOP_PROC_TIME_XCPU_UTIME) + (1 << GLIBTOP_PROC_TIME_XCPU_STIME);
/* Init function. */
void
glibtop_init_proc_time_s (glibtop *server)
{
server->sysdeps.proc_time = _glibtop_sysdeps_proc_time;
server->sysdeps.proc_time = _glibtop_sysdeps_proc_time;
if (server->ncpu)
server->sysdeps.proc_time |= _glibtop_sysdeps_proc_time_smp;
}
/* Provides detailed information about a process. */
@@ -40,5 +51,29 @@ void
glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf,
pid_t pid)
{
memset (buf, 0, sizeof (glibtop_proc_time));
libgtop_proc_state_t proc_state;
int i;
memset (buf, 0, sizeof (glibtop_proc_time));
if (glibtop_get_proc_data_proc_state_s (server, &proc_state, pid))
return;
buf->start_time = proc_state.start_time;
buf->utime = proc_state.utime;
buf->stime = proc_state.stime;
buf->cutime = proc_state.cutime;
buf->cstime = proc_state.cstime;
buf->frequency = 100;
buf->flags = _glibtop_sysdeps_proc_time;
for (i = 0; i < server->ncpu; i++) {
buf->xcpu_utime [i] = proc_state.per_cpu_utime [i];
buf->xcpu_stime [i] = proc_state.per_cpu_stime [i];
}
if (server->ncpu)
buf->flags |= _glibtop_sysdeps_proc_time_smp;
}

View File

@@ -24,14 +24,22 @@
#include <glibtop.h>
#include <glibtop/procuid.h>
static const unsigned long _glibtop_sysdeps_proc_uid = 0;
#include <glibtop_private.h>
static const unsigned long _glibtop_sysdeps_proc_uid =
(1 << GLIBTOP_PROC_UID_UID) + (1 << GLIBTOP_PROC_UID_EUID) +
(1 << GLIBTOP_PROC_UID_GID) + (1 << GLIBTOP_PROC_UID_EGID) +
(1 << GLIBTOP_PROC_UID_PID) + (1 << GLIBTOP_PROC_UID_PPID) +
(1 << GLIBTOP_PROC_UID_PGRP) + (1 << GLIBTOP_PROC_UID_SESSION) +
(1 << GLIBTOP_PROC_UID_TTY) + (1 << GLIBTOP_PROC_UID_TPGID) +
(1 << GLIBTOP_PROC_UID_PRIORITY) + (1 << GLIBTOP_PROC_UID_NICE);
/* Init function. */
void
glibtop_init_proc_uid_s (glibtop *server)
{
server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid;
server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid;
}
/* Provides detailed information about a process. */
@@ -40,5 +48,36 @@ void
glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf,
pid_t pid)
{
memset (buf, 0, sizeof (glibtop_proc_uid));
libgtop_proc_state_t proc_state;
long priority, nice;
memset (buf, 0, sizeof (glibtop_proc_uid));
if (glibtop_get_proc_data_proc_state_s (server, &proc_state, pid))
return;
buf->uid = proc_state.uid;
buf->euid = proc_state.euid;
buf->gid = proc_state.gid;
buf->egid = proc_state.egid;
buf->pid = proc_state.pid;
buf->ppid = proc_state.ppid;
buf->pgrp = proc_state.pgrp;
buf->session = proc_state.session;
buf->tty = proc_state.tty;
buf->tpgid = proc_state.tpgid;
priority = proc_state.counter;
priority = 20 - (priority * 10 + proc_state.def_priority / 2) /
proc_state.def_priority;
nice = proc_state.priority;
nice = 20 - (nice * 20 + proc_state.def_priority / 2) /
proc_state.def_priority;
buf->priority = priority;
buf->nice = nice;
buf->flags = _glibtop_sysdeps_proc_uid;
}

View File

@@ -54,4 +54,6 @@ glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf)
buf->uptime = (double) total / (double) stat.frequency;
buf->idletime = (double) stat.cpu.idle / (double) stat.frequency;
buf->flags = _glibtop_sysdeps_uptime;
}