Did some more work on the daemon.
This commit is contained in:
@@ -16,8 +16,8 @@ bin_PROGRAMS = first first_static second second_static \
|
||||
EXTRA_PROGRAMS = third third_static
|
||||
|
||||
first_SOURCES = first.c
|
||||
first_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/lib/libgtop.la \
|
||||
first_LDADD = $(top_builddir)/lib/libgtop.la \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@ @libs_xauth@
|
||||
|
||||
@@ -26,8 +26,8 @@ first_static_LDADD = $(first_LDADD)
|
||||
first_static_LDFLAGS = -static
|
||||
|
||||
second_SOURCES = second.c
|
||||
second_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/lib/libgtop.la \
|
||||
second_LDADD = $(top_builddir)/lib/libgtop.la \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@ @libs_xauth@
|
||||
|
||||
|
@@ -51,14 +51,9 @@ int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int s; /* socket / msqid to server */
|
||||
int connect_type; /* CONN_UNIX, CONN_INTERNET, or
|
||||
* CONN_IPC */
|
||||
int connect_type; /* CONN_UNIX, CONN_INTERNET, or CONN_IPC */
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
char *hostarg = NULL; /* remote hostname */
|
||||
char thishost [HOSTNAMSZ]; /* this hostname */
|
||||
char remotepath[MAXPATHLEN+1]; /* remote pathname */
|
||||
int rflg = 0; /* pathname given on cmdline */
|
||||
u_short port = 0; /* port to server */
|
||||
#endif /* INTERNET_DOMAIN_SOCKETS */
|
||||
#ifdef SYSV_IPC
|
||||
struct msgbuf *msgp; /* message */
|
||||
@@ -66,42 +61,12 @@ main (int argc, char *argv[])
|
||||
|
||||
glibtop_init ();
|
||||
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
memset (remotepath, 0, sizeof (remotepath));
|
||||
#endif /* INTERNET_DOMAIN_SOCKETS */
|
||||
|
||||
#if defined(INTERNET_DOMAIN_SOCKETS)
|
||||
connect_type = glibtop_make_connection (hostarg, port, &s);
|
||||
#else
|
||||
connect_type = glibtop_make_connection (NULL, (u_short) 0, &s);
|
||||
#endif
|
||||
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
if (connect_type == (int) CONN_INTERNET)
|
||||
{
|
||||
char *ptr;
|
||||
gethostname (thishost, HOSTNAMSZ);
|
||||
if (!rflg)
|
||||
{ /* attempt to generate a path
|
||||
* to this machine */
|
||||
if ((ptr = getenv ("LIBGTOP_NODE")) != NULL)
|
||||
/* user specified a path */
|
||||
strcpy (remotepath, ptr);
|
||||
}
|
||||
#if 0 /* This is really bogus... re-enable it if you must have it! */
|
||||
#if defined (hp9000s300) || defined (hp9000s800)
|
||||
else if (strcmp (thishost,hostarg))
|
||||
{ /* try /net/thishost */
|
||||
strcpy (remotepath, "/net/"); /* (this fails using internet
|
||||
addresses) */
|
||||
strcat (remotepath, thishost);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{ /* same machines, no need for path */
|
||||
remotepath[0] = '\0'; /* default is the empty path */
|
||||
}
|
||||
#endif /* INTERNET_DOMAIN_SOCKETS */
|
||||
|
||||
|
20
lib/open.c
20
lib/open.c
@@ -25,6 +25,8 @@
|
||||
#include <glibtop/command.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
|
||||
#include <glibtop/gnuserv.h>
|
||||
|
||||
/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */
|
||||
|
||||
void
|
||||
@@ -35,6 +37,7 @@ glibtop_open_l (glibtop *server, const char *program_name,
|
||||
char *server_command, *server_rsh, *temp;
|
||||
char *server_host, *server_user;
|
||||
glibtop_sysdeps sysdeps;
|
||||
int connect_type;
|
||||
|
||||
memset (server, 0, sizeof (glibtop));
|
||||
|
||||
@@ -43,6 +46,23 @@ glibtop_open_l (glibtop *server, const char *program_name,
|
||||
/* Is the user allowed to override the server ? */
|
||||
|
||||
if ((flags & GLIBTOP_OPEN_NO_OVERRIDE) == 0) {
|
||||
connect_type = glibtop_make_connection
|
||||
(NULL, (u_short) 0, &server->socket);
|
||||
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
if (connect_type == (int) CONN_INTERNET) {
|
||||
fprintf (stderr, "Calling GLITOP_CMND_SYSDEPS ...\n");
|
||||
|
||||
glibtop_call_l (server, GLIBTOP_CMND_SYSDEPS, 0, NULL,
|
||||
sizeof (glibtop_sysdeps), &sysdeps);
|
||||
|
||||
server->features = sysdeps.features;
|
||||
|
||||
fprintf (stderr, "Features: %lu\n", server->features);
|
||||
|
||||
return;
|
||||
}
|
||||
#endif /* INTERNET_DOMAIN_SOCKETS */
|
||||
|
||||
/* Try to get data from environment. */
|
||||
|
||||
|
31
lib/read.c
31
lib/read.c
@@ -27,15 +27,36 @@ void
|
||||
glibtop_read_l (glibtop *server, size_t size, void *buf)
|
||||
{
|
||||
size_t ssize;
|
||||
int ret;
|
||||
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
if (read (server->input [0], &ssize, sizeof (size_t)) < 0)
|
||||
glibtop_error_r (server, _("read size: %s"), strerror (errno));
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "LIBRARY: reading %d bytes, should be %d.\n", sizeof (size_t), size);
|
||||
#endif
|
||||
|
||||
if (server->socket) {
|
||||
ret = recv (server->socket, &ssize, sizeof (size_t), 0);
|
||||
} else {
|
||||
ret = read (server->input [0], &ssize, sizeof (size_t));
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
glibtop_error_io_r (server, _("read size"));
|
||||
|
||||
if (size != ssize)
|
||||
glibtop_error_r (server, _("got %d bytes but requested %d"), ssize, size);
|
||||
glibtop_error_r (server, _("got %d bytes but requested %d (ret = %d)"), ssize, size, ret);
|
||||
|
||||
if (read (server->input [0], buf, size) < 0)
|
||||
glibtop_error_r (server, _("read %d bytes: %s"), size, strerror (errno));
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "LIBRARY: really reading %d bytes.\n", size);
|
||||
#endif
|
||||
|
||||
if (server->socket) {
|
||||
ret = recv (server->socket, buf, size, 0);
|
||||
} else {
|
||||
ret = read (server->input [0], buf, size);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
glibtop_error_io_r (server, _("read %d bytes"), size);
|
||||
}
|
||||
|
@@ -29,20 +29,39 @@ glibtop_read_data_l (glibtop *server)
|
||||
{
|
||||
size_t size;
|
||||
void *ptr;
|
||||
int ret;
|
||||
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
if (read (server->input [0], &size, sizeof (size_t)) < 0)
|
||||
glibtop_error_r (server, _("read data size: %s"),
|
||||
strerror (errno));
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "LIBRARY: reading %d data bytes.\n", sizeof (size_t));
|
||||
#endif
|
||||
|
||||
if (server->socket) {
|
||||
ret = recv (server->socket, &size, sizeof (size_t), 0);
|
||||
} else {
|
||||
ret = read (server->input [0], &size, sizeof (size_t));
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
glibtop_error_io_r (server, _("read data size"));
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "LIBRARY: really reading %d data bytes (ret = %d).\n", size, ret);
|
||||
#endif
|
||||
|
||||
if (!size) return NULL;
|
||||
|
||||
ptr = glibtop_malloc_r (server, size);
|
||||
|
||||
if (read (server->input [0], ptr, size) < 0)
|
||||
glibtop_error_r (server, _("read data %d bytes: %s"),
|
||||
size, strerror (errno));
|
||||
if (server->socket) {
|
||||
ret = recv (server->socket, ptr, size, 0);
|
||||
} else {
|
||||
ret = read (server->input [0], ptr, size);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
glibtop_error_io_r (server, _("read data %d bytes"));
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
30
lib/write.c
30
lib/write.c
@@ -26,13 +26,35 @@
|
||||
void
|
||||
glibtop_write_l (glibtop *server, size_t size, void *buf)
|
||||
{
|
||||
int ret;
|
||||
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
if (write (server->output [1], &size, sizeof (size_t)) < 0)
|
||||
glibtop_error_r (server, _("write size: %s"), strerror (errno));
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "LIBRARY: writing %d bytes = %d.\n", sizeof (size_t), size);
|
||||
#endif
|
||||
|
||||
if (server->socket) {
|
||||
ret = send (server->socket, &size, sizeof (size_t), 0);
|
||||
} else {
|
||||
ret = write (server->output [1], &size, sizeof (size_t));
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
glibtop_error_io_r (server, _("write size"));
|
||||
|
||||
if (!size) return;
|
||||
|
||||
if (write (server->output [1], buf, size) < 0)
|
||||
glibtop_error_r (server, _("write %d bytes: %s"), size, strerror (errno));
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "LIBRARY: really writing %d bytes.\n", size);
|
||||
#endif
|
||||
|
||||
if (server->socket) {
|
||||
ret = send (server->socket, buf, size, 0);
|
||||
} else {
|
||||
ret = write (server->output [1], buf, size);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
glibtop_error_io_r (server, _("write %d bytes"), size);
|
||||
}
|
||||
|
25
src/daemon/Makefile.am
Normal file
25
src/daemon/Makefile.am
Normal file
@@ -0,0 +1,25 @@
|
||||
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
INCLUDES = -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \
|
||||
-I$(top_srcdir)/include -I$(top_srcdir)/intl @GUILE_INCS@ \
|
||||
-DGTOPLOCALEDIR=\"$(datadir)/locale\" -D_GNU_SOURCE
|
||||
|
||||
CFLAGS = -Wall -W @CFLAGS@ -DGTOP_SERVER=\""@LIBGTOP_SERVER@"\"
|
||||
|
||||
bin_PROGRAMS = gnuserv
|
||||
|
||||
EXTRA_PROGRAMS = gtop_daemon
|
||||
|
||||
gnuserv_SOURCES = gnuserv.c main.c
|
||||
gnuserv_LDADD = $(top_builddir)/lib/libgtop.la \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@ @X_LIBS@ -lXau
|
||||
gnuserv_LDFLAGS = -static
|
||||
|
||||
gtop_daemon_SOURCES = main.c inet.c loop.c output.c version.c
|
||||
gtop_daemon_LDADD = $(top_builddir)/lib/libgtop.la \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@
|
||||
gtop_daemon_LDFLAGS = -static
|
@@ -33,12 +33,17 @@
|
||||
static char rcsid [] = "!Header: gnuserv.c,v 2.1 95/02/16 11:58:27 arup alpha !";
|
||||
#endif
|
||||
|
||||
#define DEBUG
|
||||
|
||||
#include <glibtop/gnuserv.h>
|
||||
#include <glibtop/open.h>
|
||||
|
||||
#ifdef AIX
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
extern void handle_socket_connection __P((int));
|
||||
|
||||
#if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
|
||||
main ()
|
||||
{
|
||||
@@ -417,6 +422,10 @@ permitted (u_long host_addr, int fd)
|
||||
if (timed_read(fd, auth_protocol, AUTH_NAMESZ, AUTH_TIMEOUT, 1) <= 0)
|
||||
return FALSE;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Client sent authenticatin protocol '%s'\n", auth_protocol);
|
||||
#endif
|
||||
|
||||
if (strcmp (auth_protocol, DEFAUTH_NAME) &&
|
||||
strcmp (auth_protocol, MCOOKIE_NAME))
|
||||
{
|
||||
@@ -471,10 +480,18 @@ permitted (u_long host_addr, int fd)
|
||||
/* First find the hash key */
|
||||
key = HASH(host_addr) % TABLE_SIZE;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Doing GNU_SECURE auth ...\n");
|
||||
#endif
|
||||
|
||||
/* Now check the chain for that hash key */
|
||||
for(entry = permitted_hosts[key]; entry != NULL; entry=entry->next)
|
||||
for(entry = permitted_hosts [key]; entry != NULL; entry = entry->next) {
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Trying %ld\n", entry->host_addr);
|
||||
#endif
|
||||
if (host_addr == entry->host_addr)
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
return(FALSE);
|
||||
|
||||
@@ -630,15 +647,29 @@ handle_internet_request (int ls)
|
||||
if ((s = accept (ls, (struct sockaddr *)&peer, (void *) &addrlen)) == -1)
|
||||
glibtop_error_io ("accept");
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Connection was made from %s.\n", inet_ntoa (peer.sin_addr));
|
||||
#endif
|
||||
|
||||
/* Check that access is allowed - if not return crud to the client */
|
||||
if (!permitted (peer.sin_addr.s_addr, s))
|
||||
{
|
||||
close(s);
|
||||
glibtop_warn ("Refused connection from %s", inet_ntoa (peer.sin_addr));
|
||||
glibtop_warn ("Refused connection from %s.", inet_ntoa (peer.sin_addr));
|
||||
return;
|
||||
} /* if */
|
||||
|
||||
echo_request(s);
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Accepted connection from %s.\n", inet_ntoa (peer.sin_addr));
|
||||
#endif
|
||||
|
||||
handle_socket_connection (s);
|
||||
|
||||
close (s);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Closed connection to %s.\n", inet_ntoa (peer.sin_addr));
|
||||
#endif
|
||||
|
||||
} /* handle_internet_request */
|
||||
#endif /* INTERNET_DOMAIN_SOCKETS */
|
||||
@@ -746,7 +777,7 @@ main(argc,argv)
|
||||
struct msgbuf *msgp; /* message buffer */
|
||||
#endif /* SYSV_IPC */
|
||||
|
||||
glibtop_init ();
|
||||
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_OPEN_NO_OVERRIDE);
|
||||
|
||||
for(chan=3; chan < _NFILE; close(chan++)) /* close unwanted channels */
|
||||
;
|
||||
@@ -775,6 +806,10 @@ main(argc,argv)
|
||||
if (ils >= 0)
|
||||
FD_SET(ils, &rmask);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Server ready and waiting for connections.\n");
|
||||
#endif
|
||||
|
||||
if (select(max2(fileno(stdin),max2(uls,ils)) + 1, &rmask,
|
||||
(fd_set *)NULL, (fd_set *)NULL, (struct timeval *)NULL) < 0)
|
||||
glibtop_error_io ("select");
|
||||
|
259
src/daemon/main.c
Normal file
259
src/daemon/main.c
Normal file
@@ -0,0 +1,259 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Top Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <glibtop/gnuserv.h>
|
||||
|
||||
#include <glibtop/command.h>
|
||||
#include <glibtop/version.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
#include <glibtop/union.h>
|
||||
#include <glibtop/open.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <locale.h>
|
||||
|
||||
#if defined(HAVE_GETDTABLESIZE)
|
||||
#define GET_MAX_FDS() getdtablesize()
|
||||
#else
|
||||
/* Fallthrough case - please add other #elif cases above
|
||||
for different OS's as necessary */
|
||||
#define GET_MAX_FDS() 256
|
||||
#endif
|
||||
|
||||
static void
|
||||
do_output (int s, size_t size, const void *buf)
|
||||
{
|
||||
#ifdef REAL_DEBUG
|
||||
fprintf (stderr, "Writing %d bytes = %d.\n", sizeof (size_t), size);
|
||||
#endif
|
||||
|
||||
if (send (s, &size, sizeof (size_t), 0) < 0)
|
||||
glibtop_warn_io ("send");
|
||||
|
||||
if (!size)
|
||||
return;
|
||||
|
||||
#ifdef REAL_DEBUG
|
||||
fprintf (stderr, "Really writing %d bytes.\n", size);
|
||||
#endif
|
||||
|
||||
if (send (s, buf, size, 0) < 0)
|
||||
glibtop_warn_io ("send");
|
||||
}
|
||||
|
||||
void
|
||||
handle_socket_connection (int s)
|
||||
{
|
||||
pid_t pid;
|
||||
int nread;
|
||||
size_t size, dsize;
|
||||
char parameter [BUFSIZ];
|
||||
struct timeval tv;
|
||||
glibtop_union data;
|
||||
glibtop_command cmnd;
|
||||
glibtop_sysdeps sysdeps;
|
||||
glibtop server;
|
||||
void *ptr;
|
||||
|
||||
tv.tv_sec = 5;
|
||||
tv.tv_usec = 0;
|
||||
|
||||
while(1) {
|
||||
nread = recv (s, &size, sizeof (size_t), 0);
|
||||
|
||||
if (nread < 0) {
|
||||
glibtop_warn_io ("recv");
|
||||
return;
|
||||
}
|
||||
|
||||
if (nread == 0)
|
||||
return;
|
||||
|
||||
if (nread != sizeof (size_t)) {
|
||||
glibtop_warn ("Expected %d bytes but got %d", sizeof (size_t), nread);
|
||||
return;
|
||||
}
|
||||
|
||||
if (size != sizeof (glibtop_command)) {
|
||||
glibtop_warn ("Expected %d bytes but got %d", sizeof (size_t), nread);
|
||||
return;
|
||||
}
|
||||
|
||||
nread = recv (s, &cmnd, size, 0);
|
||||
|
||||
if (nread < 0) {
|
||||
glibtop_warn_io ("recv");
|
||||
return;
|
||||
}
|
||||
|
||||
if (nread == 0)
|
||||
return;
|
||||
|
||||
#ifdef REAL_DEBUG
|
||||
fprintf (stderr, "Received command %d from client.\n", cmnd.command);
|
||||
#endif
|
||||
|
||||
nread = recv (s, &dsize, sizeof (size_t), 0);
|
||||
|
||||
/* will return 0 if parent exits. */
|
||||
|
||||
if (nread < 0) {
|
||||
glibtop_warn_io ("recv");
|
||||
return;
|
||||
}
|
||||
|
||||
if (nread == 0)
|
||||
return;
|
||||
|
||||
if (dsize >= BUFSIZ) {
|
||||
glibtop_warn ("Client sent %d bytes, but buffer is %d", dsize, BUFSIZ);
|
||||
return;
|
||||
}
|
||||
|
||||
memset (parameter, 0, sizeof (parameter));
|
||||
|
||||
if (dsize) {
|
||||
#ifdef REAL_DEBUG
|
||||
fprintf (stderr, "Client has %d bytes of data.\n", dsize);
|
||||
#endif
|
||||
|
||||
nread = recv (s, parameter, dsize, 0);
|
||||
|
||||
/* will return 0 if parent exits. */
|
||||
|
||||
if (nread < 0) {
|
||||
glibtop_warn_io ("recv");
|
||||
return;
|
||||
}
|
||||
|
||||
if (nread == 0)
|
||||
return;
|
||||
|
||||
if (nread != (int) dsize) {
|
||||
glibtop_warn ("Expected %d bytes but got %d", dsize, nread);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (cmnd.command) {
|
||||
case GLIBTOP_CMND_SYSDEPS:
|
||||
sysdeps.features = GLIBTOP_SYSDEPS_ALL;
|
||||
do_output (s, sizeof (glibtop_sysdeps), &sysdeps);
|
||||
do_output (s, 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_CPU:
|
||||
glibtop_get_cpu_l (&server, &data.cpu);
|
||||
do_output (s, sizeof (glibtop_cpu), &data.cpu);
|
||||
do_output (s, 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_MEM:
|
||||
glibtop_get_mem_l (&server, &data.mem);
|
||||
do_output (s, sizeof (glibtop_mem), &data.mem);
|
||||
do_output (s, 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_SWAP:
|
||||
glibtop_get_swap_l (&server, &data.swap);
|
||||
do_output (s, sizeof (glibtop_swap), &data.swap);
|
||||
do_output (s, 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_UPTIME:
|
||||
glibtop_get_uptime_l (&server, &data.uptime);
|
||||
do_output (s, sizeof (glibtop_uptime), &data.uptime);
|
||||
do_output (s, 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_LOADAVG:
|
||||
glibtop_get_loadavg_l (&server, &data.loadavg);
|
||||
do_output (s, sizeof (glibtop_loadavg), &data.loadavg);
|
||||
do_output (s, 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_SHM_LIMITS:
|
||||
glibtop_get_shm_limits_l (&server, &data.shm_limits);
|
||||
do_output (s, sizeof (glibtop_shm_limits), &data.shm_limits);
|
||||
do_output (s, 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_MSG_LIMITS:
|
||||
glibtop_get_msg_limits_l (&server, &data.msg_limits);
|
||||
do_output (s, sizeof (glibtop_msg_limits), &data.msg_limits);
|
||||
do_output (s, 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_SEM_LIMITS:
|
||||
glibtop_get_sem_limits_l (&server, &data.sem_limits);
|
||||
do_output (s, sizeof (glibtop_sem_limits), &data.sem_limits);
|
||||
do_output (s, 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROCLIST:
|
||||
ptr = glibtop_get_proclist_l (&server, &data.proclist);
|
||||
do_output (s, sizeof (glibtop_proclist), &data.proclist);
|
||||
do_output (s, data.proclist.total, ptr);
|
||||
glibtop_free_r (&server, ptr);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_STATE:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_state_l
|
||||
(&server, &data.proc_state, pid);
|
||||
do_output (s, sizeof (glibtop_proc_state), &data.proc_state);
|
||||
do_output (s, 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_UID:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_uid_l
|
||||
(&server, &data.proc_uid, pid);
|
||||
do_output (s, sizeof (glibtop_proc_uid), &data.proc_uid);
|
||||
do_output (s, 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_MEM:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_mem_l
|
||||
(&server, &data.proc_mem, pid);
|
||||
do_output (s, sizeof (glibtop_proc_mem), &data.proc_mem);
|
||||
do_output (s, 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_TIME:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_time_l
|
||||
(&server, &data.proc_time, pid);
|
||||
do_output (s, sizeof (glibtop_proc_time), &data.proc_time);
|
||||
do_output (s, 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_SIGNAL:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_signal_l
|
||||
(&server, &data.proc_signal, pid);
|
||||
do_output (s, sizeof (glibtop_proc_signal), &data.proc_signal);
|
||||
do_output (s, 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_KERNEL:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_kernel_l
|
||||
(&server, &data.proc_kernel, pid);
|
||||
do_output (s, sizeof (glibtop_proc_kernel), &data.proc_kernel);
|
||||
do_output (s, 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_SEGMENT:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_segment_l
|
||||
(&server, &data.proc_segment, pid);
|
||||
do_output (s, sizeof (glibtop_proc_segment), &data.proc_segment);
|
||||
do_output (s, 0, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -12,5 +12,5 @@ gtop_proxy_SOURCES = main.c output.c version.c
|
||||
gtop_proxy_LDADD = $(top_builddir)/lib/libgtop.la \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@
|
||||
@INTLLIBS@ @LIBSUPPORT@ @libs_xauth@
|
||||
gtop_proxy_LDFLAGS = -static
|
||||
|
Reference in New Issue
Block a user