Current time: 11-28-2024, 06:07 AM Hello There, Guest! (LoginRegister)


Post Reply 
vhost monitoring
Author Message
BeNe Offline
Moderator
*****
Moderators

Posts: 5,899
Joined: Jan 2007
Reputation: 68
Post: #54
RE: vhost monitoring
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
10-18-2007 07:50 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
vhost monitoring - fulltilt - 10-12-2007, 08:48 PM
RE: vhost monitoring - BeNe - 10-12-2007, 09:31 PM
RE: vhost monitoring - fulltilt - 10-12-2007, 09:37 PM
RE: vhost monitoring - BeNe - 10-13-2007, 12:38 AM
RE: vhost monitoring - fulltilt - 10-17-2007, 03:33 AM
RE: vhost monitoring - BeNe - 10-17-2007, 04:40 AM
RE: vhost monitoring - fulltilt - 10-17-2007, 04:50 AM
RE: vhost monitoring - BeNe - 10-17-2007, 04:56 AM
RE: vhost monitoring - fulltilt - 10-17-2007, 05:04 PM
RE: vhost monitoring - BeNe - 10-17-2007, 05:20 PM
RE: vhost monitoring - fulltilt - 10-17-2007, 05:45 PM
RE: vhost monitoring - BeNe - 10-17-2007, 05:34 PM
RE: vhost monitoring - BeNe - 10-17-2007, 06:06 PM
RE: vhost monitoring - fulltilt - 10-17-2007, 06:21 PM
RE: vhost monitoring - fulltilt - 10-17-2007, 09:26 PM
RE: vhost monitoring - BeNe - 10-17-2007, 10:45 PM
RE: vhost monitoring - BeNe - 10-17-2007, 11:21 PM
RE: vhost monitoring - fulltilt - 10-17-2007, 11:30 PM
RE: vhost monitoring - BeNe - 10-17-2007, 11:23 PM
RE: vhost monitoring - joximu - 10-17-2007, 11:28 PM
RE: vhost monitoring - BeNe - 10-18-2007, 12:00 AM
RE: vhost monitoring - BeNe - 10-18-2007, 12:01 AM
RE: vhost monitoring - fulltilt - 10-18-2007, 12:09 AM
RE: vhost monitoring - BeNe - 10-18-2007, 12:12 AM
RE: vhost monitoring - fulltilt - 10-18-2007, 12:23 AM
RE: vhost monitoring - fulltilt - 10-18-2007, 12:28 AM
RE: vhost monitoring - BeNe - 10-18-2007, 12:36 AM
RE: vhost monitoring - fulltilt - 10-18-2007, 12:42 AM
RE: vhost monitoring - BeNe - 10-18-2007, 12:44 AM
RE: vhost monitoring - fulltilt - 10-18-2007, 12:47 AM
RE: vhost monitoring - BeNe - 10-18-2007, 12:51 AM
RE: vhost monitoring - BeNe - 10-18-2007, 12:52 AM
RE: vhost monitoring - fulltilt - 10-18-2007, 01:18 AM
RE: vhost monitoring - BeNe - 10-18-2007, 01:35 AM
RE: vhost monitoring - fulltilt - 10-18-2007, 02:52 AM
RE: vhost monitoring - fulltilt - 10-18-2007, 01:42 AM
RE: vhost monitoring - Slowman - 10-18-2007, 02:22 AM
RE: vhost monitoring - BeNe - 10-18-2007, 03:58 AM
RE: vhost monitoring - fulltilt - 10-18-2007, 04:45 AM
RE: vhost monitoring - BeNe - 10-18-2007, 05:11 AM
RE: vhost monitoring - fulltilt - 10-18-2007, 05:20 AM
RE: vhost monitoring - BeNe - 10-18-2007, 05:14 AM
RE: vhost monitoring - BeNe - 10-18-2007, 05:26 AM
RE: vhost monitoring - fulltilt - 10-18-2007, 05:28 AM
RE: vhost monitoring - BeNe - 10-18-2007, 05:39 AM
RE: vhost monitoring - fulltilt - 10-18-2007, 03:40 PM
RE: vhost monitoring - fulltilt - 10-18-2007, 05:38 PM
RE: vhost monitoring - BeNe - 10-18-2007, 05:53 PM
RE: vhost monitoring - fulltilt - 10-18-2007, 06:25 PM
RE: vhost monitoring - BeNe - 10-18-2007, 06:27 PM
RE: vhost monitoring - fulltilt - 10-18-2007, 06:44 PM
RE: vhost monitoring - fulltilt - 10-18-2007, 06:46 PM
RE: vhost monitoring - BeNe - 10-18-2007, 06:50 PM
RE: vhost monitoring - BeNe - 10-18-2007 07:50 PM
RE: vhost monitoring - fulltilt - 10-18-2007, 07:59 PM
RE: vhost monitoring - BeNe - 10-18-2007, 10:12 PM
RE: vhost monitoring - fulltilt - 10-18-2007, 10:20 PM
RE: vhost monitoring - fulltilt - 10-18-2007, 10:30 PM
RE: vhost monitoring - BeNe - 10-18-2007, 10:41 PM
RE: vhost monitoring - fulltilt - 10-18-2007, 10:57 PM
RE: vhost monitoring - BeNe - 10-19-2007, 12:44 AM
RE: vhost monitoring - fulltilt - 10-19-2007, 01:12 AM
RE: vhost monitoring - BeNe - 10-19-2007, 01:37 AM
RE: vhost monitoring - hbaes - 11-29-2007, 09:40 PM
RE: vhost monitoring - BeNe - 11-29-2007, 10:03 PM
RE: vhost monitoring - hbaes - 11-30-2007, 12:10 AM
RE: vhost monitoring - Galeon - 01-05-2008, 01:39 AM
RE: vhost monitoring - BeNe - 01-05-2008, 01:48 AM
RE: vhost monitoring - Galeon - 01-05-2008, 01:58 AM
RE: vhost monitoring - Galeon - 01-09-2008, 09:05 AM
RE: vhost monitoring - fulltilt - 01-09-2008, 05:34 PM

Forum Jump:


User(s) browsing this thread: 2 Guest(s)