add field for kvm descriptor.
* glibtop_machine.h: add field for kvm descriptor. * open.c: add code for opening kernel name space. * shm_limits.c: implemented. The real implementation will have this code in the daemon, since process needs to be setgid sys to be able to read kernel symbols.
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
1999-04-29 Drazen Kacar <dave@srce.hr>
|
||||
|
||||
* glibtop_machine.h: add field for kvm descriptor.
|
||||
|
||||
* open.c: add code for opening kernel name space.
|
||||
|
||||
* shm_limits.c: implemented.
|
||||
|
||||
1999-03-31 Drazen Kacar <dave@srce.hr>
|
||||
|
||||
* loadavg.c: make it work with Solaris 2.6 and older. A part
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <kstat.h>
|
||||
#include <kvm.h>
|
||||
#include <sys/sysinfo.h>
|
||||
|
||||
BEGIN_LIBGTOP_DECLS
|
||||
@@ -40,6 +41,8 @@ struct _glibtop_machine
|
||||
uid_t uid, euid;
|
||||
gid_t gid, egid;
|
||||
|
||||
kvm_t *kd;
|
||||
|
||||
kstat_ctl_t *kc;
|
||||
|
||||
kstat_t *vminfo_kstat;
|
||||
|
@@ -60,6 +60,10 @@ glibtop_open_s (glibtop *server, const char *program_name,
|
||||
if (!server->machine.kc)
|
||||
glibtop_error_io_r (server, "kstat_open ()");
|
||||
|
||||
server->machine.kd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL);
|
||||
if(!server->machine.kd)
|
||||
glibtop_warn_io_r(server, "kvm_open()");
|
||||
|
||||
fprintf (stderr, "Sleeping 2 seconds, please wait ...\n");
|
||||
sleep (2);
|
||||
}
|
||||
|
@@ -24,14 +24,25 @@
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/shm_limits.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_shm_limits = 0;
|
||||
#include <kvm.h>
|
||||
#include <sys/shm.h>
|
||||
|
||||
static struct nlist nlst[] = { {"shminfo"}, {NULL} };
|
||||
static const unsigned long _glibtop_sysdeps_shm_limits =
|
||||
(1L << GLIBTOP_IPC_SHMMAX) + (1L << GLIBTOP_IPC_SHMMIN) +
|
||||
(1L << GLIBTOP_IPC_SHMMNI) + (1L << GLIBTOP_IPC_SHMSEG);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_shm_limits_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
|
||||
kvm_t *kd = server->machine.kd;
|
||||
|
||||
if(kd && !kvm_nlist(kd, nlst))
|
||||
server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
|
||||
else
|
||||
server->sysdeps.shm_limits = 0;
|
||||
}
|
||||
|
||||
/* Provides information about sysv ipc limits. */
|
||||
@@ -39,5 +50,19 @@ glibtop_init_shm_limits_s (glibtop *server)
|
||||
void
|
||||
glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf)
|
||||
{
|
||||
kvm_t *kd = server->machine.kd;
|
||||
struct shminfo sinfo;
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_shm_limits));
|
||||
|
||||
if(!(server->sysdeps.shm_limits))
|
||||
return;
|
||||
if(kvm_read(kd, nlst[0].n_value, (void *)&sinfo,
|
||||
sizeof(struct shminfo)) != sizeof(struct shminfo))
|
||||
return;
|
||||
buf->shmmax = sinfo.shmmax;
|
||||
buf->shmmin = sinfo.shmmin;
|
||||
buf->shmmni = sinfo.shmmni;
|
||||
buf->shmseg = sinfo.shmseg;
|
||||
buf->flags = _glibtop_sysdeps_shm_limits;
|
||||
}
|
||||
|
Reference in New Issue
Block a user