Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Tue May 21, 2019 8:48 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: mod_watch - virtual website statistics
PostPosted: Wed Aug 16, 2006 10:17 am 
Offline

Joined: Sun Aug 13, 2006 5:30 pm
Posts: 10
mod_watch/Cacti v0.9

- implemented by zman818 ([email protected])
- based on original work by Anthony Howe (snert.com)


mod_watch/Cacti (mwc) is a Cacti implementation of Anthony Howe's most excellent mod_watch module for Apache/MRTG. Mod_watch will watch and collect the bytes, requests, and documents in & out per virtual host, file owner, remote-ip address, directory or location, and the web server as a whole (configured through the use of httpd.conf directives).

A more detailed overview of mod_watch itself can be viewed at http://www.snert.com/Software/mod_watch/

The example below shows simple traffic statistics for 3 individual, virtual sites running under the same apache server. Other statistics are also available (hits, documents, etc). It's a simple adaptation of the stock bandwidth graph. Obviously such things as total traffic could be added to dress it up.

Please note that this is my first attempt at packaging and distributing a template. If I've borked it, I apologize in advance. :)


Attachments:
modwatch_cacti.zip [5.56 KiB]
Downloaded 2621 times
mod_watch.png
mod_watch.png [ 81.13 KiB | Viewed 53621 times ]
Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 12:31 pm 
Offline

Joined: Mon May 02, 2005 7:11 am
Posts: 26
Location: Dortmund, Germany
Hi!

Great script/module.
But unfortunately website of mod_watch is not available these days (no longer available?).

Does anyone know if the module (as RPM for Fedora Core or as Source) is available anywhere else?

Is there any other solution to graph the traffic for different virtual hosts?

Kind regards, Jens


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 11, 2007 2:12 pm 
Offline

Joined: Thu Jan 11, 2007 12:16 pm
Posts: 1
Yeah, I found the same problem with snert not serving up pretty much anything these days, for no apparent reason. Anyway, I found this version of mod_watch lurking around somewhere, YMMV though as I haven't been able to install it yet, since I don't want to recompile and apxs wasn't loaded originally on the server I'm testing it on. I'm building a new server this weekend that I'll try to build this module into, I'll let you know if that works.

Anyway, here it is, let me know if you get it working :)

Cameron
San Diego


Attachments:
File comment: mod_watch4.03, this one is for Apache2, I don't have the older version for Apache 1.3
mod_watch403.tgz [97.25 KiB]
Downloaded 2377 times
Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 6:58 am 
Offline

Joined: Wed Jan 17, 2007 3:57 am
Posts: 4
Does a similar template exist for IIS?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 19, 2007 7:44 am 
Offline

Joined: Thu Apr 19, 2007 7:37 am
Posts: 1
Corrected version of mod_watch_4.3 for Apache 2.2 (old sources contain deprecated macro & functions). Successfuly tested on Apache/2.2.4 (FreeBSD)


Attachments:
mod_watch-4.3_apache22_mod.tar.gz [95.74 KiB]
Downloaded 4263 times
Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 06, 2007 6:35 am 
Offline

Joined: Fri Jul 06, 2007 6:28 am
Posts: 13
Hi all,

I use mod_watch4.03 with apache 2.0 (on debian sarge) but /watch-list didn't show all virtual hosts.
Only 18 of 21 :-(
The missed three are equal the other vhosts entries (all are automatic generated out of a webfrontend).

_________________
Have a N.I.C.E. day!
Image
Real programmers don't comment their code - it was hard to write, it should be hard to understand.

Cacti 0.8.6i on Debian Etch


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 09, 2007 9:34 am 
Offline

Joined: Fri Jul 06, 2007 6:28 am
Posts: 13
Hmm .. still get some crazy results .. some vhosts are listed some not :-(
Moved now from apache2.0 to 2.2 (and mod watch 4.03 to 4.3).

Edit: Ok, now I got it .. It there is no bit of the vhost requestet it isn't in the watch-hash.

_________________
Have a N.I.C.E. day!
Image
Real programmers don't comment their code - it was hard to write, it should be hard to understand.

Cacti 0.8.6i on Debian Etch


Top
 Profile  
 
 Post subject: Missing vhosts
PostPosted: Tue May 05, 2009 6:55 pm 
Offline

Joined: Tue May 05, 2009 6:54 pm
Posts: 1
Indiana -

How did you fix your problem with missing vhosts? I have the same issue.


Top
 Profile  
 
 Post subject: Modified apache2mrtg.pl for includes in Apache2.x
PostPosted: Wed Feb 17, 2010 4:24 am 
Offline

Joined: Wed Feb 17, 2010 4:11 am
Posts: 2
Ok i hope this helps. Unlike normal Apache 2 my setup uses Includes to include Virtual Hosts for different domains. So the apache2mrtg.pl script that comes with mod_watch-4.3 did not work for me, it was just unable to find my virtual_hosts.

So modified the script to parse Includes.
NOTE: This is a quick and dirty modification but works for me.
I have also added few print statements commented out here to debug.

Code:
#!/usr/bin/perl
#
# apache2mrtg.pl
#
# Copyright 2001, 2003 by Anthony Howe.  All rights reserved.
#

# Where the scripts should live
$SCRIPTDIR = "/usr/local/sbin";

##########################################################################
#       Nothing to be configured below this point.                       #
##########################################################################
$AUTHOR = '[email protected]';
$VERSION = '2.0';


unless (@ARGV == 1) {
        print STDERR "usage: apache2mrtg.pl path/to/httpd.conf\n";
        exit 2;
}

%seen = ();

sub target {
        my $name = shift;

        if ($seen{$name}) {
                print STDERR "DUPLICATE entry \"$name\"\n";
                return;
        }

        $seen{$name} = 1;

        print <<EOT;
Title[$name]: $name Data Traffic
Target[$name]: `${SCRIPTDIR}/mod_watch.pl http://$name/watch-info`
MaxBytes[$name]: 1250000
PageTop[$name]: <h2><a href="http://$name/">$name</a> Data Traffic</h2>

EOT
}

#########################################################################

$x=0;
while (<ARGV>) {
        # Skip commented blocks
        next if m!\#.*</?virtualhost!i;

        if (m!<virtualhost\s!i .. m!</virtualhost>!i) {
                $name = $1 if m!ServerName\s+(\S+)!;
        }

        if (m!</virtualhost>!i) {
                target($name);
        }

#############################################################################
#     Added to make script compliant to httpd.conf that uses Includes to    #
#     include virtual hosts. For example: Direct Admin type environments.   #
#############################################################################
        if(m!Include\s!i) {

                                my($text) = $_;
        #                       print "$_\n";
                                my($directory, $filename)= $text  =~ m/(.*\/)(.*)$/;
                                $directory =~ s/^\s+|\s+$//g ;
                                $directory =~ s/Include //;
        #                       print "D=$directory, F=$filename\n";
                                $mypath = $directory . "/" . $filename;
                                if($filename =~ m/httpd.conf/){

        #                               print "Processing $mypath we need it\n===============================================\n";
                                        $ALLHTTPDCONFS = $mypath;
                                        open(ALLHTTPDCONFS) or die("Could not open log file.");

                                        while(<ALLHTTPDCONFS>){

                                                 # Skip commented blocks
                                                        next if m!\#.*</?virtualhost!i;

                                                        if (m!<virtualhost\s!i .. m!</virtualhost>!i) {
                                                                $name = $1 if m!ServerName\s+(\S+)!;
                                                        }

                                                        if (m!</virtualhost>!i) {
        #                                                        print "Processing for: $name \n***************************************\n";
                                                                target($name);
                                                        }



                                        }

                                                $x++;
                                } else {
        #                               print "Skipping $filename we dont need it\n==============================================\n";
                                }

        }
        #       print "Processed total $x domains from includes!\n";
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 26, 2010 4:52 pm 
Offline

Joined: Fri Feb 26, 2010 4:47 pm
Posts: 2
I would like to limit monthly bandwidth usage of some of my (apache) virtualhost accounts (shared IP - domain based) and check their current bandwidth usage to via a URL.
I mean a limit like: 20 GB/Month. Is this possible with mod_watch/Cacti?

(for Apache 2.2.x.)

By the way, thanks a lot for the corrections, drewhka and ziggyz27.
Thank you all!


Last edited by deksar on Fri Feb 26, 2010 5:09 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Use mod_cband
PostPosted: Fri Feb 26, 2010 5:02 pm 
Offline

Joined: Wed Feb 17, 2010 4:11 am
Posts: 2
You should use an apache add-on like mod_cband

Checkout
http://www.freshports.org/www/mod_cband/


Top
 Profile  
 
 Post subject: Re: Use mod_cband
PostPosted: Fri Feb 26, 2010 5:07 pm 
Offline

Joined: Fri Feb 26, 2010 4:47 pm
Posts: 2
ziggyz27 wrote:
You should use an apache add-on like mod_cband
Checkout
http://www.freshports.org/www/mod_cband/


I tried it already a while ago. Too many errors..
Unfortunately, it is not getting updated anymore. It seems mod_cband died long time ago. Dozens of bugs are waiting:
http://sourceforge.net/tracker/?group_i ... tid=791368
:(


Top
 Profile  
 
 Post subject: Need help for install
PostPosted: Fri Mar 19, 2010 4:45 am 
Offline

Joined: Fri Mar 19, 2010 4:21 am
Posts: 5
I need a solution to view in realtime the bandwidth used by virtualhosts...
This should be the soluion and I am happy to see that I am not the only one trying to use this great module !!!

The instalation with apache2 looks ok (well, no error message at restart...)

BUT...
I still have nothing when I check http://mydomain/watch-info
and ./mod_watch.pl -f ifRequests,ifDocuments http://mydomain/watch-list returns 0 0 0...

Secondly, do you know how to install it as a plugin on Munin (as explain here : http://www.freshnet.org/wordpress/2007/ ... ith-munin/) ?


Regards,

Guillaume


Top
 Profile  
 
 Post subject: day after day....
PostPosted: Sun Mar 21, 2010 9:05 am 
Offline

Joined: Fri Mar 19, 2010 4:21 am
Posts: 5
I think I have read all web pages about mod_watch without any success...

I try to make it run with cacti and munin but the problem seems to come from mod_watch it self which don't want to give me any response to watch-info... (watch-table and watch-list does now...)

Quote:
And more I have found a recursive error in in my error.log :
shVerifyString(b7fa6c58, b4ac3b18) failed!
[Sun Mar 21 14:55:05 2010] [crit] (20014)Internal error: shGetLockedEntry(b7fa6c58, "SERVER") failed in watchLogHash()


I use Apache/2.2.12 (Ubuntu) PHP/5.2.10-2ubuntu6.4 with Suhosin-Patch with mod_watch-4.3_apache22_mod...

I use several access log files... Do you think it could come from that ?
Do I need to use apache2mrtg.pl ?


Please, could you tell if, finaly, it works on your servers because I become crasy !`

Thanks in advanced,

Guilgot


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 14, 2010 9:36 am 
Offline
User avatar

Joined: Thu Feb 24, 2005 4:29 pm
Posts: 40
Location: Groningen, NL
Regarding the error log / watchLogHash I found a fix here:
http://www.ovcharov.me/2009/09/01/kak-p ... #more-2295
It's in Russian but it comes to adding /altering a line in "SharedHash.c" at line 102 and should look like this:

Code:
shVerifyString(struct shTable *tp, char *str)
{
    /* if ((char *) tp->shared <= str && str < (char *) tp->eshared) { */
    if ((char *) apr_shm_baseaddr_get(tp->shared) <= str && str < (char *) tp->eshared) {
        if (str + strlen(str) < (char *) tp->eshared)
            return str;
    }

Recompile the whole bunch and it should work somewhat better (read: no more errors).

On this side of the line getting info from "watch-list" DOES work, "watch-info" however gives a 404...

_________________
This is my sick nature...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group