Added a remark for installation of the web interface.
[gnucomo.git] / doc / manual.xml
1 <?xml version="1.0"?>
2 <!DOCTYPE doc SYSTEM "/usr/local/xslt/doc.dtd">
3 <?xml-stylesheet type="text/xsl" href="/usr/local/xslt/html.xsl"?>
4 <doc style="main.css">
5
6 <!--
7       Gnucomo - Gnu Computer Monitoring Tutorial
8       Original author :  Peter Roozemaal
9       Version         : $Revision: 1.2 $
10
11       This document is prepared for XMLDoc. Transform to HTML,
12       LaTeX, Postscript or plain text with XMLDoc utilities and
13       XSLT sheets from http://www.andromeda.nl/projects/xmldoc/
14 -->
15
16 <book>
17 <titlepage>
18    <title>Gnucomo - User's Manual</title>
19    <para><picture src='logo.png' eps='logo' scale='0.7'/></para>
20    <author>Peter Roozemaal<code>&lt;mathfox@xs4all.nl&gt;</code></author>
21    <author>Arjen Baart <code>&lt;arjen@andromeda.nl&gt;</code></author>
22    <date>October 23, 2003</date>
23    <docinfo>
24       <infoitem label="Version">0.1</infoitem>
25       <infoitem label="Organization">Andromeda Technology &amp; Automation</infoitem>
26       <infoitem label="Organization">De Winter Information Solutions</infoitem>
27    </docinfo>
28    <abstract>
29    </abstract>
30 </titlepage>
31
32 <toc/>
33
34 <chapter>
35 <heading>What is GnuCoMo ?</heading>
36
37 <para>
38 The aim of the GnuCoMo (GNU COmputer MOnitoring) project is to build a
39 set of applications that will help administrators to monitor networks as
40 a whole for errors, attacks and security-breaches in a very user-friendly
41 way. It is free (GPL) software, sources are available and you are free
42 to modify it to suit your needs.
43 </para>
44 <para>
45 GnuCoMo collects system and application logfiles from the monitored
46 systems (this can be computers, routers and other devices) and stores them
47 in a database. This collected data is further interpreted and analyzed
48 until reports and alerts are generated. Because GnuCoMo can combine data
49 from multiple sources and longer timespans than common IDSs it is able
50 to recognize attacks that previously remained undetected.
51 </para>
52 <para>
53 Remeber, this manual is work in progress.
54 Although it contains some usefull pointers to help you get started
55 with Gnucomo, it is still quite incomplete.
56 You can help us improve this manual and, in fact, Gnucomo itself,
57 by sending your comments and suggestions to the mailinglist:
58 <code>gnucomo@dewinter.com</code>.
59 </para>
60
61 <section>
62 <heading>About this Document</heading>
63
64 <para>
65 This document aims to guide you through the installation of GnuCoMo on
66 a Unix (Linux) workstation. When we have completed the installation this
67 document will give a quick guided tour through the functionality GnuCoMo
68 offers. The procedures described here aim at getting the GnuCoMo demo
69 up and running as quickly as possible and may not be suited for your
70 production environment. I assume you have some experience with installing
71 software on your system.
72 </para>
73
74 <para>
75 This document is part of the Gnucomo package. Gnucomo is released under
76 the Gnu General Public License, see the file COPYING.
77 </para>
78
79 </section>
80
81 <section>
82 <heading>Reporting Bugs</heading>
83
84 <para>
85 If you think you have found a bug in GnuCoMo, this tutorial or the
86 other GnuCoMo documentation, please report it by sending an e-mail to
87 the mailinglist: <code>gnucomo@dewinter.com</code>.
88 Please include in your bug report:
89
90 <itemize>
91 <item>the GnuCoMo version you've found the bug in</item>
92 <item>what you did to provoke the error</item>
93 <item>the output (or error message) you got</item>
94 <item>(if relevant) which output you expected</item>
95 <item>processor type and kernel version you use</item>
96 <item>the versions of the packages that gnucomo depends on</item>
97 </itemize>
98
99 </para>
100
101 </section>
102 </chapter>
103
104 <chapter>
105 <heading>Installation</heading>
106
107 <para>
108 Most of the GnuCoMo installation can be done from an ordinary Unix
109 account; when you need root rights you will be told so explicitly. It is
110 however a good idea to create a gnucomo account.
111 </para>
112
113 <section>
114 <heading>Getting the software</heading>
115
116 <para>
117 GnuCoMo can be downloaded from the
118 <reference href='http://www.gnucomo.org/'>GnuCoMo website</reference>.
119 If you read this file you are likely to have a
120 copy of GnuCoMo on your system. If you are serious about using GnuCoMo
121 it would be a good idea to periodicly check the website for updates
122 and bugfixes.
123 </para>
124 <para>
125 To be able to install and run GnuCoMo you'll need several other packages:
126
127 <description>
128 <item tag='PostgreSQL'>
129    PostgreSQL is the database we use for GnuCoMo. Most
130    linux distributions provide ready to install packages for
131    PostgreSQL. We need at least the postgresql, postgresql-server,
132    postgresql-libs and postgresql-devel packages.
133    If you want to compile PostgreSQL from source: go to the
134    <reference href='http://www.postgresql.org/'>PostgreSQL homepage</reference>
135    and download the sources via one of the ftp sites. We need libpq++
136    support for GnuCoMo.
137    Though we appreciate the performance improvements that the
138    PostgreSQL 7.3 server provides, we recommend sticking to the
139    PostgreSQL 7.2 client versions for now; at least until we've
140    solved the problems with the libpq++ libraries and PostgreSQL 7.3.
141 </item>
142
143 <item tag='libpqxx'>
144    The C++ client interface for the PostgreSQL database server
145    is a separate project, not distributed with PostgreSQL.
146    This library replaces the old libpq++ library.
147    The place to find libpqxx is
148    <reference href='http://gborg.postgresql.org/project/libpqxx/projdisplay.php'>
149    the Gborg website</reference>.
150    Make sure you install libpqxx in a default library path or
151    set your LB_LIBRARY_PATH environment variable to include
152    the directory in which libpqxx is installed. The default
153    for libpqxx is /usr/local/libpqxx/lib.
154 </item>
155
156 <item tag='PHP'>
157    PHP is used as programming language for gcm_deamon. If you
158    have packages you would want to install at least the php and
159    php-pgsql packages.
160    You can get PHP sources and documentation from the
161    <reference href='http://www.php.net/'>PHP website</reference>.
162    If you're compiling yourself, don't forget
163    to include PostgreSQL support.
164 </item>
165
166 <item tag='libxml2'>
167    We use XML for configuration that we can't (or don't want
168    to) store in the database and for documentation in XMLDOC
169    format. The libxml2 library usually comes with your linux
170    system and you would want to install both the libxml2 and
171    libxml2-devel packages.  The libxml2 sources can be downloaded
172    via <reference href='http://xmlsoft.org/downloads.html'>the XMLSoft site</reference>.
173 </item>
174
175 <item tag='AXE'>
176    It's not likely that you'll find precompiled AXE packages on
177    the net, so you'll have to compile from source. Get the AXE
178    sources from the <reference href='http://www.andromeda.nl/projects/AXE/AXE.html'>
179    AXE page</reference>;
180    you'll need version 0.3 or better.
181    Instructions on compiling and installing AXE are given later in
182    this document.
183 </item>
184 </description>
185
186
187 The following packages are optional and provide additional functionality
188 to GnuCoMo:
189
190 <description>
191 <item tag='GnuPG'>
192    Recommended for encryption and signing of data that is transported
193    over the network. Not used at this moment.
194 </item>
195
196 <item tag='XMLDoc'>
197    We use XMLDoc to process our documentation. Download
198    and installation instructions can be found on the
199    <reference href='http://www.andromeda.nl/projects/xmldoc/xmldoc.html'>
200    XMLDoc site</reference>.
201 </item>
202
203 <item tag='Apache'>
204    [HELPME: basic instructions]
205 </item>
206
207 <item tag='Python + tkinter'>
208    A GUI based configuration tool named MalfisInter (mi) is being
209    worked upon. This tool is programmed in Python and requires XML
210    and TkInter support.
211 </item>
212
213 </description>
214
215 </para>
216 </section>
217
218 <section>
219 <heading>Compiling</heading>
220
221 <para>
222 If you're lucky enough to find precompiled packages for your system and
223 have root permissions to install them, things are easy for you; otherwise
224 you would have to compile from source, which takes a bit more time if
225 you allready have the standard developer tools (C and C++ compilers,
226 make, (f)lex and yacc or bison) installed. You will need those tools
227 for GnuCoMo anyway.
228 You will also need the GNU automake and autoconf packages.
229 </para>
230 <para>
231 Another essential utility is the bzip compressor package; you will need
232 it to unpack the archives. bzip2 and bunzip2 come standard with Linux,
233 but may not be available on older Unix distributions. Sources for bzip2
234 can be found at http://sources.redhat.com/bzip2/.
235 Most of the packages mentioned in this document come with detailed
236 compilation and installation instructions and I recommend to read the
237 README and INSTALL files before compiling and installing them.
238 </para>
239
240 <subsection>
241 <heading>Compiling AXE</heading>
242
243 <para>
244 For compiling AXE you need the X-windows (X11) headers and
245 libraries. Under Linux you might need to install the XFree86-devel
246 package, but these headers are usualy available whenever the C compiler
247 is installed (also on propriatary unixes).
248 [TODO]
249 </para>
250
251 </subsection>
252
253 <subsection>
254 <heading>Compiling GnuCoMo</heading>
255
256 <para>
257 The usual <code>./configure; make install</code> will compile
258 the binary applications and install <code>gcm_input</code> and
259 <code>logrunner</code> into <code>/usr/local/bin</code>.
260 You will need to copy the web interface scripts and gcm_daemon
261 manually to the appropriate directories.
262 </para>
263
264
265 </subsection>
266 </section>
267
268 <section>
269 <heading>Setting up the database</heading>
270 <para>
271 Gnucomo won't do anything usefull without a PostgreSQL database, so you will have to
272 set this up first.
273 Make sure you have the PostgreSQL server running and you have a valid userid
274 and password to access the server.
275 You also need to have the permission to create new databases.
276 If not, you will need to log in as the database administration user (usually
277 a user called <emph>postgres</emph>) and create a new user for the database.
278 </para>
279
280 <para>
281 To create the initial Gnucomo database, you need to use the SQL script
282 <code>create.sql</code>, which is in the <code>src/database</code>
283 directory of the Gnucomo distribution.
284 Type the following commands to create the database:
285
286 <verbatim>
287
288    createdb gnucomo
289    psql gnucomo -f create.sql
290
291 </verbatim>
292
293 With the default installation of PostgreSQL on RedHat 8.0,
294 you will probably encounter an authentication problem when you try to
295 use the Gnucomo web interface. The problem will look somewhat like this:
296 </para>
297
298 <para>
299 <strong>
300 Warning: pg_connect() unable to connect to PostgreSQL server:
301 FATAL 1: IDENT authentication failed for user "arjen"
302 </strong>
303 </para>
304
305 <para>
306 Refer to PostgreSQL Administrator's guide, Chapter 4: Client Authentication.
307 You probably have this line in the /var/lib/pgsql/data/pg_hba.conf:
308
309 <verbatim>
310    local   all     ident   sameuser
311 </verbatim>
312
313 (I know RedHat 8.0 does this). You need to change this into:
314
315 <verbatim>
316    local      all           password
317 </verbatim>
318
319 This tells PostgreSQL to allow any UNIX user to log into the database
320 as any database user on a local socket, using his database password.
321
322 </para>
323 </section>
324
325 <section>
326 <heading>The Gnucomo configuration file</heading>
327
328 <para>
329 All Gnucomo applications use a single configuration file, named
330 <code>gnucomo.conf</code> by default.
331 There are three places where this configuration file is stored.
332 Gnucomo applications first look for the configuration file in <code>/etc</code>,
333 and if the file is not found there, it should be in
334 <code>/usr/local/etc</code>.
335 Furthermore, you can have an additional configuration file in your home
336 directory, named <code>$HOME/.gnucomo.conf</code>.
337 The configuration file in <code>/etc</code> or in <code>/usr/local/etc</code>
338 holds the system-wide parameters.
339 The configuration file in a user's home directory may hold user-specific
340 preferences.
341 The system-wide configuration is mandatory; any user-specific configuration
342 is optional.
343 </para>
344 <para>
345 The configuration parameters are organized as a two-level tree, written
346 in XML.
347 The first level of the tree constitutes the 'sections', referring to a
348 set of related paramaters.
349 The second level contains the parameters themselves.
350 Each parameter is a single value, i.e. there are no provisions to create
351 structured parameters.
352 Here is an example of what the Gnucomo configuration file may look like:
353
354 <verbatim>
355    &lt;?xml version='1.0'?&gt;
356    &lt;gnucomo version='0.0.8'&gt;
357       &lt;database&gt;
358          &lt;type&gt;PostgreSQL&lt;/type&gt;
359          &lt;name&gt;gnucomo&lt;/name&gt;
360          &lt;user&gt;arjen&lt;/user&gt;
361          &lt;password&gt;guess-again:-)&lt;/password&gt;
362       &lt;/database&gt;
363       &lt;logging&gt;
364          &lt;method&gt;file&lt;/method&gt;
365          &lt;destination&gt;/var/log/gcm_input&lt;/destination&gt;
366          &lt;level&gt;0&lt;/level&gt;
367       &lt;/logging&gt;
368    &lt;/gnucomo&gt;
369
370 </verbatim>
371
372 At the root of the tree is an XML element, called <code>gnucomo</code>.
373 The direct children of the root element in the example above are
374 <code>database</code> and <code>logging</code>.
375 These are the 'sections', corresponding to different aspects of the Gnucomo
376 system.
377 As you may have guessed, the <code>database</code> section holds information
378 we need to access the Gnucomo database on the PostgreSQL server and the
379 <code>logging</code> section specifies how much logging we want the
380 Gnucomo applications to generate and where we want that information to go.
381 </para>
382 </section>
383
384 <section>
385 <heading>Getting the web interface up and running</heading>
386 <para>
387 Your primary view onto Gnucomo is through the web interface.
388 Gnucomo uses a web server, e.g. Apache, with PHP scripts to implement
389 its user inetrface
390 At the present, the web interface is the only way to manage the
391 information in the Gnucomo database and view the results that
392 Gnucomo produces.
393 </para>
394 <para>
395 To be able to use the web interface, you need to copy the PHP
396 scripts from the <code>src/web</code> and <code>src/phpclasses</code>
397 directories into a directory accessible through the web server.
398 On most Red Hat Linux systems, this is usually in
399 <code>/var/www/html</code>.
400 One way to accomplish this is to create a subdirectory <code>gnucomo</code> under
401 the Document Root of the webserver.
402 The main gnucomo scripts go into this directory and the PHP class library can be copied
403 either in a subdirectory <code>classes</code> or <code>../phpclasses</code>.
404 Here's an example installation:
405 <verbatim>
406   [gnucomo] # mkdir $DocumentRoot/gnucomo
407   [gnucomo] # cp src/web/* $DocumentRoot/gnucomo
408   [gnucomo] # cp -r src/phpclasses $DocumentRoot
409 </verbatim>
410
411 </para>
412 </section>
413
414 <section>
415 <heading>And now...</heading>
416 <para>
417 If you like GnuCoMo [TODO]
418 Report success under Non-Linux [TODO]
419 </para>
420 </section>
421 </chapter>
422
423 <chapter>
424 <heading>Using Gnucomo</heading>
425
426 <para>
427 Once you have the database and the web interface set up, Gnucomo is almost
428 ready to go.
429 To put Gnucomo to work, you need to enter at least one object into the database
430 and create your methods to feed information to gnucomo.
431 </para>
432
433 <section>
434 <heading>The initial entries</heading>
435
436 <para>
437 Gnucomo maintains information about monitored systems such as servers,
438 work stations, switches and that sort of thing.
439 In Gnucomo, these are called <emph>objects</emph>.
440 The <emph>objects</emph> are distinguished by their name, usually
441 a hostname in your network. Or, better still, a fully qualified name
442 on the internet. 
443 You can use the web interface to create an <emph>object</emph> by logging
444 in and selecting the picture that looks like a computer cabinet
445 in the button bar at the top.
446 Enter the object's name, for example <code>server.gnucomo.org</code>,
447 and click the <strong>Create</strong> button.
448 </para>
449
450 </section>
451
452 <section>
453 <heading>Feeding log files</heading>
454
455 <para>
456 Once an object is known by Gnucomo, i.e. the object's name is stored in the
457 database, you can start to fill the database with log entries.
458 Log entries are stored by a variety of programs into one or more log
459 files on the object's harddisk.
460 For example, system messages on most Linux distributions are put
461 in a file called <code>/var/log/messages</code>.
462 There are several ways to transfer the contents of a log file into the
463 Gnucomo database, each of which involves <code>gcm_input</code>.
464 <code>Gcm_input</code> is the Gnucomo application that reads various kinds
465 of raw input and tries to scan for as much information as possible.
466 The usefull information that is extracted from the input is stored
467 into the Gnucomo database.
468 </para>
469
470 <para>
471 The most direct way to invoke <code>gcm_input</code> maually and read
472 the log file through its standard input:
473 <verbatim>
474    gcm_input -h server.gnucomo.org &lt;/var/log/messages
475 </verbatim>
476 You'll have to explicitly specify the hostname of the object because
477 there is no way for <code>gcm_input</code> to know where the log
478 file comes from.
479 Take care not to feed the same log file another time through
480 <code>gcm_input</code>.
481 This will lead to duplicate log entries in the Gnucomo database.
482 </para>
483 <para>
484 Feeding information into the Gnucomo database can also be done through
485 a mail server, such as sendmail.
486 Create a mail alias that invokes <code>gcm_input</code> as a mailer program.
487 For example:
488 <verbatim>
489    gnucomo:        "|gcm_input"
490 </verbatim>
491 With such an email alias, Gnucomo clients can simply send log files and
492 other reports to this email address:
493 <verbatim>
494    mail gnucomo@server.gnucomo.org &lt;/var/log/messages
495 </verbatim>
496 </para>
497 <para>
498 The third method to feed log files into the Gnucomo database is by
499 using <code>logrunner</code>.
500 </para>
501 </section>
502
503 <section>
504 <heading>Viewing results</heading>
505 <para>
506 Use the web interface to review log entries, notifications and parameters.
507 </para>
508 </section>
509
510 </chapter>
511
512 <chapter>
513 <heading>Managing system parameters</heading>
514
515 <para>
516 Besides log entries which represent the transient events that occur in
517 an object, Gnucomo also maintains the state of the object.
518 The state of an object is defined by the set of parameters and
519 their values.
520 Examples of parameters are the file systems, users, processes, installed
521 packages, and so on.
522 By managing those parameters with Gnucomo, you can hold a firm grip on
523 the state of your systems.
524 Especially on large sites with many workstations, servers, switches
525 and other objects, managing the state of all those systems is not
526 a trivial task.
527 The following sections explain how Gnucomo can help.
528 </para>
529
530 <section>
531 <heading>Installed packages</heading>
532
533 <para>
534 Gnucomo can maintain a list of all packages installed on an object.
535 This list is stored in the database as parameters of class
536 <emph>package</emph>.
537 Each <emph>package</emph> parameter has one property: the version number
538 of the package.
539 Gnucomo keeps an historical record of the version number for each package,
540 so you will know when the version of a package changes.
541 Furthermore, you can compare the installed packages of two objects, so
542 you can easily find the differences between two installations.
543 </para>
544
545 <para>
546 To maintain the installed packages of an object, all you need is to
547 feed a complete list into the Gnucomo database through <emph>gcm_input</emph>.
548 The package list is a text file with a package on each line of the form
549 <code>packagename-version</code>.
550 Not the dash ('-') between the name and the version.
551 On many Linux systems that use the RedHat Package Manager (RPM), such
552 a list is easily obtained and fed into <emph>gcm_input</emph>:
553
554 <verbatim>
555    rpm -qa | gcm_input -h example.gnucomo.org
556 </verbatim>
557
558 You will have to repeat this procedure at regular intervals.
559 Each time you feed a new package list to Gnucomo, Gnucomo will
560 compare the new list with the package parameters in the database
561 and notify you of any changes.
562 </para>
563 <para>
564 For keeping your systems up-to-date, it is often convenient to maintain
565 a repository of the most recent packages.
566 Gnucomo can help you with this task.
567 To enter the list of packages and updates from a distribution into the
568 Gnucomo database, you can create a virtual <emph>object</emph> and
569 create the <emph>package</emph> parameters for this object.
570 For example, to maintain a list of RPMs for RedHat Linux 7.3, create an
571 object (using the web interface) with the name <code>redhat-7.3</code>.
572 Using this object, enter the first batch of package parameters from a directory
573 listing of the CD-ROM.
574 However, you can not use the output from <strong>ls</strong> directly as
575 input for <strong>gcm_input</strong>.
576 You need to strip off two siffixes off the filenames to make it look like
577 a <code>rpm -qa</code> output.
578 The following script will do just that:
579
580 <verbatim>
581
582 #!/bin/sh
583 #
584 #   Turn an 'ls' listing of RPM files into an 'rpm -qa' listing
585 #   Reads a list of filenames, possibly preceeded by a directory and
586 #   strips the directory path from the beginning and the two suffices
587 #   from the end of each filename. For example, the name
588 #   "/mnt/cdrom/RedHat/RPMS/kernel-2.4.20-13.7.i686.rpm" gets turned
589 #   into a simple "kernel-2.4.20-13.7".
590
591 while read filename
592 do
593    case $filename in
594    *.src.rpm)
595    ;;
596
597    *)
598       filename=`basename $filename .rpm`
599       case $filename in
600       *.athlon)
601          rpm=`basename $filename .athlon`
602       ;; 
603       *.i386)
604          rpm=`basename $filename .i386`
605       ;; 
606       *.i486)
607          rpm=`basename $filename .i486`
608       ;; 
609       *.i586)
610          rpm=`basename $filename .i586`
611       ;; 
612       *.i686)
613          rpm=`basename $filename .i686`
614       ;; 
615       *.noarch)
616          rpm=`basename $filename .noarch`
617       ;; 
618       esac
619       echo $rpm
620    ;;
621    esac
622 done
623
624 </verbatim>
625
626 Suppose this script is stored as <code>ls-rpm</code>, you can apply it
627 like this:
628
629 <verbatim>
630    ls /mnt/cdrom/RedHat/RPMS | ls-rpm | sort | uniq | gcm_input -h redhat-7.3
631 </verbatim>
632
633 You can repeat this command to enter additional packages into the database.
634 For example, to add packages from other CD-ROMs or from a directory where
635 you keep downloaded updates.
636 Remember, however, to use the <strong>-i</strong> option for "incremental"
637 with gcm_input.
638 Without this option, gcm_input will regard the list of packages as a <emph>full</emph>
639 list and remove any parameters that are not present in the new list.
640 </para>
641 <para>
642 With a list of available packages for a specific distribution in the Gnucomo
643 database, along with the list of packages installed on your systems, you
644 can easily obtain an overview of which packages you need to update.
645 To make this overview, use the web interface to compare the packages
646 on an object with the packages on the virtual object.
647 </para>
648 </section>
649
650 </chapter>
651
652 </book>
653 </doc>