Merged a few bug fixes from the HEAD.
This commit is contained in:
362
examples/timings.c
Normal file
362
examples/timings.c
Normal file
@@ -0,0 +1,362 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/open.h>
|
||||
#include <glibtop/close.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
|
||||
#include <glibtop/parameter.h>
|
||||
|
||||
#include <glibtop/union.h>
|
||||
#include <glibtop/sysdeps.h>
|
||||
|
||||
#include <sys/times.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#ifndef PROFILE_COUNT
|
||||
#define PROFILE_COUNT 100000L
|
||||
#endif
|
||||
|
||||
#ifndef PROFILE_COUNT_EXPENSIVE
|
||||
#define PROFILE_COUNT_EXPENSIVE 10000L
|
||||
#endif
|
||||
|
||||
#define ELAPSED_UTIME ((unsigned long) elapsed_utime.tv_sec * 1000000 + (unsigned long) elapsed_utime.tv_usec)
|
||||
#define ELAPSED_STIME ((unsigned long) elapsed_stime.tv_sec * 1000000 + (unsigned long) elapsed_stime.tv_usec)
|
||||
|
||||
#if defined(__bsdi__)
|
||||
#define timeradd(tvp, uvp, vvp) \
|
||||
do { \
|
||||
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
|
||||
(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
|
||||
if ((vvp)->tv_usec >= 1000000) { \
|
||||
(vvp)->tv_sec++; \
|
||||
(vvp)->tv_usec -= 1000000; \
|
||||
} \
|
||||
} while (0)
|
||||
#define timersub(tvp, uvp, vvp) \
|
||||
do { \
|
||||
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
|
||||
(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
|
||||
if ((vvp)->tv_usec < 0) { \
|
||||
(vvp)->tv_sec--; \
|
||||
(vvp)->tv_usec += 1000000; \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
glibtop_union data;
|
||||
glibtop_sysdeps sysdeps;
|
||||
unsigned c, count, port, i, *ptr;
|
||||
struct rusage total_start, total_end;
|
||||
struct rusage rusage_start, rusage_end;
|
||||
struct timeval elapsed_utime, elapsed_stime;
|
||||
char buffer [BUFSIZ];
|
||||
pid_t pid, ppid;
|
||||
char *args;
|
||||
|
||||
count = PROFILE_COUNT;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, GTOPLOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
printf ("%-12s (%-10s): %7s - %9s - %9s\n",
|
||||
"Feature", "Flags", "Count", "utime", "stime");
|
||||
printf ("-------------------------------------------"
|
||||
"---------------\n");
|
||||
|
||||
glibtop_init_r (&glibtop_global_server, 0, 0);
|
||||
|
||||
getrusage (RUSAGE_SELF, &total_start);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_cpu (&data.cpu);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("CPU (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.cpu.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT_EXPENSIVE; c++)
|
||||
glibtop_get_mem (&data.mem);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Memory (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.mem.flags, PROFILE_COUNT_EXPENSIVE,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT_EXPENSIVE,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT_EXPENSIVE);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT_EXPENSIVE; c++)
|
||||
glibtop_get_swap (&data.swap);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Swap (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.swap.flags, PROFILE_COUNT_EXPENSIVE,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT_EXPENSIVE,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT_EXPENSIVE);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_uptime (&data.uptime);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Uptime (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.uptime.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_loadavg (&data.loadavg);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Loadavg (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.loadavg.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
printf ("\n");
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT_EXPENSIVE; c++) {
|
||||
ptr = glibtop_get_proclist (&data.proclist, 0, 0);
|
||||
glibtop_free (ptr);
|
||||
}
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Proclist (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.proclist.flags,
|
||||
PROFILE_COUNT_EXPENSIVE,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT_EXPENSIVE,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT_EXPENSIVE);
|
||||
|
||||
pid = getpid ();
|
||||
|
||||
printf ("\n");
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_state (&data.proc_state, pid);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Proc_State (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.proc_state.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_uid (&data.proc_uid, pid);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Proc_Uid (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.proc_uid.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_mem (&data.proc_mem, pid);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Proc_Mem (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.proc_mem.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_segment (&data.proc_segment, pid);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Proc_Segment (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.proc_segment.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_time (&data.proc_time, pid);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Proc_Time (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.proc_time.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_signal (&data.proc_signal, pid);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Proc_Signal (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.proc_signal.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_kernel (&data.proc_kernel, pid);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Proc_Kernel (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.proc_kernel.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &total_end);
|
||||
|
||||
timersub (&total_end.ru_utime, &total_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
timersub (&total_end.ru_stime, &total_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("-------------------------------------------"
|
||||
"---------------\n");
|
||||
|
||||
printf ("%-36s %9lu - %9lu\n\n", "TOTAL",
|
||||
ELAPSED_UTIME, ELAPSED_STIME);
|
||||
|
||||
printf ("All timings are in clock ticks "
|
||||
"(1000000 ticks per second).\n\n");
|
||||
|
||||
glibtop_close ();
|
||||
|
||||
exit (0);
|
||||
}
|
38
include/glibtop/limits.h
Normal file
38
include/glibtop/limits.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GLIBTOP_LIMITS_H__
|
||||
#define __GLIBTOP_LIMITS_H__
|
||||
|
||||
#include <glibtop/global.h>
|
||||
|
||||
BEGIN_LIBGTOP_DECLS
|
||||
|
||||
/* Nobody should really be using more than 64 processors. */
|
||||
#define GLIBTOP_NCPU 64
|
||||
|
||||
END_LIBGTOP_DECLS
|
||||
|
||||
#endif
|
1
kernel/sysctl/.cvsignore
Normal file
1
kernel/sysctl/.cvsignore
Normal file
@@ -0,0 +1 @@
|
||||
*.flags
|
22
kernel/sysctl/Makefile
Normal file
22
kernel/sysctl/Makefile
Normal file
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# Makefile for the LibGTop linux sysctl interface.
|
||||
#
|
||||
# Note! Dependencies are done automagically by 'make dep', which also
|
||||
# removes any old dependencies. DON'T put your own dependencies here
|
||||
# unless it's something special (ie not a .c file).
|
||||
#
|
||||
# Note 2! The CFLAGS definition is now in the main makefile...
|
||||
|
||||
O_TARGET := kernel.o
|
||||
ifeq ($(CONFIG_LIBGTOP),y)
|
||||
O_OJBS := main.o libgtop.o
|
||||
else
|
||||
O_OBJS := main.o
|
||||
endif
|
||||
OX_OBJS := libgtop_syms.o
|
||||
|
||||
ifeq ($(CONFIG_LIBGTOP),m)
|
||||
M_OBJS := libgtop.o
|
||||
endif
|
||||
|
||||
include $(TOPDIR)/Rules.make
|
1268
kernel/sysctl/libgtop.c
Normal file
1268
kernel/sysctl/libgtop.c
Normal file
File diff suppressed because it is too large
Load Diff
242
kernel/sysctl/libgtop.h
Normal file
242
kernel/sysctl/libgtop.h
Normal file
@@ -0,0 +1,242 @@
|
||||
#ifndef _LINUX_LIBGTOP_H
|
||||
#define _LINUX_LIBGTOP_H 1
|
||||
|
||||
#include <linux/tasks.h>
|
||||
|
||||
enum {
|
||||
LIBGTOP_VERSION = 1,
|
||||
LIBGTOP_UPDATE_EXPENSIVE,
|
||||
LIBGTOP_STAT = 101,
|
||||
LIBGTOP_MEM,
|
||||
LIBGTOP_SWAP,
|
||||
LIBGTOP_PROCLIST = 201,
|
||||
LIBGTOP_PROC_STATE = 211,
|
||||
LIBGTOP_PROC_KERNEL,
|
||||
LIBGTOP_PROC_SEGMENT,
|
||||
LIBGTOP_PROC_MEM,
|
||||
LIBGTOP_PROC_SIGNAL,
|
||||
LIBGTOP_PROC_ARGS = 251,
|
||||
LIBGTOP_PROC_MAPS,
|
||||
LIBGTOP_NETLOAD = 301
|
||||
};
|
||||
|
||||
enum {
|
||||
LIBGTOP_PROCLIST_ALL = 0,
|
||||
LIBGTOP_PROCLIST_PID,
|
||||
LIBGTOP_PROCLIST_PGRP,
|
||||
LIBGTOP_PROCLIST_SESSION,
|
||||
LIBGTOP_PROCLIST_TTY,
|
||||
LIBGTOP_PROCLIST_UID,
|
||||
LIBGTOP_PROCLIST_RUID
|
||||
};
|
||||
|
||||
#define LIBGTOP_NSIG 4
|
||||
|
||||
#define LIBGTOP_PROCLIST_MASK 15
|
||||
#define LIBGTOP_MAX_GROUPS 32
|
||||
|
||||
#define LIBGTOP_EXCLUDE_IDLE 0x1000
|
||||
#define LIBGTOP_EXCLUDE_SYSTEM 0x2000
|
||||
#define LIBGTOP_EXCLUDE_NOTTY 0x4000
|
||||
|
||||
#define LIBGTOP_TASK_RUNNING 1
|
||||
#define LIBGTOP_TASK_INTERRUPTIBLE 2
|
||||
#define LIBGTOP_TASK_UNINTERRUPTIBLE 4
|
||||
#define LIBGTOP_TASK_ZOMBIE 8
|
||||
#define LIBGTOP_TASK_STOPPED 16
|
||||
#define LIBGTOP_TASK_SWAPPING 32
|
||||
|
||||
#define LIBGTOP_VM_READ 0x0001 /* currently active flags */
|
||||
#define LIBGTOP_VM_WRITE 0x0002
|
||||
#define LIBGTOP_VM_EXEC 0x0004
|
||||
#define LIBGTOP_VM_SHARED 0x0008
|
||||
|
||||
#define LIBGTOP_VM_MAYREAD 0x0010 /* limits for mprotect() etc */
|
||||
#define LIBGTOP_VM_MAYWRITE 0x0020
|
||||
#define LIBGTOP_VM_MAYEXEC 0x0040
|
||||
#define LIBGTOP_VM_MAYSHARE 0x0080
|
||||
|
||||
#define LIBGTOP_VM_GROWSDOWN 0x0100 /* general info on the segment */
|
||||
#define LIBGTOP_VM_GROWSUP 0x0200
|
||||
#define LIBGTOP_VM_SHM 0x0400 /* shared memory area, don't swap out */
|
||||
#define LIBGTOP_VM_DENYWRITE 0x0800 /* ETXTBSY on write attempts.. */
|
||||
|
||||
#define LIBGTOP_VM_EXECUTABLE 0x1000
|
||||
#define LIBGTOP_VM_LOCKED 0x2000
|
||||
#define LIBGTOP_VM_IO 0x4000 /* Memory mapped I/O or similar */
|
||||
|
||||
#define LIBGTOP_MAP_PATH_LEN (PAGE_SIZE - sizeof (libgtop_proc_maps_header_t))
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) ((a < b) ? a : b)
|
||||
#endif
|
||||
|
||||
typedef struct libgtop_stat libgtop_stat_t;
|
||||
|
||||
typedef struct libgtop_cpu libgtop_cpu_t;
|
||||
typedef struct libgtop_mem libgtop_mem_t;
|
||||
typedef struct libgtop_swap libgtop_swap_t;
|
||||
typedef struct libgtop_proclist libgtop_proclist_t;
|
||||
|
||||
typedef struct libgtop_proc_state libgtop_proc_state_t;
|
||||
typedef struct libgtop_proc_kernel libgtop_proc_kernel_t;
|
||||
typedef struct libgtop_proc_segment libgtop_proc_segment_t;
|
||||
typedef struct libgtop_proc_mem libgtop_proc_mem_t;
|
||||
typedef struct libgtop_proc_signal libgtop_proc_signal_t;
|
||||
|
||||
typedef struct libgtop_proc_maps_header libgtop_proc_maps_header_t;
|
||||
typedef struct libgtop_proc_maps libgtop_proc_maps_t;
|
||||
|
||||
typedef struct libgtop_netload libgtop_netload_t;
|
||||
|
||||
struct libgtop_cpu
|
||||
{
|
||||
unsigned long total; /* Total CPU Time */
|
||||
unsigned long user; /* CPU Time in User Mode */
|
||||
unsigned long nice; /* CPU Time in User Mode (nice) */
|
||||
unsigned long sys; /* CPU Time in System Mode */
|
||||
unsigned long idle; /* CPU Time in the Idle Task */
|
||||
};
|
||||
|
||||
struct libgtop_mem
|
||||
{
|
||||
unsigned long totalram; /* Total usable main memory size */
|
||||
unsigned long freeram; /* Available memory size */
|
||||
unsigned long sharedram; /* Amount of shared memory */
|
||||
unsigned long bufferram; /* Memory used by buffers */
|
||||
unsigned long cachedram;
|
||||
};
|
||||
|
||||
struct libgtop_swap
|
||||
{
|
||||
unsigned long totalswap; /* Total swap space size */
|
||||
unsigned long freeswap; /* swap space still available */
|
||||
};
|
||||
|
||||
struct libgtop_proclist
|
||||
{
|
||||
int count;
|
||||
int nr_running, nr_tasks, last_pid;
|
||||
unsigned pids [NR_TASKS];
|
||||
};
|
||||
|
||||
struct libgtop_stat
|
||||
{
|
||||
int ncpu; /* Number of CPUs */
|
||||
unsigned long frequency; /* Tick frequency (HZ) */
|
||||
libgtop_cpu_t cpu; /* CPU statistics */
|
||||
libgtop_cpu_t xcpu [NR_CPUS]; /* SMP per-CPU statistics */
|
||||
double loadavg [3]; /* Load average */
|
||||
unsigned long total_forks; /* Total # of forks */
|
||||
unsigned int context_swtch; /* Total # of context switches */
|
||||
unsigned long boot_time; /* Boot time (seconds s. epoch) */
|
||||
unsigned int pgpgin, pgpgout; /* # of pages paged in/out */
|
||||
unsigned int pswpin, pswpout; /* # of swap pgs brought in/out */
|
||||
};
|
||||
|
||||
struct libgtop_proc_state
|
||||
{
|
||||
long state;
|
||||
unsigned long flags;
|
||||
char comm [16];
|
||||
int uid, euid, suid, fsuid;
|
||||
int gid, egid, sgid, fsgid;
|
||||
int pid, pgrp, ppid;
|
||||
int session;
|
||||
unsigned int tty;
|
||||
int tpgid;
|
||||
long priority, counter, def_priority;
|
||||
long utime, stime, cutime, cstime, start_time;
|
||||
long per_cpu_utime [NR_CPUS], per_cpu_stime [NR_CPUS];
|
||||
int has_cpu, processor, last_processor;
|
||||
|
||||
unsigned long context;
|
||||
unsigned long start_code, end_code, start_data, end_data;
|
||||
unsigned long start_brk, brk, start_stack, start_mmap;
|
||||
unsigned long arg_start, arg_end, env_start, env_end;
|
||||
unsigned long rss, rlim, total_vm, locked_vm;
|
||||
|
||||
unsigned long policy, rt_priority;
|
||||
unsigned long it_real_value, it_prof_value, it_virt_value;
|
||||
unsigned long it_real_incr, it_prof_incr, it_virt_incr;
|
||||
|
||||
unsigned long keip, kesp;
|
||||
unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
|
||||
unsigned long nswap, cnswap;
|
||||
|
||||
int ngroups, groups [LIBGTOP_MAX_GROUPS];
|
||||
};
|
||||
|
||||
struct libgtop_proc_kernel
|
||||
{
|
||||
unsigned long wchan;
|
||||
};
|
||||
|
||||
struct libgtop_proc_segment
|
||||
{
|
||||
unsigned long vsize, data, exec, stack, lib;
|
||||
};
|
||||
|
||||
struct libgtop_proc_mem
|
||||
{
|
||||
libgtop_proc_segment_t segment;
|
||||
int size, resident, share, trs, lrs, drs, dt;
|
||||
unsigned long rss, rlim;
|
||||
};
|
||||
|
||||
struct libgtop_proc_signal
|
||||
{
|
||||
unsigned long signal [LIBGTOP_NSIG];
|
||||
unsigned long blocked [LIBGTOP_NSIG];
|
||||
unsigned long ignore [LIBGTOP_NSIG];
|
||||
unsigned long catch [LIBGTOP_NSIG];
|
||||
};
|
||||
|
||||
struct libgtop_proc_maps_header
|
||||
{
|
||||
unsigned long start, end, offset, perm;
|
||||
off_t filename_offset;
|
||||
ino_t inode;
|
||||
dev_t device;
|
||||
} __attribute__ ((aligned (64)));
|
||||
|
||||
struct libgtop_proc_maps
|
||||
{
|
||||
libgtop_proc_maps_header_t header;
|
||||
char filename [LIBGTOP_MAP_PATH_LEN];
|
||||
};
|
||||
|
||||
struct libgtop_netload
|
||||
{
|
||||
unsigned long rx_packets; /* total packets received */
|
||||
unsigned long tx_packets; /* total packets transmitted */
|
||||
unsigned long rx_bytes; /* total bytes received */
|
||||
unsigned long tx_bytes; /* total bytes transmitted */
|
||||
unsigned long rx_errors; /* bad packets received */
|
||||
unsigned long tx_errors; /* packet transmit problems */
|
||||
unsigned long rx_dropped; /* no space in linux buffers */
|
||||
unsigned long tx_dropped; /* no space available in linux */
|
||||
unsigned long multicast; /* multicast packets received */
|
||||
unsigned long collisions;
|
||||
|
||||
/* detailed rx_errors: */
|
||||
unsigned long rx_length_errors;
|
||||
unsigned long rx_over_errors; /* receiver ring buff overflow */
|
||||
unsigned long rx_crc_errors; /* recved pkt with crc error */
|
||||
unsigned long rx_frame_errors; /* recv'd frame alignment error */
|
||||
unsigned long rx_fifo_errors; /* recv'r fifo overrun */
|
||||
unsigned long rx_missed_errors; /* receiver missed packet */
|
||||
|
||||
/* detailed tx_errors */
|
||||
unsigned long tx_aborted_errors;
|
||||
unsigned long tx_carrier_errors;
|
||||
unsigned long tx_fifo_errors;
|
||||
unsigned long tx_heartbeat_errors;
|
||||
unsigned long tx_window_errors;
|
||||
|
||||
/* for cslip etc */
|
||||
unsigned long rx_compressed;
|
||||
unsigned long tx_compressed;
|
||||
};
|
||||
|
||||
#endif
|
30
kernel/sysctl/libgtop_syms.c
Normal file
30
kernel/sysctl/libgtop_syms.c
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* linux/libgtop/libgtop_syms.c
|
||||
* Copyright (C) 1999 Martin Baulig
|
||||
*/
|
||||
|
||||
#include <linux/config.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#include <linux/sched.h>
|
||||
|
||||
#include <linux/mm.h>
|
||||
#include <linux/pagemap.h>
|
||||
#include <linux/swap.h>
|
||||
|
||||
extern unsigned long total_forks;
|
||||
|
||||
EXPORT_SYMBOL(task);
|
||||
EXPORT_SYMBOL(init_mm);
|
||||
EXPORT_SYMBOL(pidhash);
|
||||
EXPORT_SYMBOL(avenrun);
|
||||
EXPORT_SYMBOL(nr_running);
|
||||
EXPORT_SYMBOL(nr_tasks);
|
||||
EXPORT_SYMBOL(last_pid);
|
||||
EXPORT_SYMBOL(total_forks);
|
||||
EXPORT_SYMBOL(si_swapinfo);
|
||||
|
||||
extern void scheduling_functions_start_here(void);
|
||||
extern void scheduling_functions_end_here(void);
|
||||
EXPORT_SYMBOL(scheduling_functions_start_here);
|
||||
EXPORT_SYMBOL(scheduling_functions_end_here);
|
4
kernel/sysctl/main.c
Normal file
4
kernel/sysctl/main.c
Normal file
@@ -0,0 +1,4 @@
|
||||
/*
|
||||
* linux/libgtop/main.c
|
||||
* Copyright (C) 1999 Martin Baulig
|
||||
*/
|
81
kernel/sysctl/patch-2.2.1
Normal file
81
kernel/sysctl/patch-2.2.1
Normal file
@@ -0,0 +1,81 @@
|
||||
diff -ru linux-2.2.1/Makefile hacker/Makefile
|
||||
--- linux-2.2.1/Makefile Sun Jan 31 22:45:42 1999
|
||||
+++ hacker/Makefile Sun Mar 21 16:10:41 1999
|
||||
@@ -109,6 +109,7 @@
|
||||
DRIVERS =drivers/block/block.a \
|
||||
drivers/char/char.a \
|
||||
drivers/misc/misc.a
|
||||
+EXTRAS =
|
||||
LIBS =$(TOPDIR)/lib/lib.a
|
||||
SUBDIRS =kernel drivers mm fs net ipc lib
|
||||
|
||||
@@ -186,6 +187,11 @@
|
||||
DRIVERS := $(DRIVERS) drivers/net/irda/irda_drivers.a
|
||||
endif
|
||||
|
||||
+ifdef CONFIG_LIBGTOP
|
||||
+SUBDIRS := $(SUBDIRS) libgtop
|
||||
+EXTRAS := $(EXTRAS) libgtop/kernel.o
|
||||
+endif
|
||||
+
|
||||
include arch/$(ARCH)/Makefile
|
||||
|
||||
.S.s:
|
||||
@@ -206,6 +212,7 @@
|
||||
$(FILESYSTEMS) \
|
||||
$(NETWORKS) \
|
||||
$(DRIVERS) \
|
||||
+ $(EXTRAS) \
|
||||
$(LIBS) \
|
||||
--end-group \
|
||||
-o vmlinux
|
||||
diff -ru linux-2.2.1/arch/i386/config.in hacker/arch/i386/config.in
|
||||
--- linux-2.2.1/arch/i386/config.in Sun Jan 31 22:25:25 1999
|
||||
+++ hacker/arch/i386/config.in Sat Mar 20 18:26:18 1999
|
||||
@@ -84,6 +84,9 @@
|
||||
bool 'System V IPC' CONFIG_SYSVIPC
|
||||
bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT
|
||||
bool 'Sysctl support' CONFIG_SYSCTL
|
||||
+if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
|
||||
+ tristate 'LibGTop support' CONFIG_LIBGTOP
|
||||
+fi
|
||||
tristate 'Kernel support for a.out binaries' CONFIG_BINFMT_AOUT
|
||||
tristate 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF
|
||||
tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC
|
||||
diff -ru linux-2.2.1/include/linux/sysctl.h hacker/include/linux/sysctl.h
|
||||
--- linux-2.2.1/include/linux/sysctl.h Sun Jan 31 22:24:14 1999
|
||||
+++ hacker/include/linux/sysctl.h Sat Mar 20 19:12:54 1999
|
||||
@@ -56,7 +56,8 @@
|
||||
CTL_PROC=4, /* Process info */
|
||||
CTL_FS=5, /* Filesystems */
|
||||
CTL_DEBUG=6, /* Debugging */
|
||||
- CTL_DEV=7 /* Devices */
|
||||
+ CTL_DEV=7, /* Devices */
|
||||
+ CTL_LIBGTOP=408 /* LibGTop */
|
||||
};
|
||||
|
||||
|
||||
diff -ru linux-2.2.1/kernel/sysctl.c hacker/kernel/sysctl.c
|
||||
--- linux-2.2.1/kernel/sysctl.c Sun Jan 31 22:24:43 1999
|
||||
+++ hacker/kernel/sysctl.c Sat Mar 20 19:24:34 1999
|
||||
@@ -82,7 +82,9 @@
|
||||
static ctl_table fs_table[];
|
||||
static ctl_table debug_table[];
|
||||
static ctl_table dev_table[];
|
||||
-
|
||||
+#ifdef CONFIG_LIBGTOP
|
||||
+extern ctl_table libgtop_table[];
|
||||
+#endif
|
||||
|
||||
/* /proc declarations: */
|
||||
|
||||
@@ -148,6 +150,9 @@
|
||||
{CTL_FS, "fs", NULL, 0, 0555, fs_table},
|
||||
{CTL_DEBUG, "debug", NULL, 0, 0555, debug_table},
|
||||
{CTL_DEV, "dev", NULL, 0, 0555, dev_table},
|
||||
+#ifdef CONFIG_LIBGTOP
|
||||
+ {CTL_LIBGTOP, "libgtop", NULL, 0, 0555, libgtop_table},
|
||||
+#endif
|
||||
{0}
|
||||
};
|
||||
|
@@ -36,6 +36,10 @@ print 'static void';
|
||||
print '_glibtop_missing_feature (glibtop *server, const char *feature,';
|
||||
print "\t\t\t const u_int64_t present, u_int64_t *required)";
|
||||
print '{';
|
||||
print "\tu_int64_t old_required = *required;\n";
|
||||
print "\t/* Return if we have all required fields. */";
|
||||
print "\tif ((~present & old_required) == 0)";
|
||||
print "\t\treturn;\n";
|
||||
print "\tswitch (server->error_method) {";
|
||||
print "\tcase GLIBTOP_ERROR_METHOD_WARN_ONCE:";
|
||||
print "\t\t*required &= present;";
|
||||
@@ -43,13 +47,13 @@ print "\tcase GLIBTOP_ERROR_METHOD_WARN:";
|
||||
print "\t\tglibtop_warn_r (server,";
|
||||
print "\t\t\t\t_(\"glibtop_get_%s (): Client requested \"";
|
||||
print "\t\t\t\t \"field mask %05Lx, but only have %05Lx.\"),";
|
||||
print "\t\t\t\t feature, required, present);";
|
||||
print "\t\t\t\t feature, old_required, present);";
|
||||
print "\t\tbreak;";
|
||||
print "\tcase GLIBTOP_ERROR_METHOD_ABORT:";
|
||||
print "\t\tglibtop_error_r (server,";
|
||||
print "\t\t\t\t _(\"glibtop_get_%s (): Client requested \"";
|
||||
print "\t\t\t\t \"field mask %05x, but only have %05x.\"),";
|
||||
print "\t\t\t\t feature, required, present);";
|
||||
print "\t\t\t\t feature, old_required, present);";
|
||||
print "\t\tbreak;";
|
||||
print "\t}";
|
||||
print '}';
|
||||
|
26
misc/timings/timings.linux-proc
Normal file
26
misc/timings/timings.linux-proc
Normal file
@@ -0,0 +1,26 @@
|
||||
This statistics were made on a PPRO 200 running Linux 2.2.1
|
||||
reading everything from /proc while the system was idle.
|
||||
|
||||
|
||||
Feature (Flags ): Count - utime - stime
|
||||
----------------------------------------------------------
|
||||
CPU (0x000007ff): 100000 - 13.90 - 181.80
|
||||
Memory (0x0000007f): 10000 - 32.00 - 8061.00
|
||||
Swap (0x0000001f): 10000 - 46.00 - 8130.00
|
||||
Uptime (0x00000003): 100000 - 19.60 - 72.20
|
||||
Loadavg (0x0000000f): 100000 - 32.40 - 77.10
|
||||
|
||||
Proclist (0x00000007): 10000 - 2250.00 - 4419.00
|
||||
|
||||
Proc_State (0x0000000f): 100000 - 40.70 - 221.00
|
||||
Proc_Uid (0x00000fff): 100000 - 72.40 - 327.30
|
||||
Proc_Mem (0x0000003f): 100000 - 65.70 - 283.90
|
||||
Proc_Segment (0x000000f5): 100000 - 76.50 - 281.10
|
||||
Proc_Time (0x000001ff): 100000 - 37.00 - 160.90
|
||||
Proc_Signal (0x0000000f): 100000 - 52.50 - 148.50
|
||||
Proc_Kernel (0x0000017f): 100000 - 56.70 - 153.50
|
||||
----------------------------------------------------------
|
||||
TOTAL 70030000 - 396830000
|
||||
|
||||
All timings are in clock ticks (1000000 ticks per second).
|
||||
|
27
misc/timings/timings.linux-sysctl
Normal file
27
misc/timings/timings.linux-sysctl
Normal file
@@ -0,0 +1,27 @@
|
||||
This statistics were made on a PPRO 200 running Linux 2.2.1
|
||||
(the same machine I made the timings.linux-proc on) with my
|
||||
new sysctl () based kernel module.
|
||||
|
||||
|
||||
Feature (Flags ): Count - utime - stime
|
||||
----------------------------------------------------------
|
||||
CPU (0x0000003f): 100000 - 3.50 - 5.40
|
||||
Memory (0x0000003f): 10000 - 3.00 - 6.00
|
||||
Swap (0x0000001f): 10000 - 10.00 - 7.00
|
||||
Uptime (0x00000003): 100000 - 2.30 - 7.00
|
||||
Loadavg (0x00000001): 100000 - 3.00 - 5.60
|
||||
|
||||
Proclist (0x00000007): 10000 - 13.00 - 46.00
|
||||
|
||||
Proc_State (0x0000000d): 100000 - 3.20 - 7.70
|
||||
Proc_Uid (0x00000fff): 100000 - 3.60 - 7.40
|
||||
Proc_Mem (0x0000003f): 100000 - 4.10 - 34.30
|
||||
Proc_Segment (0x000000ff): 100000 - 5.90 - 41.50
|
||||
Proc_Time (0x0000013d): 100000 - 3.50 - 7.50
|
||||
Proc_Signal (0x0000000f): 100000 - 2.70 - 8.80
|
||||
Proc_Kernel (0x000000fe): 100000 - 4.00 - 13.30
|
||||
----------------------------------------------------------
|
||||
TOTAL 3840000 - 14440000
|
||||
|
||||
All timings are in clock ticks (1000000 ticks per second).
|
||||
|
2
po/de.po
2
po/de.po
@@ -5,7 +5,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: libgtop VERSION\n"
|
||||
"POT-Creation-Date: 1999-02-27 22:24+0100\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: Martin Baulig <martin@home-of-linux.org>\n"
|
||||
"Language-Team: Martin Baulig <martin@home-of-linux.org>\n"
|
||||
|
2
po/es.po
2
po/es.po
@@ -1,7 +1,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: glibtop 1.0.0\n"
|
||||
"POT-Creation-Date: 1999-02-23 13:48+0100\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"PO-Revision-Date: 1998-12-13 04:38+0100\n"
|
||||
"Last-Translator: Pablo Saratxaga <srtxg@chanae.alphanet.ch>\n"
|
||||
"Language-Team: Pablo Saratxaga <srtxg@chanae.alphanet.ch>\n"
|
||||
|
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1999-02-27 22:24+0100\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1999-02-27 22:24+0100\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1999-02-27 22:24+0100\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1999-02-27 22:24+0100\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1999-02-27 22:24+0100\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1999-02-27 22:24+0100\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1999-02-27 22:24+0100\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
2
po/fr.po
2
po/fr.po
@@ -5,7 +5,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: libgtop VERSION\n"
|
||||
"POT-Creation-Date: 1999-02-27 22:24+0100\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: Vincent Renardias <vincent@waw.com>\n"
|
||||
"Language-Team: Vincent Renardias <vincent@waw.com>\n"
|
||||
|
2
po/ja.po
2
po/ja.po
@@ -4,7 +4,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: libgtop VERSION\n"
|
||||
"POT-Creation-Date: 1999-02-27 22:24+0100\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"PO-Revision-Date: 1998-12-11 06:53+09:00\n"
|
||||
"Last-Translator: Eiichiro ITANI <emu@ceres.dti.ne.jp>\n"
|
||||
"Language-Team: <gnome@lists.hypercore.co.jp>\n"
|
||||
|
2
po/ko.po
2
po/ko.po
@@ -5,7 +5,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: libgtop VERSION\n"
|
||||
"POT-Creation-Date: 1999-02-27 22:24+0100\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"PO-Revision-Date: 1999-02-04 14:31:38+0900\n"
|
||||
"Last-Translator: Sung-Hyun Nam <namsh@lgic.co.kr>\n"
|
||||
"Language-Team: Korean <ko@li.org>\n"
|
||||
|
2
po/no.po
2
po/no.po
@@ -5,7 +5,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: libgtop 0.99.3\n"
|
||||
"POT-Creation-Date: 1999-02-27 22:24+0100\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"PO-Revision-Date: 1999-01-27 23:22+0100\n"
|
||||
"Last-Translator: Kjartan Maraas <kmaraas@fib.hl.no>\n"
|
||||
"Language-Team: Norwegian <no@li.org>\n"
|
||||
|
@@ -1,3 +1,30 @@
|
||||
Thu Apr 8 23:47:29 1999 Timur Bakeyev <timur@gnu.org>
|
||||
|
||||
* cpu.c, mem.c, netload.c, procargs.c, procstate.c, proctime.c,
|
||||
sem_limits.c, shm_limits.c, swap.c: Added initial port for BSD/OS
|
||||
(aka BSDI) 2.x and 3.x. 4.x should also(?) work.
|
||||
|
||||
Still, this port require more close look and extended check.
|
||||
|
||||
1999-03-19 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
Added basic support for BSDI. It compiles without problems on
|
||||
BSDI 2.1 and 3.1, but it is *untested* - I'm neither root on
|
||||
the machine nor have I access to /dev/kmem, so I don't know
|
||||
whether it will work.
|
||||
|
||||
You need to give configure the `--enable-hacker-mode' parameter
|
||||
to use the code.
|
||||
|
||||
If someone can verify whether it actually works, please let me
|
||||
know.
|
||||
|
||||
1999-03-18 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* ppp.c: Don't use `sppp.pp_phase' if we don't HAVE_I4B_ACCT.
|
||||
This is an ugly hack until someone tells me which versions have
|
||||
this field and which not.
|
||||
|
||||
1999-02-25 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* prockernel.c, proctime.c: Applied patch Stanislav Grozev for
|
||||
|
@@ -34,7 +34,11 @@ static const unsigned long _glibtop_sysdeps_cpu =
|
||||
|
||||
/* nlist structure for kernel access */
|
||||
static struct nlist nlst [] = {
|
||||
#ifdef __bsdi__
|
||||
{ "_cpustats" },
|
||||
#else
|
||||
{ "_cp_time" },
|
||||
#endif
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
|
@@ -33,7 +33,8 @@
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_mem =
|
||||
(1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) +
|
||||
(1 << GLIBTOP_MEM_FREE) + (1 << GLIBTOP_MEM_SHARED) +
|
||||
(1 << GLIBTOP_MEM_FREE) +
|
||||
(1 << GLIBTOP_MEM_SHARED) +
|
||||
(1 << GLIBTOP_MEM_BUFFER) +
|
||||
#ifdef __FreeBSD__
|
||||
(1 << GLIBTOP_MEM_CACHED) +
|
||||
@@ -53,7 +54,9 @@ static int pageshift; /* log base 2 of the pagesize */
|
||||
/* nlist structure for kernel access */
|
||||
static struct nlist nlst [] = {
|
||||
{ "_cnt" },
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__bsdi__)
|
||||
{ "_bufcachemem" },
|
||||
#elif defined(__FreeBSD__)
|
||||
{ "_bufspace" },
|
||||
#else
|
||||
{ "_bufpages" },
|
||||
@@ -62,8 +65,12 @@ static struct nlist nlst [] = {
|
||||
};
|
||||
|
||||
/* MIB array for sysctl */
|
||||
/* static int mib_length=2; */
|
||||
static int mib_length=2;
|
||||
#ifdef __bsdi__
|
||||
static int mib [] = { CTL_VM, VM_TOTAL };
|
||||
#else
|
||||
static int mib [] = { CTL_VM, VM_METER };
|
||||
#endif
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -135,7 +142,7 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
|
||||
|
||||
/* convert memory stats to Kbytes */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__)
|
||||
v_total_count = vmm.v_page_count;
|
||||
#else
|
||||
v_total_count = vmm.v_kernel_pages +
|
||||
|
@@ -27,9 +27,26 @@
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#if (defined __bsdi__) && (_BSDI_VERSION < 199700)
|
||||
/* Older versions of BSDI don't seem to have this. */
|
||||
|
||||
void
|
||||
glibtop_init_msg_limits_p (glibtop *server)
|
||||
{ }
|
||||
|
||||
void
|
||||
glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
|
||||
{
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_msg_limits));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* #define KERNEL to get declaration of `struct msginfo'. */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if (defined __FreeBSD__) || (defined __bsdi__)
|
||||
#define KERNEL 1
|
||||
#else
|
||||
#define _KERNEL 1
|
||||
@@ -93,3 +110,6 @@ glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
|
||||
|
||||
buf->flags = _glibtop_sysdeps_msg_limits;
|
||||
}
|
||||
|
||||
#endif /* either a newer BSDI or no BSDI at all. */
|
||||
|
||||
|
@@ -107,7 +107,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
||||
sizeof (ifnet)) != sizeof (ifnet))
|
||||
glibtop_error_io_r (server, "kvm_read (ifnetaddr)");
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) || defined(__bsdi__)
|
||||
if (kvm_read (server->machine.kd, (u_long) ifnet.if_name,
|
||||
tname, 16) != 16)
|
||||
glibtop_error_io_r (server, "kvm_read (if_name)");
|
||||
@@ -116,9 +116,9 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
||||
tname [15] = 0;
|
||||
#endif
|
||||
|
||||
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300000)
|
||||
#if defined(__FreeBSD__) && (__FreeBSD_version >= 300000)
|
||||
ifaddraddr = (u_long) ifnet.if_addrhead.tqh_first;
|
||||
#elif (defined __FreeBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__bsdi__)
|
||||
ifaddraddr = (u_long) ifnet.if_addrlist;
|
||||
#else
|
||||
ifaddraddr = (u_long) ifnet.if_addrlist.tqh_first;
|
||||
@@ -194,18 +194,18 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
||||
return;
|
||||
}
|
||||
|
||||
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300000)
|
||||
#if defined(__FreeBSD__) && (__FreeBSD_version >= 300000)
|
||||
ifaddraddr = (u_long)ifaddr.ifa.ifa_link.tqe_next;
|
||||
#elif (defined __FreeBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__bsdi__)
|
||||
ifaddraddr = (u_long)ifaddr.ifa.ifa_next;
|
||||
#else
|
||||
ifaddraddr = (u_long)ifaddr.ifa.ifa_list.tqe_next;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300000)
|
||||
#if defined(__FreeBSD__) && (__FreeBSD_version >= 300000)
|
||||
ifnetaddr = (u_long) ifnet.if_link.tqe_next;
|
||||
#elif (defined __FreeBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__bsdi__)
|
||||
ifnetaddr = (u_long) ifnet.if_next;
|
||||
#else
|
||||
ifnetaddr = (u_long) ifnet.if_list.tqe_next;
|
||||
|
@@ -110,10 +110,15 @@ glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device)
|
||||
#ifdef HAVE_I4B_ACCT
|
||||
phase = data.sc_if_un.scu_sp.pp_phase;
|
||||
#else
|
||||
/* FIXME: Which FreeBSD version have this field and
|
||||
* which not. */
|
||||
#if 0
|
||||
phase = data.pp_phase;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
switch (phase) {
|
||||
#ifdef HAVE_I4B_ACCT
|
||||
case PHASE_DEAD:
|
||||
case PHASE_TERMINATE:
|
||||
buf->state = GLIBTOP_PPP_STATE_HANGUP;
|
||||
@@ -122,6 +127,7 @@ glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device)
|
||||
case PHASE_NETWORK:
|
||||
buf->state = GLIBTOP_PPP_STATE_ONLINE;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
buf->state = GLIBTOP_PPP_STATE_UNKNOWN;
|
||||
break;
|
||||
|
@@ -54,8 +54,10 @@ glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
|
||||
unsigned size = 0, pos = 0;
|
||||
int count;
|
||||
|
||||
#ifndef __bsdi__
|
||||
char filename [BUFSIZ];
|
||||
struct stat statb;
|
||||
#endif
|
||||
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_ARGS), 0);
|
||||
|
||||
@@ -64,8 +66,10 @@ glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
|
||||
/* swapper, init, pagedaemon, vmdaemon, update - this doen't work. */
|
||||
if (pid < 5) return NULL;
|
||||
|
||||
#ifndef __bsdi__
|
||||
sprintf (filename, "/proc/%d/mem", pid);
|
||||
if (stat (filename, &statb)) return NULL;
|
||||
#endif
|
||||
|
||||
glibtop_suid_enter (server);
|
||||
|
||||
|
@@ -31,10 +31,12 @@
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/proc.h>
|
||||
#ifndef __OpenBSD__
|
||||
#if (!defined __OpenBSD__) && (!defined __bsdi__)
|
||||
#include <sys/user.h>
|
||||
#endif
|
||||
#ifndef __bsdi__
|
||||
#include <machine/pcb.h>
|
||||
#endif
|
||||
#ifdef __FreeBSD__
|
||||
#include <machine/tss.h>
|
||||
#endif
|
||||
@@ -122,7 +124,7 @@ glibtop_get_proc_kernel_p (glibtop *server,
|
||||
/* NOTE: You need to mount the /proc filesystem to make
|
||||
* `kvm_uread' work. */
|
||||
|
||||
sprintf (filename, "/proc/%d/mem", pid);
|
||||
sprintf (filename, "/proc/%d/mem", (int) pid);
|
||||
if (stat (filename, &statb)) return;
|
||||
|
||||
glibtop_suid_enter (server);
|
||||
@@ -162,7 +164,11 @@ glibtop_get_proc_kernel_p (glibtop *server,
|
||||
#endif
|
||||
#else
|
||||
buf->kstk_esp = (u_int64_t) pcb.pcb_tss.tss_esp0;
|
||||
#ifdef __bsdi__
|
||||
buf->kstk_eip = (u_int64_t) pcb.pcb_tss.tss_eip;
|
||||
#else
|
||||
buf->kstk_eip = (u_int64_t) pcb.pcb_tss.__tss_eip;
|
||||
#endif
|
||||
|
||||
buf->flags |= _glibtop_sysdeps_proc_kernel_pcb;
|
||||
#endif
|
||||
|
@@ -42,7 +42,7 @@
|
||||
#include <ufs/ufs/inode.h>
|
||||
|
||||
#include <sys/ucred.h>
|
||||
#ifndef __OpenBSD__
|
||||
#if (!defined __OpenBSD__) && (!defined __bsdi__)
|
||||
#include <sys/user.h>
|
||||
#endif
|
||||
#include <sys/sysctl.h>
|
||||
|
@@ -39,7 +39,7 @@
|
||||
#include <ufs/ufs/inode.h>
|
||||
|
||||
#include <sys/ucred.h>
|
||||
#ifndef __OpenBSD__
|
||||
#if (!defined __OpenBSD__) && (!defined __bsdi__)
|
||||
#include <sys/user.h>
|
||||
#endif
|
||||
#include <sys/sysctl.h>
|
||||
|
@@ -27,13 +27,14 @@
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#ifndef __OpenBSD__
|
||||
#if !defined(__OpenBSD__)
|
||||
//&& (!defined __bsdi__)
|
||||
#include <sys/user.h>
|
||||
#endif
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_state =
|
||||
(1 << GLIBTOP_PROC_STATE_CMD) + (1 << GLIBTOP_PROC_STATE_STATE) +
|
||||
(1 << GLIBTOP_PROC_STATE_UID) + (1 << GLIBTOP_PROC_STATE_GID);
|
||||
(1 << GLIBTOP_PROC_STATE_CMD) + (1 << GLIBTOP_PROC_STATE_UID) +
|
||||
(1 << GLIBTOP_PROC_STATE_GID);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -73,27 +74,28 @@ glibtop_get_proc_state_p (glibtop *server,
|
||||
buf->uid = pinfo [0].kp_eproc.e_pcred.p_svuid;
|
||||
buf->gid = pinfo [0].kp_eproc.e_pcred.p_svgid;
|
||||
|
||||
switch (pinfo [0].kp_proc.p_stat) {
|
||||
case SIDL:
|
||||
buf->state = 'I';
|
||||
break;
|
||||
case SRUN:
|
||||
buf->state = 'R';
|
||||
break;
|
||||
case SSLEEP:
|
||||
buf->state = 'S';
|
||||
break;
|
||||
case SSTOP:
|
||||
buf->state = 'T';
|
||||
break;
|
||||
case SZOMB:
|
||||
buf->state = 'Z';
|
||||
break;
|
||||
default:
|
||||
buf->state = '?';
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set the flags for the data we're about to return*/
|
||||
buf->flags = _glibtop_sysdeps_proc_state;
|
||||
|
||||
switch (pinfo [0].kp_proc.p_stat) {
|
||||
case SIDL:
|
||||
buf->state = 0;
|
||||
break;
|
||||
case SRUN:
|
||||
buf->state = GLIBTOP_PROCESS_RUNNING;
|
||||
break;
|
||||
case SSLEEP:
|
||||
buf->state = GLIBTOP_PROCESS_INTERRUPTIBLE;
|
||||
break;
|
||||
case SSTOP:
|
||||
buf->state = GLIBTOP_PROCESS_STOPPED;
|
||||
break;
|
||||
case SZOMB:
|
||||
buf->state = GLIBTOP_PROCESS_ZOMBIE;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
buf->flags |= (1 << GLIBTOP_PROC_STATE_STATE);
|
||||
}
|
||||
|
@@ -140,8 +140,10 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
|
||||
/* It does not work for the swapper task. */
|
||||
if (pid == 0) return;
|
||||
|
||||
sprintf (filename, "/proc/%d/mem", pid);
|
||||
#ifndef __bsdi__
|
||||
sprintf (filename, "/proc/%d/mem", (int) pid);
|
||||
if (stat (filename, &statb)) return;
|
||||
#endif
|
||||
|
||||
/* Get the process information */
|
||||
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
|
||||
|
@@ -27,9 +27,26 @@
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#if defined(__bsdi__) && (_BSDI_VERSION < 199700)
|
||||
/* Older versions of BSDI don't seem to have this. */
|
||||
|
||||
void
|
||||
glibtop_init_sem_limits_p (glibtop *server)
|
||||
{ }
|
||||
|
||||
void
|
||||
glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
|
||||
{
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_sem_limits));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* #define KERNEL to get declaration of `struct seminfo'. */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) || defined(__bsdi__)
|
||||
#define KERNEL 1
|
||||
#else
|
||||
#define _KERNEL 1
|
||||
@@ -98,3 +115,6 @@ glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
|
||||
|
||||
buf->flags = _glibtop_sysdeps_sem_limits;
|
||||
}
|
||||
|
||||
#endif /* either a newer BSDI or no BSDI at all. */
|
||||
|
||||
|
@@ -27,9 +27,26 @@
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#if defined(__bsdi__) && (_BSDI_VERSION < 199700)
|
||||
/* Older versions of BSDI don't seem to have this. */
|
||||
|
||||
void
|
||||
glibtop_init_shm_limits_p (glibtop *server)
|
||||
{ }
|
||||
|
||||
void
|
||||
glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
|
||||
{
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_shm_limits));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* #define KERNEL to get declaration of `struct shminfo'. */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) || defined(__bsdi__)
|
||||
#define KERNEL 1
|
||||
#else
|
||||
#define _KERNEL 1
|
||||
@@ -93,3 +110,6 @@ glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
|
||||
|
||||
buf->flags = _glibtop_sysdeps_shm_limits;
|
||||
}
|
||||
|
||||
#endif /* either a newer BSDI or no BSDI at all. */
|
||||
|
||||
|
@@ -34,15 +34,24 @@ static const unsigned long _glibtop_sysdeps_swap =
|
||||
(1 << GLIBTOP_SWAP_FREE) + (1 << GLIBTOP_SWAP_PAGEIN) +
|
||||
(1 << GLIBTOP_SWAP_PAGEOUT);
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) || defined(__bsdi__)
|
||||
|
||||
#include <sys/conf.h>
|
||||
#ifdef __bsdi__
|
||||
#include <vm/swap_pager.h>
|
||||
#else
|
||||
#include <sys/rlist.h>
|
||||
#endif
|
||||
#include <sys/vmmeter.h>
|
||||
|
||||
#if __FreeBSD__ < 4
|
||||
|
||||
/* nlist structure for kernel access */
|
||||
|
||||
#if defined(__bsdi__)
|
||||
static struct nlist nlst [] = {
|
||||
{ "_swapstats" }, /* general swap info */
|
||||
{ 0 }
|
||||
};
|
||||
#elif __FreeBSD__ < 4
|
||||
static struct nlist nlst [] = {
|
||||
#define VM_SWAPLIST 0
|
||||
{ "_swaplist" },/* list of free swap areas */
|
||||
@@ -56,10 +65,9 @@ static struct nlist nlst [] = {
|
||||
{ "_dmmax" }, /* maximum size of a swap block */
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#elif (defined __NetBSD__)
|
||||
#elif defined(__NetBSD__)
|
||||
|
||||
#include <vm/vm_swap.h>
|
||||
|
||||
@@ -76,8 +84,8 @@ static struct nlist nlst2 [] = {
|
||||
void
|
||||
glibtop_init_swap_p (glibtop *server)
|
||||
{
|
||||
#ifdef __FreeBSD__
|
||||
#if __FreeBSD__ < 4
|
||||
#if defined(__FreeBSD__) || defined(__bsdi__)
|
||||
#if __FreeBSD__ < 4 || defined(__bsdi__)
|
||||
if (kvm_nlist (server->machine.kd, nlst) != 0) {
|
||||
glibtop_warn_io_r (server, "kvm_nlist (swap)");
|
||||
return;
|
||||
@@ -86,14 +94,14 @@ glibtop_init_swap_p (glibtop *server)
|
||||
struct kvm_swap dummy;
|
||||
|
||||
if (kvm_getswapinfo (server->machine.kd, &dummy, 1, 0) != 0) {
|
||||
glibtop_warn_io_r (server, "kvm_nlist (swap)");
|
||||
glibtop_warn_io_r (server, "kvm_swap (swap)");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (kvm_nlist (server->machine.kd, nlst2) != 0) {
|
||||
glibtop_warn_io_r (server, "kvm_nlist (swap)");
|
||||
glibtop_warn_io_r (server, "kvm_nlist (cnt)");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -110,8 +118,9 @@ glibtop_init_swap_p (glibtop *server)
|
||||
void
|
||||
glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
{
|
||||
#ifdef __FreeBSD__
|
||||
#if __FreeBSD__ < 4
|
||||
#if defined(__FreeBSD__)
|
||||
|
||||
# if __FreeBSD__ < 4
|
||||
char *header;
|
||||
int hlen, nswdev, dmmax;
|
||||
int div, nfree, npfree;
|
||||
@@ -122,11 +131,14 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
struct rlist *swapptr;
|
||||
size_t sw_size;
|
||||
u_long ptr;
|
||||
#else
|
||||
# else
|
||||
int nswdev;
|
||||
struct kvm_swap kvmsw[16];
|
||||
#endif
|
||||
#elif (defined __NetBSD__)
|
||||
# endif
|
||||
|
||||
#elif defined(__bsdi__)
|
||||
struct swapstats swap;
|
||||
#elif defined(__NetBSD__)
|
||||
struct swapent *swaplist;
|
||||
#endif
|
||||
|
||||
@@ -174,7 +186,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
swappgsout = vmm.v_swpout;
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__)
|
||||
|
||||
#if __FreeBSD__ < 4
|
||||
|
||||
@@ -214,7 +226,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
|
||||
if (kvm_read (server->machine.kd, nlst[VM_SWDEVT].n_value,
|
||||
&ptr, sizeof (ptr)) != sizeof (ptr)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (swaplist)");
|
||||
glibtop_warn_io_r (server, "kvm_read (swdevt)");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -328,7 +340,24 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
|
||||
#endif
|
||||
|
||||
#elif (defined __NetBSD__)
|
||||
#elif defined(__bsdi__)
|
||||
|
||||
/* General info about swap devices. */
|
||||
|
||||
if (kvm_read (server->machine.kd, nlst[0].n_value,
|
||||
&swap, sizeof (swap)) != sizeof (swap)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (swap)");
|
||||
return;
|
||||
}
|
||||
|
||||
buf->flags = _glibtop_sysdeps_swap;
|
||||
|
||||
buf->used = swap.swap_total - swap.swap_free;
|
||||
buf->free = swap.swap_free;
|
||||
|
||||
buf->total = swap.swap_total;
|
||||
|
||||
#elif defined(__NetBSD__)
|
||||
|
||||
nswap = swapctl (SWAP_NSWAP, NULL, 0);
|
||||
if (nswap < 0) {
|
||||
|
89
sysdeps/kernel/glibtop_private.h
Normal file
89
sysdeps/kernel/glibtop_private.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GLIBTOP_PRIVATE_H__
|
||||
#define __GLIBTOP_PRIVATE_H__
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/user.h>
|
||||
|
||||
#undef LIBGTOP_VERSION
|
||||
#include <linux/libgtop.h>
|
||||
|
||||
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);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_mem_s (glibtop *server,
|
||||
libgtop_proc_mem_t *proc_mem,
|
||||
pid_t pid);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_signal_s (glibtop *server,
|
||||
libgtop_proc_signal_t *proc_signal,
|
||||
pid_t pid);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_kernel_s (glibtop *server,
|
||||
libgtop_proc_kernel_t *proc_kernel,
|
||||
pid_t pid);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_args_s (glibtop *server, pid_t pid,
|
||||
char *result, size_t max_len);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_maps_s (glibtop *server, pid_t pid,
|
||||
libgtop_proc_maps_t *result,
|
||||
size_t max_len);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_netload_s (glibtop *server,
|
||||
libgtop_netload_t *netload,
|
||||
const char *device);
|
||||
|
||||
END_LIBGTOP_DECLS
|
||||
|
||||
#endif __GLIBTOP_PRIVATE_H__
|
94
sysdeps/kernel/sysinfo.c
Normal file
94
sysdeps/kernel/sysinfo.c
Normal file
@@ -0,0 +1,94 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop/cpu.h>
|
||||
#include <glibtop/sysinfo.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_sysinfo =
|
||||
(1 << GLIBTOP_SYSINFO_CPUINFO);
|
||||
|
||||
static glibtop_sysinfo sysinfo;
|
||||
|
||||
static void
|
||||
init_sysinfo (glibtop *server)
|
||||
{
|
||||
char buffer [BUFSIZ];
|
||||
static int init = 0;
|
||||
glibtop_entry *cpuinfo = NULL;
|
||||
FILE *f;
|
||||
|
||||
if (init) return;
|
||||
|
||||
init = TRUE;
|
||||
|
||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0);
|
||||
|
||||
memset (&sysinfo, 0, sizeof (glibtop_sysinfo));
|
||||
|
||||
g_return_if_fail (f = fopen ("/proc/cpuinfo", "r"));
|
||||
|
||||
while (fgets (buffer, BUFSIZ, f)) {
|
||||
char *p, *start, *key, *value;
|
||||
|
||||
if (cpuinfo == NULL) {
|
||||
cpuinfo = &sysinfo.cpuinfo [sysinfo.ncpu++];
|
||||
|
||||
cpuinfo->labels = g_ptr_array_new ();
|
||||
|
||||
cpuinfo->values = g_hash_table_new (NULL, NULL);
|
||||
|
||||
if (sysinfo.ncpu > GLIBTOP_NCPU)
|
||||
sysinfo.ncpu = GLIBTOP_NCPU;
|
||||
}
|
||||
|
||||
p = strchr (buffer, ':');
|
||||
if (!p) continue;
|
||||
|
||||
/* Remove leading spaces from `p'. */
|
||||
*p = '\0'; start = p; p++;
|
||||
while (isspace (*p)) p++;
|
||||
|
||||
/* Remove trailing spaces from `buffer'. */
|
||||
while ((start > buffer) && (*start) && isspace (*start))
|
||||
*start-- = '\0';
|
||||
|
||||
key = g_strdup (buffer);
|
||||
value = g_strdup (p);
|
||||
|
||||
g_ptr_array_add (cpuinfo->labels, key);
|
||||
|
||||
g_hash_table_insert (cpuinfo->values, key, value);
|
||||
}
|
||||
|
||||
fclose (f);
|
||||
|
||||
sysinfo.flags = _glibtop_sysdeps_sysinfo;
|
||||
}
|
||||
|
||||
glibtop_sysinfo *
|
||||
glibtop_get_sysinfo_s (glibtop *server)
|
||||
{
|
||||
init_sysinfo (server);
|
||||
return &sysinfo;
|
||||
}
|
@@ -64,11 +64,13 @@ init_sysinfo (glibtop *server)
|
||||
|
||||
p = strchr (buffer, ':');
|
||||
if (!p) continue;
|
||||
|
||||
|
||||
/* Remove leading spaces from `p'. */
|
||||
*p = '\0'; start = p; p++;
|
||||
while (isspace (*p)) p++;
|
||||
|
||||
while ((start > buffer) && isspace (*start))
|
||||
/* Remove trailing spaces from `buffer'. */
|
||||
while ((start > buffer) && (*start) && isspace (*start))
|
||||
*start-- = '\0';
|
||||
|
||||
key = g_strdup (buffer);
|
||||
|
6
sysdeps/solaris/.cvsignore
Normal file
6
sysdeps/solaris/.cvsignore
Normal file
@@ -0,0 +1,6 @@
|
||||
.deps
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
libgtop_sysdeps.la
|
||||
*.lo
|
144
sysdeps/solaris/ChangeLog
Normal file
144
sysdeps/solaris/ChangeLog
Normal file
@@ -0,0 +1,144 @@
|
||||
1999-05-03 Drazen Kacar <dave@srce.hr>
|
||||
|
||||
* glibtop_private.h: Fixed typoo.
|
||||
|
||||
* procmap.c (glibtop_get_proc_map_s): Implemented start, end,
|
||||
offset and perm for mapped segments. File name and inode
|
||||
should be accessible from bunyip kstat data. The only
|
||||
obstacle is that the data format is undocumented and
|
||||
possibly not the same accross releases.
|
||||
|
||||
1999-05-03 Drazen Kacar <dave@srce.hr>
|
||||
|
||||
* glibtop_private.h, procdata.c (glibtop_get_proc_status_s):
|
||||
Read pstatus info from /proc
|
||||
|
||||
* procsignal.c (glibtop_get_proc_signal_s): Implemented
|
||||
set of pending and blocked signals. The rest should probably
|
||||
be read from /proc/<pid>/sigact, but I'm not sure it's
|
||||
worth implementing before thread API comes into place.
|
||||
|
||||
* siglist.c: Added Solaris 7 signals. Someone will gettextize
|
||||
it eventually. Besides, signal list should become a pointer
|
||||
instead of being fixed field. We need some run time initializations.
|
||||
The code is written, but commented out.
|
||||
|
||||
1999-05-03 Drazen Kacar <dave@srce.hr>
|
||||
|
||||
* glibtop_private.h: Ups, forgot to put prototypes in.
|
||||
|
||||
1999-05-02 Drazen Kacar <dave@srce.hr>
|
||||
|
||||
* open.c (glibtop_get_kstats): Yet another kstat_chain_update
|
||||
check. Added machine.cpu_stat_kstat[x] = NULL when processor
|
||||
x is not configured.
|
||||
|
||||
* procdata.c (glibtop_get_proc_credentials_s): Read prcred
|
||||
structure from /proc.
|
||||
|
||||
* procstate.c (glibtop_get_proc_state_s): Added ruid, rgid,
|
||||
has_cpu, processor and last_processor.
|
||||
|
||||
* procuid.c (glibtop_get_proc_uid_s): Added priority, nice,
|
||||
suid, sgid, ngroups and groups. The last four will be
|
||||
filled only if our process has the authority to read prcred
|
||||
structure of another process.
|
||||
|
||||
1999-05-02 Drazen Kacar <dave@srce.hr>
|
||||
|
||||
procdata.c: Use pread() instead of read().
|
||||
|
||||
1999-05-02 Drazen Kacar <dave@srce.hr>
|
||||
|
||||
* glibtop_machine.h: added fields for page size, clock ticks and
|
||||
boot time. These are constants. Also added three new kstats.
|
||||
|
||||
* open.c (glibtop_get_kstats): Initialize kstats in *server.
|
||||
We need to call this at init time (obviously) and each time
|
||||
kstat_chain_update() says that kstat chain has changed. In this
|
||||
case all kstat pointers and data are invalid, so we need to
|
||||
reinitialize everything.
|
||||
|
||||
(glibtop_open_s): Made it call glibtop_get_kstats(). Added
|
||||
initialization for run time constants in struct machine.
|
||||
|
||||
* cpu.c (glibtop_get_cpu_s): Call kstat_chain_update().
|
||||
See if processor is on-line and set bits in xcpu_flags.
|
||||
Added frequency (bad name, should have been ticks).
|
||||
|
||||
* swap.c (glibtop_get_swap_s): Call kstat_chain_update().
|
||||
I probably broke vminfo_snaptime consistency. Fix later.
|
||||
|
||||
* uptime.c (glibtop_get_uptime_s): Implemented uptime and boot_time.
|
||||
Still looking for a sane way to get idletime.
|
||||
|
||||
* mem.c (glibtop_get_mem_s): Implemented. Will use bunyip
|
||||
module if it's loaded. Or when it gets loaded. kstat_chain_update()
|
||||
is our friend. And with a friends like that...
|
||||
|
||||
* loadavg.c (glibtop_get_loadavg_s): Solaris 2.6 code brought
|
||||
into sync with everything else.
|
||||
|
||||
* msg_limits.c (glibtop_init_msg_limits_s): Implemented.
|
||||
|
||||
* sem_limits.c (glibtop_get_sem_limits_s): Implemented.
|
||||
|
||||
Solaris takes kernel modularity too seriously. We can't get
|
||||
IPC configuration data if the kernel module is not loaded and
|
||||
it won't be loaded until some process actually asks for a
|
||||
particular IPC resource. There's no way to tell our applications
|
||||
about this. Possible API additions?
|
||||
|
||||
All three IPC functions should go into daemon, but I'm keeping
|
||||
them in the normal library because I can't build daemon yet. All
|
||||
praise 64 bits!
|
||||
|
||||
1999-04-29 Drazen Kacar <dave@srce.hr>
|
||||
|
||||
* glibtop_machine.h: added field for kvm descriptor.
|
||||
|
||||
* open.c: added 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
|
||||
of it should be moved to open.c.
|
||||
|
||||
1999-03-19 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
Added first kstat based implementation for Solaris 7.
|
||||
|
||||
* open.c (glibtop_open_s): Walk kstat list and save interesting
|
||||
kstats in the `server->machine'.
|
||||
|
||||
* cpu.c: This can already provide `idle', `user' and `sys' with
|
||||
full SMP support.
|
||||
|
||||
* swap.c: This can already provide `total', `used' and `free'.
|
||||
|
||||
1999-03-17 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
Initial import of my Solaris 7 port.
|
||||
|
||||
* loadavg.c: We use getloadavg () to get the `loadavg' field.
|
||||
|
||||
* procdata.c: This file will handle all interaction with the
|
||||
/proc filesystem.
|
||||
(glibtop_get_proc_data_psinfo_s): Read `/proc/<pid>/psinfo' and
|
||||
return the resulting `struct psinfo'.
|
||||
(glibtop_get_proc_data_usage_s): Read `/proc/<pid>/usage' and
|
||||
return the resulting `struct prusage'.
|
||||
|
||||
* proclist.c: We use readdir () on /proc to get the list of
|
||||
all pids.
|
||||
|
||||
* procstate.c: Read `uid' and `gid' from the `struct psinfo'.
|
||||
|
||||
* proctime.c: Read `start_time', `rtime', `utime' and `stime'
|
||||
from the `struct prusage'.
|
||||
|
||||
* procuid.c: Read `euid', `uid', `egid', `gid', `pid', `ppid',
|
||||
`pgrp', `session' and `tty' from the `struct psinfo'.
|
||||
|
18
sysdeps/solaris/Makefile.am
Normal file
18
sysdeps/solaris/Makefile.am
Normal file
@@ -0,0 +1,18 @@
|
||||
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
INCLUDES = @INCLUDES@
|
||||
|
||||
lib_LTLIBRARIES = libgtop_sysdeps.la
|
||||
|
||||
libgtop_sysdeps_la_SOURCES = open.c close.c siglist.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 procdata.c
|
||||
|
||||
libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO)
|
||||
|
||||
include_HEADERS = glibtop_server.h glibtop_machine.h
|
||||
noinst_HEADERS = glibtop_private.h
|
||||
|
30
sysdeps/solaris/close.c
Normal file
30
sysdeps/solaris/close.c
Normal file
@@ -0,0 +1,30 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop/close.h>
|
||||
|
||||
/* Closes pipe to gtop server. */
|
||||
|
||||
void
|
||||
glibtop_close_s (glibtop *server)
|
||||
{ }
|
106
sysdeps/solaris/cpu.c
Normal file
106
sysdeps/solaris/cpu.c
Normal file
@@ -0,0 +1,106 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/cpu.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <sys/processor.h>
|
||||
|
||||
#include <glibtop_private.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_cpu =
|
||||
(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) +
|
||||
(1L << GLIBTOP_CPU_SYS) + (1L << GLIBTOP_CPU_IDLE) +
|
||||
(1L << GLIBTOP_XCPU_TOTAL) + (1L << GLIBTOP_XCPU_USER) +
|
||||
(1L << GLIBTOP_XCPU_SYS) + (1L << GLIBTOP_XCPU_IDLE) +
|
||||
(1L << GLIBTOP_CPU_FREQUENCY) + (1L << GLIBTOP_XCPU_FLAGS);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_cpu_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.cpu = _glibtop_sysdeps_cpu;
|
||||
}
|
||||
|
||||
/* Provides information about cpu usage. */
|
||||
|
||||
void
|
||||
glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
|
||||
{
|
||||
kstat_ctl_t *kc = server->machine.kc;
|
||||
cpu_stat_t cpu_stat;
|
||||
processorid_t cpu;
|
||||
int ncpu, found;
|
||||
kid_t ret;
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_cpu));
|
||||
|
||||
if(!kc)
|
||||
return;
|
||||
switch(kstat_chain_update(kc))
|
||||
{
|
||||
case -1: assert(0); /* Debugging purposes, shouldn't happen */
|
||||
case 0: break;
|
||||
default: glibtop_get_kstats(server);
|
||||
}
|
||||
ncpu = server->ncpu;
|
||||
if (ncpu > GLIBTOP_NCPU)
|
||||
ncpu = GLIBTOP_NCPU;
|
||||
|
||||
for (cpu = 0, found = 0; cpu < GLIBTOP_NCPU && found != ncpu; cpu++)
|
||||
{
|
||||
kstat_t *ksp = server->machine.cpu_stat_kstat [cpu];
|
||||
if (!ksp) continue;
|
||||
|
||||
++found;
|
||||
if(p_online(cpu, P_STATUS) == P_ONLINE)
|
||||
buf->xcpu_flags |= (1L << cpu);
|
||||
else
|
||||
continue;
|
||||
ret = kstat_read (kc, ksp, &cpu_stat);
|
||||
|
||||
if (ret == -1) {
|
||||
glibtop_warn_io_r (server, "kstat_read (cpu_stat%d)", cpu);
|
||||
continue;
|
||||
}
|
||||
|
||||
buf->xcpu_idle [cpu] = cpu_stat.cpu_sysinfo.cpu [CPU_IDLE];
|
||||
buf->xcpu_user [cpu] = cpu_stat.cpu_sysinfo.cpu [CPU_USER];
|
||||
buf->xcpu_sys [cpu] = cpu_stat.cpu_sysinfo.cpu [CPU_KERNEL];
|
||||
|
||||
buf->xcpu_total [cpu] = buf->xcpu_idle [cpu] + buf->xcpu_user [cpu] +
|
||||
buf->xcpu_sys [cpu];
|
||||
|
||||
buf->idle += cpu_stat.cpu_sysinfo.cpu [CPU_IDLE];
|
||||
buf->user += cpu_stat.cpu_sysinfo.cpu [CPU_USER];
|
||||
buf->sys += cpu_stat.cpu_sysinfo.cpu [CPU_KERNEL];
|
||||
}
|
||||
|
||||
buf->total = buf->idle + buf->user + buf->sys;
|
||||
buf->frequency = server->machine.ticks;
|
||||
|
||||
buf->flags = _glibtop_sysdeps_cpu;
|
||||
}
|
65
sysdeps/solaris/glibtop_machine.h
Normal file
65
sysdeps/solaris/glibtop_machine.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GLIBTOP_MACHINE_H__
|
||||
#define __GLIBTOP_MACHINE_H__
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <procfs.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <kstat.h>
|
||||
#include <kvm.h>
|
||||
#include <sys/sysinfo.h>
|
||||
|
||||
BEGIN_LIBGTOP_DECLS
|
||||
|
||||
typedef struct _glibtop_machine glibtop_machine;
|
||||
|
||||
struct _glibtop_machine
|
||||
{
|
||||
uid_t uid, euid;
|
||||
gid_t gid, egid;
|
||||
|
||||
kvm_t *kd;
|
||||
|
||||
kstat_ctl_t *kc;
|
||||
|
||||
kstat_t *vminfo_kstat;
|
||||
hrtime_t vminfo_snaptime;
|
||||
vminfo_t vminfo;
|
||||
|
||||
kstat_t *cpu_stat_kstat [64];
|
||||
|
||||
kstat_t *system; /* boot_time & avenrun* where needed */
|
||||
kstat_t *syspages; /* memory usage */
|
||||
kstat_t *bunyip; /* more memory usage */
|
||||
|
||||
int pagesize; /* in kilobytes */
|
||||
int ticks; /* clock ticks, as returned by sysconf(_SC_CLK_TCK) */
|
||||
unsigned boot; /* boot time, it's ui32 in kstat */
|
||||
};
|
||||
|
||||
END_LIBGTOP_DECLS
|
||||
|
||||
#endif __GLIBTOP_MACHINE_H__
|
54
sysdeps/solaris/glibtop_private.h
Normal file
54
sysdeps/solaris/glibtop_private.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GLIBTOP_PRIVATE_H__
|
||||
#define __GLIBTOP_PRIVATE_H__
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <procfs.h>
|
||||
#include <kstat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
BEGIN_LIBGTOP_DECLS
|
||||
|
||||
/* Read /proc/<pid>/psinfo */
|
||||
int glibtop_get_proc_data_psinfo_s (glibtop *server, struct psinfo *psinfo, pid_t pid);
|
||||
|
||||
/* Read /proc/<pid>/usage */
|
||||
int glibtop_get_proc_data_usage_s (glibtop *server, struct prusage *prusage, pid_t pid);
|
||||
|
||||
/* Read /proc/<pid>/cred */
|
||||
int glibtop_get_proc_credentials_s(glibtop *, struct prcred *, pid_t);
|
||||
|
||||
/* Read /proc/<pid>/status */
|
||||
int glibtop_get_proc_status_s(glibtop *, struct pstatus *, pid_t);
|
||||
|
||||
/* Reread kstat chains */
|
||||
void glibtop_get_kstats(glibtop *);
|
||||
|
||||
END_LIBGTOP_DECLS
|
||||
|
||||
#endif __GLIBTOP_PRIVATE_H__
|
52
sysdeps/solaris/glibtop_server.h
Normal file
52
sysdeps/solaris/glibtop_server.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GLIBTOP_SERVER_H__
|
||||
#define __GLIBTOP_SERVER_H__
|
||||
|
||||
BEGIN_LIBGTOP_DECLS
|
||||
|
||||
#define GLIBTOP_SUID_CPU 0
|
||||
#define GLIBTOP_SUID_MEM 0
|
||||
#define GLIBTOP_SUID_SWAP 0
|
||||
#define GLIBTOP_SUID_UPTIME 0
|
||||
#define GLIBTOP_SUID_LOADAVG 0
|
||||
#define GLIBTOP_SUID_SHM_LIMITS 0
|
||||
#define GLIBTOP_SUID_MSG_LIMITS 0
|
||||
#define GLIBTOP_SUID_SEM_LIMITS 0
|
||||
#define GLIBTOP_SUID_PROCLIST 0
|
||||
#define GLIBTOP_SUID_PROC_STATE 0
|
||||
#define GLIBTOP_SUID_PROC_UID 0
|
||||
#define GLIBTOP_SUID_PROC_MEM 0
|
||||
#define GLIBTOP_SUID_PROC_TIME 0
|
||||
#define GLIBTOP_SUID_PROC_SIGNAL 0
|
||||
#define GLIBTOP_SUID_PROC_KERNEL 0
|
||||
#define GLIBTOP_SUID_PROC_SEGMENT 0
|
||||
#define GLIBTOP_SUID_PROC_ARGS 0
|
||||
#define GLIBTOP_SUID_PROC_MAP 0
|
||||
#define GLIBTOP_SUID_NETLOAD 0
|
||||
#define GLIBTOP_SUID_PPP 0
|
||||
|
||||
END_LIBGTOP_DECLS
|
||||
|
||||
#endif
|
87
sysdeps/solaris/loadavg.c
Normal file
87
sysdeps/solaris/loadavg.c
Normal file
@@ -0,0 +1,87 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. 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>
|
||||
|
||||
#ifdef HAVE_GETLOADAVG
|
||||
#include <sys/loadavg.h>
|
||||
#else
|
||||
#include <assert.h>
|
||||
#include <sys/param.h>
|
||||
#include <kstat.h>
|
||||
#endif
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_loadavg =
|
||||
(1L << GLIBTOP_LOADAVG_LOADAVG);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_loadavg_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
|
||||
}
|
||||
|
||||
/* Provides load average. */
|
||||
|
||||
void
|
||||
glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf)
|
||||
{
|
||||
#ifndef HAVE_GETLOADAVG
|
||||
kstat_ctl_t *kc;
|
||||
kstat_t *ksp;
|
||||
int i;
|
||||
static char *avestrings[] = { "avenrun_1min",
|
||||
"avenrun_5min",
|
||||
"avenrun_15min" };
|
||||
#endif
|
||||
memset (buf, 0, sizeof (glibtop_loadavg));
|
||||
|
||||
#ifdef HAVE_GETLOADAVG
|
||||
if (getloadavg (buf->loadavg, 3))
|
||||
return;
|
||||
#else
|
||||
if(!(kc = server->machine.kc))
|
||||
return;
|
||||
switch(kstat_chain_update(kc))
|
||||
{
|
||||
case -1: assert(0); /* Debugging, shouldn't happen */
|
||||
case 0: break;
|
||||
default: glibtop_get_kstats(server);
|
||||
}
|
||||
if(!(ksp = server->machine.system))
|
||||
return;
|
||||
if(kstat_read(kc, ksp, NULL) < 0)
|
||||
return;
|
||||
for(i = 0; i < 3; ++i) /* Do we have a countof macro? */
|
||||
{
|
||||
kstat_named_t *kn;
|
||||
|
||||
kn = (kstat_named_t *)kstat_data_lookup(ksp, avestrings[i]);
|
||||
if(kn)
|
||||
buf->loadavg[i] = (double)kn->value.ul / FSCALE;
|
||||
}
|
||||
#endif
|
||||
buf->flags = _glibtop_sysdeps_loadavg;
|
||||
}
|
123
sysdeps/solaris/mem.c
Normal file
123
sysdeps/solaris/mem.c
Normal file
@@ -0,0 +1,123 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/mem.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <glibtop_private.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_mem_os_sysconf =
|
||||
(1L << GLIBTOP_MEM_TOTAL);
|
||||
static const unsigned long _glibtop_sysdeps_mem_os_kstat =
|
||||
(1L << GLIBTOP_MEM_FREE) + (1L << GLIBTOP_MEM_USED) +
|
||||
(1L << GLIBTOP_MEM_LOCKED);
|
||||
static const unsigned long _glibtop_sysdeps_mem_bunyip =
|
||||
(1L << GLIBTOP_MEM_SHARED) + (1L << GLIBTOP_MEM_BUFFER) +
|
||||
(1L << GLIBTOP_MEM_USER);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_mem_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.mem = _glibtop_sysdeps_mem_os_sysconf +
|
||||
_glibtop_sysdeps_mem_os_kstat + _glibtop_sysdeps_mem_bunyip;
|
||||
}
|
||||
|
||||
/* Provides information about memory usage. */
|
||||
|
||||
void
|
||||
glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
|
||||
{
|
||||
kstat_ctl_t *kc = server->machine.kc;
|
||||
kstat_t *ksp;
|
||||
kstat_named_t *kn;
|
||||
int pagesize = server->machine.pagesize;
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_mem));
|
||||
|
||||
buf->total = (u_int64_t)sysconf(_SC_PHYS_PAGES) * pagesize;
|
||||
buf->flags = _glibtop_sysdeps_mem_os_sysconf;
|
||||
|
||||
if(!kc)
|
||||
return;
|
||||
switch(kstat_chain_update(kc))
|
||||
{
|
||||
case -1: assert(0); /* Debugging purposes, shouldn't happen */
|
||||
case 0: break;
|
||||
default: glibtop_get_kstats(server);
|
||||
}
|
||||
|
||||
if((ksp = server->machine.syspages) && kstat_read(kc, ksp, NULL) >= 0)
|
||||
{
|
||||
kn = (kstat_named_t *)kstat_data_lookup(ksp, "pagesfree");
|
||||
if(kn)
|
||||
{
|
||||
#ifdef _LP64
|
||||
buf->free = kn->value.ui64 * pagesize;
|
||||
#else
|
||||
buf->free = kn->value.ui32 * pagesize;
|
||||
#endif
|
||||
buf->used = buf->total - buf->free;
|
||||
}
|
||||
kn = (kstat_named_t *)kstat_data_lookup(ksp, "pageslocked");
|
||||
if(kn)
|
||||
#ifdef _LP64
|
||||
buf->locked = kn->value.ui64 * pagesize;
|
||||
#else
|
||||
buf->locked = kn->value.ui32 * pagesize;
|
||||
#endif
|
||||
buf->flags += _glibtop_sysdeps_mem_os_kstat;
|
||||
}
|
||||
|
||||
/* Bunyip module provides data in multiples of system page size */
|
||||
|
||||
if((ksp = server->machine.bunyip) && kstat_read(kc, ksp, NULL) >= 0)
|
||||
{
|
||||
kn = (kstat_named_t *)kstat_data_lookup(ksp, "pages_anon");
|
||||
if(kn)
|
||||
#ifdef _LP64
|
||||
buf->user = kn->value.ui64 * pagesize;
|
||||
#else
|
||||
buf->user = kn->value.ui32 * pagesize;
|
||||
#endif
|
||||
kn = (kstat_named_t *)kstat_data_lookup(ksp, "pages_exec");
|
||||
if(kn)
|
||||
#ifdef _LP64
|
||||
buf->shared = kn->value.ui64 * pagesize;
|
||||
#else
|
||||
buf->shared = kn->value.ui32 * pagesize;
|
||||
#endif
|
||||
kn = (kstat_named_t *)kstat_data_lookup(ksp, "pages_vnode");
|
||||
if(kn)
|
||||
#ifdef _LP64
|
||||
buf->buffer = kn->value.ui64 * pagesize;
|
||||
#else
|
||||
buf->buffer = kn->value.ui32 * pagesize;
|
||||
#endif
|
||||
buf->flags += _glibtop_sysdeps_mem_bunyip;
|
||||
}
|
||||
}
|
74
sysdeps/solaris/msg_limits.c
Normal file
74
sysdeps/solaris/msg_limits.c
Normal file
@@ -0,0 +1,74 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/msg_limits.h>
|
||||
|
||||
#include <kvm.h>
|
||||
#include <sys/msg.h>
|
||||
|
||||
static struct nlist nlst[] = { {"msginfo"}, {NULL} };
|
||||
static const unsigned long _glibtop_sysdeps_msg_limits =
|
||||
(1L << GLIBTOP_IPC_MSGPOOL) + (1L << GLIBTOP_IPC_MSGMAP) +
|
||||
(1L << GLIBTOP_IPC_MSGMAX) + (1L << GLIBTOP_IPC_MSGMNB) +
|
||||
(1L << GLIBTOP_IPC_MSGMNI) + (1L << GLIBTOP_IPC_MSGSSZ) +
|
||||
(1L << GLIBTOP_IPC_MSGTQL);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_msg_limits_s (glibtop *server)
|
||||
{
|
||||
kvm_t *kd = server->machine.kd;
|
||||
|
||||
if(kd && !kvm_nlist(kd, nlst))
|
||||
server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
|
||||
else
|
||||
server->sysdeps.msg_limits = 0;
|
||||
}
|
||||
|
||||
/* Provides information about sysv ipc limits. */
|
||||
|
||||
void
|
||||
glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
|
||||
{
|
||||
kvm_t *kd = server->machine.kd;
|
||||
struct msginfo minfo;
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_msg_limits));
|
||||
|
||||
if(!(server->sysdeps.msg_limits))
|
||||
return;
|
||||
if(kvm_read(kd, nlst[0].n_value, (void *)&minfo,
|
||||
sizeof(struct msginfo)) != sizeof(struct msginfo))
|
||||
return;
|
||||
|
||||
buf->msgmap = minfo.msgmap;
|
||||
buf->msgmax = minfo.msgmax;
|
||||
buf->msgmnb = minfo.msgmnb;
|
||||
buf->msgmni = minfo.msgmni;
|
||||
buf->msgssz = minfo.msgssz;
|
||||
buf->msgtql = minfo.msgtql;
|
||||
buf->msgpool = minfo.msgmni * minfo.msgmnb >> 10;
|
||||
buf->flags = _glibtop_sysdeps_msg_limits;
|
||||
}
|
45
sysdeps/solaris/netload.c
Normal file
45
sysdeps/solaris/netload.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/netload.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_netload = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_netload_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.netload = _glibtop_sysdeps_netload;
|
||||
}
|
||||
|
||||
/* Provides network statistics. */
|
||||
|
||||
void
|
||||
glibtop_get_netload_s (glibtop *server, glibtop_netload *buf,
|
||||
const char *interface)
|
||||
{
|
||||
memset (buf, 0, sizeof (glibtop_netload));
|
||||
}
|
183
sysdeps/solaris/open.c
Normal file
183
sysdeps/solaris/open.c
Normal file
@@ -0,0 +1,183 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop/open.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/processor.h>
|
||||
|
||||
#include <glibtop_private.h>
|
||||
|
||||
/* We need to call this when kstat_chain_update() returns new KID.
|
||||
* In that case all kstat pointers and data are invalid, so we
|
||||
* need to reread everything. The condition shouldn't happen very
|
||||
* often.
|
||||
*/
|
||||
|
||||
void
|
||||
glibtop_get_kstats(glibtop *server)
|
||||
{
|
||||
kstat_ctl_t *kc = server->machine.kc;
|
||||
kstat_t *ksp;
|
||||
int nproc_same, new_ncpu;
|
||||
|
||||
new_ncpu = sysconf(_SC_NPROCESSORS_CONF);
|
||||
|
||||
if(!kc)
|
||||
{
|
||||
server->ncpu = new_ncpu;
|
||||
server->machine.vminfo_kstat = NULL;
|
||||
server->machine.system = NULL;
|
||||
server->machine.syspages = NULL;
|
||||
server->machine.bunyip = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
ksp = kstat_lookup(kc, "unix", -1, "vminfo");
|
||||
server->machine.vminfo_kstat = ksp;
|
||||
if(ksp)
|
||||
{
|
||||
kstat_read(kc, ksp, &server->machine.vminfo);
|
||||
server->machine.vminfo_snaptime = ksp->ks_snaptime;
|
||||
}
|
||||
|
||||
/* We don't know why was kstat chain invalidated. It could have
|
||||
been because the number of processors changed. The sysconf()
|
||||
man page says that values returned won't change during the
|
||||
life time of a process, but let's hope that's just an error in
|
||||
the documentation. */
|
||||
|
||||
if(nproc_same = new_ncpu == server->ncpu)
|
||||
{
|
||||
int checked, i;
|
||||
char cpu[20];
|
||||
|
||||
for(i = 0, checked = 0; i < GLIBTOP_NCPU || checked == new_ncpu; ++i)
|
||||
if(server->machine.cpu_stat_kstat[i])
|
||||
{
|
||||
sprintf(cpu, "cpu_stat%d", i);
|
||||
if(!(server->machine.cpu_stat_kstat[i] =
|
||||
kstat_lookup(kc, "cpu_stat", -1, cpu)))
|
||||
{
|
||||
nproc_same = 0;
|
||||
break;
|
||||
}
|
||||
++checked;
|
||||
}
|
||||
}
|
||||
if(!nproc_same)
|
||||
{
|
||||
processorid_t p;
|
||||
int found;
|
||||
char cpu[20];
|
||||
|
||||
if(new_ncpu > GLIBTOP_NCPU)
|
||||
new_ncpu = GLIBTOP_NCPU;
|
||||
server->ncpu = new_ncpu;
|
||||
for(p = 0, found = 0; p < GLIBTOP_NCPU && found != new_ncpu; ++p)
|
||||
{
|
||||
if(p_online(p, P_STATUS) < 0)
|
||||
{
|
||||
server->machine.cpu_stat_kstat[p] = NULL;
|
||||
continue;
|
||||
}
|
||||
sprintf(cpu, "cpu_stat%d", (int)p);
|
||||
server->machine.cpu_stat_kstat[p] =
|
||||
kstat_lookup(kc, "cpu_stat", -1, cpu);
|
||||
++found;
|
||||
}
|
||||
}
|
||||
|
||||
server->machine.system = kstat_lookup(kc, "unix", -1, "system_misc");
|
||||
server->machine.syspages = kstat_lookup(kc, "unix", -1, "system_pages");
|
||||
server->machine.bunyip = kstat_lookup(kc, "bunyip", -1, "mempages");
|
||||
|
||||
} while(kstat_chain_update(kc) > 0 &&
|
||||
(new_ncpu = sysconf(_SC_NPROCESSORS_CONF)));
|
||||
|
||||
/* We'll ignore -1 from kstat_chain_update here, since it really
|
||||
shouldn't happen */
|
||||
}
|
||||
|
||||
void
|
||||
glibtop_open_s (glibtop *server, const char *program_name,
|
||||
const unsigned long features, const unsigned flags)
|
||||
{
|
||||
kstat_ctl_t *kc;
|
||||
kstat_t *ksp;
|
||||
kstat_named_t *kn;
|
||||
|
||||
server->name = program_name;
|
||||
|
||||
server->machine.pagesize = sysconf(_SC_PAGESIZE) >> 10;
|
||||
server->machine.ticks = sysconf(_SC_CLK_TCK);
|
||||
server->machine.kc = kc = kstat_open ();
|
||||
|
||||
#if 0
|
||||
for (ksp = server->machine.kc->kc_chain; ksp != NULL; ksp = ksp->ks_next) {
|
||||
if (!strcmp (ksp->ks_class, "vm") && !strcmp (ksp->ks_name, "vminfo")) {
|
||||
server->machine.vminfo_kstat = ksp;
|
||||
kstat_read (server->machine.kc, ksp, &server->machine.vminfo);
|
||||
server->machine.vminfo_snaptime = ksp->ks_snaptime;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp (ksp->ks_class, "misc") && !strncmp (ksp->ks_name, "cpu_stat", 8)) {
|
||||
int cpu;
|
||||
|
||||
if ((sscanf (ksp->ks_name+8, "%d", &cpu) != 1) || (cpu > 63))
|
||||
continue;
|
||||
|
||||
if (cpu >= server->ncpu)
|
||||
server->ncpu = cpu+1;
|
||||
|
||||
server->machine.cpu_stat_kstat [cpu] = ksp;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (!kc)
|
||||
glibtop_warn_io_r (server, "kstat_open ()");
|
||||
|
||||
server->ncpu = -1; /* Force processor detection */
|
||||
glibtop_get_kstats(server);
|
||||
|
||||
server->machine.boot = 0;
|
||||
if((ksp = server->machine.system) && kstat_read(kc, ksp, NULL) >= 0)
|
||||
{
|
||||
kn = (kstat_named_t *)kstat_data_lookup(ksp, "boot_time");
|
||||
if(kn)
|
||||
server->machine.boot = kn->value.ui32;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
44
sysdeps/solaris/ppp.c
Normal file
44
sysdeps/solaris/ppp.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/ppp.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_ppp = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_ppp_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.ppp = _glibtop_sysdeps_ppp;
|
||||
}
|
||||
|
||||
/* Provides PPP/ISDN information. */
|
||||
|
||||
void
|
||||
glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device)
|
||||
{
|
||||
memset (buf, 0, sizeof (glibtop_ppp));
|
||||
}
|
47
sysdeps/solaris/procargs.c
Normal file
47
sysdeps/solaris/procargs.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
#include <glibtop/procargs.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_args = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_args_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_args = _glibtop_sysdeps_proc_args;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
char *
|
||||
glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
|
||||
pid_t pid, unsigned max_len)
|
||||
{
|
||||
memset (buf, 0, sizeof (glibtop_proc_args));
|
||||
return NULL;
|
||||
}
|
121
sysdeps/solaris/procdata.c
Normal file
121
sysdeps/solaris/procdata.c
Normal file
@@ -0,0 +1,121 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop_private.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
/* Read /proc/<pid>/psinfo. */
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_psinfo_s (glibtop *server, struct psinfo *psinfo, pid_t pid)
|
||||
{
|
||||
int fd;
|
||||
char buffer [BUFSIZ];
|
||||
|
||||
sprintf (buffer, "/proc/%d/psinfo", (int) pid);
|
||||
fd = open (buffer, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
glibtop_warn_io_r (server, "open (%s)", buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pread (fd, psinfo, sizeof (struct psinfo), 0) != sizeof (struct psinfo)) {
|
||||
close (fd);
|
||||
glibtop_warn_io_r (server, "pread (%s)", buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_usage_s (glibtop *server, struct prusage *prusage, pid_t pid)
|
||||
{
|
||||
int fd;
|
||||
char buffer [BUFSIZ];
|
||||
|
||||
sprintf (buffer, "/proc/%d/usage", (int) pid);
|
||||
fd = open (buffer, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
glibtop_warn_io_r (server, "open (%s)", buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pread (fd, prusage, sizeof (struct prusage), 0) != sizeof (struct prusage)) {
|
||||
close (fd);
|
||||
glibtop_warn_io_r (server, "pread (%s)", buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
glibtop_get_proc_credentials_s(glibtop *server, struct prcred *prcred, pid_t pid)
|
||||
{
|
||||
int fd;
|
||||
char buffer[BUFSIZ];
|
||||
|
||||
sprintf(buffer, "/proc/%d/cred", (int)pid);
|
||||
if((fd = open(buffer, O_RDONLY)) < 0)
|
||||
{
|
||||
if(errno != EPERM && errno != EACCES)
|
||||
glibtop_warn_io_r(server, "open (%s)", buffer);
|
||||
return -1;
|
||||
}
|
||||
if(pread(fd, prcred, sizeof(struct prcred), 0) != sizeof(struct prcred))
|
||||
{
|
||||
close(fd);
|
||||
glibtop_warn_io_r(server, "pread (%s)", buffer);
|
||||
return -1;
|
||||
}
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
glibtop_get_proc_status_s(glibtop *server, struct pstatus *pstatus, pid_t pid)
|
||||
{
|
||||
int fd;
|
||||
char buffer[BUFSIZ];
|
||||
|
||||
sprintf(buffer, "/proc/%d/status", (int)pid);
|
||||
if((fd = open(buffer, O_RDONLY)) < 0)
|
||||
{
|
||||
if(errno != EPERM && errno != EACCES)
|
||||
glibtop_warn_io_r(server, "open (%s)", buffer);
|
||||
return -1;
|
||||
}
|
||||
if(pread(fd, pstatus, sizeof(struct pstatus), 0) != sizeof(struct pstatus))
|
||||
{
|
||||
close(fd);
|
||||
glibtop_warn_io_r(server, "pread (%s)", buffer);
|
||||
return -1;
|
||||
}
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
44
sysdeps/solaris/prockernel.c
Normal file
44
sysdeps/solaris/prockernel.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/prockernel.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_kernel = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_kernel_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
memset (buf, 0, sizeof (glibtop_proc_kernel));
|
||||
}
|
162
sysdeps/solaris/proclist.c
Normal file
162
sysdeps/solaris/proclist.c
Normal file
@@ -0,0 +1,162 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/proclist.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define GLIBTOP_PROCLIST_FLAGS 3
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proclist =
|
||||
(1 << GLIBTOP_PROCLIST_TOTAL) + (1 << GLIBTOP_PROCLIST_NUMBER) +
|
||||
(1 << GLIBTOP_PROCLIST_SIZE);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proclist_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proclist = _glibtop_sysdeps_proclist;
|
||||
}
|
||||
|
||||
#define BLOCK_COUNT 256
|
||||
#define BLOCK_SIZE (BLOCK_COUNT * sizeof (unsigned))
|
||||
|
||||
/* Fetch list of currently running processes.
|
||||
*
|
||||
* IMPORTANT NOTE:
|
||||
* On error, this function MUST return NULL and set buf->flags to zero !
|
||||
* On success, it returnes a pointer to a list of buf->number elements
|
||||
* each buf->size big. The total size is stored in buf->total. */
|
||||
|
||||
unsigned *
|
||||
glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
|
||||
int64_t which, int64_t arg)
|
||||
{
|
||||
DIR *proc;
|
||||
struct dirent *entry;
|
||||
char buffer [BUFSIZ];
|
||||
unsigned count, total, pid;
|
||||
unsigned pids [BLOCK_COUNT], *pids_chain = NULL;
|
||||
unsigned pids_size = 0, pids_offset = 0, new_size;
|
||||
struct stat statb;
|
||||
int len, i, ok;
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proclist));
|
||||
|
||||
proc = opendir ("/proc");
|
||||
if (!proc) return NULL;
|
||||
|
||||
/* read every every entry in /proc */
|
||||
|
||||
for (count = total = 0, entry = readdir (proc);
|
||||
entry; entry = readdir (proc)) {
|
||||
ok = 1; len = strlen (entry->d_name);
|
||||
|
||||
/* does it consist entirely of digits? */
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
if (!isdigit (entry->d_name [i])) ok = 0;
|
||||
if (!ok) continue;
|
||||
|
||||
/* convert it in a number */
|
||||
|
||||
if (sscanf (entry->d_name, "%u", &pid) != 1) continue;
|
||||
|
||||
/* is it really a directory? */
|
||||
|
||||
sprintf (buffer, "/proc/%d", pid);
|
||||
|
||||
if (stat (buffer, &statb)) continue;
|
||||
|
||||
if (!S_ISDIR (statb.st_mode)) continue;
|
||||
|
||||
/* Fine. Now we first try to store it in pids. If this buffer is
|
||||
* full, we copy it to the pids_chain. */
|
||||
|
||||
if (count >= BLOCK_COUNT) {
|
||||
/* The following call to glibtop_realloc will be
|
||||
* equivalent to glibtop_malloc () if `pids_chain' is
|
||||
* NULL. We just calculate the new size and copy `pids'
|
||||
* to the beginning of the newly allocated block. */
|
||||
|
||||
new_size = pids_size + BLOCK_SIZE;
|
||||
|
||||
pids_chain = glibtop_realloc_r
|
||||
(server, pids_chain, new_size);
|
||||
|
||||
memcpy (pids_chain + pids_offset, pids, BLOCK_SIZE);
|
||||
|
||||
pids_size = new_size;
|
||||
|
||||
pids_offset += BLOCK_COUNT;
|
||||
|
||||
count = 0;
|
||||
}
|
||||
|
||||
/* pids is now big enough to hold at least one single pid. */
|
||||
|
||||
pids [count++] = pid;
|
||||
|
||||
total++;
|
||||
}
|
||||
|
||||
closedir (proc);
|
||||
|
||||
/* count is only zero if an error occured (one a running Linux system,
|
||||
* we have at least one single process). */
|
||||
|
||||
if (!count) return NULL;
|
||||
|
||||
/* The following call to glibtop_realloc will be equivalent to
|
||||
* glibtop_malloc if pids_chain is NULL. We just calculate the
|
||||
* new size and copy pids to the beginning of the newly allocated
|
||||
* block. */
|
||||
|
||||
new_size = pids_size + count * sizeof (unsigned);
|
||||
|
||||
pids_chain = glibtop_realloc_r (server, pids_chain, new_size);
|
||||
|
||||
memcpy (pids_chain + pids_offset, pids, count * sizeof (unsigned));
|
||||
|
||||
pids_size = new_size;
|
||||
|
||||
pids_offset += BLOCK_COUNT;
|
||||
|
||||
/* Since everything is ok now, we can set buf->flags, fill in the
|
||||
* remaining fields and return the `pids_chain'. */
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proclist;
|
||||
|
||||
buf->size = sizeof (unsigned);
|
||||
buf->number = total;
|
||||
|
||||
buf->total = total * sizeof (unsigned);
|
||||
|
||||
return pids_chain;
|
||||
}
|
114
sysdeps/solaris/procmap.c
Normal file
114
sysdeps/solaris/procmap.c
Normal file
@@ -0,0 +1,114 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
#include <glibtop/procmap.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <alloca.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_map =
|
||||
(1L << GLIBTOP_PROC_MAP_NUMBER) + (1L << GLIBTOP_PROC_MAP_TOTAL) +
|
||||
(1L << GLIBTOP_PROC_MAP_SIZE);
|
||||
static const unsigned long _glibtop_sysdeps_map_entry =
|
||||
(1L << GLIBTOP_MAP_ENTRY_START) + (1L << GLIBTOP_MAP_ENTRY_END) +
|
||||
(1L << GLIBTOP_MAP_ENTRY_OFFSET) + (1L << GLIBTOP_MAP_ENTRY_PERM);
|
||||
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_map_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
glibtop_map_entry *
|
||||
glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
||||
{
|
||||
int fd, i, nmaps;
|
||||
prmap_t *maps;
|
||||
glibtop_map_entry *entry;
|
||||
struct stat inode;
|
||||
char buffer[BUFSIZ];
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_map));
|
||||
|
||||
sprintf(buffer, "/proc/%d/map", (int)pid);
|
||||
if((fd = open(buffer, O_RDONLY)) < 0)
|
||||
{
|
||||
if(errno != EPERM && errno != EACCES)
|
||||
glibtop_warn_io_r(server, "open (%s)", buffer);
|
||||
return NULL;
|
||||
}
|
||||
if(fstat(fd, &inode) < 0)
|
||||
{
|
||||
if(errno != EOVERFLOW)
|
||||
glibtop_warn_io_r(server, "fstat (%s)", buffer);
|
||||
/* else call daemon for 64-bit support */
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
maps = alloca(inode.st_size);
|
||||
nmaps = inode.st_size / sizeof(prmap_t);
|
||||
if(pread(fd, maps, inode.st_size, 0) != inode.st_size)
|
||||
{
|
||||
glibtop_warn_io_r(server, "pread (%s)", buffer);
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
close(fd);
|
||||
if(!(entry = glibtop_malloc_r(server, nmaps * sizeof(glibtop_map_entry))))
|
||||
return NULL;
|
||||
|
||||
buf->number = nmaps;
|
||||
buf->size = sizeof(glibtop_map_entry);
|
||||
buf->total = nmaps * sizeof(glibtop_map_entry);
|
||||
|
||||
memset(entry, 0, nmaps * sizeof(glibtop_map_entry));
|
||||
for(i = 0; i < nmaps; ++i)
|
||||
{
|
||||
entry[i].start = maps[i].pr_vaddr;
|
||||
entry[i].end = maps[i].pr_vaddr + maps[i].pr_size;
|
||||
entry[i].offset = maps[i].pr_offset;
|
||||
if(maps[i].pr_mflags & MA_READ)
|
||||
entry[i].perm |= GLIBTOP_MAP_PERM_READ;
|
||||
if(maps[i].pr_mflags & MA_WRITE)
|
||||
entry[i].perm |= GLIBTOP_MAP_PERM_WRITE;
|
||||
if(maps[i].pr_mflags & MA_EXEC)
|
||||
entry[i].perm |= GLIBTOP_MAP_PERM_EXECUTE;
|
||||
if(maps[i].pr_mflags & MA_SHARED)
|
||||
entry[i].perm |= GLIBTOP_MAP_PERM_SHARED;
|
||||
else
|
||||
entry[i].perm |= GLIBTOP_MAP_PERM_PRIVATE;
|
||||
entry[i].flags = _glibtop_sysdeps_map_entry;
|
||||
}
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_map;
|
||||
return entry;
|
||||
}
|
44
sysdeps/solaris/procmem.c
Normal file
44
sysdeps/solaris/procmem.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/procmem.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_mem = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_mem_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
memset (buf, 0, sizeof (glibtop_proc_mem));
|
||||
}
|
44
sysdeps/solaris/procsegment.c
Normal file
44
sysdeps/solaris/procsegment.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/procsegment.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_segment = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_segment_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
memset (buf, 0, sizeof (glibtop_proc_segment));
|
||||
}
|
66
sysdeps/solaris/procsignal.c
Normal file
66
sysdeps/solaris/procsignal.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/procsignal.h>
|
||||
|
||||
#include <glibtop_private.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_signal =
|
||||
(1L << GLIBTOP_PROC_SIGNAL_SIGNAL) + (1L << GLIBTOP_PROC_SIGNAL_BLOCKED);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_signal_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
struct pstatus pstatus;
|
||||
int size;
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_signal));
|
||||
|
||||
if(glibtop_get_proc_status_s(server, &pstatus, pid))
|
||||
return;
|
||||
|
||||
if(sizeof(buf->signal) < sizeof(sigset_t))
|
||||
size = sizeof(buf->signal);
|
||||
else
|
||||
size = sizeof(sigset_t);
|
||||
|
||||
memcpy(buf->signal, &pstatus.pr_sigpend, size);
|
||||
memcpy(buf->blocked, &pstatus.pr_lwp.pr_lwphold, size);
|
||||
|
||||
/* Technically, most of this is meaningless on a process level,
|
||||
but this should be a good enough approximation. */
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_signal;
|
||||
}
|
79
sysdeps/solaris/procstate.c
Normal file
79
sysdeps/solaris/procstate.c
Normal file
@@ -0,0 +1,79 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/procstate.h>
|
||||
|
||||
#include <glibtop_private.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_state =
|
||||
(1L << GLIBTOP_PROC_STATE_CMD) + (1L << GLIBTOP_PROC_STATE_STATE) +
|
||||
(1L << GLIBTOP_PROC_STATE_UID) + (1L << GLIBTOP_PROC_STATE_GID) +
|
||||
(1L << GLIBTOP_PROC_STATE_RUID) + (1L << GLIBTOP_PROC_STATE_RGID) +
|
||||
(1L << GLIBTOP_PROC_STATE_HAS_CPU) + (1L << GLIBTOP_PROC_STATE_PROCESSOR) +
|
||||
(1L << GLIBTOP_PROC_STATE_LAST_PROCESSOR);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_state_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_state = _glibtop_sysdeps_proc_state;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid)
|
||||
{
|
||||
struct psinfo psinfo;
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_state));
|
||||
|
||||
if (glibtop_get_proc_data_psinfo_s (server, &psinfo, pid))
|
||||
return;
|
||||
|
||||
buf->uid = psinfo.pr_euid;
|
||||
buf->gid = psinfo.pr_egid;
|
||||
buf->ruid = psinfo.pr_uid;
|
||||
buf->rgid = psinfo.pr_gid;
|
||||
switch(psinfo.pr_lwp.pr_state)
|
||||
{
|
||||
case SONPROC: buf->has_cpu = 1;
|
||||
buf->processor = psinfo.pr_lwp.pr_onpro;
|
||||
case SRUN: buf->state = GLIBTOP_PROCESS_RUNNING;
|
||||
break;
|
||||
case SZOMB: buf->state = GLIBTOP_PROCESS_ZOMBIE;
|
||||
break;
|
||||
case SSLEEP:
|
||||
case SSTOP: buf->state = GLIBTOP_PROCESS_STOPPED;
|
||||
break;
|
||||
case SIDL: buf->state = GLIBTOP_PROCESS_UNINTERRUPTIBLE;
|
||||
}
|
||||
buf->last_processor = psinfo.pr_lwp.pr_onpro;
|
||||
|
||||
|
||||
strncpy (buf->cmd, psinfo.pr_fname, 39);
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_state;
|
||||
}
|
65
sysdeps/solaris/proctime.c
Normal file
65
sysdeps/solaris/proctime.c
Normal file
@@ -0,0 +1,65 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/proctime.h>
|
||||
|
||||
#include <glibtop_private.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_time =
|
||||
(1 << GLIBTOP_PROC_TIME_START_TIME) + (1 << GLIBTOP_PROC_TIME_RTIME) +
|
||||
(1 << GLIBTOP_PROC_TIME_UTIME) + (1 << GLIBTOP_PROC_TIME_STIME);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_time_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_time = _glibtop_sysdeps_proc_time;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
struct prusage prusage;
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_time));
|
||||
|
||||
if (glibtop_get_proc_data_usage_s (server, &prusage, pid))
|
||||
return;
|
||||
|
||||
buf->start_time = prusage.pr_create.tv_sec * 1E+6 +
|
||||
prusage.pr_create.tv_nsec / 1E+3;
|
||||
|
||||
buf->rtime = prusage.pr_rtime.tv_sec * 1E+6 +
|
||||
prusage.pr_rtime.tv_nsec / 1E+3;
|
||||
buf->utime = prusage.pr_utime.tv_sec * 1E+6 +
|
||||
prusage.pr_utime.tv_nsec / 1E+3;
|
||||
buf->stime = prusage.pr_stime.tv_sec * 1E+6 +
|
||||
prusage.pr_stime.tv_nsec / 1E+3;
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_time;
|
||||
}
|
98
sysdeps/solaris/procuid.c
Normal file
98
sysdeps/solaris/procuid.c
Normal file
@@ -0,0 +1,98 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/procuid.h>
|
||||
|
||||
#include <glibtop_private.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_uid_psinfo =
|
||||
(1L << GLIBTOP_PROC_UID_EUID) + (1L << GLIBTOP_PROC_UID_UID) +
|
||||
(1L << GLIBTOP_PROC_UID_EGID) + (1L << GLIBTOP_PROC_UID_GID) +
|
||||
(1L << GLIBTOP_PROC_UID_PID) + (1L << GLIBTOP_PROC_UID_PPID) +
|
||||
(1L << GLIBTOP_PROC_UID_PGRP) + (1L << GLIBTOP_PROC_UID_SESSION) +
|
||||
(1L << GLIBTOP_PROC_UID_TTY) + (1L << GLIBTOP_PROC_UID_PRIORITY) +
|
||||
(1L << GLIBTOP_PROC_UID_NICE);
|
||||
static const unsigned long _glibtop_sysdeps_proc_uid_prcred =
|
||||
(1L << GLIBTOP_PROC_UID_SUID) + (1L << GLIBTOP_PROC_UID_SGID) +
|
||||
(1L << GLIBTOP_PROC_UID_NGROUPS) + (1L << GLIBTOP_PROC_UID_GROUPS);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_uid_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid_psinfo +
|
||||
_glibtop_sysdeps_proc_uid_prcred;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid)
|
||||
{
|
||||
struct psinfo psinfo;
|
||||
struct prcred prcred;
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_uid));
|
||||
|
||||
if (glibtop_get_proc_data_psinfo_s (server, &psinfo, pid))
|
||||
return;
|
||||
|
||||
buf->euid = psinfo.pr_euid;
|
||||
buf->uid = psinfo.pr_uid;
|
||||
buf->egid = psinfo.pr_egid;
|
||||
buf->gid = psinfo.pr_gid;
|
||||
|
||||
buf->pid = psinfo.pr_pid;
|
||||
buf->ppid = psinfo.pr_ppid;
|
||||
buf->pgrp = psinfo.pr_pgid;
|
||||
|
||||
buf->session = psinfo.pr_sid;
|
||||
buf->tty = psinfo.pr_ttydev;
|
||||
|
||||
buf->priority = psinfo.pr_lwp.pr_pri;
|
||||
buf->nice = psinfo.pr_lwp.pr_nice;
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_uid_psinfo;
|
||||
|
||||
if(glibtop_get_proc_credentials_s(server, &prcred, pid))
|
||||
return;
|
||||
|
||||
buf->suid = prcred.pr_suid;
|
||||
buf->sgid = prcred.pr_sgid;
|
||||
buf->ngroups = (prcred.pr_ngroups <= GLIBTOP_MAX_GROUPS) ?
|
||||
prcred.pr_ngroups : GLIBTOP_MAX_GROUPS;
|
||||
|
||||
if(sizeof(int) == sizeof(gid_t))
|
||||
memcpy(buf->groups, prcred.pr_groups,
|
||||
buf->ngroups * sizeof(gid_t));
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < buf->ngroups; ++i)
|
||||
buf->groups[i] = prcred.pr_groups[i];
|
||||
}
|
||||
buf->flags += _glibtop_sysdeps_proc_uid_prcred;
|
||||
}
|
77
sysdeps/solaris/sem_limits.c
Normal file
77
sysdeps/solaris/sem_limits.c
Normal file
@@ -0,0 +1,77 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/sem_limits.h>
|
||||
|
||||
#include <kvm.h>
|
||||
#include <sys/sem.h>
|
||||
|
||||
static struct nlist nlst[] = { {"seminfo"}, {NULL} };
|
||||
static const unsigned long _glibtop_sysdeps_sem_limits =
|
||||
(1L << GLIBTOP_IPC_SEMMAP) + (1L << GLIBTOP_IPC_SEMMNI) +
|
||||
(1L << GLIBTOP_IPC_SEMMNS) + (1L << GLIBTOP_IPC_SEMMNU) +
|
||||
(1L << GLIBTOP_IPC_SEMMSL) + (1L << GLIBTOP_IPC_SEMOPM) +
|
||||
(1L << GLIBTOP_IPC_SEMUME) + (1L << GLIBTOP_IPC_SEMUSZ) +
|
||||
(1L << GLIBTOP_IPC_SEMVMX) + (1L << GLIBTOP_IPC_SEMAEM);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_sem_limits_s (glibtop *server)
|
||||
{
|
||||
kvm_t *kd = server->machine.kd;
|
||||
|
||||
if(kd && !kvm_nlist(kd, nlst))
|
||||
server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits;
|
||||
else
|
||||
server->sysdeps.sem_limits = 0;
|
||||
}
|
||||
|
||||
/* Provides information about sysv sem limits. */
|
||||
|
||||
void
|
||||
glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf)
|
||||
{
|
||||
kvm_t *kd = server->machine.kd;
|
||||
struct seminfo sinfo;
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_sem_limits));
|
||||
|
||||
if(!(server->sysdeps.sem_limits))
|
||||
return;
|
||||
if(kvm_read(kd, nlst[0].n_value, (void *)&sinfo,
|
||||
sizeof(struct seminfo)) != sizeof(struct seminfo))
|
||||
return;
|
||||
buf->semmap = sinfo.semmap;
|
||||
buf->semmni = sinfo.semmni;
|
||||
buf->semmns = sinfo.semmns;
|
||||
buf->semmnu = sinfo.semmnu;
|
||||
buf->semmsl = sinfo.semmsl;
|
||||
buf->semopm = sinfo.semopm;
|
||||
buf->semume = sinfo.semume;
|
||||
buf->semusz = sinfo.semusz;
|
||||
buf->semvmx = sinfo.semvmx;
|
||||
buf->semaem = sinfo.semaem;
|
||||
buf->flags = _glibtop_sysdeps_sem_limits;
|
||||
}
|
68
sysdeps/solaris/shm_limits.c
Normal file
68
sysdeps/solaris/shm_limits.c
Normal file
@@ -0,0 +1,68 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/shm_limits.h>
|
||||
|
||||
#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)
|
||||
{
|
||||
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. */
|
||||
|
||||
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;
|
||||
}
|
127
sysdeps/solaris/siglist.c
Normal file
127
sysdeps/solaris/siglist.c
Normal file
@@ -0,0 +1,127 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/signal.h>
|
||||
|
||||
static const glibtop_signame glibtop_sys_siglist [] =
|
||||
{ { 1, "SIGHUP", "Hangup" },
|
||||
{ 2, "SIGINT", "Interrupt" },
|
||||
{ 3, "SIGQUIT", "Quit" },
|
||||
{ 4, "SIGILL", "Illegal instruction" },
|
||||
{ 5, "SIGTRAP", "Trace or breakpoint trap" },
|
||||
{ 6, "SIGABRT", "Abort" },
|
||||
{ 7, "SIGEMT", "Emulation trap" },
|
||||
{ 8, "SIGFPE", "Arithmetic exception" },
|
||||
{ 9, "SIGKILL", "Kill" },
|
||||
{ 10, "SIGBUS", "Bus error" },
|
||||
{ 11, "SIGSEGV", "Segmentation fault" },
|
||||
{ 12, "SIGSYS", "Bad system call" },
|
||||
{ 13, "SIGPIPE", "Broken pipe" },
|
||||
{ 14, "SIGALRM", "Alarm clock" },
|
||||
{ 15, "SIGTERM", "Terminate" },
|
||||
{ 16, "SIGUSR1", "User signal 1" },
|
||||
{ 17, "SIGUSR2", "User signal 2" },
|
||||
{ 18, "SIGCHLD", "Child status changed" },
|
||||
{ 19, "SIGPWR", "Power fail or restart" },
|
||||
{ 20, "SIGWINCH","Window size change" },
|
||||
{ 21, "SIGURG", "Urgent socket condition" },
|
||||
{ 22, "SIGPOLL", "Pollable event" },
|
||||
{ 23, "SIGSTOP", "Stop (cannot be ignored)" },
|
||||
{ 24, "SIGTSTP", "User stop requested from tty" },
|
||||
{ 25, "SIGCONT", "Continue" },
|
||||
{ 26, "SIGTTIN", "Background tty read attempted" },
|
||||
{ 27, "SIGTTOU", "Background tty write attempted" },
|
||||
{ 28, "SIGVTALRM","Virtual timer expired" },
|
||||
{ 29, "SIGPROF", "Profiling timer expired" },
|
||||
{ 30, "SIGXCPU", "CPU time limit exceeded" },
|
||||
{ 31, "SIGXFSZ", "File size limit exceeded" },
|
||||
{ 32, "SIGWAITING","process' lwps are blocked" },
|
||||
{ 33, "SIGLWP", "Inter-LWP signal reserved by threads library" },
|
||||
{ 34, "SIGFREEZE","Check point freeze" },
|
||||
{ 35, "SIGTHAW", "Check point thaw" },
|
||||
{ 36, "SIGCANCEL","Cancelation signal reserved by threads library" },
|
||||
{ 37, "SIGLOST", "Resource lost" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
/*
|
||||
* Now, just for the fun of it, let's try to be forward and backward
|
||||
* compatible. The above list is from Solaris 7. If later releases
|
||||
* include new signals, binary from the earlier release won't be
|
||||
* able to get the signal names, but it can get the correct numbers.
|
||||
* So...
|
||||
*/
|
||||
|
||||
/*
|
||||
#define MY_PRIVATE_COUNTOF(x) (sizeof(x)/sizeof(x[0]))
|
||||
|
||||
glibtop_signame *glibtop_sys_siglist;
|
||||
|
||||
static char *unknown = "Unknown";
|
||||
static glibtop_signame rt_min =
|
||||
{ 0, "SIGRTMIN", "First (highest-priority) realtime signal" };
|
||||
static glibtop_signame rt_max =
|
||||
{ 0, "SIGRTMIN", "Last (lowest-priority) realtime signal" };
|
||||
static char *rt_desc = "Real time signal %d";
|
||||
|
||||
void
|
||||
glibtop_init_signals(void)
|
||||
{
|
||||
int rtmin, rtmax, sigs, to, i;
|
||||
char *bureq, p;
|
||||
|
||||
rtmin = sysconf(_SC_SIGRT_MIN);
|
||||
rtmax = sysconf(_SC_SIGRT_MAX);
|
||||
sigs = MY_PRIVATE_COUNTOF(siglist);
|
||||
|
||||
glibtop_sys_siglist = (glibtop_signame *)
|
||||
malloc(rtmax * sizeof(glibtop_signame));
|
||||
bureq = malloc((rtmax - rtmin - 1) * (strlen(rt_desc) + 4));
|
||||
to = (sigs <= rtmin) ? sigs : rtmin;
|
||||
memcpy(glibtop_sys_siglist, siglist, to * sizeof(glibtop_signame));
|
||||
for(i = sigs; i < rtmin; ++i)
|
||||
{
|
||||
glibtop_sys_siglist[i].number = i + 1;
|
||||
glibtop_sys_siglist[i].name = glibtop_sys_siglist[i].label = unknown;
|
||||
}
|
||||
glibtop_sys_siglist[rtmin - 1].number = rtmin;
|
||||
glibtop_sys_siglist[rtmin - 1].name = rt_min.name;
|
||||
glibtop_sys_siglist[rtmin - 1].label = rt_min.label;
|
||||
for(p = bureq, i = rtmin; i < rtmax; ++i)
|
||||
{
|
||||
glibtop_sys_siglist[i].number = i + 1;
|
||||
to = sprintf(p, "%d", i + 1) + 1;
|
||||
glibtop_sys_siglist[i].name = p;
|
||||
p += to;
|
||||
to = sprintf(p, rt_desc, i - rtmin + 2) + 1;
|
||||
glibtop_sys_siglist[i].label = p;
|
||||
p += to;
|
||||
}
|
||||
glibtop_sys_siglist[rtmax - 1].number = rtmax;
|
||||
glibtop_sys_siglist[rtmax - 1].name = rt_max.name;
|
||||
glibtop_sys_siglist[rtmax - 1].label = rt_max.label;
|
||||
glibtop_sys_siglist[rtmax].number = 0;
|
||||
glibtop_sys_siglist[rtmax].name = glibtop_sys_siglist[rtmax].label = NULL;
|
||||
}
|
||||
*/
|
89
sysdeps/solaris/swap.c
Normal file
89
sysdeps/solaris/swap.c
Normal file
@@ -0,0 +1,89 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/swap.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <sys/sysinfo.h>
|
||||
|
||||
#include <glibtop_private.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_swap =
|
||||
(1L << GLIBTOP_SWAP_TOTAL) + (1L << GLIBTOP_SWAP_USED) +
|
||||
(1L << GLIBTOP_SWAP_FREE);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_swap_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.swap = _glibtop_sysdeps_swap;
|
||||
}
|
||||
|
||||
/* Provides information about swap usage. */
|
||||
|
||||
void
|
||||
glibtop_get_swap_s (glibtop *server, glibtop_swap *buf)
|
||||
{
|
||||
kstat_ctl_t *kc = server->machine.kc;
|
||||
kstat_t *ksp = server->machine.vminfo_kstat;
|
||||
u_int64_t swap_resv, swap_alloc, swap_avail, swap_free;
|
||||
vminfo_t vminfo;
|
||||
double rate;
|
||||
kid_t ret;
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_swap));
|
||||
|
||||
if (!ksp) return;
|
||||
|
||||
switch(kstat_chain_update(kc))
|
||||
{
|
||||
case -1: assert(0); /* Debugging, shouldn't happen */
|
||||
case 0: break;
|
||||
default: glibtop_get_kstats(server);
|
||||
}
|
||||
ret = kstat_read (kc, ksp, &vminfo);
|
||||
|
||||
if (ret == -1) {
|
||||
glibtop_warn_io_r (server, "kstat_read (vminfo)");
|
||||
return;
|
||||
}
|
||||
|
||||
rate = (ksp->ks_snaptime - server->machine.vminfo_snaptime) / 1E+9;
|
||||
|
||||
swap_resv = (vminfo.swap_resv - server->machine.vminfo.swap_resv) / rate;
|
||||
swap_alloc = (vminfo.swap_alloc - server->machine.vminfo.swap_alloc) / rate;
|
||||
swap_avail = (vminfo.swap_avail - server->machine.vminfo.swap_avail) / rate;
|
||||
swap_free = (vminfo.swap_free - server->machine.vminfo.swap_free) / rate;
|
||||
|
||||
memcpy (&server->machine.vminfo, &vminfo, sizeof (vminfo_t));
|
||||
server->machine.vminfo_snaptime = ksp->ks_snaptime;
|
||||
|
||||
buf->total = swap_resv + swap_avail;
|
||||
buf->used = swap_alloc;
|
||||
buf->free = buf->total - buf->used;
|
||||
|
||||
buf->flags = _glibtop_sysdeps_swap;
|
||||
}
|
53
sysdeps/solaris/uptime.c
Normal file
53
sysdeps/solaris/uptime.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/uptime.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_uptime =
|
||||
(1L << GLIBTOP_UPTIME_UPTIME) + (1L <<GLIBTOP_UPTIME_BOOT_TIME);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_uptime_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.uptime = _glibtop_sysdeps_uptime;
|
||||
}
|
||||
|
||||
/* Provides uptime and idle time. */
|
||||
|
||||
void
|
||||
glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf)
|
||||
{
|
||||
memset (buf, 0, sizeof (glibtop_uptime));
|
||||
|
||||
if(!(server->machine.boot))
|
||||
return;
|
||||
buf->boot_time = server->machine.boot;
|
||||
buf->uptime = time(NULL) - server->machine.boot;
|
||||
|
||||
buf->flags = _glibtop_sysdeps_uptime;
|
||||
}
|
Reference in New Issue
Block a user