Blame doc/reference/libgtop-docs.xml

Packit Service 407539
Packit Service 407539
Packit Service 407539
               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
Packit Service 407539
<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
Packit Service 407539
  <bookinfo>
Packit Service 407539
    <title>Libgtop Reference Manual</title>
Packit Service 407539
    <releaseinfo>for libgtop <xi:include href="version.xml"/></releaseinfo>
Packit Service 407539
    <authorgroup>
Packit Service 407539
      <author>
Packit Service 407539
	<firstname>Martin </firstname>
Packit Service 407539
	<surname>Baulig</surname>
Packit Service 407539
	<affiliation>
Packit Service 407539
	  <address>
Packit Service 407539
	    <email>martin@home-of-linux.org</email>
Packit Service 407539
	  </address>
Packit Service 407539
	</affiliation>
Packit Service 407539
      </author>
Packit Service 407539
      <author>
Packit Service 407539
	<firstname>Germán</firstname>
Packit Service 407539
	<surname>Poó-Caamaño</surname>
Packit Service 407539
	<affiliation>
Packit Service 407539
	  <address>
Packit Service 407539
	    <email>gpoo@ubiobio.cl</email>
Packit Service 407539
	  </address>
Packit Service 407539
	</affiliation>
Packit Service 407539
      </author>
Packit Service 407539
    </authorgroup>
Packit Service 407539
Packit Service 407539
    <legalnotice>
Packit Service 407539
      <para>Permission is granted to copy, distribute and/or modify
Packit Service 407539
      this document under the terms of the <citetitle>GNU Free
Packit Service 407539
      Documentation License</citetitle>, Version 1.1 or any later
Packit Service 407539
      version published by the Free Software Foundation with no
Packit Service 407539
      Invariant Sections, no Front-Cover Texts, and no Back-Cover
Packit Service 407539
      Texts. You may obtain a copy of the <citetitle>GNU Free
Packit Service 407539
      Documentation License</citetitle> from the Free Software
Packit Service 407539
      Foundation by visiting 
Packit Service 407539
      url="http://www.fsf.org">their Web site</ulink> or by writing
Packit Service 407539
      to: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Packit Service 407539
      Boston, MA 02110-1301, USA.</para>
Packit Service 407539
Packit Service 407539
      <para>Many of the names used by companies to distinguish their
Packit Service 407539
      products and services are claimed as trademarks. Where those
Packit Service 407539
      names appear in any GNOME documentation, and those trademarks
Packit Service 407539
      are made aware to the members of the GNOME Documentation
Packit Service 407539
      Project, the names have been printed in caps or initial
Packit Service 407539
      caps.</para>
Packit Service 407539
    </legalnotice>
Packit Service 407539
Packit Service 407539
    <abstract>
Packit Service 407539
      <para>
Packit Service 407539
      LibGTop is a library to get system specific data such as CPU and 
Packit Service 407539
      Memory Usage and information about running Processes.</para>
Packit Service 407539
Packit Service 407539
      <para>On Systems like Solaris or Digital Unix where you need special
Packit Service 407539
      privileges to get those data, it uses a setuid/setgid server to do 
Packit Service 407539
      so.</para>
Packit Service 407539
Packit Service 407539
      <para>Even if LibGTop is a part of the GNOME desktop environment
Packit Service 407539
      (@uref{http://www.gnome.org}), the main interface of LibGTop is totally
Packit Service 407539
      independent from any particular desktop environment, so you can also
Packit Service 407539
      use it as a standalone library in any piece of GPLed software.</para>
Packit Service 407539
Packit Service 407539
      <para>This manual documents the interfaces of the libgtop
Packit Service 407539
      library and has some short notes to help get you up to speed
Packit Service 407539
      with using the library.</para>
Packit Service 407539
    </abstract>
Packit Service 407539
  </bookinfo>
Packit Service 407539
Packit Service 407539
  
Packit Service 407539
Packit Service 407539
  <chapter id="libgtop-white-paper">
Packit Service 407539
    <title>White paper</title>
Packit Service 407539
Packit Service 407539
    <sect1 id="libgtop-white-paper-introduction">
Packit Service 407539
      <title>Introduction</title>
Packit Service 407539
      <para>Many modern UNIX systems like Solaris, BSD or Digitial Unix 
Packit Service 407539
      only allow priviledged processes to read information like CPU and 
Packit Service 407539
      Memory Usage or information about running processes.</para>
Packit Service 407539
Packit Service 407539
      <itemizedlist>
Packit Service 407539
      <listitem><para>
Packit Service 407539
      BSD, for instance, doesn't have any other way to get those data than reading
Packit Service 407539
      directly from @file{/dev/kmem} and you need to be in the @code{kmem} group to
Packit Service 407539
      be able to read this.</para></listitem>
Packit Service 407539
Packit Service 407539
      <listitem><para>
Packit Service 407539
      Other systems, like Digital Unix, allow all users to get things like CPU and
Packit Service 407539
      Memory statistics, but only root may read information about any process other
Packit Service 407539
      than the current one (you may not even get information about your own processes
Packit Service 407539
      if you're not root).</para></listitem>
Packit Service 407539
Packit Service 407539
      <listitem><para>
Packit Service 407539
      Linux has a very nice @file{/proc} filesystem, but reading and parsing
Packit Service 407539
      @file{/proc} is very slow and inefficient.</para></listitem>
Packit Service 407539
Packit Service 407539
      <listitem><para>
Packit Service 407539
      Solaris is a bit better, but you still need to be in the @code{sys} group or
Packit Service 407539
      even root to get some data.</para></listitem>
Packit Service 407539
      </itemizedlist>
Packit Service 407539
Packit Service 407539
      <para>
Packit Service 407539
      Because of this system utilities like @code{ps}, @code{uptime} or @code{top}
Packit Service 407539
      often are setgid kmem or setuid root. Usually, they're also very specific to
Packit Service 407539
      the system they're written for and not easily portable to other systems without
Packit Service 407539
      a lot of work.</para>
Packit Service 407539
Packit Service 407539
      <para>
Packit Service 407539
      This, of cause, becomes a problem for graphical tools like @code{gtop} - making
Packit Service 407539
      a GTK+ program setgid or even setuid would be a security hole as big as you can
Packit Service 407539
      drive the entire X11 source code through. For the GNOME project, we also needed
Packit Service 407539
      some kind of library which provides all the required information in a portable
Packit Service 407539
      since there's more than just one single program that wants to use them - for
Packit Service 407539
      instance @code{gtop} and the @code{multiload}, @code{cpumemusage} and
Packit Service 407539
      @code{netload} panel applets.</para>
Packit Service 407539
Packit Service 407539
    </sect1>
Packit Service 407539
Packit Service 407539
    <sect1 id="libgtop-white-paper-overview">
Packit Service 407539
      <title>Overview</title>
Packit Service 407539
      <para>This section should give you a short overview on how LibGTop
Packit Service 407539
      was developed, which things needed to be considered and how it 
Packit Service 407539
      works.</para>
Packit Service 407539
Packit Service 407539
      <sect2 id="libgtop-white-paper-overview-design">
Packit Service 407539
      <title>Interface Design: Things that need to be considered</title>
Packit Service 407539
      <para>
Packit Service 407539
At the very beginning, it was necessary to collect all the data the library part
Packit Service 407539
should provide and put them into some C structures. This was not that easiy as it
Packit Service 407539
might sound since LibGTop should be portable to any modern UNIX system with a common
Packit Service 407539
library part on all those systems, but the data that should be returned vary from
Packit Service 407539
system to system. For instance some systems support shared memory, but some others
Packit Service 407539
may not.</para>
Packit Service 407539
Packit Service 407539
      <para>
Packit Service 407539
The header files where we define these C structures (which are system-independent) are
Packit Service 407539
shared between client and server. This way we can call the system dependent code
Packit Service 407539
directly where we do not need any special privileges to do so.</para>
Packit Service 407539
Packit Service 407539
      <para>
Packit Service 407539
All of those structures contain a @code{flags} member which is interpreted as a bit
Packit Service 407539
mask and tells the caller of the library functions which of the fields in the returned
Packit Service 407539
structure are valid and which are not.</para>
Packit Service 407539
      </sect2>
Packit Service 407539
Packit Service 407539
      <sect2 id="libgtop-white-paper-overview-server">
Packit Service 407539
      <title>Server Implementation: The LibGTop "server"</title>
Packit Service 407539
      <para>
Packit Service 407539
The LibGTop @dfn{server} is a setgid/setuid binary which contains all the system
Packit Service 407539
dependent code which needs special privileges. It is only build if it's required
Packit Service 407539
on the current system (for instance, the Linux kernel provides all the required
Packit Service 407539
data via its @file{/proc} filesystem so we do not need the server at all) and it
Packit Service 407539
only contains the @dfn{features} which need privileges.</para>
Packit Service 407539
Packit Service 407539
      <para>
Packit Service 407539
Whenever we do not need any privileges to get all the data for some of the requested
Packit Service 407539
structures (here called @dfn{features}) the library calls the sysdeps code directly
Packit Service 407539
rather than using the server.</para>
Packit Service 407539
      </sect2>
Packit Service 407539
    </sect1>
Packit Service 407539
Packit Service 407539
  </chapter>
Packit Service 407539
Packit Service 407539
  <chapter id="libgtop-lib">
Packit Service 407539
    <title>Libgtop Library Reference</title>
Packit Service 407539
Packit Service 407539
    <para>This section contains the API reference for libgtop.  All
Packit Service 407539
    the public interfaces are documented here.</para>
Packit Service 407539
Packit Service 407539
    <xi:include href="xml/glibtop.xml"/>
Packit Service 407539
    <xi:include href="xml/close.xml"/>
Packit Service 407539
    <xi:include href="xml/command.xml"/>
Packit Service 407539
    <xi:include href="xml/glibtop-server.xml"/>
Packit Service 407539
    <xi:include href="xml/netload.xml"/>
Packit Service 407539
    <xi:include href="xml/ppp.xml"/>
Packit Service 407539
    <xi:include href="xml/shm_limits.xml"/>
Packit Service 407539
    <xi:include href="xml/uptime.xml"/>
Packit Service 407539
    <xi:include href="xml/netlist.xml"/>
Packit Service 407539
    <xi:include href="xml/open.xml"/>
Packit Service 407539
    <xi:include href="xml/parameter.xml"/>
Packit Service 407539
    <xi:include href="xml/procargs.xml"/>
Packit Service 407539
    <xi:include href="xml/procmem.xml"/>
Packit Service 407539
    <xi:include href="xml/procopenfiles.xml"/>
Packit Service 407539
    <xi:include href="xml/procsegment.xml"/>
Packit Service 407539
    <xi:include href="xml/procsignal.xml"/>
Packit Service 407539
    <xi:include href="xml/sysdeps.xml"/>
Packit Service 407539
    <xi:include href="xml/procstate.xml"/>
Packit Service 407539
    <xi:include href="xml/procuid.xml"/>
Packit Service 407539
    <xi:include href="xml/proctime.xml"/>
Packit Service 407539
    <xi:include href="xml/signal.xml"/>
Packit Service 407539
    <xi:include href="xml/procmap.xml"/>
Packit Service 407539
    <xi:include href="xml/sysinfo.xml"/>
Packit Service 407539
    <xi:include href="xml/union.xml"/>
Packit Service 407539
    <xi:include href="xml/version.xml"/>
Packit Service 407539
    <xi:include href="xml/proclist.xml"/>
Packit Service 407539
    <xi:include href="xml/sem_limits.xml"/>
Packit Service 407539
    <xi:include href="xml/prockernel.xml"/>
Packit Service 407539
    <xi:include href="xml/fsusage.xml"/>
Packit Service 407539
    <xi:include href="xml/loadavg.xml"/>
Packit Service 407539
    <xi:include href="xml/mem.xml"/>
Packit Service 407539
    <xi:include href="xml/mountlist.xml"/>
Packit Service 407539
    <xi:include href="xml/msg_limits.xml"/>
Packit Service 407539
    <xi:include href="xml/cpu.xml"/>
Packit Service 407539
    <xi:include href="xml/swap.xml"/>
Packit Service 407539
  </chapter>
Packit Service 407539
</book>