Ich will das jetzt nochmals alles zusammen fassen.
Wenn es läuft werde ich es ins Wiki übernehmen.
Pakete besorgen / Module aktivieren / Apache2 neustarten
Code:
apt-get install apache2-dev libcrypt-ssleay-perl libwww-perl
a2enmod info
a2enmod status
/etc/init.d/apache2 force-reload
 
mod_watch besorgen / entpacken / bauen
Code:
wget http://forums.cacti.net/download.php?id=8888
mv download.php\?id\=8888 mod_watch-4.3_apache22_mod.tar.gz
tar -xvzf mod_watch-4.3_apache22_mod.tar.gz
cd mod_watch-4.3_apache22_mod
vi Makefile.dso
 
Den Inhalt für Debian Etch so anpassen
Code:
# The location of apxs utility.
#
#APXS=/home/apache2/bin/apxs
APXS=/usr/bin/apxs2
#
# The location of apachectl utility to stop/start/restart targets.
#
APACHECTL=apache2ctl
#
# Where the scripts should live
#
SCRIPTDIR=/usr/local/sbin
#
# Where to store the weenie files.
#
STATEDIR=/usr/lib/apache2/modules/mod_watch/
 
modul bauen
Code:
make -f Makefile.dso build
make -f Makefile.dso install
 
Module in Apache laden
Code:
vi /etc/apache2/httpd.conf
 
und das hier einfügen
Code:
LoadModule watch_module /usr/lib/apache2/modules/mod_watch.so
 
Apache config anpassen, der erste Teil sollte schon so drin stehen weil die module vorher eingebunden wurden, wenn nicht dann bitte einfügen
Code:
<IfModule mod_status.c>
     #Allow server status reports generated by mod_status,
     #with the URL of http://servername/server-status
     #Change the ".example.com" to match your domain to enable.
    <Location /server-status>
        SetHandler server-status
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1
    </Location>
</IfModule>
<IfModule mod_info.c>
     #Allow remote server configuration reports, with the URL of
     # http://servername/server-info (requires that mod_info.c be loaded).
     #Change the ".example.com" to match your domain to enable.
    <Location /server-info>
        SetHandler server-info
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1
    </Location>
</IfModule>
 
und das hier (auch) noch hinzufügen:
Code:
<IfModule mod_watch.c>
    # Allows the URL used to query virtual host data:
    #
    # http://www.snert.com/watch-info
    #
    <Location /watch-info>
    SetHandler watch-info
    Order allow,deny
    Allow from 127.0.0.1
    </Location>
    # Intended for debugging and analysis of shared memory
    # hash table and weenie files:
    #
    #http://127.0.0.1/watch-table
    #
    <Location /watch-table>
    SetHandler watch-table
    Order allow,deny
    Allow from 127.0.0.1
    </Location>
    <Location /watch-list>
    SetHandler watch-list
    Order allow,deny
    Allow from 127.0.0.1
    </Location>
</IfModule>
 
apache neustarten / mod_watch.c kopieren
Code:
/etc/init.d/apache2 restart
cd /root/mod_watch-4.3_apache22_mod
cp mod_watch.c /usr/share/munin/plugins/
chmod 777 /usr/share/munin/plugins/mod_watch.c
 
apache_watch_ erstellen
Code:
vi /usr/share/munin/plugins/apache_watch_
 
Folgender inhalt muss da rein:
Code:
#!/usr/bin/perl
#
# Parameters supported:
#
#     config
#     autoconf
#
# Configurable variables
#
#     url      - Override default status-url
#
# Must be symlinked to what the graph should monitor. Run with --suggest
# to see valid targets - or just run munin-node-configure --shell
#
# Written by Bj�rn Ruberg 2006-2007
#
# Magic markers:
#%# family=auto
#%# capabilities=autoconf suggest
my $ret = undef;
if (!eval "require LWP::UserAgent;") {
  $ret = "LWP::UserAgent not found";
}
# watch-list exists on localhost
# watch-info does not
my %plugs = (
         'bytes'     => 'Input/output (bytes)',
         'requests'  => 'Requests',
         'documents' => 'Documents served',
            );
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://localhost:%d/watch-list";
my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (80);
my $type = "throughput";
if (exists $ARGV[0] and $ARGV[0] eq "autoconf") {
  if ($ret) {
    print "no ($ret)\n";
    exit 1;
  }
  my $ua = LWP::UserAgent->new (timeout => 30);
  my @badports;
    
  foreach my $port (@PORTS) {
    my $url = sprintf $URL, $port;
    my $response = $ua->request (HTTP::Request->new('GET', $url));
    push @badports, $port unless $response->is_success;
  }
    
  if (@badports) {
    print "no (no mod_watch exists on ports @badports)\n";
    exit 1;
  } else {
    print "yes\n";
    exit 0;
  }
}
if (exists $ARGV[0] and $ARGV[0] eq "suggest") {
  while (my ($key, undef) = each %plugs) {
    print "$key\n";
  }
  exit 0;
}
my @servers = ();
my @data;
foreach my $port (@PORTS) {
  my $ua = LWP::UserAgent->new (timeout => 30);
  my $url = sprintf $URL, $port;
  my $response = $ua->request (HTTP::Request->new ('GET', $url));
  foreach my $string (split (/\n/, $response->content)) {
    my ($server, undef, $ifInOctets, $ifOutOctets, $ifRequests,
        $ifDocuments) = split (/\s/, $string, 6);
    push @servers, $server unless $server eq "SERVER";
    push @data, "$server $ifInOctets $ifOutOctets $ifRequests $ifDocuments" 
      unless $server eq "SERVER";
  }
}
# From here and out, the plugin must be run with a symlinked service.
my $check = join ("|", keys %plugs);
die ("Plugin must be symlinked to aspect to be monitored")
  unless $0 =~ /\_($check)$/;
my $action = $1;
if (exists $ARGV[0] and $ARGV[0] eq "config") {
  print "graph_title Apache $plugs{$action}\n";
  print "graph_args --base 1000 -l 0\n";
  print "graph_category apache\n";
  print "graph_vlabel activity\n";
  my $i = 0;
  foreach my $server (sort (@servers)) {
    (my $txtserver = $server) =~ s/(-|\.)/\_/g;
    my $draw = ($i==0) ? 'AREA' : 'STACK';
    if ($action eq "bytes") {
      print "${txtserver}.label $server\n";
      print "${txtserver}.draw $draw\n";
      print "${txtserver}.type COUNTER\n";
    } else {
      print "${txtserver}.label $server\n";
      print "${txtserver}.draw $draw\n";
      print "${txtserver}.type COUNTER\n";
    }
    $i++;
  }
  exit 0;
}
foreach my $string (sort (@data)) {
  my ($server, $ifInOctets, $ifOutOctets, $ifRequests, $ifDocuments) =
    split (/\s/, $string);
  (my $txtserver = $server) =~ s/(-|\.)/\_/g;
  if ($action eq "documents") {
    print "${txtserver}.value $ifDocuments\n";
  } elsif ($action eq "requests") {
    print "${txtserver}.value $ifRequests\n";
  } elsif ($action eq "bytes") {
    print "${txtserver}.value " . ($ifInOctets + $ifOutOctets) . "\n";
  }
}
 
Plugin in Munin bekannt machen
Code:
cd /etc/munin/plugins
ln -sf /usr/share/munin/plugins/apache_watch_ apache_watch_
ln -sf /usr/share/munin/plugins/apache_watch_ apache_watch_bytes 
ln -sf /usr/share/munin/plugins/apache_watch_ apache_watch_documents
ln -sf /usr/share/munin/plugins/apache_watch_ apache_watch_requests
/etc/init.d/munin-node restart
 
Testen:
Code:
cd /usr/local/sbin/
./mod_watch.pl -f ifRequests,ifDocuments http://127.0.0.1/watch-list/
 
Es sollte eine Ausgabe erfolgen
Code:
2294
165
1:20.25
SERVER
 
Plugin configurieren und links testen:
Code:
cd /usr/share/munin/plugins/
./apache_watch_ autoconf
./apache_watch_ suggest
munin-run apache_watch_bytes
munin-run apache_watch_documents
munin-run apache_watch_requests
 
Das ist jetzt einfach mal quick & dirty sollte aber gehen.
Greez BeNe