New file. Imported from top 3.4.

1998-07-15  Martin Baulig  <martin@home-of-linux.org>

	* sysdeps/sun4/loadavg.h: New file. Imported from top 3.4.

	* sysdeps/sun4/uptime.c (glibtop_get_uptime_p): Added
	implementation of that function using glibtop_get_cpu ().

	* sysdeps/sun4/loadavg.c (glibtop_get_loadavg_p): Added
	implementation of that feature.

	* sysdeps/sun4/{shm_limits.c, msg_limits.c, shm_limits.c}:
	Added implementation of this features.
This commit is contained in:
Martin Baulig
1998-07-14 23:30:36 +00:00
committed by Martin Baulig
parent 4bfef8c254
commit 5f4131f248
11 changed files with 240 additions and 7 deletions

View File

@@ -1,3 +1,16 @@
1998-07-15 Martin Baulig <martin@home-of-linux.org>
* sysdeps/sun4/loadavg.h: New file. Imported from top 3.4.
* sysdeps/sun4/uptime.c (glibtop_get_uptime_p): Added
implementation of that function using glibtop_get_cpu ().
* sysdeps/sun4/loadavg.c (glibtop_get_loadavg_p): Added
implementation of that feature.
* sysdeps/sun4/{shm_limits.c, msg_limits.c, shm_limits.c}:
Added implementation of this features.
1998-07-14 Martin Baulig <baulig@Stud.Informatik.uni-trier.de> 1998-07-14 Martin Baulig <baulig@Stud.Informatik.uni-trier.de>
* src/daemon/server_config.h.in: Added some comments. * src/daemon/server_config.h.in: Added some comments.

View File

@@ -19,7 +19,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <config.h> #include <glibtop.h>
#include <glibtop/cpu.h> #include <glibtop/cpu.h>
static const unsigned long _glibtop_sysdeps_cpu = static const unsigned long _glibtop_sysdeps_cpu =

View File

@@ -44,6 +44,8 @@
#include <sys/syscall.h> #include <sys/syscall.h>
#endif #endif
#include "loadavg.h"
__BEGIN_DECLS __BEGIN_DECLS
/* Older versions of SunOS don't have a typedef for pid_t. /* Older versions of SunOS don't have a typedef for pid_t.
@@ -63,10 +65,13 @@ typedef int pid_t;
#define X_CP_TIME 6 #define X_CP_TIME 6
#define X_PAGES 7 #define X_PAGES 7
#define X_EPAGES 8 #define X_EPAGES 8
#define X_SHMINFO 9
#define X_MSGINFO 10
#define X_SEMINFO 11
#ifdef MULTIPROCESSOR #ifdef MULTIPROCESSOR
#define X_NCPU 9 #define X_NCPU 12
#define X_MP_TIME 10 #define X_MP_TIME 13
#endif #endif
/* Log base 2 of 1024 is 10 (2^10 == 1024) */ /* Log base 2 of 1024 is 10 (2^10 == 1024) */

63
sysdeps/sun4/loadavg.c Normal file
View File

@@ -0,0 +1,63 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/loadavg.h>
static const unsigned long _glibtop_sysdeps_loadavg =
(1 << GLIBTOP_LOADAVG_LOADAVG);
/* Provides load averange. */
void
glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf)
{
load_avg avenrun [3];
int i;
glibtop_init_r (&server, 0, 0);
memset (buf, 0, sizeof (glibtop_loadavg));
/* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
setregid (server->machine.gid, server->machine.egid);
/* get the load average array */
(void) _glibtop_getkval (server, _glibtop_nlist [X_AVENRUN].n_value,
(int *) avenrun, sizeof (avenrun),
_glibtop_nlist [X_AVENRUN].n_name);
if (setregid (server->machine.egid, server->machine.gid))
_exit (1);
/* !!! END OF SGID KMEM PART !!! */
for (i = 0; i < 3; i++) {
/* Calculate loadavg values from avenrun. */
buf->loadavg [i] = loaddouble (avenrun [i]);
}
/* Now we can set the flags. */
buf->flags = _glibtop_sysdeps_loadavg;
}

View File

@@ -19,7 +19,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <config.h> #include <glibtop.h>
#include <glibtop/mem.h> #include <glibtop/mem.h>
static const unsigned long _glibtop_sysdeps_mem = static const unsigned long _glibtop_sysdeps_mem =

View File

@@ -19,14 +19,53 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/msg_limits.h> #include <glibtop/msg_limits.h>
/* #define KERNEL to get declaration of `struct msginfo'. */
#define KERNEL
#include <sys/ipc.h>
#include <sys/msg.h>
static const unsigned long _glibtop_sysdeps_msg_limits =
(1 << GLIBTOP_IPC_MSGMAP) + (1 << GLIBTOP_IPC_MSGMAX) +
(1 << GLIBTOP_IPC_MSGMNB) + (1 << GLIBTOP_IPC_MSGMNI) +
(1 << GLIBTOP_IPC_MSGSSZ) + (1 << GLIBTOP_IPC_MSGTQL);
/* Provides information about sysv ipc limits. */ /* Provides information about sysv ipc limits. */
void void
glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf) glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
{ {
struct msginfo msginfo;
glibtop_init_r (&server, 0, 0); glibtop_init_r (&server, 0, 0);
memset (buf, 0, sizeof (glibtop_msg_limits)); memset (buf, 0, sizeof (glibtop_msg_limits));
/* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
setregid (server->machine.gid, server->machine.egid);
/* get the load average array */
(void) _glibtop_getkval (server, _glibtop_nlist [X_MSGINFO].n_value,
(int *) &msginfo, sizeof (msginfo),
_glibtop_nlist [X_MSGINFO].n_name);
if (setregid (server->machine.egid, server->machine.gid))
_exit (1);
/* !!! END OF SGID KMEM PART !!! */
buf->msgmap = msginfo.msgmap;
buf->msgmax = msginfo.msgmax;
buf->msgmnb = msginfo.msgmnb;
buf->msgmni = msginfo.msgmni;
buf->msgssz = msginfo.msgssz;
buf->msgtql = msginfo.msgtql;
buf->flags = _glibtop_sysdeps_msg_limits;
} }

View File

@@ -34,6 +34,9 @@ struct nlist _glibtop_nlist[] = {
{ "cp_time" }, /* 6 */ { "cp_time" }, /* 6 */
{ "pages" }, /* 7 */ { "pages" }, /* 7 */
{ "epages" }, /* 8 */ { "epages" }, /* 8 */
{ "shminfo" }, /* 9 */
{ "msginfo" }, /* 10 */
{ "seminfo" }, /* 11 */
#else #else
{ "_avenrun" }, /* 0 */ { "_avenrun" }, /* 0 */
{ "_ccpu" }, /* 1 */ { "_ccpu" }, /* 1 */
@@ -44,6 +47,9 @@ struct nlist _glibtop_nlist[] = {
{ "_cp_time" }, /* 6 */ { "_cp_time" }, /* 6 */
{ "_pages" }, /* 7 */ { "_pages" }, /* 7 */
{ "_epages" }, /* 8 */ { "_epages" }, /* 8 */
{ "_shminfo" }, /* 9 */
{ "_msginfo" }, /* 10 */
{ "_seminfo" }, /* 11 */
#ifdef MULTIPROCESSOR #ifdef MULTIPROCESSOR
{ "_ncpu" }, { "_ncpu" },
{ "_mp_time" }, { "_mp_time" },

View File

@@ -19,14 +19,59 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/sem_limits.h> #include <glibtop/sem_limits.h>
/* #define KERNEL to get declaration of `struct seminfo'. */
#define KERNEL
#include <sys/ipc.h>
#include <sys/sem.h>
static unsigned long _glibtop_sysdeps_sem_limits =
(1 << GLIBTOP_IPC_SEMMAP) + (1 << GLIBTOP_IPC_SEMMNI) +
(1 << GLIBTOP_IPC_SEMMNS) + (1 << GLIBTOP_IPC_SEMMNU) +
(1 << GLIBTOP_IPC_SEMMSL) + (1 << GLIBTOP_IPC_SEMOPM) +
(1 << GLIBTOP_IPC_SEMUME) + (1 << GLIBTOP_IPC_SEMUSZ) +
(1 << GLIBTOP_IPC_SEMVMX) + (1 << GLIBTOP_IPC_SEMAEM);
/* Provides information about sysv sem limits. */ /* Provides information about sysv sem limits. */
void void
glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf) glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
{ {
struct seminfo seminfo;
glibtop_init_r (&server, 0, 0); glibtop_init_r (&server, 0, 0);
memset (buf, 0, sizeof (glibtop_sem_limits)); memset (buf, 0, sizeof (glibtop_sem_limits));
/* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
setregid (server->machine.gid, server->machine.egid);
/* get the load average array */
(void) _glibtop_getkval (server, _glibtop_nlist [X_SEMINFO].n_value,
(int *) &seminfo, sizeof (seminfo),
_glibtop_nlist [X_SEMINFO].n_name);
if (setregid (server->machine.egid, server->machine.gid))
_exit (1);
/* !!! END OF SGID KMEM PART !!! */
buf->semmap = seminfo.semmap;
buf->semmni = seminfo.semmni;
buf->semmns = seminfo.semmns;
buf->semmnu = seminfo.semmnu;
buf->semmsl = seminfo.semmsl;
buf->semopm = seminfo.semopm;
buf->semume = seminfo.semume;
buf->semusz = seminfo.semusz;
buf->semvmx = seminfo.semvmx;
buf->semaem = seminfo.semaem;
buf->flags = _glibtop_sysdeps_sem_limits;
} }

View File

@@ -19,14 +19,52 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/shm_limits.h> #include <glibtop/shm_limits.h>
/* #define KERNEL to get declaration of `struct shminfo'. */
#define KERNEL
#include <sys/ipc.h>
#include <sys/shm.h>
static unsigned long _glibtop_sysdeps_shm_limits =
(1 << GLIBTOP_IPC_SHMMAX) + (1 << GLIBTOP_IPC_SHMMIN) +
(1 << GLIBTOP_IPC_SHMMNI) + (1 << GLIBTOP_IPC_SHMSEG) +
(1 << GLIBTOP_IPC_SHMALL);
/* Provides information about sysv ipc limits. */ /* Provides information about sysv ipc limits. */
void void
glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf) glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
{ {
struct shminfo shminfo;
glibtop_init_r (&server, 0, 0); glibtop_init_r (&server, 0, 0);
memset (buf, 0, sizeof (glibtop_shm_limits)); memset (buf, 0, sizeof (glibtop_shm_limits));
/* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
setregid (server->machine.gid, server->machine.egid);
/* get the load average array */
(void) _glibtop_getkval (server, _glibtop_nlist [X_SHMINFO].n_value,
(int *) &shminfo, sizeof (shminfo),
_glibtop_nlist [X_SHMINFO].n_name);
if (setregid (server->machine.egid, server->machine.gid))
_exit (1);
/* !!! END OF SGID KMEM PART !!! */
buf->shmmax = shminfo.shmmax;
buf->shmmin = shminfo.shmmin;
buf->shmmni = shminfo.shmmni;
buf->shmseg = shminfo.shmseg;
buf->shmall = shminfo.shmall;
buf->flags = _glibtop_sysdeps_shm_limits;
} }

View File

@@ -19,7 +19,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <config.h> #include <glibtop.h>
#include <glibtop/swap.h> #include <glibtop/swap.h>
/* Provides information about swap usage. */ /* Provides information about swap usage. */

View File

@@ -19,15 +19,39 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <config.h> #include <glibtop.h>
#include <glibtop/cpu.h>
#include <glibtop/uptime.h> #include <glibtop/uptime.h>
static const unsigned long _glibtop_sysdeps_uptime =
(1 << GLIBTOP_UPTIME_UPTIME) + (1 << GLIBTOP_UPTIME_IDLETIME);
/* Provides uptime and idle time. */ /* Provides uptime and idle time. */
void void
glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf) glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf)
{ {
glibtop_cpu cpu;
glibtop_init_r (&server, 0, 0); glibtop_init_r (&server, 0, 0);
memset (buf, 0, sizeof (glibtop_uptime)); /* Get currect cpu usage. */
glibtop_get_cpu_p (server, &cpu);
/* Make sure all required fields are present. */
if (((cpu.flags & GLIBTOP_CPU_TOTAL) == 0) ||
((cpu.flags & GLIBTOP_CPU_IDLE) == 0) ||
((cpu.flags & GLIBTOP_CPU_FREQUENCY) == 0) ||
(cpu.frequency == 0))
return;
/* Simply calculate uptime and idle time from
* cpu usage. */
buf->uptime = (double) cpu.total / (double) cpu.frequency;
buf->idletime = (double) cpu.idle / (double) cpu.frequency;
buf->flags = _glibtop_sysdeps_uptime;
} }