AIX support updated by Laurent Vivier <Laurent.Vivier@BULL.NET>.

* Makefile.am:
	* cpu.c: (glibtop_init_cpu_p), (glibtop_get_cpu_p):
	* glibtop_machine.h:
	* glibtop_server.h:
	* mem.c: (glibtop_get_mem_s):
	* netload.c: (glibtop_get_netload_p):
	* procargs.c: (glibtop_get_proc_args_s):
	* prockernel.c: (glibtop_get_proc_kernel_s):
	* proclist.c: (glibtop_get_proclist_s):
	* procmem.c: (glibtop_get_proc_mem_s):
	* procsegment.c: (glibtop_get_proc_segment_s):
	* procsignal.c: (glibtop_get_proc_signal_s):
	* procstate.c: (glibtop_get_proc_state_s):
	* proctime.c: (glibtop_get_proc_time_s):
	* procuid.c: (glibtop_get_proc_uid_s):
	* swap.c: (glibtop_get_swap_s):
	* sysinfo.c: (add_info), (init_sysinfo):
	* uptime.c: (glibtop_init_uptime_s), (glibtop_get_uptime_s):

	AIX support updated by Laurent Vivier <Laurent.Vivier@BULL.NET>.

	Fixed cpu/uptime/sysinfo.
	Added missing calls to glibtop_init_s.
This commit is contained in:
Benoît Dejean
2004-10-04 11:57:05 +00:00
parent ca8d9657f0
commit 9f91b2ddb8
19 changed files with 123 additions and 65 deletions

View File

@@ -1,3 +1,29 @@
2004-10-04 Benoît Dejean <tazforever@dlfp.org>
* Makefile.am:
* cpu.c: (glibtop_init_cpu_p), (glibtop_get_cpu_p):
* glibtop_machine.h:
* glibtop_server.h:
* mem.c: (glibtop_get_mem_s):
* netload.c: (glibtop_get_netload_p):
* procargs.c: (glibtop_get_proc_args_s):
* prockernel.c: (glibtop_get_proc_kernel_s):
* proclist.c: (glibtop_get_proclist_s):
* procmem.c: (glibtop_get_proc_mem_s):
* procsegment.c: (glibtop_get_proc_segment_s):
* procsignal.c: (glibtop_get_proc_signal_s):
* procstate.c: (glibtop_get_proc_state_s):
* proctime.c: (glibtop_get_proc_time_s):
* procuid.c: (glibtop_get_proc_uid_s):
* swap.c: (glibtop_get_swap_s):
* sysinfo.c: (add_info), (init_sysinfo):
* uptime.c: (glibtop_init_uptime_s), (glibtop_get_uptime_s):
AIX support updated by Laurent Vivier <Laurent.Vivier@BULL.NET>.
Fixed cpu/uptime/sysinfo.
Added missing calls to glibtop_init_s.
2004-06-13 Benoît Dejean <tazforever@dlfp.org>
* sysinfo.c: Added missing const qualifier.

View File

@@ -3,16 +3,18 @@ INCLUDES = @INCLUDES@
noinst_LTLIBRARIES = libgtop_sysdeps-2.0.la libgtop_sysdeps_suid-2.0.la
libgtop_sysdeps_2_0_la_SOURCES = siglist.c nosuid.c
libgtop_sysdeps_2_0_la_SOURCES = siglist.c nosuid.c mem.c swap.c uptime.c \
procargs.c prockernel.c proclist.c procmap.c \
procmem.c procsegment.c procsignal.c \
proctime.c procuid.c procmem.c utils.c \
procstate.c sysinfo.c
libgtop_sysdeps_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
libgtop_sysdeps_suid_2_0_la_SOURCES = open.c close.c cpu.c mem.c swap.c \
uptime.c loadavg.c shm_limits.c msg_limits.c \
sem_limits.c proclist.c procstate.c procuid.c \
proctime.c procmem.c procsignal.c prockernel.c \
procsegment.c procargs.c procmap.c netload.c \
ppp.c utils.c utils.h sysinfo.c
libgtop_sysdeps_suid_2_0_la_SOURCES = open.c close.c cpu.c loadavg.c \
msg_limits.c shm_limits.c sem_limits.c \
netload.c ppp.c utils.c
libgtop_sysdeps_suid_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
libgtop_sysdeps_suid_2_0_la_LIBADD = $(top_builddir)/sysdeps/common/libgtop_suid_common-2.0.la $(GLIB_LIBS)

View File

@@ -52,6 +52,13 @@ glibtop_init_cpu_p (glibtop *server)
server->ncpu = 0; /* means single-processor, see glibtop.h */
}
result = _glibtop_get_kmem_offset(server, "sysinfo");
if (result == -1)
{
return;
}
server->machine.sysinfo_offset = result;
result = _glibtop_get_kmem_offset(server, "cpuinfo");
if (result == -1)
{
@@ -73,11 +80,27 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
{
int result;
int cpu;
struct sysinfo sysinfo;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_CPU), 0);
memset (buf, 0, sizeof (glibtop_cpu));
result = _glibtop_get_kmem_info(server, server->machine.sysinfo_offset,
&sysinfo, sizeof(struct sysinfo));
if (result <= 0)
{
glibtop_error_io_r (server, "Cannot read sysinfo");
return;
}
buf->idle = sysinfo.cpu[CPU_IDLE];
buf->user = sysinfo.cpu[CPU_USER];
buf->sys = sysinfo.cpu[CPU_KERNEL];
buf->nice = sysinfo.cpu[CPU_WAIT];
buf->total = buf->idle + buf->user + buf->sys + buf->nice ;
result = _glibtop_get_kmem_info(server, server->machine.cpuinfo_offset,
server->machine.cpuinfo,
_system_configuration.ncpus
@@ -89,13 +112,8 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
return;
}
buf->idle = 0;
buf->user = 0;
buf->sys = 0;
buf->nice = 0;
for (cpu = 0; cpu < _system_configuration.ncpus; cpu++)
{
if (cpu < GLIBTOP_NCPU)
for (cpu = 0; cpu < MIN(GLIBTOP_NCPU, _system_configuration.ncpus); cpu++)
{
buf->xcpu_idle[cpu] =
server->machine.cpuinfo[cpu].cpu[CPU_IDLE];
@@ -112,13 +130,6 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
buf->xcpu_nice[cpu];
}
buf->idle += server->machine.cpuinfo[cpu].cpu[CPU_IDLE];
buf->user += server->machine.cpuinfo[cpu].cpu[CPU_USER];
buf->sys += server->machine.cpuinfo[cpu].cpu[CPU_KERNEL];
buf->nice += server->machine.cpuinfo[cpu].cpu[CPU_WAIT];
buf->total = buf->idle + buf->user + buf->sys + buf->nice ;
}
buf->frequency = sysconf(_SC_CLK_TCK);
buf->flags = _glibtop_sysdeps_cpu;

View File

@@ -38,6 +38,7 @@ struct _glibtop_machine
int kmem_fd;
off_t cpuinfo_offset;
off_t sysinfo_offset;
off_t ifnet_offset;
off_t loadavg_offset;
off_t shminfo_offset;

View File

@@ -29,7 +29,7 @@ G_BEGIN_DECLS
#define GLIBTOP_SUID_CPU (1 << GLIBTOP_SYSDEPS_CPU)
#define GLIBTOP_SUID_MEM 0
#define GLIBTOP_SUID_SWAP 0
#define GLIBTOP_SUID_UPTIME (1 << GLIBTOP_SYSDEPS_UPTIME)
#define GLIBTOP_SUID_UPTIME 0
#define GLIBTOP_SUID_LOADAVG (1 << GLIBTOP_SYSDEPS_LOADAVG)
#define GLIBTOP_SUID_SHM_LIMITS (1 << GLIBTOP_SYSDEPS_SHM_LIMITS)
#define GLIBTOP_SUID_MSG_LIMITS (1 << GLIBTOP_SYSDEPS_MSG_LIMITS)

View File

@@ -49,6 +49,8 @@ glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
int pagesize;
int result;
glibtop_init_s (&server, (1L << GLIBTOP_SYSDEPS_MEM), 0);
memset (buf, 0, sizeof (glibtop_mem));
pagesize = sysconf(_SC_PAGESIZE);

View File

@@ -119,6 +119,8 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
long mask;
char name[16];
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_UPTIME), 0);
memset (buf, 0, sizeof (glibtop_netload));
for ( offset = server->machine.ifnet_offset;

View File

@@ -62,6 +62,8 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
int result;
int len;
glibtop_init_s (&server, (1L << GLIBTOP_SYSDEPS_PROC_ARGS), 0);
memset (buf, 0, sizeof (glibtop_proc_args));
pinfo = _glibtop_get_procinfo(server, pid);

View File

@@ -57,6 +57,8 @@ glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf,
tid_t thid;
int result;
glibtop_init_s (&server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
memset (buf, 0, sizeof (glibtop_proc_kernel));
pinfo = _glibtop_get_procinfo(server, pid);

View File

@@ -59,6 +59,8 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
pid_t current;
int result;
glibtop_init_s (&server, (1L << GLIBTOP_SYSDEPS_PROCLIST), 0);
memset (buf, 0, sizeof (glibtop_proclist));
for( count = total = 0, current = 0

View File

@@ -53,6 +53,8 @@ glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf,
struct procsinfo *pinfo;
int pagesize;
glibtop_init_s (&server, (1L << GLIBTOP_SYSDEPS_PROC_MEM), 0);
memset (buf, 0, sizeof (glibtop_proc_mem));
pinfo = _glibtop_get_procinfo(server, pid);

View File

@@ -53,6 +53,8 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf,
struct procsinfo *pinfo;
int pagesize;
glibtop_init_s (&server, (1L << GLIBTOP_SYSDEPS_PROC_SEGMENT), 0);
memset (buf, 0, sizeof (glibtop_proc_segment));
pinfo = _glibtop_get_procinfo(server, pid);

View File

@@ -54,6 +54,8 @@ glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf,
int i;
long bit;
glibtop_init_s (&server, (1L << GLIBTOP_SYSDEPS_PROC_SIGNAL), 0);
memset (buf, 0, sizeof (glibtop_proc_signal));
pinfo = _glibtop_get_procinfo(server, pid);

View File

@@ -53,6 +53,8 @@ glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf,
tid_t thid;
int result;
glibtop_init_s (&server, (1L << GLIBTOP_SYSDEPS_PROC_STATE), 0);
memset (buf, 0, sizeof (glibtop_proc_state));
pinfo = _glibtop_get_procinfo(server, pid);

View File

@@ -51,6 +51,8 @@ glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf,
{
struct procsinfo *pinfo;
glibtop_init_s (&server, (1L << GLIBTOP_SYSDEPS_PROC_TIME), 0);
memset (buf, 0, sizeof (glibtop_proc_time));
pinfo = _glibtop_get_procinfo(server, pid);

View File

@@ -59,6 +59,8 @@ glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf,
tid_t thid;
int result;
glibtop_init_s (&server, (1L << GLIBTOP_SYSDEPS_PROC_UID), 0);
memset (buf, 0, sizeof (glibtop_proc_uid));
pinfo = _glibtop_get_procinfo(server, pid);

View File

@@ -57,6 +57,8 @@ glibtop_get_swap_s (glibtop *server, glibtop_swap *buf)
int comment = 0;
int pos = 0;
glibtop_init_s (&server, (1L << GLIBTOP_SYSDEPS_SWAP), 0);
memset (buf, 0, sizeof (glibtop_swap));
pagesize = sysconf(_SC_PAGESIZE);

View File

@@ -31,10 +31,16 @@ static const unsigned long _glibtop_sysdeps_sysinfo =
static glibtop_sysinfo sysinfo;
static void add_info(glibtop_entry* entry, char* label, char* value)
static void add_info(glibtop_entry* entry, char* label, char* attribute)
{
g_ptr_array_add(entry->labels, g_strdup(label));
g_hash_table_insert(entry->values, label, g_strdup(value));
char* key;
char* value;
key = g_strdup(label);
value = g_strdup(attribute);
g_ptr_array_add(entry->labels, key);
g_hash_table_insert(entry->values, key, value);
}
static void init_sysinfo(void)
@@ -60,22 +66,22 @@ static void init_sysinfo(void)
case POWER_RS:
add_info( &sysinfo.cpuinfo[cpu]
, "architecture"
, "Power Classic architecture");
, "Power Classic");
break;
case POWER_PC:
add_info( &sysinfo.cpuinfo[cpu]
, "architecture"
, "Power PC architecture");
, "Power PC");
break;
case IA64:
add_info( &sysinfo.cpuinfo[cpu]
, "architecture"
, "Intel IA64 architecture");
, "Intel IA64");
break;
default:
add_info( &sysinfo.cpuinfo[cpu]
, "architecture"
, "Unknown architecture");
, "Unknown");
break;
}
@@ -161,7 +167,7 @@ static void init_sysinfo(void)
sprintf(buf,"%d", _system_configuration.width);
add_info( &sysinfo.cpuinfo[cpu], "width", buf);
if (_system_configuration.cache_attrib & (1 << 31))
if (_system_configuration.cache_attrib & 1 )
{
/* L1 cache is present */

View File

@@ -21,6 +21,8 @@
Boston, MA 02111-1307, USA.
*/
#include <sys/times.h>
#include <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/uptime.h>
@@ -32,16 +34,13 @@
#include <time.h>
static const unsigned long _glibtop_sysdeps_uptime =
(1L << GLIBTOP_UPTIME_UPTIME) + (1L << GLIBTOP_UPTIME_IDLETIME);
(1L << GLIBTOP_UPTIME_UPTIME) + (1L << GLIBTOP_UPTIME_BOOT_TIME);
static const unsigned long _required_cpu_flags =
(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_IDLE) +
(1L << GLIBTOP_CPU_FREQUENCY);
/* Init function. */
void
glibtop_init_uptime_p (glibtop *server)
glibtop_init_uptime_s (glibtop *server)
{
server->sysdeps.uptime = _glibtop_sysdeps_uptime;
}
@@ -49,28 +48,17 @@ glibtop_init_uptime_p (glibtop *server)
/* Provides uptime and idle time. */
void
glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf)
glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf)
{
glibtop_cpu cpu;
time_t uptime;
struct tms tbuf;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_UPTIME), 0);
glibtop_init_s (&server, (1L << GLIBTOP_SYSDEPS_UPTIME), 0);
memset (buf, 0, sizeof (glibtop_uptime));
/* We simply calculate it from the CPU usage. */
glibtop_get_cpu_p (server, &cpu);
/* Make sure all required fields are present. */
if ((cpu.flags & _required_cpu_flags) != _required_cpu_flags)
return;
/* Calculate values. */
buf->uptime = (double) cpu.total / (double) cpu.frequency;
buf->idletime = (double) cpu.idle / (double) cpu.frequency;
buf->uptime = (double)times(&tbuf) / (double)sysconf(_SC_CLK_TCK);
buf->boot_time = (guint64) time(NULL) - (guint64) buf->uptime;
buf->flags = _glibtop_sysdeps_uptime;
}