This is now a LibGTop backend which can be loaded additionally to the
2000-01-23 Martin Baulig <martin@home-of-linux.org> This is now a LibGTop backend which can be loaded additionally to the normal Linux sysdeps code. * open.c, close.c: Removed. * shm_limits.c, msg_limits.c, sem_limits.c, ppp.c: Removed. * siglist.c, sysinfo.c: Removed. * backend-kernel.c: New file. * glibtop-backend-private.h: New file. * libgtop-kernel.backend: New file. * backend-kernel.pl: New file. Automatically creates `backend-kernel.h'. * marshal.pl: New file. Automatically creates `marshal.c'. * glibtop_server.h: Replaced all `GLIBTOP_SUID_<feature>' constants with `GLIBTOP_IMPL_<feature>' ones; they're used in marshal.c to find out which features this backend implements. * *.c: Renamed all `glibtop_get_<feature>_s' functions to `glibtop_get_<feature>_k' and all `glibtop_init_<feature>_s' ones to `glibtop_init_<feature>_k'.
This commit is contained in:
committed by
Martin Baulig
parent
d2f4502e74
commit
3455d025a2
@@ -2,5 +2,7 @@
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
libgtop_sysdeps.la
|
||||
*.lo
|
||||
*.la
|
||||
marshal.c
|
||||
backend-kernel.h
|
||||
|
@@ -1,3 +1,29 @@
|
||||
2000-01-23 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
This is now a LibGTop backend which can be loaded additionally
|
||||
to the normal Linux sysdeps code.
|
||||
|
||||
* open.c, close.c: Removed.
|
||||
* shm_limits.c, msg_limits.c, sem_limits.c, ppp.c: Removed.
|
||||
* siglist.c, sysinfo.c: Removed.
|
||||
|
||||
* backend-kernel.c: New file.
|
||||
* glibtop-backend-private.h: New file.
|
||||
* libgtop-kernel.backend: New file.
|
||||
|
||||
* backend-kernel.pl: New file. Automatically creates
|
||||
`backend-kernel.h'.
|
||||
|
||||
* marshal.pl: New file. Automatically creates `marshal.c'.
|
||||
|
||||
* glibtop_server.h: Replaced all `GLIBTOP_SUID_<feature>' constants
|
||||
with `GLIBTOP_IMPL_<feature>' ones; they're used in marshal.c to
|
||||
find out which features this backend implements.
|
||||
|
||||
* *.c: Renamed all `glibtop_get_<feature>_s' functions to
|
||||
`glibtop_get_<feature>_k' and all `glibtop_init_<feature>_s' ones
|
||||
to `glibtop_init_<feature>_k'.
|
||||
|
||||
1999-12-22 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* procdata.c: Distinguish between GLIBTOP_ERROR_NO_KERNEL_SUPPORT
|
||||
|
@@ -1,18 +1,48 @@
|
||||
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
LINK = \
|
||||
$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
INCLUDES = @INCLUDES@
|
||||
INCLUDES = \
|
||||
@INCLUDES@
|
||||
|
||||
lib_LTLIBRARIES = libgtop_sysdeps.la
|
||||
backenddir = \
|
||||
@LIBGTOP_BACKEND_DIR@
|
||||
|
||||
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 \
|
||||
netinfo.c interfaces.c ppp.c procdata.c \
|
||||
sysinfo.c
|
||||
backend_LTLIBRARIES = \
|
||||
libgtop_backend_kernel.la
|
||||
|
||||
libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO)
|
||||
backend_DATA = \
|
||||
libgtop-kernel.backend
|
||||
|
||||
include_HEADERS = glibtop_server.h glibtop_private.h
|
||||
libgtop_backend_kernel_la_SOURCES = \
|
||||
cpu.c mem.c swap.c uptime.c loadavg.c \
|
||||
proclist.c procstate.c procuid.c \
|
||||
proctime.c procmem.c procsignal.c prockernel.c \
|
||||
procsegment.c procargs.c procmap.c netload.c \
|
||||
netinfo.c interfaces.c procdata.c \
|
||||
backend-kernel.c marshal.c
|
||||
|
||||
libgtop_backend_kernel_la_LDFLAGS = \
|
||||
$(LT_VERSION_INFO)
|
||||
|
||||
noinst_HEADERS = \
|
||||
glibtop_server.h glibtop_private.h
|
||||
|
||||
BUILT_SOURCES = \
|
||||
marshal.c \
|
||||
backend-kernel.h
|
||||
|
||||
EXTRA_DIST = \
|
||||
marshal.pl \
|
||||
backend-kernel.pl \
|
||||
libgtop-sysdeps.backend
|
||||
|
||||
CLEANFILES = $(BUILT_SOURCES)
|
||||
|
||||
marshal.c: marshal.pl $(top_builddir)/config.h $(top_srcdir)/features.def $(top_srcdir)/scripts/c_types.pl
|
||||
$(PERL) -I $(top_srcdir)/scripts $(srcdir)/marshal.pl < $(top_srcdir)/features.def > tmp-t
|
||||
mv tmp-t marshal.c
|
||||
|
||||
backend-kernel.h: backend-kernel.pl $(top_builddir)/config.h $(top_srcdir)/features.def $(top_srcdir)/scripts/c_types.pl
|
||||
$(PERL) -I $(top_srcdir)/scripts $(srcdir)/backend-kernel.pl < $(top_srcdir)/features.def > tmp-t
|
||||
mv tmp-t backend-kernel.h
|
||||
|
||||
|
88
sysdeps/kernel/backend-kernel.c
Normal file
88
sysdeps/kernel/backend-kernel.c
Normal file
@@ -0,0 +1,88 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/global.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
|
||||
#include <glibtop/open.h>
|
||||
#include <glibtop/backend.h>
|
||||
#include <glibtop-backend-private.h>
|
||||
|
||||
#include <glibtop_private.h>
|
||||
|
||||
static int
|
||||
_open_kernel (glibtop *, glibtop_backend *, u_int64_t, const char **);
|
||||
|
||||
static int
|
||||
_close_kernel (glibtop *, glibtop_backend *);
|
||||
|
||||
extern glibtop_call_vector glibtop_backend_kernel_call_vector;
|
||||
extern glibtop_init_func_t _glibtop_init_hook_k [];
|
||||
|
||||
glibtop_backend_info LibGTopBackendInfo = {
|
||||
"glibtop-backend-kernel", _open_kernel, _close_kernel,
|
||||
&glibtop_backend_kernel_call_vector
|
||||
};
|
||||
|
||||
static int
|
||||
_open_kernel (glibtop *server, glibtop_backend *backend,
|
||||
u_int64_t features, const char **backend_args)
|
||||
{
|
||||
glibtop_init_func_t *init_fkt;
|
||||
int version, name [2] = { CTL_LIBGTOP, LIBGTOP_VERSION };
|
||||
size_t size = sizeof (int);
|
||||
|
||||
if (sysctl (name, 2, &version, &size, NULL, 0)) {
|
||||
if (errno == ENOTDIR)
|
||||
return -GLIBTOP_ERROR_NO_KERNEL_SUPPORT;
|
||||
else
|
||||
glibtop_warn_io_r (server, "sysctl (libgtop/stat)");
|
||||
return -1;
|
||||
}
|
||||
|
||||
backend->_priv = glibtop_calloc_r
|
||||
(server, 1, sizeof (glibtop_backend_private));
|
||||
|
||||
/* Do the initialization, but only if not already initialized. */
|
||||
|
||||
if ((server->flags & _GLIBTOP_INIT_STATE_SYSDEPS) == 0) {
|
||||
for (init_fkt = _glibtop_init_hook_k; *init_fkt; init_fkt++)
|
||||
(*init_fkt) (server);
|
||||
|
||||
server->sysdeps.pointer_size = sizeof (void*)*8;
|
||||
|
||||
server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_close_kernel (glibtop *server, glibtop_backend *backend)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
152
sysdeps/kernel/backend-kernel.pl
Normal file
152
sysdeps/kernel/backend-kernel.pl
Normal file
@@ -0,0 +1,152 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
require 'c_types.pl';
|
||||
|
||||
$[ = 1; # set array base to 1
|
||||
$, = ' '; # set output field separator
|
||||
$\ = "\n"; # set output record separator
|
||||
|
||||
$always_use_temp_storage = 1;
|
||||
|
||||
sub toupper {
|
||||
local($_) = @_;
|
||||
tr/a-z/A-Z/;
|
||||
return $_;
|
||||
}
|
||||
|
||||
sub tolower {
|
||||
local($_) = @_;
|
||||
tr/A-Z/a-z/;
|
||||
return $_;
|
||||
}
|
||||
|
||||
print '/* backend-kernel.h */';
|
||||
print "/* This is a generated file. Please modify `backend-kernel.pl' */";
|
||||
print '';
|
||||
|
||||
print '#ifndef __GLIBTOP_BACKEND_KERNEL_H__';
|
||||
print '#define __GLIBTOP_BACKEND_KERNEL_H__';
|
||||
print '';
|
||||
print '#include <glibtop.h>';
|
||||
print '#include <glibtop/union.h>';
|
||||
print '';
|
||||
print 'BEGIN_LIBGTOP_DECLS';
|
||||
print '';
|
||||
|
||||
$feature_count = 0;
|
||||
|
||||
while (<>) {
|
||||
chop; # strip record separator
|
||||
|
||||
if (/^[^#]/) {
|
||||
&output($_);
|
||||
}
|
||||
}
|
||||
|
||||
sub output {
|
||||
local($line) = @_;
|
||||
@line_fields = split(/\|/, $line, 9999);
|
||||
$retval = $line_fields[1];
|
||||
$feature = $line_fields[2];
|
||||
$param_def = $line_fields[4];
|
||||
|
||||
$orig = $feature;
|
||||
$feature =~ s/^@//;
|
||||
$space = $feature;
|
||||
$space =~ s/./ /g;
|
||||
|
||||
$features{++$feature_count} = $orig;
|
||||
|
||||
return if $orig =~ /^@/;
|
||||
|
||||
if ($retval eq 'retval') {
|
||||
$retval_param = '&retval';
|
||||
$call_prefix = '';
|
||||
$call_prefix_space = '';
|
||||
$prefix = 'retval = ';
|
||||
$prefix_space = ' ';
|
||||
$retval = 'int';
|
||||
}
|
||||
elsif ($retval !~ /^void$/) {
|
||||
$retval_param = 'NULL';
|
||||
$prefix = 'retval = ';
|
||||
$prefix_space = ' ';
|
||||
$call_prefix = 'retval = ';
|
||||
$call_prefix_space = ' ';
|
||||
}
|
||||
else {
|
||||
$retval_param = 'NULL';
|
||||
$call_prefix = '';
|
||||
$call_prefix_space = '';
|
||||
$prefix = '';
|
||||
$prefix_space = '';
|
||||
}
|
||||
|
||||
if ($retval =~ /^(array|pointer)\((.*)\)$/) {
|
||||
$retval = ($2 eq 'string') ? 'char **' : "$2 *";
|
||||
}
|
||||
|
||||
$need_temp_storage = $always_use_temp_storage;
|
||||
$first_param_name = '';
|
||||
|
||||
$call_param = '';
|
||||
$param_decl = '';
|
||||
$need_temp_len = 0;
|
||||
$nr_params = (@params = split(/:/, $param_def, 9999));
|
||||
for ($param = 1; $param <= $nr_params; $param++) {
|
||||
$list = $params[$param];
|
||||
$type = $params[$param];
|
||||
$type =~ s/\(.*//;
|
||||
$list =~ s/^.*\(//;
|
||||
$list =~ s/\)$//;
|
||||
$count = (@fields = split(/,/, $list, 9999));
|
||||
for ($field = 1; $field <= $count; $field++) {
|
||||
my $c_type = $typeinfo->{$type}->[1];
|
||||
|
||||
if ($first_param_name eq '') {
|
||||
$first_param_name = $fields[$field];
|
||||
}
|
||||
|
||||
if ($typeinfo->{$type}->[2]) {
|
||||
$need_temp_storage = 1;
|
||||
}
|
||||
|
||||
if ($param_decl eq '') {
|
||||
$param_decl = ",\n " . $space . ' ';
|
||||
}
|
||||
else {
|
||||
$param_decl = $param_decl . ', ';
|
||||
}
|
||||
$param_decl = $param_decl . $c_type . ' ' . $fields[$field];
|
||||
$call_param = $call_param . ', ' . $fields[$field];
|
||||
}
|
||||
}
|
||||
|
||||
$func_decl = sprintf ("int\nglibtop_init_%s_k (glibtop *server);\n\n",
|
||||
$feature);
|
||||
|
||||
$func_decl .= $retval."\n";
|
||||
if ($line_fields[3] eq '') {
|
||||
$func_decl .= sprintf ("glibtop_get_%s_k (glibtop *server%s);\n",
|
||||
$feature, $param_decl);
|
||||
} elsif ($line_fields[3] eq 'array') {
|
||||
$func_decl .= sprintf ("glibtop_get_%s_k (glibtop *server, glibtop_array *array%s);\n",
|
||||
$feature, $param_decl);
|
||||
} elsif ($line_fields[3] =~ /^array/) {
|
||||
$func_decl .= sprintf ("glibtop_get_%s_k (glibtop *server, glibtop_array *array, %s *buf%s);\n",
|
||||
$feature, 'glibtop_'.$feature, $param_decl);
|
||||
} else {
|
||||
$func_decl .= sprintf ("glibtop_get_%s_k (glibtop *server, %s *buf%s);\n",
|
||||
$feature, 'glibtop_'.$feature, $param_decl);
|
||||
}
|
||||
|
||||
$total_code = $func_decl;
|
||||
|
||||
print $total_code;
|
||||
}
|
||||
|
||||
print '';
|
||||
print 'END_LIBGTOP_DECLS';
|
||||
print '';
|
||||
print '#endif';
|
||||
print '';
|
@@ -41,7 +41,7 @@ static const unsigned long _glibtop_sysdeps_cpu_smp =
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_cpu_s (glibtop *server)
|
||||
glibtop_init_cpu_k (glibtop *server)
|
||||
{
|
||||
server->sysdeps.cpu = _glibtop_sysdeps_cpu;
|
||||
|
||||
@@ -54,14 +54,14 @@ glibtop_init_cpu_s (glibtop *server)
|
||||
/* Provides information about cpu usage. */
|
||||
|
||||
int
|
||||
glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
|
||||
glibtop_get_cpu_k (glibtop *server, glibtop_cpu *buf)
|
||||
{
|
||||
libgtop_stat_t stat;
|
||||
int retval, i;
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_cpu));
|
||||
|
||||
retval = glibtop_get_proc_data_stat_s (server, &stat);
|
||||
retval = glibtop_get_proc_data_stat_k (server, &stat);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
|
@@ -23,10 +23,12 @@
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop/close.h>
|
||||
#ifndef __GLIBTOP_BACKEND_PRIVATE_H__
|
||||
#define __GLIBTOP_BACKEND_PRIVATE_H__
|
||||
|
||||
/* Closes pipe to gtop server. */
|
||||
struct _glibtop_backend_private
|
||||
{
|
||||
u_int64_t flags;
|
||||
};
|
||||
|
||||
void
|
||||
glibtop_close_s (glibtop *server)
|
||||
{ }
|
||||
#endif
|
@@ -38,54 +38,56 @@
|
||||
|
||||
BEGIN_LIBGTOP_DECLS
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_stat_s (glibtop *server, libgtop_stat_t *stat);
|
||||
#include "backend-kernel.h"
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_mem_s (glibtop *server, libgtop_mem_t *mem);
|
||||
glibtop_get_proc_data_stat_k (glibtop *server, libgtop_stat_t *stat);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_swap_s (glibtop *server, libgtop_swap_t *swap);
|
||||
glibtop_get_proc_data_mem_k (glibtop *server, libgtop_mem_t *mem);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proclist_s (glibtop *server,
|
||||
glibtop_get_proc_data_swap_k (glibtop *server, libgtop_swap_t *swap);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proclist_k (glibtop *server,
|
||||
libgtop_proclist_t *proclist,
|
||||
u_int64_t which, u_int64_t arg);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_state_s (glibtop *server,
|
||||
glibtop_get_proc_data_proc_state_k (glibtop *server,
|
||||
libgtop_proc_state_t *proc_state,
|
||||
pid_t pid);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_mem_s (glibtop *server,
|
||||
glibtop_get_proc_data_proc_mem_k (glibtop *server,
|
||||
libgtop_proc_mem_t *proc_mem,
|
||||
pid_t pid);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_signal_s (glibtop *server,
|
||||
glibtop_get_proc_data_proc_signal_k (glibtop *server,
|
||||
libgtop_proc_signal_t *proc_signal,
|
||||
pid_t pid);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_kernel_s (glibtop *server,
|
||||
glibtop_get_proc_data_proc_kernel_k (glibtop *server,
|
||||
libgtop_proc_kernel_t *proc_kernel,
|
||||
pid_t pid);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_args_s (glibtop *server, pid_t pid,
|
||||
glibtop_get_proc_data_proc_args_k (glibtop *server, pid_t pid,
|
||||
char *result, size_t max_len);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_maps_s (glibtop *server, pid_t pid,
|
||||
glibtop_get_proc_data_proc_maps_k (glibtop *server, pid_t pid,
|
||||
libgtop_proc_maps_t *result,
|
||||
size_t max_len);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_netload_s (glibtop *server,
|
||||
glibtop_get_proc_data_netload_k (glibtop *server,
|
||||
libgtop_netload_t *netload,
|
||||
const char *device);
|
||||
|
||||
END_LIBGTOP_DECLS
|
||||
|
||||
#endif __GLIBTOP_PRIVATE_H__
|
||||
#endif /* __GLIBTOP_PRIVATE_H__ */
|
||||
|
@@ -28,26 +28,28 @@
|
||||
|
||||
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
|
||||
#define GLIBTOP_IMPL_CPU (1 << GLIBTOP_SYSDEPS_CPU)
|
||||
#define GLIBTOP_IMPL_MEM (1 << GLIBTOP_SYSDEPS_MEM)
|
||||
#define GLIBTOP_IMPL_SWAP (1 << GLIBTOP_SYSDEPS_SWAP)
|
||||
#define GLIBTOP_IMPL_UPTIME (1 << GLIBTOP_SYSDEPS_UPTIME)
|
||||
#define GLIBTOP_IMPL_LOADAVG (1 << GLIBTOP_SYSDEPS_LOADAVG)
|
||||
#define GLIBTOP_IMPL_SHM_LIMITS 0
|
||||
#define GLIBTOP_IMPL_MSG_LIMITS 0
|
||||
#define GLIBTOP_IMPL_SEM_LIMITS 0
|
||||
#define GLIBTOP_IMPL_PROCLIST (1 << GLIBTOP_SYSDEPS_PROCLIST)
|
||||
#define GLIBTOP_IMPL_PROC_STATE (1 << GLIBTOP_SYSDEPS_PROC_STATE)
|
||||
#define GLIBTOP_IMPL_PROC_UID (1 << GLIBTOP_SYSDEPS_PROC_UID)
|
||||
#define GLIBTOP_IMPL_PROC_MEM (1 << GLIBTOP_SYSDEPS_PROC_MEM)
|
||||
#define GLIBTOP_IMPL_PROC_TIME (1 << GLIBTOP_SYSDEPS_PROC_TIME)
|
||||
#define GLIBTOP_IMPL_PROC_SIGNAL (1 << GLIBTOP_SYSDEPS_PROC_SIGNAL)
|
||||
#define GLIBTOP_IMPL_PROC_KERNEL (1 << GLIBTOP_SYSDEPS_PROC_KERNEL)
|
||||
#define GLIBTOP_IMPL_PROC_SEGMENT (1 << GLIBTOP_SYSDEPS_PROC_SEGMENT)
|
||||
#define GLIBTOP_IMPL_PROC_ARGS (1 << GLIBTOP_SYSDEPS_PROC_ARGS)
|
||||
#define GLIBTOP_IMPL_PROC_MAP (1 << GLIBTOP_SYSDEPS_PROC_MAP)
|
||||
#define GLIBTOP_IMPL_NETLOAD (1 << GLIBTOP_SYSDEPS_NETLOAD)
|
||||
#define GLIBTOP_IMPL_NETINFO (1 << GLIBTOP_SYSDEPS_NETINFO)
|
||||
#define GLIBTOP_IMPL_INTERFACE_NAMES (1 << GLIBTOP_SYSDEPS_INTERFACE_NAMES)
|
||||
#define GLIBTOP_IMPL_PPP 0
|
||||
|
||||
END_LIBGTOP_DECLS
|
||||
|
||||
|
@@ -27,6 +27,8 @@
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/interfaces.h>
|
||||
|
||||
#include <glibtop_private.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_interface_names =
|
||||
(1L << GLIBTOP_INTERFACE_NAMES_NUMBER) +
|
||||
(1L << GLIBTOP_INTERFACE_NAMES_SIZE);
|
||||
@@ -34,7 +36,7 @@ static const unsigned long _glibtop_sysdeps_interface_names =
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_interface_names_s (glibtop *server)
|
||||
glibtop_init_interface_names_k (glibtop *server)
|
||||
{
|
||||
server->sysdeps.interface_names = _glibtop_sysdeps_interface_names;
|
||||
|
||||
@@ -44,7 +46,7 @@ glibtop_init_interface_names_s (glibtop *server)
|
||||
/* Provides network statistics. */
|
||||
|
||||
glibtop_interface *
|
||||
glibtop_get_interface_names_s (glibtop *server, glibtop_interface_names *buf,
|
||||
glibtop_get_interface_names_k (glibtop *server, glibtop_interface_names *buf,
|
||||
u_int64_t interface, u_int64_t number,
|
||||
u_int64_t instance, u_int64_t strategy)
|
||||
{
|
||||
|
12
sysdeps/kernel/libgtop-kernel.backend
Normal file
12
sysdeps/kernel/libgtop-kernel.backend
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0"?> <!-- -*-xml-*- -->
|
||||
<libgtop:Backends xmlns:libgtop="http://www.home-of-linux.org/libgtop/1.1">
|
||||
|
||||
<libgtop:Backend>
|
||||
<libgtop:Name>glibtop-backend-kernel</libgtop:Name>
|
||||
<libgtop:Location>
|
||||
<libgtop:LibtoolName>libgtop_backend_kernel.la</libgtop:LibtoolName>
|
||||
<libgtop:ShlibName>libgtop_backend_kernel.so</libgtop:ShlibName>
|
||||
</libgtop:Location>
|
||||
</libgtop:Backend>
|
||||
|
||||
</libgtop:Backends>
|
@@ -34,7 +34,7 @@ static const unsigned long _glibtop_sysdeps_loadavg =
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_loadavg_s (glibtop *server)
|
||||
glibtop_init_loadavg_k (glibtop *server)
|
||||
{
|
||||
server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
|
||||
|
||||
@@ -44,14 +44,14 @@ glibtop_init_loadavg_s (glibtop *server)
|
||||
/* Provides load averange. */
|
||||
|
||||
int
|
||||
glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf)
|
||||
glibtop_get_loadavg_k (glibtop *server, glibtop_loadavg *buf)
|
||||
{
|
||||
libgtop_stat_t stat;
|
||||
int retval;
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_loadavg));
|
||||
|
||||
retval = glibtop_get_proc_data_stat_s (server, &stat);
|
||||
retval = glibtop_get_proc_data_stat_k (server, &stat);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
|
201
sysdeps/kernel/marshal.pl
Normal file
201
sysdeps/kernel/marshal.pl
Normal file
@@ -0,0 +1,201 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
require 'c_types.pl';
|
||||
|
||||
$[ = 1; # set array base to 1
|
||||
$, = ' '; # set output field separator
|
||||
$\ = "\n"; # set output record separator
|
||||
|
||||
$always_use_temp_storage = 1;
|
||||
|
||||
sub toupper {
|
||||
local($_) = @_;
|
||||
tr/a-z/A-Z/;
|
||||
return $_;
|
||||
}
|
||||
|
||||
sub tolower {
|
||||
local($_) = @_;
|
||||
tr/A-Z/a-z/;
|
||||
return $_;
|
||||
}
|
||||
|
||||
print '/* marshal.c */';
|
||||
print "/* This is a generated file. Please modify `marshal.pl' */";
|
||||
print '';
|
||||
|
||||
print '#include <glibtop.h>';
|
||||
print '#include <glibtop/open.h>';
|
||||
print '#include <glibtop/xmalloc.h>';
|
||||
print '';
|
||||
print '#include <glibtop/sysdeps.h>';
|
||||
print '#include <glibtop/union.h>';
|
||||
print '';
|
||||
print '#include <glibtop/backend.h>';
|
||||
print '';
|
||||
print '#include <glibtop-backend-private.h>';
|
||||
print '#include <glibtop_private.h>';
|
||||
print '#include <glibtop_server.h>';
|
||||
print '';
|
||||
|
||||
$feature_count = 0;
|
||||
|
||||
while (<>) {
|
||||
chop; # strip record separator
|
||||
|
||||
if (/^[^#]/) {
|
||||
&output($_);
|
||||
}
|
||||
}
|
||||
|
||||
sub output {
|
||||
local($line) = @_;
|
||||
@line_fields = split(/\|/, $line, 9999);
|
||||
$retval = $line_fields[1];
|
||||
$feature = $line_fields[2];
|
||||
$param_def = $line_fields[4];
|
||||
|
||||
$orig = $feature;
|
||||
$feature =~ s/^@//;
|
||||
$space = $feature;
|
||||
$space =~ s/./ /g;
|
||||
|
||||
$features{++$feature_count} = $orig;
|
||||
|
||||
return if $orig =~ /^@/;
|
||||
|
||||
if ($retval eq 'retval') {
|
||||
$retval_param = '&retval';
|
||||
$call_prefix = '';
|
||||
$call_prefix_space = '';
|
||||
$prefix = 'retval = ';
|
||||
$prefix_space = ' ';
|
||||
$retval = 'int';
|
||||
}
|
||||
elsif ($retval !~ /^void$/) {
|
||||
$retval_param = 'NULL';
|
||||
$prefix = 'retval = ';
|
||||
$prefix_space = ' ';
|
||||
$call_prefix = 'retval = ';
|
||||
$call_prefix_space = ' ';
|
||||
}
|
||||
else {
|
||||
$retval_param = 'NULL';
|
||||
$call_prefix = '';
|
||||
$call_prefix_space = '';
|
||||
$prefix = '';
|
||||
$prefix_space = '';
|
||||
}
|
||||
|
||||
if ($retval =~ /^(array|pointer)\((.*)\)$/) {
|
||||
$retval = ($2 eq 'string') ? 'char **' : "$2 *";
|
||||
}
|
||||
|
||||
$need_temp_storage = $always_use_temp_storage;
|
||||
$first_param_name = '';
|
||||
|
||||
$call_param = '';
|
||||
$param_decl = '';
|
||||
$need_temp_len = 0;
|
||||
$nr_params = (@params = split(/:/, $param_def, 9999));
|
||||
for ($param = 1; $param <= $nr_params; $param++) {
|
||||
$list = $params[$param];
|
||||
$type = $params[$param];
|
||||
$type =~ s/\(.*//;
|
||||
$list =~ s/^.*\(//;
|
||||
$list =~ s/\)$//;
|
||||
$count = (@fields = split(/,/, $list, 9999));
|
||||
for ($field = 1; $field <= $count; $field++) {
|
||||
my $c_type = $typeinfo->{$type}->[1];
|
||||
|
||||
if ($first_param_name eq '') {
|
||||
$first_param_name = $fields[$field];
|
||||
}
|
||||
|
||||
if ($typeinfo->{$type}->[2]) {
|
||||
$need_temp_storage = 1;
|
||||
}
|
||||
|
||||
if ($param_decl eq '') {
|
||||
$param_decl = ",\n " . $space . ' ';
|
||||
}
|
||||
else {
|
||||
$param_decl = $param_decl . ', ';
|
||||
}
|
||||
$param_decl = $param_decl . $c_type . ' ' . $fields[$field];
|
||||
$call_param = $call_param . ', ' . $fields[$field];
|
||||
}
|
||||
}
|
||||
|
||||
if ($line_fields[3] eq '') {
|
||||
$total_code = sprintf
|
||||
("\treturn glibtop_get_%s_k (server%s);\n", $feature, $call_param);
|
||||
} elsif ($line_fields[3] eq 'array') {
|
||||
$total_code = sprintf
|
||||
("\treturn glibtop_get_%s_k (server, array%s);\n", $feature, $call_param);
|
||||
} elsif ($line_fields[3] =~ /^array/) {
|
||||
$total_code = sprintf
|
||||
("\treturn glibtop_get_%s_k (server, array, buf%s);\n", $feature, $call_param);
|
||||
} else {
|
||||
$total_code = sprintf
|
||||
("\treturn glibtop_get_%s_k (server, buf%s);\n", $feature, $call_param);
|
||||
}
|
||||
|
||||
$func_decl = 'static '.$retval."\n";
|
||||
if ($line_fields[3] eq '') {
|
||||
$func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend%s)\n",
|
||||
$feature, $param_decl);
|
||||
} elsif ($line_fields[3] eq 'array') {
|
||||
$func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, glibtop_array *array%s)\n",
|
||||
$feature, $param_decl);
|
||||
} elsif ($line_fields[3] =~ /^array/) {
|
||||
$func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, glibtop_array *array, %s *buf%s)\n",
|
||||
$feature, 'glibtop_'.$feature, $param_decl);
|
||||
} else {
|
||||
$func_decl .= sprintf ("_glibtop_get_%s_c (glibtop *server, glibtop_backend *backend, %s *buf%s)\n",
|
||||
$feature, 'glibtop_'.$feature, $param_decl);
|
||||
}
|
||||
|
||||
$total_code = sprintf ("%s{\n%s\n%s}\n", $func_decl, $total_code);
|
||||
|
||||
$total_code = sprintf ("#if (GLIBTOP_IMPL_%s)\n\n%s\n#endif /* GLIBTOP_IMPL_%s */\n\n",
|
||||
&toupper($feature), $total_code,
|
||||
&toupper($feature));
|
||||
|
||||
print $total_code;
|
||||
}
|
||||
|
||||
$init_hook_code = '';
|
||||
$call_vector_code = '';
|
||||
for ($nr = 1; $nr <= $feature_count; $nr++) {
|
||||
$feature = $features{$nr};
|
||||
|
||||
if ($feature =~ /^@/) {
|
||||
$call_vector_code .= sprintf (qq[\tNULL,\n]);
|
||||
} else {
|
||||
$call_vector_code .= sprintf
|
||||
(qq[\#if GLIBTOP_IMPL_%s\n\t_glibtop_get_%s_c,\n\#else\n\tNULL,\n\#endif\n],
|
||||
&toupper($feature), $feature);
|
||||
}
|
||||
|
||||
if (!($feature =~ /^@/)) {
|
||||
$init_hook_code .= sprintf
|
||||
(qq[\#if GLIBTOP_IMPL_%s\n\tglibtop_init_%s_k,\n\#endif\n],
|
||||
&toupper($feature), $feature);
|
||||
}
|
||||
}
|
||||
$init_hook_code .= sprintf (qq[\tNULL\n]);
|
||||
|
||||
chop $init_hook_code;
|
||||
chop $call_vector_code;
|
||||
|
||||
print 'glibtop_call_vector glibtop_backend_kernel_call_vector = {';
|
||||
print $call_vector_code;
|
||||
print '};';
|
||||
print '';
|
||||
|
||||
print 'glibtop_init_func_t _glibtop_init_hook_k [] = {';
|
||||
print $init_hook_code;
|
||||
print '};';
|
||||
print '';
|
||||
|
@@ -36,7 +36,7 @@ static const unsigned long _glibtop_sysdeps_mem =
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_mem_s (glibtop *server)
|
||||
glibtop_init_mem_k (glibtop *server)
|
||||
{
|
||||
server->sysdeps.mem = _glibtop_sysdeps_mem;
|
||||
|
||||
@@ -46,14 +46,14 @@ glibtop_init_mem_s (glibtop *server)
|
||||
/* Provides information about memory usage. */
|
||||
|
||||
int
|
||||
glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
|
||||
glibtop_get_mem_k (glibtop *server, glibtop_mem *buf)
|
||||
{
|
||||
libgtop_mem_t mem;
|
||||
int retval;
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_mem));
|
||||
|
||||
retval = glibtop_get_proc_data_mem_s (server, &mem);
|
||||
retval = glibtop_get_proc_data_mem_k (server, &mem);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
|
@@ -1,72 +0,0 @@
|
||||
/* -*- 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>, 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/msg_limits.h>
|
||||
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/msg.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_msg_limits =
|
||||
(1L << GLIBTOP_MSG_LIMITS_MSGPOOL) + (1L << GLIBTOP_MSG_LIMITS_MSGMAP) +
|
||||
(1L << GLIBTOP_MSG_LIMITS_MSGMAX) + (1L << GLIBTOP_MSG_LIMITS_MSGMNB) +
|
||||
(1L << GLIBTOP_MSG_LIMITS_MSGMNI) + (1L << GLIBTOP_MSG_LIMITS_MSGSSZ) +
|
||||
(1L << GLIBTOP_MSG_LIMITS_MSGTQL);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_msg_limits_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Provides information about sysv ipc limits. */
|
||||
|
||||
int
|
||||
glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
|
||||
{
|
||||
struct msginfo msginfo;
|
||||
|
||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_msg_limits));
|
||||
|
||||
buf->flags = _glibtop_sysdeps_msg_limits;
|
||||
|
||||
if (msgctl (0, IPC_INFO, (struct msqid_ds *) &msginfo))
|
||||
return -1;
|
||||
|
||||
buf->msgpool = msginfo.msgpool;
|
||||
buf->msgmap = msginfo.msgmap;
|
||||
buf->msgmax = msginfo.msgmax;
|
||||
buf->msgmnb = msginfo.msgmnb;
|
||||
buf->msgmni = msginfo.msgmni;
|
||||
buf->msgssz = msginfo.msgssz;
|
||||
buf->msgtql = msginfo.msgtql;
|
||||
|
||||
return 0;
|
||||
}
|
@@ -63,7 +63,7 @@ static const unsigned long _glibtop_sysdeps_netinfo =
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_netinfo_s (glibtop *server)
|
||||
glibtop_init_netinfo_k (glibtop *server)
|
||||
{
|
||||
server->sysdeps.netinfo = _glibtop_sysdeps_netinfo;
|
||||
|
||||
@@ -73,7 +73,7 @@ glibtop_init_netinfo_s (glibtop *server)
|
||||
/* Provides network statistics. */
|
||||
|
||||
int
|
||||
glibtop_get_netinfo_s (glibtop *server, glibtop_netinfo *buf,
|
||||
glibtop_get_netinfo_k (glibtop *server, glibtop_netinfo *buf,
|
||||
const char *interface, unsigned transport)
|
||||
{
|
||||
int skfd;
|
||||
|
@@ -70,7 +70,7 @@ static const unsigned long _glibtop_sysdeps_netload =
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_netload_s (glibtop *server)
|
||||
glibtop_init_netload_k (glibtop *server)
|
||||
{
|
||||
server->sysdeps.netload = _glibtop_sysdeps_netload;
|
||||
|
||||
@@ -80,7 +80,7 @@ glibtop_init_netload_s (glibtop *server)
|
||||
/* Provides network statistics. */
|
||||
|
||||
int
|
||||
glibtop_get_netload_s (glibtop *server, glibtop_netload *buf,
|
||||
glibtop_get_netload_k (glibtop *server, glibtop_netload *buf,
|
||||
const char *interface, unsigned transport,
|
||||
unsigned protocol)
|
||||
{
|
||||
@@ -89,7 +89,7 @@ glibtop_get_netload_s (glibtop *server, glibtop_netload *buf,
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_netload));
|
||||
|
||||
retval = glibtop_get_proc_data_netload_s (server, &netload, interface);
|
||||
retval = glibtop_get_proc_data_netload_k (server, &netload, interface);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
|
@@ -1,35 +0,0 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
#include <glibtop/open.h>
|
||||
|
||||
/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */
|
||||
|
||||
void
|
||||
glibtop_open_s (glibtop *server, const char *program_name,
|
||||
const unsigned long features, const unsigned flags)
|
||||
{
|
||||
server->name = program_name;
|
||||
}
|
@@ -1,208 +0,0 @@
|
||||
/* -*- 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>, 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/xmalloc.h>
|
||||
#include <glibtop/ppp.h>
|
||||
|
||||
#include <linux/isdn.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_ppp =
|
||||
(1L << GLIBTOP_PPP_STATE) + (1L << GLIBTOP_PPP_BYTES_IN) +
|
||||
(1L << GLIBTOP_PPP_BYTES_OUT);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_ppp_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.ppp = _glibtop_sysdeps_ppp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
get_ISDN_stats (glibtop *server, int *in, int *out)
|
||||
{
|
||||
unsigned long *isdn_stats, *ptr;
|
||||
int fd, i;
|
||||
|
||||
*in = *out = 0;
|
||||
|
||||
isdn_stats = glibtop_calloc_r (server, ISDN_MAX_CHANNELS * 2,
|
||||
sizeof (unsigned long));
|
||||
|
||||
fd = open ("/dev/isdninfo", O_RDONLY);
|
||||
if (fd < 0) {
|
||||
glibtop_free_r (server, isdn_stats);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((ioctl (fd, IIOCGETCPS, isdn_stats) < 0) && (errno != 0)) {
|
||||
glibtop_free_r (server, isdn_stats);
|
||||
close (fd);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (i = 0, ptr = isdn_stats; i < ISDN_MAX_CHANNELS; i++) {
|
||||
*in += *ptr++; *out += *ptr++;
|
||||
}
|
||||
|
||||
glibtop_free_r (server, isdn_stats);
|
||||
close (fd);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int is_ISDN_on (glibtop *server, int *online)
|
||||
{
|
||||
FILE *f = 0;
|
||||
char buffer [BUFSIZ], *p;
|
||||
int i;
|
||||
|
||||
/* Perhaps I should try to explain this code a little bit.
|
||||
*
|
||||
* ------------------------------------------------------------
|
||||
* This is from the manpage of isdninfo(4):
|
||||
*
|
||||
* DESCRIPTION
|
||||
* /dev/isdninfo is a character device with major number 45
|
||||
* and minor number 255. It delivers status information from
|
||||
* the Linux ISDN subsystem to user level.
|
||||
*
|
||||
* DATA FORMAT
|
||||
* When reading from this device, the current status of the
|
||||
* Linux ISDN subsystem is delivered in 6 lines of text. Each
|
||||
* line starts with a tag string followed by a colon and
|
||||
* whitespace. After that the status values are appended sep-
|
||||
* arated by whitespace.
|
||||
*
|
||||
* flags is the tag of line 5. In this line for every driver
|
||||
* slot, it's B-Channel status is shown. If no driver
|
||||
* is registered in a slot, a ? is shown. For every
|
||||
* established B-Channel of the driver, a bit is set
|
||||
* in the shown value. The driver's first channel is
|
||||
* mapped to bit 0, the second channel to bit 1 and so
|
||||
* on.
|
||||
* ------------------------------------------------------------
|
||||
*
|
||||
* So we open /dev/isdninfo, discard the first four lines of text
|
||||
* and then check whether we have something that is not `0' or `?'
|
||||
* in one of the flags fields.
|
||||
*
|
||||
* Sounds complicated, but I don't see any other way to check whether
|
||||
* we are connected. Also, this is the method some other ISDN tools
|
||||
* for Linux use.
|
||||
*
|
||||
* Martin
|
||||
*/
|
||||
|
||||
f = fopen ("/dev/isdninfo", "r");
|
||||
|
||||
if (!f) return FALSE;
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
if (fgets (buffer, BUFSIZ, f) == NULL) {
|
||||
fclose (f);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (strncmp (buffer, "flags:", 6)) {
|
||||
fclose (f);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
p = buffer+6;
|
||||
|
||||
while (*p) {
|
||||
char *end = p;
|
||||
|
||||
if (isspace (*p)) {
|
||||
p++;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (end = p; *end && !isspace (*end); end++)
|
||||
;
|
||||
|
||||
if (*end == 0)
|
||||
break;
|
||||
else
|
||||
*end = 0;
|
||||
|
||||
if (!strcmp (p, "?") || !strcmp (p, "0")) {
|
||||
p = end+1;
|
||||
continue;
|
||||
}
|
||||
|
||||
fclose (f);
|
||||
|
||||
*online = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
fclose (f);
|
||||
|
||||
*online = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Provides PPP/ISDN information. */
|
||||
|
||||
int
|
||||
glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device,
|
||||
unsigned short isdn, const char *lockfile)
|
||||
{
|
||||
int in, out, online;
|
||||
|
||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_PPP, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_ppp));
|
||||
|
||||
if (is_ISDN_on (server, &online)) {
|
||||
buf->state = online ? GLIBTOP_PPP_STATE_ONLINE :
|
||||
GLIBTOP_PPP_STATE_HANGUP;
|
||||
buf->flags |= (1L << GLIBTOP_PPP_STATE);
|
||||
}
|
||||
|
||||
if (get_ISDN_stats (server, &in, &out)) {
|
||||
buf->bytes_in = in;
|
||||
buf->bytes_out = out;
|
||||
buf->flags |= (1L << GLIBTOP_PPP_BYTES_IN) |
|
||||
(1L << GLIBTOP_PPP_BYTES_OUT);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@@ -36,7 +36,7 @@ static const unsigned long _glibtop_sysdeps_proc_args =
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_proc_args_s (glibtop *server)
|
||||
glibtop_init_proc_args_k (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_args = _glibtop_sysdeps_proc_args;
|
||||
|
||||
@@ -46,7 +46,7 @@ glibtop_init_proc_args_s (glibtop *server)
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
char **
|
||||
glibtop_get_proc_args_s (glibtop *server, glibtop_array *array, pid_t pid)
|
||||
glibtop_get_proc_args_k (glibtop *server, glibtop_array *array, pid_t pid)
|
||||
{
|
||||
char *ptr = NULL, *pos, **ptrlist;
|
||||
size_t count = 0, max_len, total;
|
||||
@@ -57,7 +57,7 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_array *array, pid_t pid)
|
||||
max_len = PAGE_SIZE;
|
||||
ptr = glibtop_malloc_r (server, max_len + 1);
|
||||
|
||||
ret = glibtop_get_proc_data_proc_args_s (server, pid, ptr, max_len);
|
||||
ret = glibtop_get_proc_data_proc_args_k (server, pid, ptr, max_len);
|
||||
if (ret < 0) {
|
||||
glibtop_free_r (server, ptr);
|
||||
return NULL;
|
||||
|
@@ -27,7 +27,7 @@
|
||||
#include <glibtop_private.h>
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_stat_s (glibtop *server, libgtop_stat_t *stat)
|
||||
glibtop_get_proc_data_stat_k (glibtop *server, libgtop_stat_t *stat)
|
||||
{
|
||||
int name [2] = { CTL_LIBGTOP, LIBGTOP_STAT };
|
||||
size_t size = sizeof (libgtop_stat_t);
|
||||
@@ -44,7 +44,7 @@ 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)
|
||||
glibtop_get_proc_data_mem_k (glibtop *server, libgtop_mem_t *mem)
|
||||
{
|
||||
int name [2] = { CTL_LIBGTOP, LIBGTOP_MEM };
|
||||
size_t size = sizeof (libgtop_mem_t);
|
||||
@@ -61,7 +61,7 @@ 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)
|
||||
glibtop_get_proc_data_swap_k (glibtop *server, libgtop_swap_t *swap)
|
||||
{
|
||||
int name [2] = { CTL_LIBGTOP, LIBGTOP_SWAP };
|
||||
size_t size = sizeof (libgtop_swap_t);
|
||||
@@ -78,7 +78,7 @@ glibtop_get_proc_data_swap_s (glibtop *server, libgtop_swap_t *swap)
|
||||
}
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proclist_s (glibtop *server,
|
||||
glibtop_get_proc_data_proclist_k (glibtop *server,
|
||||
libgtop_proclist_t *proclist,
|
||||
u_int64_t which, u_int64_t arg)
|
||||
{
|
||||
@@ -98,7 +98,7 @@ glibtop_get_proc_data_proclist_s (glibtop *server,
|
||||
}
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_state_s (glibtop *server,
|
||||
glibtop_get_proc_data_proc_state_k (glibtop *server,
|
||||
libgtop_proc_state_t *proc_state,
|
||||
pid_t pid)
|
||||
{
|
||||
@@ -119,7 +119,7 @@ glibtop_get_proc_data_proc_state_s (glibtop *server,
|
||||
}
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_mem_s (glibtop *server,
|
||||
glibtop_get_proc_data_proc_mem_k (glibtop *server,
|
||||
libgtop_proc_mem_t *proc_mem,
|
||||
pid_t pid)
|
||||
{
|
||||
@@ -140,7 +140,7 @@ glibtop_get_proc_data_proc_mem_s (glibtop *server,
|
||||
}
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_signal_s (glibtop *server,
|
||||
glibtop_get_proc_data_proc_signal_k (glibtop *server,
|
||||
libgtop_proc_signal_t *proc_signal,
|
||||
pid_t pid)
|
||||
{
|
||||
@@ -161,7 +161,7 @@ glibtop_get_proc_data_proc_signal_s (glibtop *server,
|
||||
}
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_kernel_s (glibtop *server,
|
||||
glibtop_get_proc_data_proc_kernel_k (glibtop *server,
|
||||
libgtop_proc_kernel_t *proc_kernel,
|
||||
pid_t pid)
|
||||
{
|
||||
@@ -182,7 +182,7 @@ glibtop_get_proc_data_proc_kernel_s (glibtop *server,
|
||||
}
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_args_s (glibtop *server, pid_t pid,
|
||||
glibtop_get_proc_data_proc_args_k (glibtop *server, pid_t pid,
|
||||
char *result, size_t max_len)
|
||||
{
|
||||
int name [3] = { CTL_LIBGTOP, LIBGTOP_PROC_ARGS, pid };
|
||||
@@ -202,7 +202,7 @@ glibtop_get_proc_data_proc_args_s (glibtop *server, pid_t pid,
|
||||
}
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_maps_s (glibtop *server, pid_t pid,
|
||||
glibtop_get_proc_data_proc_maps_k (glibtop *server, pid_t pid,
|
||||
libgtop_proc_maps_t *result,
|
||||
size_t max_len)
|
||||
{
|
||||
@@ -223,7 +223,7 @@ glibtop_get_proc_data_proc_maps_s (glibtop *server, pid_t pid,
|
||||
}
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_netload_s (glibtop *server,
|
||||
glibtop_get_proc_data_netload_k (glibtop *server,
|
||||
libgtop_netload_t *netload,
|
||||
const char *device)
|
||||
{
|
||||
|
@@ -42,7 +42,7 @@ static const unsigned long _glibtop_sysdeps_proc_kernel_kernel =
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_proc_kernel_s (glibtop *server)
|
||||
glibtop_init_proc_kernel_k (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel |
|
||||
_glibtop_sysdeps_proc_kernel_kernel;
|
||||
@@ -53,7 +53,7 @@ glibtop_init_proc_kernel_s (glibtop *server)
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
int
|
||||
glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf,
|
||||
glibtop_get_proc_kernel_k (glibtop *server, glibtop_proc_kernel *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
libgtop_proc_state_t proc_state;
|
||||
@@ -62,7 +62,7 @@ glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf,
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_kernel));
|
||||
|
||||
retval = glibtop_get_proc_data_proc_state_s (server, &proc_state, pid);
|
||||
retval = glibtop_get_proc_data_proc_state_k (server, &proc_state, pid);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
@@ -75,7 +75,7 @@ glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf,
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_kernel;
|
||||
|
||||
retval = glibtop_get_proc_data_proc_kernel_s (server, &proc_kernel, pid);
|
||||
retval = glibtop_get_proc_data_proc_kernel_k (server, &proc_kernel, pid);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
|
@@ -38,7 +38,7 @@ static const unsigned long _glibtop_sysdeps_proclist =
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_proclist_s (glibtop *server)
|
||||
glibtop_init_proclist_k (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proclist = _glibtop_sysdeps_proclist;
|
||||
|
||||
@@ -53,7 +53,7 @@ glibtop_init_proclist_s (glibtop *server)
|
||||
* each buf->size big. The total size is stored in buf->total. */
|
||||
|
||||
unsigned *
|
||||
glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
|
||||
glibtop_get_proclist_k (glibtop *server, glibtop_proclist *buf,
|
||||
int64_t which, int64_t arg)
|
||||
{
|
||||
libgtop_proclist_t proclist;
|
||||
@@ -62,7 +62,7 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proclist));
|
||||
|
||||
if (glibtop_get_proc_data_proclist_s (server, &proclist, which, arg))
|
||||
if (glibtop_get_proc_data_proclist_k (server, &proclist, which, arg))
|
||||
return NULL;
|
||||
|
||||
ret = glibtop_calloc_r (server, proclist.count, sizeof (unsigned));
|
||||
|
@@ -46,7 +46,7 @@ static const unsigned long _glibtop_sysdeps_map_entry_vmfile =
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_proc_map_s (glibtop *server)
|
||||
glibtop_init_proc_map_k (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
|
||||
|
||||
@@ -56,7 +56,7 @@ glibtop_init_proc_map_s (glibtop *server)
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
glibtop_map_entry *
|
||||
glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
||||
glibtop_get_proc_map_k (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
||||
{
|
||||
glibtop_map_entry *retval = NULL;
|
||||
libgtop_proc_maps_t *maps;
|
||||
@@ -68,13 +68,13 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
||||
memset (buf, 0, sizeof (glibtop_proc_map));
|
||||
|
||||
/* Get number of map entries. */
|
||||
count = glibtop_get_proc_data_proc_maps_s (server, pid, NULL, 0);
|
||||
count = glibtop_get_proc_data_proc_maps_k (server, pid, NULL, 0);
|
||||
|
||||
/* Allocate memory. */
|
||||
maps = glibtop_calloc_r (server, count, sizeof (libgtop_proc_maps_t));
|
||||
max_len = count * sizeof (libgtop_proc_maps_t);
|
||||
|
||||
ret = glibtop_get_proc_data_proc_maps_s (server, pid, maps, max_len);
|
||||
ret = glibtop_get_proc_data_proc_maps_k (server, pid, maps, max_len);
|
||||
if (ret < 0) {
|
||||
glibtop_free_r (server, maps);
|
||||
return NULL;
|
||||
|
@@ -46,7 +46,7 @@ static int pageshift; /* log base 2 of the pagesize */
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_proc_mem_s (glibtop *server)
|
||||
glibtop_init_proc_mem_k (glibtop *server)
|
||||
{
|
||||
register int pagesize;
|
||||
|
||||
@@ -66,7 +66,7 @@ glibtop_init_proc_mem_s (glibtop *server)
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
int
|
||||
glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf,
|
||||
glibtop_get_proc_mem_k (glibtop *server, glibtop_proc_mem *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
libgtop_proc_mem_t proc_mem;
|
||||
@@ -74,7 +74,7 @@ glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf,
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_mem));
|
||||
|
||||
retval = glibtop_get_proc_data_proc_mem_s (server, &proc_mem, pid);
|
||||
retval = glibtop_get_proc_data_proc_mem_k (server, &proc_mem, pid);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
|
@@ -53,7 +53,7 @@ static int pageshift; /* log base 2 of the pagesize */
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_proc_segment_s (glibtop *server)
|
||||
glibtop_init_proc_segment_k (glibtop *server)
|
||||
{
|
||||
register int pagesize;
|
||||
|
||||
@@ -74,7 +74,7 @@ glibtop_init_proc_segment_s (glibtop *server)
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
int
|
||||
glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf,
|
||||
glibtop_get_proc_segment_k (glibtop *server, glibtop_proc_segment *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
libgtop_proc_mem_t proc_mem;
|
||||
@@ -83,7 +83,7 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf,
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_segment));
|
||||
|
||||
retval = glibtop_get_proc_data_proc_mem_s (server, &proc_mem, pid);
|
||||
retval = glibtop_get_proc_data_proc_mem_k (server, &proc_mem, pid);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
@@ -101,7 +101,7 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf,
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_segment;
|
||||
|
||||
retval = glibtop_get_proc_data_proc_state_s (server, &proc_state, pid);
|
||||
retval = glibtop_get_proc_data_proc_state_k (server, &proc_state, pid);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
|
@@ -37,7 +37,7 @@ static const unsigned long _glibtop_sysdeps_proc_signal =
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_proc_signal_s (glibtop *server)
|
||||
glibtop_init_proc_signal_k (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal;
|
||||
|
||||
@@ -47,7 +47,7 @@ glibtop_init_proc_signal_s (glibtop *server)
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
int
|
||||
glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf,
|
||||
glibtop_get_proc_signal_k (glibtop *server, glibtop_proc_signal *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
libgtop_proc_signal_t proc_signal;
|
||||
@@ -55,7 +55,7 @@ glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf,
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_signal));
|
||||
|
||||
retval = glibtop_get_proc_data_proc_signal_s (server, &proc_signal, pid);
|
||||
retval = glibtop_get_proc_data_proc_signal_k (server, &proc_signal, pid);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
|
@@ -38,7 +38,7 @@ static const unsigned long _glibtop_sysdeps_proc_state =
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_proc_state_s (glibtop *server)
|
||||
glibtop_init_proc_state_k (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_state = _glibtop_sysdeps_proc_state;
|
||||
|
||||
@@ -48,7 +48,7 @@ glibtop_init_proc_state_s (glibtop *server)
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
int
|
||||
glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf,
|
||||
glibtop_get_proc_state_k (glibtop *server, glibtop_proc_state *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
libgtop_proc_state_t proc_state;
|
||||
@@ -56,7 +56,7 @@ glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf,
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_state));
|
||||
|
||||
retval = glibtop_get_proc_data_proc_state_s (server, &proc_state, pid);
|
||||
retval = glibtop_get_proc_data_proc_state_k (server, &proc_state, pid);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
|
@@ -39,7 +39,7 @@ static const unsigned long _glibtop_sysdeps_proc_time_smp =
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_proc_time_s (glibtop *server)
|
||||
glibtop_init_proc_time_k (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_time = _glibtop_sysdeps_proc_time;
|
||||
|
||||
@@ -52,7 +52,7 @@ glibtop_init_proc_time_s (glibtop *server)
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
int
|
||||
glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf,
|
||||
glibtop_get_proc_time_k (glibtop *server, glibtop_proc_time *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
libgtop_proc_state_t proc_state;
|
||||
@@ -60,7 +60,7 @@ glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf,
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_time));
|
||||
|
||||
retval = glibtop_get_proc_data_proc_state_s (server, &proc_state, pid);
|
||||
retval = glibtop_get_proc_data_proc_state_k (server, &proc_state, pid);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
|
@@ -46,7 +46,7 @@ static const unsigned long _glibtop_sysdeps_proc_uid =
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_proc_uid_s (glibtop *server)
|
||||
glibtop_init_proc_uid_k (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid;
|
||||
|
||||
@@ -56,7 +56,7 @@ glibtop_init_proc_uid_s (glibtop *server)
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
int
|
||||
glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf,
|
||||
glibtop_get_proc_uid_k (glibtop *server, glibtop_proc_uid *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
libgtop_proc_state_t proc_state;
|
||||
@@ -65,7 +65,7 @@ glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf,
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_uid));
|
||||
|
||||
retval = glibtop_get_proc_data_proc_state_s (server, &proc_state, pid);
|
||||
retval = glibtop_get_proc_data_proc_state_k (server, &proc_state, pid);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
|
@@ -1,93 +0,0 @@
|
||||
/* -*- 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>, 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/sem_limits.h>
|
||||
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/sem.h>
|
||||
|
||||
#ifdef _SEM_SEMUN_UNDEFINED
|
||||
|
||||
/* glibc 2.1 will no longer defines semun, instead it defines
|
||||
* _SEM_SEMUN_UNDEFINED so users can define semun on their own.
|
||||
* Thanks to Albert K T Hui <avatar@deva.net>. */
|
||||
|
||||
union semun
|
||||
{
|
||||
int val;
|
||||
struct semid_ds *buf;
|
||||
unsigned short int *array;
|
||||
struct seminfo *__buf;
|
||||
};
|
||||
#endif
|
||||
|
||||
static unsigned long _glibtop_sysdeps_sem_limits =
|
||||
(1L << GLIBTOP_SEM_LIMITS_SEMMAP) + (1L << GLIBTOP_SEM_LIMITS_SEMMNI) +
|
||||
(1L << GLIBTOP_SEM_LIMITS_SEMMNS) + (1L << GLIBTOP_SEM_LIMITS_SEMMNU) +
|
||||
(1L << GLIBTOP_SEM_LIMITS_SEMMSL) + (1L << GLIBTOP_SEM_LIMITS_SEMOPM) +
|
||||
(1L << GLIBTOP_SEM_LIMITS_SEMUME) + (1L << GLIBTOP_SEM_LIMITS_SEMUSZ) +
|
||||
(1L << GLIBTOP_SEM_LIMITS_SEMVMX) + (1L << GLIBTOP_SEM_LIMITS_SEMAEM);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_sem_limits_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Provides information about sysv ipc limits. */
|
||||
|
||||
int
|
||||
glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf)
|
||||
{
|
||||
struct seminfo seminfo;
|
||||
union semun arg;
|
||||
|
||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_sem_limits));
|
||||
|
||||
buf->flags = _glibtop_sysdeps_sem_limits;
|
||||
|
||||
arg.array = (ushort *) &seminfo;
|
||||
if (semctl (0, 0, IPC_INFO, arg))
|
||||
return -1;
|
||||
|
||||
buf->semmap = seminfo.semmap;
|
||||
buf->semmni = seminfo.semmni;
|
||||
buf->semmns = seminfo.semmns;
|
||||
buf->semmnu = seminfo.semmnu;
|
||||
buf->semmsl = seminfo.semmsl;
|
||||
buf->semopm = seminfo.semopm;
|
||||
buf->semume = seminfo.semume;
|
||||
buf->semusz = seminfo.semusz;
|
||||
buf->semvmx = seminfo.semvmx;
|
||||
buf->semaem = seminfo.semaem;
|
||||
|
||||
return 0;
|
||||
}
|
@@ -1,69 +0,0 @@
|
||||
/* -*- 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>, 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/shm_limits.h>
|
||||
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
|
||||
static unsigned long _glibtop_sysdeps_shm_limits =
|
||||
(1L << GLIBTOP_SHM_LIMITS_SHMMAX) + (1L << GLIBTOP_SHM_LIMITS_SHMMIN) +
|
||||
(1L << GLIBTOP_SHM_LIMITS_SHMMNI) + (1L << GLIBTOP_SHM_LIMITS_SHMSEG) +
|
||||
(1L << GLIBTOP_SHM_LIMITS_SHMALL);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_shm_limits_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Provides information about sysv ipc limits. */
|
||||
|
||||
int
|
||||
glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf)
|
||||
{
|
||||
struct shminfo shminfo;
|
||||
|
||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_shm_limits));
|
||||
|
||||
buf->flags = _glibtop_sysdeps_shm_limits;
|
||||
|
||||
if (shmctl (0, IPC_INFO, (struct shmid_ds *) &shminfo))
|
||||
return -1;
|
||||
|
||||
buf->shmmax = shminfo.shmmax;
|
||||
buf->shmmin = shminfo.shmmin;
|
||||
buf->shmmni = shminfo.shmmni;
|
||||
buf->shmseg = shminfo.shmseg;
|
||||
buf->shmall = shminfo.shmall;
|
||||
|
||||
return 0;
|
||||
}
|
@@ -1,62 +0,0 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/signal.h>
|
||||
|
||||
const glibtop_signame glibtop_sys_siglist [] =
|
||||
{ { 1, "SIGHUP", NULL }, /* Hangup (POSIX). */
|
||||
{ 2, "SIGINT", NULL }, /* Interrupt (ANSI). */
|
||||
{ 3, "SIGQUIT", NULL }, /* Quit (POSIX). */
|
||||
{ 4, "SIGILL", NULL }, /* Illegal instruction (ANSI). */
|
||||
{ 5, "SIGTRAP", NULL }, /* Trace trap (POSIX). */
|
||||
{ 6, "SIGABRT", NULL }, /* Abort (ANSI). */
|
||||
{ 7, "SIGBUS", NULL }, /* BUS error (4.2 BSD). */
|
||||
{ 8, "SIGFPE", NULL }, /* Floating-point exception (ANSI). */
|
||||
{ 9, "SIGKILL", NULL }, /* Kill, unblockable (POSIX). */
|
||||
{ 10, "SIGUSR1", NULL }, /* User-defined signal 1 (POSIX). */
|
||||
{ 11, "SIGSEGV", NULL }, /* Segmentation violation (ANSI). */
|
||||
{ 12, "SIGUSR2", NULL }, /* User-defined signal 2 (POSIX). */
|
||||
{ 13, "SIGPIPE", NULL }, /* Broken pipe (POSIX). */
|
||||
{ 14, "SIGALRM", NULL }, /* Alarm clock (POSIX). */
|
||||
{ 15, "SIGTERM", NULL }, /* Termination (ANSI). */
|
||||
{ 16, "SIGSTKFLT", NULL }, /* ??? */
|
||||
{ 17, "SIGCHLD", NULL }, /* Child status has changed (POSIX). */
|
||||
{ 18, "SIGCONT", NULL }, /* Continue (POSIX). */
|
||||
{ 19, "SIGSTOP", NULL }, /* Stop, unblockable (POSIX). */
|
||||
{ 20, "SIGTSTP", NULL }, /* Keyboard stop (POSIX). */
|
||||
{ 21, "SIGTTIN", NULL }, /* Background read from tty (POSIX). */
|
||||
{ 22, "SIGTTOU", NULL }, /* Background write to tty (POSIX). */
|
||||
{ 23, "SIGURG", NULL }, /* Urgent condition on socket (4.2 BSD). */
|
||||
{ 24, "SIGXCPU", NULL }, /* CPU limit exceeded (4.2 BSD). */
|
||||
{ 25, "SIGXFSZ", NULL }, /* File size limit exceeded (4.2 BSD). */
|
||||
{ 26, "SIGVTALRM", NULL }, /* Virtual alarm clock (4.2 BSD). */
|
||||
{ 27, "SIGPROF", NULL }, /* Profiling alarm clock (4.2 BSD). */
|
||||
{ 28, "SIGWINCH", NULL }, /* Window size change (4.3 BSD, Sun). */
|
||||
{ 29, "SIGIO", NULL }, /* I/O now possible (4.2 BSD). */
|
||||
{ 30, "SIGPWR", NULL }, /* Power failure restart (System V). */
|
||||
{ 31, "SIGUNUSED", NULL },
|
||||
{ 0, NULL, NULL },
|
||||
};
|
@@ -38,7 +38,7 @@ static const unsigned long _glibtop_sysdeps_swap_stat =
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_swap_s (glibtop *server)
|
||||
glibtop_init_swap_k (glibtop *server)
|
||||
{
|
||||
server->sysdeps.swap = _glibtop_sysdeps_swap |
|
||||
_glibtop_sysdeps_swap_stat;
|
||||
@@ -49,7 +49,7 @@ glibtop_init_swap_s (glibtop *server)
|
||||
/* Provides information about swap usage. */
|
||||
|
||||
int
|
||||
glibtop_get_swap_s (glibtop *server, glibtop_swap *buf)
|
||||
glibtop_get_swap_k (glibtop *server, glibtop_swap *buf)
|
||||
{
|
||||
libgtop_stat_t stat;
|
||||
libgtop_swap_t swap;
|
||||
@@ -57,7 +57,7 @@ glibtop_get_swap_s (glibtop *server, glibtop_swap *buf)
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_swap));
|
||||
|
||||
retval = glibtop_get_proc_data_swap_s (server, &swap);
|
||||
retval = glibtop_get_proc_data_swap_k (server, &swap);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
@@ -67,7 +67,7 @@ glibtop_get_swap_s (glibtop *server, glibtop_swap *buf)
|
||||
|
||||
buf->flags = _glibtop_sysdeps_swap;
|
||||
|
||||
retval = glibtop_get_proc_data_stat_s (server, &stat);
|
||||
retval = glibtop_get_proc_data_stat_k (server, &stat);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
|
@@ -1,98 +0,0 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop/cpu.h>
|
||||
#include <glibtop/sysinfo.h>
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_sysinfo =
|
||||
(1L << 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;
|
||||
}
|
@@ -35,7 +35,7 @@ static unsigned long _glibtop_sysdeps_uptime =
|
||||
/* Init function. */
|
||||
|
||||
int
|
||||
glibtop_init_uptime_s (glibtop *server)
|
||||
glibtop_init_uptime_k (glibtop *server)
|
||||
{
|
||||
server->sysdeps.uptime = _glibtop_sysdeps_uptime;
|
||||
|
||||
@@ -45,7 +45,7 @@ glibtop_init_uptime_s (glibtop *server)
|
||||
/* Provides uptime and idle time. */
|
||||
|
||||
int
|
||||
glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf)
|
||||
glibtop_get_uptime_k (glibtop *server, glibtop_uptime *buf)
|
||||
{
|
||||
libgtop_stat_t stat;
|
||||
unsigned long total;
|
||||
@@ -53,7 +53,7 @@ glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf)
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_uptime));
|
||||
|
||||
retval = glibtop_get_proc_data_stat_s (server, &stat);
|
||||
retval = glibtop_get_proc_data_stat_k (server, &stat);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
|
Reference in New Issue
Block a user