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


Post Reply 
vhost monitoring
Author Message
fulltilt Offline
Member
***

Posts: 1,225
Joined: Apr 2007
Reputation: 5
Post: #57
RE: vhost monitoring
Ja klappt alles prima ...
Bei mir werden momentan nicht alle v-hosts angezeigt ...
Da liegt wohl am Traffic des/ der Webs.

Habe das Teil nochmal etwas überarbeitet:

Code:
apt-get install apache2-dev libcrypt-ssleay-perl libwww-perl
a2enmod info
a2enmod status
/etc/init.d/apache2 force-reload

####################################################
oder bei apache prefork
apt-get install apache2-prefork-dev libcrypt-ssleay-perl libwww-perl
a2enmod info
a2enmod status
/etc/init.d/apache2 force-reload
###################################################
Code:
cd /root
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
nano Makefile.dso
Code:
anpassen der makefile.dso
(bei Debian 4.0)

# 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/

#
# Define to use unsigned long long counters.
#
#BIG=-DUSE_OCTET_COUNTER_64

#
# Extras
#
DEF=$(BIG) -DSTATEDIR='\"$(STATEDIR)\"'
INC=
LIB=

cd /root/mod_watch-4.3_apache22_mod
Code:
make -f Makefile.dso build
make -f Makefile.dso install
Code:
nano /etc/apache2/httpd.conf
einfügen falls nicht schon vorhanden:

LoadModule watch_module /usr/lib/apache2/modules/mod_watch.so
Code:
apache2.conf > ändern
nano /etc/apache2/apache2.conf

<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.
    #
    ExtendedStatus On
    <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>


<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>

Code:
cd /root/mod_watch-4.3_apache22_mod
cp mod_watch.c /usr/share/munin/plugins/
chmod 755 /usr/share/munin/plugins/mod_watch.c

/etc/init.d/apache2 force-reload
Code:
nano /usr/share/munin/plugins/apache_watch_
einfügen >

#!/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";
  }
}
Code:
dann:
chmod 755 /usr/share/munin/plugins/apache_watch_

ln -s /usr/share/munin/plugins/apache_watch_ /etc/munin/plugins/apache_watch_bytes
ln -s /usr/share/munin/plugins/apache_watch_ /etc/munin/plugins/apache_watch_documents
ln -s /usr/share/munin/plugins/apache_watch_ /etc/munin/plugins/apache_watch_requests

cd /usr/share/munin/plugins/
./apache_watch_ autoconf

/etc/init.d/apache2 restart
/etc/init.d/munin-node restart
Code:
Test:
cd /usr/local/sbin/
./mod_watch.pl -f ifRequests,ifDocuments http://127.0.0.1/watch-list/
69
13
6.10
SERVER

cd /usr/share/munin/plugins/
munin-run apache_watch_bytes config
munin-run apache_watch_documents config
munin-run apache_watch_requests config

Wenn keine Fehler auftauchen sollte alles O.K. sein.
(This post was last modified: 10-18-2007 10:31 PM by fulltilt.)
10-18-2007 10:20 PM
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: 3 Guest(s)