ed8cbd1efe0aac99ae6dbc86c6700065b6762c9b
[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="gnucomo.css">
5
6 <!--
7       Gnucomo - Gnu Computer Monitoring Tutorial
8       Original author :  Peter Roozemaal
9       Version         : $Revision: 1.3 $
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 25, 2007</date>
23    <docinfo>
24       <infoitem label="Version">0.2</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 </para>
90
91 <itemize>
92 <item>the GnuCoMo version you've found the bug in</item>
93 <item>what you did to provoke the error</item>
94 <item>the output (or error message) you got</item>
95 <item>(if relevant) which output you expected</item>
96 <item>processor type and kernel version you use</item>
97 <item>the versions of the packages that gnucomo depends on</item>
98 </itemize>
99
100 </section>
101 </chapter>
102
103 <chapter>
104 <heading>Installation</heading>
105
106 <para>
107 Most of the GnuCoMo installation can be done from an ordinary Unix
108 account; when you need root rights you will be told so explicitly. It is
109 however a good idea to create a gnucomo account.
110 </para>
111
112 <section>
113 <heading>Getting the software</heading>
114
115 <para>
116 GnuCoMo can be downloaded from the
117 <reference href='http://www.gnucomo.org/'>GnuCoMo website</reference>.
118 If you read this file you are likely to have a
119 copy of GnuCoMo on your system. If you are serious about using GnuCoMo
120 it would be a good idea to periodicly check the website for updates
121 and bugfixes.
122 </para>
123 <para>
124 To be able to install and run GnuCoMo you'll need several other packages:
125 </para>
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 <para>
188 The following packages are optional and provide additional functionality
189 to GnuCoMo:
190 </para>
191
192 <description>
193 <item tag='GnuPG'>
194    Recommended for encryption and signing of data that is transported
195    over the network. Not used at this moment.
196 </item>
197
198 <item tag='XMLDoc'>
199    We use XMLDoc to process our documentation. Download
200    and installation instructions can be found on the
201    <reference href='http://www.andromeda.nl/projects/xmldoc/xmldoc.html'>
202    XMLDoc site</reference>.
203 </item>
204
205 <item tag='Apache'>
206    [HELPME: basic instructions]
207 </item>
208
209 <item tag='Python + tkinter'>
210    A GUI based configuration tool named MalfisInter (mi) is being
211    worked upon. This tool is programmed in Python and requires XML
212    and TkInter support.
213 </item>
214
215 </description>
216
217 </section>
218
219 <section>
220 <heading>Compiling</heading>
221
222 <para>
223 If you're lucky enough to find precompiled packages for your system and
224 have root permissions to install them, things are easy for you; otherwise
225 you would have to compile from source, which takes a bit more time if
226 you allready have the standard developer tools (C and C++ compilers,
227 make, (f)lex and yacc or bison) installed. You will need those tools
228 for GnuCoMo anyway.
229 You will also need the GNU automake and autoconf packages.
230 </para>
231 <para>
232 Another essential utility is the bzip compressor package; you will need
233 it to unpack the archives. bzip2 and bunzip2 come standard with Linux,
234 but may not be available on older Unix distributions. Sources for bzip2
235 can be found at http://sources.redhat.com/bzip2/.
236 Most of the packages mentioned in this document come with detailed
237 compilation and installation instructions and I recommend to read the
238 README and INSTALL files before compiling and installing them.
239 </para>
240
241 <subsection>
242 <heading>Compiling AXE</heading>
243
244 <para>
245 For compiling AXE you need the X-windows (X11) headers and
246 libraries. Under Linux you might need to install the XFree86-devel
247 package, but these headers are usualy available whenever the C compiler
248 is installed (also on propriatary unixes).
249 [TODO]
250 </para>
251
252 </subsection>
253
254 <subsection>
255 <heading>Compiling GnuCoMo</heading>
256
257 <para>
258 The usual <code>./configure; make install</code> will compile
259 the binary applications and install <code>gcm_input</code> and
260 <code>logrunner</code> into <code>/usr/local/bin</code>.
261 You will need to copy the web interface scripts and gcm_daemon
262 manually to the appropriate directories.
263 </para>
264
265
266 </subsection>
267 </section>
268
269 <section>
270 <heading>Setting up the database</heading>
271 <para>
272 Gnucomo won't do anything usefull without a PostgreSQL database, so you will have to
273 set this up first.
274 Make sure you have the PostgreSQL server running and you have a valid userid
275 and password to access the server.
276 You also need to have the permission to create new databases.
277 If not, you will need to log in as the database administration user (usually
278 a user called <emph>postgres</emph>) and create a new user for the database.
279 </para>
280
281 <para>
282 To create the initial Gnucomo database, you need to use the SQL script
283 <code>create.sql</code>, which is in the <code>src/database</code>
284 directory of the Gnucomo distribution.
285 Type the following commands to create the database:
286 </para>
287
288 <verbatim>
289
290    createdb gnucomo
291    psql gnucomo -f create.sql
292
293 </verbatim>
294
295 <para>
296 With the default installation of PostgreSQL on RedHat 8.0,
297 you will probably encounter an authentication problem when you try to
298 use the Gnucomo web interface. The problem will look somewhat like this:
299 </para>
300
301 <para>
302 <strong>
303 Warning: pg_connect() unable to connect to PostgreSQL server:
304 FATAL 1: IDENT authentication failed for user "arjen"
305 </strong>
306 </para>
307
308 <para>
309 Refer to PostgreSQL Administrator's guide, Chapter 4: Client Authentication.
310 You probably have this line in the /var/lib/pgsql/data/pg_hba.conf:
311 </para>
312
313 <verbatim>
314    local   all     ident   sameuser
315 </verbatim>
316
317 <para>
318 (I know RedHat 8.0 does this). You need to change this into:
319 </para>
320
321 <verbatim>
322    local      all           password
323 </verbatim>
324
325 <para>
326 This tells PostgreSQL to allow any UNIX user to log into the database
327 as any database user on a local socket, using his database password.
328 </para>
329 </section>
330
331 <section>
332 <heading>The Gnucomo configuration file</heading>
333
334 <para>
335 <label name='configuration'/>
336 All Gnucomo applications use a single configuration file, named
337 <code>gnucomo.conf</code> by default.
338 There are three places where this configuration file is stored.
339 Gnucomo applications first look for the configuration file in <code>/etc</code>,
340 and if the file is not found there, it should be in
341 <code>/usr/local/etc</code>.
342 Furthermore, you can have an additional configuration file in your home
343 directory, named <code>$HOME/.gnucomo.conf</code>.
344 The configuration file in <code>/etc</code> or in <code>/usr/local/etc</code>
345 holds the system-wide parameters.
346 The configuration file in a user's home directory may hold user-specific
347 preferences.
348 The system-wide configuration is mandatory; any user-specific configuration
349 is optional.
350 </para>
351 <para>
352 The configuration parameters are organized as a two-level tree, written
353 in XML.
354 The first level of the tree constitutes the 'sections', referring to a
355 set of related paramaters.
356 The second level contains the parameters themselves.
357 Each parameter is a single value, i.e. there are no provisions to create
358 structured parameters.
359 Here is an example of what the Gnucomo configuration file may look like:
360 </para>
361
362 <verbatim>
363    &lt;?xml version='1.0'?&gt;
364    &lt;gnucomo version='0.0.8'&gt;
365       &lt;database&gt;
366          &lt;type&gt;PostgreSQL&lt;/type&gt;
367          &lt;name&gt;gnucomo&lt;/name&gt;
368          &lt;user&gt;arjen&lt;/user&gt;
369          &lt;password&gt;guess-again:-)&lt;/password&gt;
370       &lt;/database&gt;
371       &lt;logging&gt;
372          &lt;method&gt;file&lt;/method&gt;
373          &lt;destination&gt;/var/log/gcm_input&lt;/destination&gt;
374          &lt;level&gt;0&lt;/level&gt;
375       &lt;/logging&gt;
376    &lt;/gnucomo&gt;
377
378 </verbatim>
379
380 <para>
381 At the root of the tree is an XML element, called <code>gnucomo</code>.
382 The direct children of the root element in the example above are
383 <code>database</code> and <code>logging</code>.
384 These are the 'sections', corresponding to different aspects of the Gnucomo
385 system.
386 As you may have guessed, the <code>database</code> section holds information
387 we need to access the Gnucomo database on the PostgreSQL server and the
388 <code>logging</code> section specifies how much logging we want the
389 Gnucomo applications to generate and where we want that information to go.
390 </para>
391 <para>
392 Here is a full list of the parameters that are used by Gnucomo, subdivided
393 in their various sections:
394 </para>
395 <itemize>
396
397   <item>
398   <strong>database</strong>
399   <para>
400   All parameters that provide Gnucomo applications access to the database.
401   </para>
402   <description>
403     <item tag='type'>
404     The type of the database server. Currently, only PostgreSQL is supported.
405     </item>
406     <item tag='host'>
407     The hostname of the system on which the database server runs.
408     </item>
409     <item tag='port'>
410     The TCP port used by the database server.
411     </item>
412     <item tag='name'>
413     The name of the database to use for Gnucomo.
414     </item>
415     <item tag='user'>
416     The user name with which to log in on the database server.
417     </item>
418     <item tag='password'>
419     The password used for logging in to the database server.
420     </item>
421   </description>
422   </item>
423
424   <item>
425   <strong>logging</strong>
426   <para>
427   The amount of logging generated by Gnucomo applications and where to send it.
428   </para>
429   <description>
430     <item tag='method'>
431     The method for sending log information.
432     </item>
433     <item tag='destination'>
434     Where the logging information is sent.
435     </item>
436     <item tag='level'>
437     Choose a higher level for more information.
438     </item>
439   </description>
440   </item>
441
442   <item>
443   <strong>logfile</strong>
444   <para>
445   Primarily used by <emph>logrunner</emph>.
446   A list of files that are scanned for system logging that in sent to the Gnucomo server.
447   There can be more than one <strong>logfile</strong> element in a Gnucomo configuration file.
448   </para>
449   <description>
450     <item tag='name'>
451     Name of the file to scan for logging, e.g. <code>/var/log/messages</code>.
452     </item>
453     <item tag='type'>
454     The type of the logging information.
455     Types supported by Gnucomo are <code>system log</code>,
456     <code>apache access log</code> and <code>apache error log</code>.
457     </item>
458     <item tag='fromhost'>
459     Hostname (not a FQDN) of the system for which the log entries are sent.
460     Only log entries that originate from this host are sent to the Gnucomo server.
461     This option applies to system log files that may have log entries for several hosts,
462     in case the system acts as a syslog server.
463     </item>
464     <item tag='filter'>
465     A regular expression to filter out log entries before sending to the Gnucomo server.
466     There may be several <strong>filter</strong> elements in a single
467     <strong>logfile</strong> element.
468     </item>
469   </description>
470   </item>
471
472 </itemize>
473 </section>
474
475 <section>
476 <heading>Getting the web interface up and running</heading>
477 <para>
478 Your primary view onto Gnucomo is through the web interface.
479 Gnucomo uses a web server, e.g. Apache, with PHP scripts to implement
480 its user inetrface
481 At the present, the web interface is the only way to manage the
482 information in the Gnucomo database and view the results that
483 Gnucomo produces.
484 </para>
485 <para>
486 To be able to use the web interface, you need to copy the PHP
487 scripts from the <code>src/web</code> and <code>src/phpclasses</code>
488 directories into a directory accessible through the web server.
489 On most Red Hat Linux systems, this is usually in
490 <code>/var/www/html</code>.
491 One way to accomplish this is to create a subdirectory <code>gnucomo</code> under
492 the Document Root of the webserver.
493 The main gnucomo scripts go into this directory and the PHP class library can be copied
494 either in a subdirectory <code>classes</code> or <code>../phpclasses</code>.
495 Here's an example installation:
496 </para>
497 <verbatim>
498   [gnucomo] # mkdir $DocumentRoot/gnucomo
499   [gnucomo] # cp src/web/* $DocumentRoot/gnucomo
500   [gnucomo] # cp -r src/phpclasses $DocumentRoot
501 </verbatim>
502
503 </section>
504
505 <section>
506 <heading>And now...</heading>
507 <para>
508 If you like GnuCoMo [TODO]
509 Report success under Non-Linux [TODO]
510 </para>
511 </section>
512 </chapter>
513
514 <chapter>
515 <heading>Using Gnucomo</heading>
516
517 <para>
518 Once you have the database and the web interface set up, Gnucomo is almost
519 ready to go.
520 To put Gnucomo to work, you need to enter at least one object into the database
521 and create your methods to feed information to gnucomo.
522 </para>
523
524 <section>
525 <heading>The initial entries</heading>
526
527 <para>
528 Gnucomo maintains information about monitored systems such as servers,
529 work stations, switches and that sort of thing.
530 In Gnucomo, these are called <emph>objects</emph>.
531 The <emph>objects</emph> are distinguished by their name, usually
532 a hostname in your network. Or, better still, a fully qualified name
533 on the internet. 
534 You can use the web interface to create an <emph>object</emph> by logging
535 in and selecting the picture that looks like a computer cabinet
536 in the button bar at the top.
537 Enter the object's name, for example <code>server.gnucomo.org</code>,
538 and click the <strong>Create</strong> button.
539 </para>
540
541 </section>
542
543 <section>
544 <heading>Feeding log files</heading>
545
546 <para>
547 Once an object is known by Gnucomo, i.e. the object's name is stored in the
548 database, you can start to fill the database with log entries.
549 Log entries are stored by a variety of programs into one or more log
550 files on the object's harddisk.
551 For example, system messages on most Linux distributions are put
552 in a file called <code>/var/log/messages</code>.
553 There are several ways to transfer the contents of a log file into the
554 Gnucomo database, each of which involves <code>gcm_input</code>.
555 <code>Gcm_input</code> is the Gnucomo application that reads various kinds
556 of raw input and tries to scan for as much information as possible.
557 The usefull information that is extracted from the input is stored
558 into the Gnucomo database.
559 </para>
560
561 <para>
562 The most direct way to invoke <code>gcm_input</code> maually and read
563 the log file through its standard input:
564 </para>
565 <verbatim>
566    gcm_input -h server.gnucomo.org &lt;/var/log/messages
567 </verbatim>
568 <para>
569 You'll have to explicitly specify the hostname of the object because
570 there is no way for <code>gcm_input</code> to know where the log
571 file comes from.
572 Take care not to feed the same log file another time through
573 <code>gcm_input</code>.
574 This will lead to duplicate log entries in the Gnucomo database.
575 </para>
576 <para>
577 Feeding information into the Gnucomo database can also be done through
578 a mail server, such as sendmail or postfix.
579 Create a mail alias that invokes <code>gcm_input</code> as a mailer program.
580 For example:
581 </para>
582 <verbatim>
583    gnucomo:        "|gcm_input"
584 </verbatim>
585 <para>
586 With such an email alias, Gnucomo clients can simply send log files and
587 other reports to this email address:
588 </para>
589 <verbatim>
590    mail gnucomo@server.gnucomo.org &lt;/var/log/messages
591 </verbatim>
592 <para>
593 The third method to feed log files into the Gnucomo database is by
594 using <code>logrunner</code>.
595 Where the previous methods can only feed complete logfiles as a whole,
596 logrunner can feed partial logiles to the Gnucomo server.
597 Logrunner keeps track of the growth of a logfile and converts the newly
598 added log entries into an XML message suitable for gcm_input.
599 A practical way to deploy logrunner is:
600 </para>
601 <verbatim>
602   /usr/local/bin/logrunner -1 | mail gnucomo@gnucomo.server
603 </verbatim>
604 <para>
605 Note the '-1' option for logrunner. This option is needed to keep
606 logrunner from generating multiple XML documents in one output stream.
607 Which logfiles are scanned by logrunner is specified in the Gnucomo
608 <ref to='configuration'>configuration file</ref>.
609 </para>
610 </section>
611
612 <section>
613 <heading>Viewing results</heading>
614 <para>
615 Use the web interface to review log entries, notifications and parameters.
616 The <emph>Objects</emph> page shows statistics about the data that is collected
617 for each monitored object.
618 Clicking on the links in the statistics will display the specific data for that object.
619 The icon of each object takes you to a form for editing information about that object,
620 such as an identification code, physical location and services used by that object.
621 </para>
622
623 <para>
624 After feeding the log entries of monitored objects to the Gnucomo server,
625 these log entries can be analyzed by the Gnucomo analyzer daemon, <code>gcm_daemon</code>.
626 The present version of Gnucomo does not yet support the operation of a real
627 daemon, so you will have to start <code>gcm_daemon</code> explicitly.
628 This performs a number of analyses on the log entries and updates the statistics
629 for each object.
630 When the <code>gcm_daemon</code> finds something out of the ordinary, it will
631 create a <emph>Notification</emph>.
632 Notifications are created to alert you to the fact that something may be wrong
633 with that object.
634 </para>
635 <para>
636 The checks made by Gnucomo are related to services that run on a monitored object.
637 A few checks are predefined in Gnucomo.
638 You can add more checks to tailor your situation through the <emph>Services</emph> page.
639 Click on the icon of a specific service to edit the list of checks that are
640 performed for log entries generated by that service.
641 Each check consists of a <emph>pattern</emph> in the form of a regular expression
642 and an action.
643 For example, the following pattern matches a log entry from postfix which states that
644 outgoing mail is delivered:
645 </para>
646 <example>
647   to=.+, relay=.+, delay=[0-9]{1,2}, status=sent \(250 .+\)
648 </example>
649 <para>
650 The action is performed when the regular expression matches with a log entry.
651 Each check is tagged with a rank number for defining the order in which the
652 checks are applied.
653 The first pattern that matches is used to perform the action.
654 The very last check is a 'catch all' pattern, predefined in the Gnucomo database.
655 When a pattern matches, one of four actions is executed:
656 </para>
657 <description>
658 <item tag='ignore'>
659 Simply ignore this log entry.
660 </item>
661 <item tag='notify'>
662 Create a notification.
663 The <emph>Issue</emph> for the notification is stated in the <emph>Argument</emph> field.
664 </item>
665 <item tag='abuse'>
666 Add one to the number of abuses detected for the IP address or hostname that is mentioned in
667 the log file.
668 The argument for this action is almost always "$1", which is the first part of the pattern
669 between parenthesis.
670 Note that this requires a special form of regular expression in the pattern which will select
671 certain parts as a sub expression.
672 </item>
673 <item tag='forgive'>
674 Remove one abuse for the IP address of hostname in the argument.
675 </item>
676 </description>
677 <para>
678 A notification is always created with a specific <emph>Issue</emph> which states
679 what Gnucomo thinks is going wrong.
680 A number of issues are predefined in the Gnucomo database.
681 You can create your own issues and have Gnucomo generate notifications with these
682 issues on the Issues page.
683 </para>
684 </section>
685
686 <section>
687 <heading>Abuse and intrusion detection</heading>
688 <para>
689 Gnucomo maintains a list of IP addresses that have committed some kind of abuse.
690 This can be attempts to send spam, attempts to intrude a system from the internet
691 or any other kind of malicious action.
692 These abuses are detected by creating the proper patterns in checks for log entries
693 as discussed in the previous section.
694 Each time an abuse is detected in the log, one abuse is added to the record for
695 that <emph>Object</emph> and IP address.
696 A reference to the log entry in which the abuse was detected is also maintained.
697 When the number of abuses for a certain IP address exceeds the limit (32 in this
698 version of Gnucomo), the status for the IP address is set to 'dropped'.
699 You can review the list of abusing IP addresses by clicking on the 'Abuse list'
700 in the <emph>Objects</emph> page.
701 </para>
702 <para>
703 The most useful application of the abuse list is to maintain a firewall
704 and block all IP addresses that have the 'dropped' status.
705 A short shell script will do this job:
706 </para>
707 <verbatim>
708 #!/bin/sh
709 #
710 #  Create a firewall script from the gnucomo abuses table
711 #
712
713 psql -h samos -t gnucomo arjen -c "select source from object_abuse
714          where status='dropped' and objectid=$1"|grep -v '^$'&gt;/tmp/gnucomo-abuses
715
716 while read ADDRESS
717 do
718    echo iptables -I INPUT -s $ADDRESS    -j DROP
719 done &lt; /tmp/gnucomo-abuses
720 </verbatim>
721
722 </section>
723
724 </chapter>
725
726 <chapter>
727 <heading>Managing system parameters</heading>
728
729 <para>
730 Besides log entries which represent the transient events that occur in
731 an object, Gnucomo also maintains the state of the object.
732 The state of an object is defined by the set of parameters and
733 their values.
734 Examples of parameters are the file systems, users, processes, installed
735 packages, and so on.
736 By managing those parameters with Gnucomo, you can hold a firm grip on
737 the state of your systems.
738 Especially on large sites with many workstations, servers, switches
739 and other objects, managing the state of all those systems is not
740 a trivial task.
741 The following sections explain how Gnucomo can help.
742 </para>
743
744 <section>
745 <heading>Installed packages</heading>
746
747 <para>
748 Gnucomo can maintain a list of all packages installed on an object.
749 This list is stored in the database as parameters of class
750 <emph>package</emph>.
751 Each <emph>package</emph> parameter has one property: the version number
752 of the package.
753 Gnucomo keeps an historical record of the version number for each package,
754 so you will know when the version of a package changes.
755 Furthermore, you can compare the installed packages of two objects, so
756 you can easily find the differences between two installations.
757 </para>
758
759 <para>
760 To maintain the installed packages of an object, all you need is to
761 feed a complete list into the Gnucomo database through <emph>gcm_input</emph>.
762 The package list is a text file with a package on each line of the form
763 <code>packagename-version</code>.
764 Not the dash ('-') between the name and the version.
765 On many Linux systems that use the RedHat Package Manager (RPM), such
766 a list is easily obtained and fed into <emph>gcm_input</emph>:
767 </para>
768
769 <verbatim>
770    rpm -qa | gcm_input -h example.gnucomo.org
771 </verbatim>
772
773 <para>
774 You will have to repeat this procedure at regular intervals.
775 Each time you feed a new package list to Gnucomo, Gnucomo will
776 compare the new list with the package parameters in the database
777 and notify you of any changes.
778 </para>
779 <para>
780 For keeping your systems up-to-date, it is often convenient to maintain
781 a repository of the most recent packages.
782 Gnucomo can help you with this task.
783 To enter the list of packages and updates from a distribution into the
784 Gnucomo database, you can create a virtual <emph>object</emph> and
785 create the <emph>package</emph> parameters for this object.
786 For example, to maintain a list of RPMs for RedHat Linux 7.3, create an
787 object (using the web interface) with the name <code>redhat-7.3</code>.
788 Using this object, enter the first batch of package parameters from a directory
789 listing of the CD-ROM.
790 However, you can not use the output from <strong>ls</strong> directly as
791 input for <strong>gcm_input</strong>.
792 You need to strip off two siffixes off the filenames to make it look like
793 a <code>rpm -qa</code> output.
794 The following script will do just that:
795 </para>
796
797 <verbatim>
798
799 #!/bin/sh
800 #
801 #   Turn an 'ls' listing of RPM files into an 'rpm -qa' listing
802 #   Reads a list of filenames, possibly preceeded by a directory and
803 #   strips the directory path from the beginning and the two suffices
804 #   from the end of each filename. For example, the name
805 #   "/mnt/cdrom/RedHat/RPMS/kernel-2.4.20-13.7.i686.rpm" gets turned
806 #   into a simple "kernel-2.4.20-13.7".
807
808 while read filename
809 do
810    case $filename in
811    *.src.rpm)
812    ;;
813
814    *)
815       filename=`basename $filename .rpm`
816       case $filename in
817       *.athlon)
818          rpm=`basename $filename .athlon`
819       ;; 
820       *.i386)
821          rpm=`basename $filename .i386`
822       ;; 
823       *.i486)
824          rpm=`basename $filename .i486`
825       ;; 
826       *.i586)
827          rpm=`basename $filename .i586`
828       ;; 
829       *.i686)
830          rpm=`basename $filename .i686`
831       ;; 
832       *.noarch)
833          rpm=`basename $filename .noarch`
834       ;; 
835       esac
836       echo $rpm
837    ;;
838    esac
839 done
840
841 </verbatim>
842
843 <para>
844 Suppose this script is stored as <code>ls-rpm</code>, you can apply it
845 like this:
846 </para>
847
848 <verbatim>
849    ls /mnt/cdrom/RedHat/RPMS | ls-rpm | sort | uniq | gcm_input -h redhat-7.3
850 </verbatim>
851
852 <para>
853 You can repeat this command to enter additional packages into the database.
854 For example, to add packages from other CD-ROMs or from a directory where
855 you keep downloaded updates.
856 Remember, however, to use the <strong>-i</strong> option for "incremental"
857 with gcm_input.
858 Without this option, gcm_input will regard the list of packages as a <emph>full</emph>
859 list and remove any parameters that are not present in the new list.
860 </para>
861 <para>
862 With a list of available packages for a specific distribution in the Gnucomo
863 database, along with the list of packages installed on your systems, you
864 can easily obtain an overview of which packages you need to update.
865 To make this overview, use the web interface to compare the packages
866 on an object with the packages on the virtual object.
867 </para>
868 </section>
869
870 </chapter>
871
872 </book>
873 </doc>