Compare commits
18 Commits
LIBGTOP_2_
...
wip/libgto
Author | SHA1 | Date | |
---|---|---|---|
|
1ed2177a36 | ||
|
6b264b847b | ||
|
009949a773 | ||
|
2ab7ad075c | ||
|
e4b740fb90 | ||
|
b6eb0873e7 | ||
|
2c08229f04 | ||
|
753d9abb13 | ||
|
af7e9cd1b6 | ||
|
552ea7ec3a | ||
|
43f19912e3 | ||
|
16bb5c8075 | ||
|
bebcb377af | ||
|
4cffb2f094 | ||
|
5adaa90de3 | ||
|
f9e8ae8dfc | ||
|
efeb24a96c | ||
|
3c4ddb5572 |
103
.gitignore
vendored
Normal file
103
.gitignore
vendored
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
service/*.o
|
||||||
|
service/.deps
|
||||||
|
service/gtop-dbus-service
|
||||||
|
sysdeps/Makefile
|
||||||
|
sysdeps/Makefile.in
|
||||||
|
sysdeps/*/Makefile
|
||||||
|
sysdeps/*/Makefile.in
|
||||||
|
sysdeps/*/.deps
|
||||||
|
sysdeps/*/.libs
|
||||||
|
sysdeps/*/*.o
|
||||||
|
sysdeps/*/*.lo
|
||||||
|
sysdeps/*/*.la
|
||||||
|
src/*/Makefile
|
||||||
|
src/*/Makefile.in
|
||||||
|
src/*/.deps
|
||||||
|
src/Makefile
|
||||||
|
src/Makefile.in
|
||||||
|
stamp-h1
|
||||||
|
po/*.gmo
|
||||||
|
po/stamp-it
|
||||||
|
po/POTFILES
|
||||||
|
po/Makefile.in.in
|
||||||
|
po/Makefile.in
|
||||||
|
po/Makefile
|
||||||
|
missing
|
||||||
|
misc/Makefile
|
||||||
|
misc/Makefile.in
|
||||||
|
m4/
|
||||||
|
ltmain.sh
|
||||||
|
libtool
|
||||||
|
libgtopconfig.h
|
||||||
|
libgtop.spec
|
||||||
|
libgtop-2.0.pc
|
||||||
|
lib/Makefile
|
||||||
|
lib/Makefile.in
|
||||||
|
lib/.deps
|
||||||
|
lib/.libs
|
||||||
|
lib/*.o
|
||||||
|
lib/*.lo
|
||||||
|
lib/*.la
|
||||||
|
lib/lib.c
|
||||||
|
lib/GTop-2.0.gir
|
||||||
|
lib/GTop-2.0.typelib
|
||||||
|
INSTALL
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
aclocal.m4
|
||||||
|
autom4te.cache/
|
||||||
|
config.guess
|
||||||
|
config.h
|
||||||
|
config.h.in
|
||||||
|
config.log
|
||||||
|
config.status
|
||||||
|
config.sub
|
||||||
|
configure
|
||||||
|
depcomp
|
||||||
|
doc/Makefile
|
||||||
|
doc/Makefile.in
|
||||||
|
doc/libgtop2.info
|
||||||
|
doc/mdate-sh
|
||||||
|
doc/reference/Makefile
|
||||||
|
doc/reference/Makefile.in
|
||||||
|
doc/reference/html/
|
||||||
|
doc/reference/libgtop-decl-list.txt
|
||||||
|
doc/reference/libgtop-decl.txt
|
||||||
|
doc/reference/tmpl/
|
||||||
|
doc/reference/version.xml
|
||||||
|
doc/reference/xml/
|
||||||
|
doc/stamp-vti
|
||||||
|
doc/texinfo.tex
|
||||||
|
doc/version.texi
|
||||||
|
examples/.deps/
|
||||||
|
examples/.libs/
|
||||||
|
examples/*.o
|
||||||
|
examples/Makefile
|
||||||
|
examples/Makefile.in
|
||||||
|
examples/affinity
|
||||||
|
examples/df
|
||||||
|
examples/first
|
||||||
|
examples/mem
|
||||||
|
examples/mountlist
|
||||||
|
examples/netlist
|
||||||
|
examples/netload
|
||||||
|
examples/openfiles
|
||||||
|
examples/pprint
|
||||||
|
examples/procargs
|
||||||
|
examples/proclist
|
||||||
|
examples/procmap
|
||||||
|
examples/second
|
||||||
|
examples/smp
|
||||||
|
examples/sysdeps
|
||||||
|
examples/timings
|
||||||
|
examples/wd
|
||||||
|
gtk-doc.make
|
||||||
|
include/Makefile
|
||||||
|
include/Makefile.in
|
||||||
|
include/glibtop/Makefile
|
||||||
|
include/glibtop/Makefile.in
|
||||||
|
install-sh
|
||||||
|
intltool-extract.in
|
||||||
|
intltool-merge.in
|
||||||
|
intltool-update.in
|
||||||
|
|
@@ -6,7 +6,7 @@ else
|
|||||||
EXAMPLES_DIR =
|
EXAMPLES_DIR =
|
||||||
endif
|
endif
|
||||||
|
|
||||||
SUBDIRS = po misc include sysdeps lib src $(EXAMPLES_DIR) doc
|
SUBDIRS = po misc include sysdeps lib src $(EXAMPLES_DIR) doc service
|
||||||
|
|
||||||
libgtopinclude_HEADERS = glibtop.h libgtopconfig.h
|
libgtopinclude_HEADERS = glibtop.h libgtopconfig.h
|
||||||
libgtopincludedir = $(includedir)/libgtop-2.0
|
libgtopincludedir = $(includedir)/libgtop-2.0
|
||||||
|
@@ -6,7 +6,7 @@ test -z "$srcdir" && srcdir=.
|
|||||||
|
|
||||||
PKG_NAME="Gnome Top Library"
|
PKG_NAME="Gnome Top Library"
|
||||||
|
|
||||||
(test -f $srcdir/configure.in \
|
(test -f $srcdir/configure.ac \
|
||||||
&& test -f $srcdir/copyright.txt \
|
&& test -f $srcdir/copyright.txt \
|
||||||
&& test -d $srcdir/sysdeps) || {
|
&& test -d $srcdir/sysdeps) || {
|
||||||
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
|
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
|
||||||
|
@@ -4,7 +4,7 @@ dnl
|
|||||||
|
|
||||||
m4_define([libgtop_major_version], [2])
|
m4_define([libgtop_major_version], [2])
|
||||||
m4_define([libgtop_minor_version], [28])
|
m4_define([libgtop_minor_version], [28])
|
||||||
m4_define([libgtop_micro_version], [5])
|
m4_define([libgtop_micro_version], [6])
|
||||||
m4_define([libgtop_version], [libgtop_major_version.libgtop_minor_version.libgtop_micro_version])
|
m4_define([libgtop_version], [libgtop_major_version.libgtop_minor_version.libgtop_micro_version])
|
||||||
|
|
||||||
dnl increment if the interface has additions, changes, removals.
|
dnl increment if the interface has additions, changes, removals.
|
||||||
@@ -226,7 +226,7 @@ GLIB_DEFINE_LOCALEDIR([GTOPLOCALEDIR])
|
|||||||
AC_PATH_XTRA
|
AC_PATH_XTRA
|
||||||
|
|
||||||
dnl For Solaris
|
dnl For Solaris
|
||||||
dnl Please don't move this before AC_PATH_XTRA
|
dnl Please don\'t move this before AC_PATH_XTRA
|
||||||
AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)])
|
AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)])
|
||||||
AC_CHECK_FUNC(connect,,[AC_CHECK_LIB(socket,connect)])
|
AC_CHECK_FUNC(connect,,[AC_CHECK_LIB(socket,connect)])
|
||||||
AC_CHECK_FUNC(inet_aton,,[AC_CHECK_LIB(resolv,inet_aton)])
|
AC_CHECK_FUNC(inet_aton,,[AC_CHECK_LIB(resolv,inet_aton)])
|
||||||
@@ -364,12 +364,20 @@ AC_SUBST(sysdeps_suid_lib)
|
|||||||
AC_SUBST(server_programs)
|
AC_SUBST(server_programs)
|
||||||
|
|
||||||
GTK_DOC_CHECK(1.4)
|
GTK_DOC_CHECK(1.4)
|
||||||
|
GLIB_REQUIRED=2.37.3
|
||||||
|
|
||||||
|
PKG_CHECK_MODULES(GTOP_DBUS,
|
||||||
|
glib-2.0 >= $GLIB_REQUIRED
|
||||||
|
gio-2.0 >= $GLIB_REQUIRED
|
||||||
|
gio-unix-2.0 >= $GLIB_REQUIRED
|
||||||
|
)
|
||||||
|
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
Makefile
|
Makefile
|
||||||
libgtop.spec
|
libgtop.spec
|
||||||
po/Makefile.in
|
po/Makefile.in
|
||||||
misc/Makefile
|
misc/Makefile
|
||||||
|
service/Makefile
|
||||||
include/Makefile
|
include/Makefile
|
||||||
include/glibtop/Makefile
|
include/glibtop/Makefile
|
||||||
sysdeps/Makefile
|
sysdeps/Makefile
|
@@ -219,17 +219,8 @@ glibtop_set_parameter_l
|
|||||||
<INCLUDE>glibtop/procargs.h</INCLUDE>
|
<INCLUDE>glibtop/procargs.h</INCLUDE>
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>procargs</FILE>
|
<FILE>procargs</FILE>
|
||||||
GLIBTOP_PROC_ARGS_SIZE
|
|
||||||
GLIBTOP_MAX_PROC_ARGS
|
|
||||||
glibtop_proc_args
|
glibtop_proc_args
|
||||||
glibtop_get_proc_args_l
|
|
||||||
glibtop_get_proc_args
|
glibtop_get_proc_args
|
||||||
glibtop_get_proc_args_r
|
|
||||||
glibtop_init_proc_args_p
|
|
||||||
glibtop_get_proc_args_p
|
|
||||||
glibtop_init_proc_args_s
|
|
||||||
glibtop_get_proc_args_s
|
|
||||||
glibtop_get_proc_argv_l
|
|
||||||
glibtop_get_proc_argv
|
glibtop_get_proc_argv
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
@@ -420,26 +411,8 @@ glibtop_get_proc_uid_s
|
|||||||
<INCLUDE>glibtop/proctime.h</INCLUDE>
|
<INCLUDE>glibtop/proctime.h</INCLUDE>
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>proctime</FILE>
|
<FILE>proctime</FILE>
|
||||||
GLIBTOP_PROC_TIME_START_TIME
|
|
||||||
GLIBTOP_PROC_TIME_RTIME
|
|
||||||
GLIBTOP_PROC_TIME_UTIME
|
|
||||||
GLIBTOP_PROC_TIME_STIME
|
|
||||||
GLIBTOP_PROC_TIME_CUTIME
|
|
||||||
GLIBTOP_PROC_TIME_CSTIME
|
|
||||||
GLIBTOP_PROC_TIME_TIMEOUT
|
|
||||||
GLIBTOP_PROC_TIME_IT_REAL_VALUE
|
|
||||||
GLIBTOP_PROC_TIME_FREQUENCY
|
|
||||||
GLIBTOP_PROC_TIME_XCPU_UTIME
|
|
||||||
GLIBTOP_PROC_TIME_XCPU_STIME
|
|
||||||
GLIBTOP_MAX_PROC_TIME
|
|
||||||
glibtop_proc_time
|
glibtop_proc_time
|
||||||
glibtop_get_proc_time
|
glibtop_get_proc_time
|
||||||
glibtop_get_proc_time_r
|
|
||||||
glibtop_get_proc_time_l
|
|
||||||
glibtop_init_proc_time_p
|
|
||||||
glibtop_get_proc_time_p
|
|
||||||
glibtop_init_proc_time_s
|
|
||||||
glibtop_get_proc_time_s
|
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
<INCLUDE>glibtop/signal.h</INCLUDE>
|
<INCLUDE>glibtop/signal.h</INCLUDE>
|
||||||
@@ -515,10 +488,6 @@ glibtop_send_version
|
|||||||
<INCLUDE>glibtop/proclist.h</INCLUDE>
|
<INCLUDE>glibtop/proclist.h</INCLUDE>
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>proclist</FILE>
|
<FILE>proclist</FILE>
|
||||||
GLIBTOP_PROCLIST_NUMBER
|
|
||||||
GLIBTOP_PROCLIST_TOTAL
|
|
||||||
GLIBTOP_PROCLIST_SIZE
|
|
||||||
GLIBTOP_MAX_PROCLIST
|
|
||||||
GLIBTOP_KERN_PROC_ALL
|
GLIBTOP_KERN_PROC_ALL
|
||||||
GLIBTOP_KERN_PROC_PID
|
GLIBTOP_KERN_PROC_PID
|
||||||
GLIBTOP_KERN_PROC_PGRP
|
GLIBTOP_KERN_PROC_PGRP
|
||||||
@@ -532,12 +501,6 @@ GLIBTOP_EXCLUDE_SYSTEM
|
|||||||
GLIBTOP_EXCLUDE_NOTTY
|
GLIBTOP_EXCLUDE_NOTTY
|
||||||
glibtop_proclist
|
glibtop_proclist
|
||||||
glibtop_get_proclist
|
glibtop_get_proclist
|
||||||
glibtop_get_proclist_r
|
|
||||||
glibtop_get_proclist_l
|
|
||||||
glibtop_init_proclist_p
|
|
||||||
glibtop_get_proclist_p
|
|
||||||
glibtop_init_proclist_s
|
|
||||||
glibtop_get_proclist_s
|
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
<INCLUDE>glibtop/sem_limits.h</INCLUDE>
|
<INCLUDE>glibtop/sem_limits.h</INCLUDE>
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
## Process this file with automake to produce Makefile.in
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
|
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(AM_LDFLAGS) -o $@
|
||||||
|
|
||||||
INCLUDES = @INCLUDES@
|
INCLUDES = @INCLUDES@
|
||||||
|
|
||||||
DEFS = @DEFS@
|
DEFS = @DEFS@
|
||||||
|
|
||||||
LDFLAGS = $(LIBGTOP_EXTRA_LIBS)
|
AM_LDFLAGS = $(LIBGTOP_EXTRA_LIBS)
|
||||||
|
|
||||||
noinst_PROGRAMS = first second pprint procargs df netlist \
|
noinst_PROGRAMS = first second pprint procargs df netlist \
|
||||||
mountlist procmap netload sysdeps timings \
|
mountlist procmap netload sysdeps timings \
|
||||||
|
@@ -36,22 +36,89 @@ G_BEGIN_DECLS
|
|||||||
/* You can use the folowing constants as the `which' member of
|
/* You can use the folowing constants as the `which' member of
|
||||||
* glibtop_get_proclist () to specify which processes to fetch. */
|
* glibtop_get_proclist () to specify which processes to fetch. */
|
||||||
|
|
||||||
#define GLIBTOP_KERN_PROC_ALL 0 /* all processes */
|
/**
|
||||||
|
* GLIBTOP_KERN_PROC_ALL:
|
||||||
|
*
|
||||||
|
* Return information about all processes
|
||||||
|
**/
|
||||||
|
#define GLIBTOP_KERN_PROC_ALL 0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GLIBTOP_KERN_PROC_PID:
|
||||||
|
*
|
||||||
|
* Return all processes with the pid which is passed in @arg. You can use this to find out whether some process still exists.
|
||||||
|
**/
|
||||||
#define GLIBTOP_KERN_PROC_PID 1
|
#define GLIBTOP_KERN_PROC_PID 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GLIBTOP_KERN_PROC_PGRP:
|
||||||
|
*
|
||||||
|
* Return all processes in the process group passed in @arg.
|
||||||
|
**/
|
||||||
#define GLIBTOP_KERN_PROC_PGRP 2
|
#define GLIBTOP_KERN_PROC_PGRP 2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GLIBTOP_KERN_PROC_SESSION:
|
||||||
|
*
|
||||||
|
* Return all processes in the session passed in @arg.
|
||||||
|
**/
|
||||||
#define GLIBTOP_KERN_PROC_SESSION 3
|
#define GLIBTOP_KERN_PROC_SESSION 3
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GLIBTOP_KERN_PROC_TTY:
|
||||||
|
*
|
||||||
|
* Return all processes which have the controlling tty passed in @arg
|
||||||
|
* (which is interpreted as the device number).
|
||||||
|
**/
|
||||||
#define GLIBTOP_KERN_PROC_TTY 4
|
#define GLIBTOP_KERN_PROC_TTY 4
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GLIBTOP_KERN_PROC_UID:
|
||||||
|
*
|
||||||
|
* Return all processes with the effective uid passed in @arg.
|
||||||
|
**/
|
||||||
#define GLIBTOP_KERN_PROC_UID 5
|
#define GLIBTOP_KERN_PROC_UID 5
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GLIBTOP_KERN_PROC_RUID:
|
||||||
|
*
|
||||||
|
* Return all processes with the real uid passed in @arg.
|
||||||
|
**/
|
||||||
#define GLIBTOP_KERN_PROC_RUID 6
|
#define GLIBTOP_KERN_PROC_RUID 6
|
||||||
|
|
||||||
#define GLIBTOP_KERN_PROC_MASK 15
|
#define GLIBTOP_KERN_PROC_MASK 15
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GLIBTOP_EXCLUDE_IDLE:
|
||||||
|
*
|
||||||
|
* Exclude idle processes.
|
||||||
|
**/
|
||||||
#define GLIBTOP_EXCLUDE_IDLE 0x1000
|
#define GLIBTOP_EXCLUDE_IDLE 0x1000
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GLIBTOP_EXCLUDE_SYSTEM:
|
||||||
|
*
|
||||||
|
* Exclude system (on most UNIXes root's) processes.
|
||||||
|
**/
|
||||||
#define GLIBTOP_EXCLUDE_SYSTEM 0x2000
|
#define GLIBTOP_EXCLUDE_SYSTEM 0x2000
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GLIBTOP_EXCLUDE_NOTTY:
|
||||||
|
*
|
||||||
|
* Exclude processes without a controlling terminal.
|
||||||
|
**/
|
||||||
#define GLIBTOP_EXCLUDE_NOTTY 0x4000
|
#define GLIBTOP_EXCLUDE_NOTTY 0x4000
|
||||||
|
|
||||||
typedef struct _glibtop_proclist glibtop_proclist;
|
typedef struct _glibtop_proclist glibtop_proclist;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* glibtop_proclist:
|
||||||
|
* @number: Number of entries in the returned list.
|
||||||
|
* @total: Total size of the returned list (this equals @number * @size).
|
||||||
|
* @size: Size of a single entry in the returned list
|
||||||
|
* (this equals <type>sizeof(unsigned)</type>).
|
||||||
|
*/
|
||||||
struct _glibtop_proclist
|
struct _glibtop_proclist
|
||||||
{
|
{
|
||||||
guint64 flags;
|
guint64 flags;
|
||||||
|
@@ -46,26 +46,50 @@ typedef struct _glibtop_proc_time glibtop_proc_time;
|
|||||||
|
|
||||||
/* Time section */
|
/* Time section */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* glibtop_proc_time:
|
||||||
|
* @start_time: Start time of process in seconds since the epoch.
|
||||||
|
* @rtime: Real time accumulated by process (should be @utime + @stime).
|
||||||
|
* @utime: User-mode CPU time accumulated by process.
|
||||||
|
* @stime: Kernel-mode CPU time accumulated by process.
|
||||||
|
* @cutime: Cumulative utime of process and reaped children.
|
||||||
|
* @cstime: Cumulative stime of process and reaped children.
|
||||||
|
* @timeout: The time (in jiffies) of the process’s next timeout.
|
||||||
|
* @it_real_value: The time (in jiffies) before the next <type>SIGALRM</type>
|
||||||
|
* is sent to the process due to an interval timer.
|
||||||
|
* @frequency: Tick frequency.
|
||||||
|
* @xcpu_utime: SMP user-mode CPU time accumulated by process.
|
||||||
|
* @xcpu_stime: SMP kernel-mode CPU time accumulated by process
|
||||||
|
*
|
||||||
|
* Process time data filled by glibtop_get_proc_time().
|
||||||
|
*
|
||||||
|
* Under Linux the @start_time value may be wrong due to the information
|
||||||
|
* available from the kernel.
|
||||||
|
*
|
||||||
|
* The Linux kernel defines <type>INITIAL_JIFFIES</type> which implies a time
|
||||||
|
* shift. Because <type>INITIAL_JIFFIES</type> is not user-space defined,
|
||||||
|
* we cannot use it to compute an accurate @start_time. On Linux 2.6,
|
||||||
|
* <type>INITIAL_JIFFIES</type> is 300 so @start_time is
|
||||||
|
* always 3s different from the real start time of the given process. You
|
||||||
|
* may also get shift results if your system clock is not synchronised
|
||||||
|
* with your hardware clock. See <command>man hwclock</command>.
|
||||||
|
*/
|
||||||
struct _glibtop_proc_time
|
struct _glibtop_proc_time
|
||||||
{
|
{
|
||||||
|
/*< private >*/
|
||||||
guint64 flags;
|
guint64 flags;
|
||||||
guint64 start_time; /* start time of process --
|
/*< public >*/
|
||||||
* seconds since 1-1-70 */
|
guint64 start_time;
|
||||||
guint64 rtime; /* real time accumulated by process */
|
guint64 rtime;
|
||||||
guint64 utime; /* user-mode CPU time accumulated by process */
|
guint64 utime;
|
||||||
guint64 stime; /* kernel-mode CPU time accumulated by process */
|
guint64 stime;
|
||||||
guint64 cutime; /* cumulative utime of process and
|
guint64 cutime;
|
||||||
* reaped children */
|
guint64 cstime;
|
||||||
guint64 cstime; /* cumulative stime of process and
|
guint64 timeout;
|
||||||
* reaped children */
|
guint64 it_real_value;
|
||||||
guint64 timeout; /* The time (in jiffies) of the process's
|
guint64 frequency;
|
||||||
* next timeout */
|
guint64 xcpu_utime [GLIBTOP_NCPU];
|
||||||
guint64 it_real_value; /* The time (in jiffies) before the
|
guint64 xcpu_stime [GLIBTOP_NCPU];
|
||||||
* next SIGALRM is sent to the process
|
|
||||||
* due to an interval timer. */
|
|
||||||
guint64 frequency; /* Tick frequency. */
|
|
||||||
guint64 xcpu_utime [GLIBTOP_NCPU]; /* utime and stime for all CPUs on */
|
|
||||||
guint64 xcpu_stime [GLIBTOP_NCPU]; /* SMP machines. */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -237,10 +237,10 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
AC_MSG_CHECKING(what we need to define to get struct msginfo)
|
AC_MSG_CHECKING(what we need to define to get struct msginfo)
|
||||||
AC_CACHE_VAL(msginfo_needs,
|
AC_CACHE_VAL(msginfo_cv_needs,
|
||||||
msginfo_needs=
|
msginfo_cv_needs=
|
||||||
for def in nothing KERNEL _KERNEL; do
|
for def in nothing KERNEL _KERNEL; do
|
||||||
AC_COMPILE_IFELSE([#define $def
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([#define $def
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/msg.h>
|
#include <sys/msg.h>
|
||||||
@@ -252,23 +252,23 @@ main (void)
|
|||||||
struct msginfo mi;
|
struct msginfo mi;
|
||||||
mi.msgmax = 0;
|
mi.msgmax = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}],
|
}])],
|
||||||
[
|
[
|
||||||
msginfo_needs=$def
|
msginfo_cv_needs=$def
|
||||||
if test ${msginfo_needs} = KERNEL; then
|
if test ${msginfo_cv_needs} = KERNEL; then
|
||||||
AC_DEFINE(STRUCT_MSGINFO_NEEDS_KERNEL, 1,
|
AC_DEFINE(STRUCT_MSGINFO_NEEDS_KERNEL, 1,
|
||||||
[Define to 1 if we need to define KERNEL to get 'struct msginfo'])
|
[Define to 1 if we need to define KERNEL to get 'struct msginfo'])
|
||||||
elif test ${msginfo_needs} = _KERNEL; then
|
elif test ${msginfo_cv_needs} = _KERNEL; then
|
||||||
AC_DEFINE(STRUCT_MSGINFO_NEEDS__KERNEL, 1,
|
AC_DEFINE(STRUCT_MSGINFO_NEEDS__KERNEL, 1,
|
||||||
[Define to 1 if we need to define _KERNEL to get 'struct msginfo'])
|
[Define to 1 if we need to define _KERNEL to get 'struct msginfo'])
|
||||||
fi
|
fi
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
test -n "${msginfo_needs}" && break
|
test -n "${msginfo_cv_needs}" && break
|
||||||
done
|
done
|
||||||
)
|
)
|
||||||
AC_MSG_RESULT($msginfo_needs)
|
AC_MSG_RESULT($msginfo_cv_needs)
|
||||||
if test -z "${msginfo_needs}"; then
|
if test -z "${msginfo_cv_needs}"; then
|
||||||
AC_MSG_ERROR([Could not find the definition of 'struct msginfo'])
|
AC_MSG_ERROR([Could not find the definition of 'struct msginfo'])
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
8
service/Makefile.am
Normal file
8
service/Makefile.am
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(AM_LDFLAGS) -o $@
|
||||||
|
|
||||||
|
noinst_PROGRAMS = gtop-dbus-service
|
||||||
|
|
||||||
|
AM_CPPFLAGS= ${GTOP_DBUS_CFLAGS}
|
||||||
|
|
||||||
|
gtop_dbus_service_SOURCES = gtop-dbus-service.h gtop-dbus-service.c
|
||||||
|
gtop_dbus_service_LDADD = $(GTOP_DBUS_LIBS)
|
273
service/gtop-dbus-service.c
Normal file
273
service/gtop-dbus-service.c
Normal file
@@ -0,0 +1,273 @@
|
|||||||
|
#include <gio/gio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <config.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include "gtop-dbus-service.h"
|
||||||
|
|
||||||
|
// required for renice
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
static const gchar object_name[] = "/org/gnome/gtopServer";
|
||||||
|
static const gchar processes_object_name[] = "/org/gnome/gtopServer/Processes";
|
||||||
|
|
||||||
|
#define VERBOSE 1
|
||||||
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static GDBusNodeInfo *introspection_data = NULL;
|
||||||
|
|
||||||
|
/* Introspection data for the service we are exporting */
|
||||||
|
static const gchar introspection_xml[] =
|
||||||
|
"<node name='/org/gnome/gtopServer'>"
|
||||||
|
" <interface name='org.gnome.gtop'>"
|
||||||
|
" <property type='s' name='Version' access='read'/>"
|
||||||
|
" </interface>"
|
||||||
|
" <interface name='org.gnome.gtop.Processes'>"
|
||||||
|
" <method name='SendSignal'>"
|
||||||
|
" <arg name='pid' type='i' direction='in' />"
|
||||||
|
" <arg name='signal' type='i' direction='in' />"
|
||||||
|
" </method>"
|
||||||
|
" <method name='Renice'>"
|
||||||
|
" <arg name='pid' type='i' direction='in' />"
|
||||||
|
" <arg name='nice' type='i' direction='in' />"
|
||||||
|
" </method>"
|
||||||
|
" <method name='GetProperties'>"
|
||||||
|
" <arg name='pid' type='i' direction='in' />"
|
||||||
|
" <arg name='propertyList' type='as' direction='in' />"
|
||||||
|
" <arg name='properties' type='a{sv}' direction='out' />"
|
||||||
|
" </method>"
|
||||||
|
" </interface>"
|
||||||
|
"</node>";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a call to a method. (Parameters should be obvious.)
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
handle_method_call (GDBusConnection *connection,
|
||||||
|
const gchar *sender,
|
||||||
|
const gchar *object_path,
|
||||||
|
const gchar *interface_name,
|
||||||
|
const gchar *method_name,
|
||||||
|
GVariant *parameters,
|
||||||
|
GDBusMethodInvocation *invocation,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
#ifdef VERBOSE
|
||||||
|
gchar *paramstr = g_variant_print (parameters, TRUE);
|
||||||
|
fprintf (stderr, MSG_PREFIX
|
||||||
|
"handle_method_call (%p,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",(invocation),%p)\n",
|
||||||
|
connection, sender, object_path, interface_name, method_name,
|
||||||
|
paramstr, user_data);
|
||||||
|
g_free (paramstr);
|
||||||
|
#endif
|
||||||
|
if (g_strcmp0 (method_name, "Renice") == 0)
|
||||||
|
{
|
||||||
|
int pid, prio;
|
||||||
|
g_variant_get (parameters, "(ii)", &pid, &prio);
|
||||||
|
gint renice_result = setpriority (PRIO_PROCESS, pid, CLAMP(prio, PRIO_MIN, PRIO_MAX));
|
||||||
|
#ifdef VERBOSE
|
||||||
|
fprintf (stderr, MSG_PREFIX"renicing '%d' to '%d' priority returned %d", pid, prio, renice_result);
|
||||||
|
#endif
|
||||||
|
if (renice_result == 0)
|
||||||
|
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||||
|
else {
|
||||||
|
switch (errno) {
|
||||||
|
case ESRCH: g_dbus_method_invocation_return_error (invocation,
|
||||||
|
G_IO_ERROR,
|
||||||
|
G_IO_ERROR_NOT_FOUND,
|
||||||
|
MSG_PREFIX "Process '%d' not found",
|
||||||
|
pid);
|
||||||
|
break;
|
||||||
|
case EACCES:
|
||||||
|
case EPERM: g_dbus_method_invocation_return_error (invocation,
|
||||||
|
G_IO_ERROR,
|
||||||
|
G_IO_ERROR_PERMISSION_DENIED,
|
||||||
|
MSG_PREFIX "Permission denied to change priority of process '%d' to '%d'",
|
||||||
|
pid, prio);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Anything else is an error.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Default: No such method
|
||||||
|
g_dbus_method_invocation_return_error (invocation,
|
||||||
|
G_IO_ERROR,
|
||||||
|
G_IO_ERROR_INVALID_ARGUMENT,
|
||||||
|
MSG_PREFIX "Invalid method: '%s' on '%s'",
|
||||||
|
method_name, interface_name);
|
||||||
|
}
|
||||||
|
} // handle_method_call
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a request to set a property.
|
||||||
|
*/
|
||||||
|
static gboolean
|
||||||
|
handle_set_property (GDBusConnection *connection,
|
||||||
|
const gchar *sender,
|
||||||
|
const gchar *object_path,
|
||||||
|
const gchar *interface_name,
|
||||||
|
const gchar *property_name,
|
||||||
|
GVariant *value,
|
||||||
|
GError **error,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
// Print an optional log message
|
||||||
|
#ifdef VERBOSE
|
||||||
|
gchar *valstr = g_variant_print (value, TRUE);
|
||||||
|
fprintf (stderr, MSG_PREFIX
|
||||||
|
"handle_set_property (%p,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",(error),%p)\n",
|
||||||
|
connection, sender, object_path, interface_name, property_name,
|
||||||
|
valstr, user_data);
|
||||||
|
g_free (valstr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
g_set_error (error,
|
||||||
|
G_IO_ERROR,
|
||||||
|
G_IO_ERROR_FAILED,
|
||||||
|
MSG_PREFIX "No such property: '%s'",
|
||||||
|
property_name);
|
||||||
|
return 0;
|
||||||
|
} // handle_set_property
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a request for a property. (Parameters should be obvious.)
|
||||||
|
*/
|
||||||
|
static GVariant *
|
||||||
|
handle_get_property (GDBusConnection *connection,
|
||||||
|
const gchar *sender,
|
||||||
|
const gchar *object_path,
|
||||||
|
const gchar *interface_name,
|
||||||
|
const gchar *property_name,
|
||||||
|
GError **error,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
// Print an optional log message
|
||||||
|
#ifdef VERBOSE
|
||||||
|
fprintf (stderr, MSG_PREFIX
|
||||||
|
"handle_get_property (%p,\"%s\",\"%s\",\"%s\",\"%s\",(error),%p)\n",
|
||||||
|
connection, sender, object_path, interface_name, property_name,
|
||||||
|
user_data);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (g_strcmp0 (property_name, "Version") == 0)
|
||||||
|
{
|
||||||
|
return g_variant_new_string (LIBGTOP_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Anything else is an error.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_set_error (error,
|
||||||
|
G_IO_ERROR,
|
||||||
|
G_IO_ERROR_FAILED,
|
||||||
|
MSG_PREFIX "Invalid property '%s'",
|
||||||
|
property_name);
|
||||||
|
return NULL;
|
||||||
|
} // unknown property
|
||||||
|
} // handle_get_property
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What to do when the bus gets acquired.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
on_bus_acquired (GDBusConnection *connection,
|
||||||
|
const gchar *name,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
static GDBusInterfaceVTable interface_vtable =
|
||||||
|
{
|
||||||
|
handle_method_call,
|
||||||
|
handle_get_property,
|
||||||
|
handle_set_property
|
||||||
|
};
|
||||||
|
|
||||||
|
guint registration_id;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
// A bit of (optional) notification
|
||||||
|
#ifdef VERBOSE
|
||||||
|
fprintf (stderr, MSG_PREFIX "on_bus_acquired (%p, \"%s\", %p)\n",
|
||||||
|
connection, name, user_data);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
registration_id =
|
||||||
|
g_dbus_connection_register_object (connection,
|
||||||
|
object_name,
|
||||||
|
introspection_data->interfaces[0],
|
||||||
|
&interface_vtable,
|
||||||
|
NULL, // Optional user data
|
||||||
|
NULL, // Func. for freeing user data
|
||||||
|
&error);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
registration_id =
|
||||||
|
g_dbus_connection_register_object (connection,
|
||||||
|
processes_object_name,
|
||||||
|
introspection_data->interfaces[1],
|
||||||
|
&interface_vtable,
|
||||||
|
NULL, // Optional user data
|
||||||
|
NULL, // Func. for freeing user data
|
||||||
|
&error);
|
||||||
|
|
||||||
|
} // on_bus_acquired
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_name_acquired (GDBusConnection *connection,
|
||||||
|
const gchar *name,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
// A bit of (optional) notification
|
||||||
|
#ifdef VERBOSE
|
||||||
|
fprintf (stderr, MSG_PREFIX "on_name_acquired (%p, \"%s\", %p)\n",
|
||||||
|
connection, name, user_data);
|
||||||
|
#endif
|
||||||
|
} // on_name_acquired
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_name_lost (GDBusConnection *connection,
|
||||||
|
const gchar *name,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
// A bit of (optional) notification
|
||||||
|
#ifdef VERBOSE
|
||||||
|
fprintf (stderr, MSG_PREFIX "on_name_lost (%p, \"%s\", %p)\n",
|
||||||
|
connection, name, user_data);
|
||||||
|
#endif
|
||||||
|
// Things seem to have gone badly wrong, so give up
|
||||||
|
exit (1);
|
||||||
|
} // on_name_lost
|
||||||
|
|
||||||
|
int main ( int argc, char ** argv ) {
|
||||||
|
guint owner_id;
|
||||||
|
GMainLoop *loop;
|
||||||
|
|
||||||
|
introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
|
||||||
|
|
||||||
|
owner_id = g_bus_own_name (G_BUS_TYPE_SYSTEM,
|
||||||
|
GTOP_SERVER,
|
||||||
|
G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||||
|
on_bus_acquired,
|
||||||
|
on_name_acquired,
|
||||||
|
on_name_lost,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
g_main_loop_run (loop);
|
||||||
|
|
||||||
|
// Tell the bus that we're done with the name
|
||||||
|
g_bus_unown_name (owner_id);
|
||||||
|
|
||||||
|
// Clean up after ourselves
|
||||||
|
g_dbus_node_info_unref (introspection_data);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
5
service/gtop-dbus-service.h
Normal file
5
service/gtop-dbus-service.h
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#define MSG_PREFIX "[libgtop dbus server] "
|
||||||
|
|
||||||
|
static const gchar GTOP_SERVER[] = "org.gnome.gtopServer";
|
@@ -134,19 +134,19 @@ glibtop_get_proc_uid(glibtop_proc_uid *buf, pid_t pid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:proctime
|
||||||
|
* @title: Process Time
|
||||||
|
* @short_description: Get process time information
|
||||||
|
* @stability: Stable
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* glibtop_get_proc_time:
|
* glibtop_get_proc_time:
|
||||||
* @buf:
|
* @buf: Returned process time information - see #glibtop_proc_time.
|
||||||
* @pid: Process id to get the user and tty information
|
* @pid: Process id
|
||||||
*
|
*
|
||||||
* Please note that under Linux, #start_time value may be strange.
|
* Get process time information.
|
||||||
* Linux kernel defines <type>INITIAL_JIFFIES</type> which implies a time
|
|
||||||
* shift. Because <type>INITIAL_JIFFIES</type> is not user-space defined,
|
|
||||||
* we cannot use it to compute accurate @code{start_time}. On Linux2.6,
|
|
||||||
* <type>INITIAL_JIFFIES</type> is 300 so <type>start_time</type> is
|
|
||||||
* always 3s different from real start time of the given process. You
|
|
||||||
* may also get shift results if your system clock is not synchronised
|
|
||||||
* with your hardware clock. See <command>man hwclock</command>.
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
glibtop_get_proc_time(glibtop_proc_time *buf, pid_t pid)
|
glibtop_get_proc_time(glibtop_proc_time *buf, pid_t pid)
|
||||||
@@ -197,6 +197,26 @@ glibtop_get_proc_map(glibtop_proc_map *buf, pid_t pid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:procargs
|
||||||
|
* @title: Process Arguments
|
||||||
|
* @short_description: Get process command line arguments
|
||||||
|
* @see_also: #libgtop-Process-List
|
||||||
|
* @stability: Stable
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* glibtop_get_proc_args:
|
||||||
|
* @buf: Struct with @size of returned string.
|
||||||
|
* @pid: Process id
|
||||||
|
* @max_len: Maximum length of string to return (use zero to get all arguments).
|
||||||
|
*
|
||||||
|
* Get process command line arguments.
|
||||||
|
*
|
||||||
|
* Returns: @pid's command line arguments separated by null bytes; the length of
|
||||||
|
* this string is returned in the @buf size field. You are required to free
|
||||||
|
* the string when done.
|
||||||
|
*/
|
||||||
char *
|
char *
|
||||||
glibtop_get_proc_args(glibtop_proc_args *buf, pid_t pid, unsigned max_len)
|
glibtop_get_proc_args(glibtop_proc_args *buf, pid_t pid, unsigned max_len)
|
||||||
{
|
{
|
||||||
@@ -204,6 +224,18 @@ glibtop_get_proc_args(glibtop_proc_args *buf, pid_t pid, unsigned max_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* glibtop_get_proc_argv
|
||||||
|
* @buf: Struct with @size of combined returned arguments.
|
||||||
|
* @pid: Process id
|
||||||
|
* @max_len: Maximum length of all arguments combined (use zero to get all arguments).
|
||||||
|
*
|
||||||
|
* Get process command line arguments.
|
||||||
|
*
|
||||||
|
* Returns: A NULL-terminated array of strings with all arguments of process pid
|
||||||
|
* (up to @max_len characters). Remember to <function>g_strfreev</function>
|
||||||
|
* the returned array to avoid a memory leak.
|
||||||
|
*/
|
||||||
char **
|
char **
|
||||||
glibtop_get_proc_argv(glibtop_proc_args *buf, pid_t pid, unsigned max_len)
|
glibtop_get_proc_argv(glibtop_proc_args *buf, pid_t pid, unsigned max_len)
|
||||||
{
|
{
|
||||||
@@ -211,6 +243,23 @@ glibtop_get_proc_argv(glibtop_proc_args *buf, pid_t pid, unsigned max_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:proclist
|
||||||
|
* @title: Process List
|
||||||
|
* @short_description: List running processes
|
||||||
|
* @stability: Stable
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* glibtop_get_proclist
|
||||||
|
* @buf: Extra return information, see #glibtop_proclist.
|
||||||
|
* @which: Criteria for processes in returned list. See the <type>GLIBTOP_KERN_PROC_*</type> and <type>GLIBTOP_EXCLUDE_*</type> constants.
|
||||||
|
* @arg: Extra arguments applied to @which. Only <type>GLIBTOP_KERN_PROC_*</type> constants take arguments, see each constant definition for particular @arg description.
|
||||||
|
*
|
||||||
|
* Returns: A list of running processes or <type>NULL</type> on error. The
|
||||||
|
* returned list is allocated using <function>g_malloc</function> and must be
|
||||||
|
* freed using <function>g_free</function> to avoid a memory leak.
|
||||||
|
*/
|
||||||
pid_t*
|
pid_t*
|
||||||
glibtop_get_proclist(glibtop_proclist *buf, gint64 which, gint64 arg)
|
glibtop_get_proclist(glibtop_proclist *buf, gint64 which, gint64 arg)
|
||||||
{
|
{
|
||||||
|
@@ -36,7 +36,7 @@ static glibtop_sysinfo sysinfo = { .flags = 0 };
|
|||||||
static void
|
static void
|
||||||
init_sysinfo (glibtop *server)
|
init_sysinfo (glibtop *server)
|
||||||
{
|
{
|
||||||
char buffer [16384];
|
char buffer [65536];
|
||||||
gchar ** processors;
|
gchar ** processors;
|
||||||
|
|
||||||
if(G_LIKELY(sysinfo.flags)) return;
|
if(G_LIKELY(sysinfo.flags)) return;
|
||||||
|
Reference in New Issue
Block a user