ispCP - Board - Support
vhost monitoring - Printable Version

+- ispCP - Board - Support (http://www.isp-control.net/forum)
+-- Forum: ispCP Omega International Area (/forum-22.html)
+--- Forum: German Corner (/forum-26.html)
+--- Thread: vhost monitoring (/thread-1511.html)

Pages: 1 2 3 4 5 6 7 8


RE: vhost monitoring - fulltilt - 10-18-2007 06:44 PM

Jaa sieht ganz gut aus ...
Bei mir ist nach den Logs alles O.K. es werden aber keine .png Bildchen erzeugt ...

Was muss ich tun?
Könnte auch an meiner hosts config liegen ...


BeNe Wrote:Ich glaube ich habe es --> http://ispcpdemo.homeip.net/munin/localdomain/localhost.localdomain.html#Apache

Schau es Dir mal an Smile

Greez BeNe



RE: vhost monitoring - fulltilt - 10-18-2007 06:46 PM

mein Post ist auch weg

BeNe Wrote:Ich glaube ich habe es --> http://ispcpdemo.homeip.net/munin/localdomain/localhost.localdomain.html#Apache

Schau es Dir mal an Smile

Greez BeNe



RE: vhost monitoring - BeNe - 10-18-2007 06:50 PM

*damn* Es geht tatsächlich... [Image: a040.gif]

Ja, jetzt muss ich noch versuchen herauszufinden was ich genau wo geändert habe.
Ich schreibe nochmals alles zusammen und poste es dann hier!

Greez BeNe


RE: vhost monitoring - BeNe - 10-18-2007 07:50 PM

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


RE: vhost monitoring - fulltilt - 10-18-2007 07:59 PM

Hi BeNe,

werde ich gleich mal durchtesten.
Irgendwo habe ich noch etwas in der apache_watch_ oder mod_watch.c gesehen wg. ddos Prevention ...
Das sollte man vieleicht noch checken.


RE: vhost monitoring - BeNe - 10-18-2007 10:12 PM

Habe jetzt auf die schnelle nix wegen DDos gefunden Rolleyes
Jetzt sind ein paar Domains drin, habe einfach mal welche auf das Demo gelegt und es schein wirklich gut zu funktionieren.
Jeder vHost ist eingetragen worden.

[Image: vhostbx5.th.jpg]

Greez BeNe


RE: vhost monitoring - fulltilt - 10-18-2007 10:20 PM

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.



RE: vhost monitoring - fulltilt - 10-18-2007 10:30 PM

Dauert ein wenig bis alle v-hosts erscheinen ... habs mal auf einem echten Server getestet werden jetzt 30 von 60 Webs angezeigt ... wächst noch.


RE: vhost monitoring - BeNe - 10-18-2007 10:41 PM

Hoffe das es noch wächst...
Ok - dann haben wir es ja doch Geschafft [Image: e016.gif]
Ich werde das so ins Wiki aufnehmen.
Habe auch schon wieder neue Sachen im Kopf, habe das Plugin für ProFTPD,Postfix,AMaVIS,Dovecot gesehen Big Grin Werde ich nach und nach mal testen...

Danke für deine Zusammenarbeit!

Greez BeNe


RE: vhost monitoring - fulltilt - 10-18-2007 10:57 PM

Hi BeNe,

Bedanken muss ich mich wohl eher bei Dir Big Grin

Ist wirklich sehr hilfreich das Teil, auch gerade wenn von einem löchrigen Script in einem Web Attacken gefahren werden.
So hat man immer alles im Blick.

Es gibt auch noch ein Plugin für Fail2Ban ... ist sicher auch interessant.

BeNe Wrote:Hoffe das es noch wächst...
Ok - dann haben wir es ja doch Geschafft [Image: e016.gif]
Ich werde das so ins Wiki aufnehmen.
Habe auch schon wieder neue Sachen im Kopf, habe das Plugin für ProFTPD,Postfix,AMaVIS,Dovecot gesehen Big Grin Werde ich nach und nach mal testen...

Danke für deine Zusammenarbeit!

Greez BeNe