[XML] ApacheStats version 0.2
Moderators: Developers, Moderators
-
- Posts: 42
- Joined: Wed Dec 10, 2003 7:19 am
Alan - just checking a few more items
Alan:
Are you running it against the localhost?
Either way, can you check whether the request for /server-status is actually showing up in any of the web server logs on the apache server's end?
If yes, then I'm a bit stumped !
Will have to get back to you if your web server sees the request....
Thanks,
Rolf.
Are you running it against the localhost?
Either way, can you check whether the request for /server-status is actually showing up in any of the web server logs on the apache server's end?
If yes, then I'm a bit stumped !
Will have to get back to you if your web server sees the request....
Thanks,
Rolf.
-
- Posts: 13
- Joined: Mon May 03, 2004 5:26 pm
Rolf,
The machine that I am running the apache script on, is the machine that i am targeting with the the script.
i.e. uniquehost.foobar.com runs the following command succesfully:
Here is the relevant apache log:
however it fails (returns no values) when uniquehost.foobar.com runs the following command:
From my desktop to the server running Cacti there is no proxy. And there is no squid proxy runnning on the machine uniquehost.foobar.com.
Thanks,
Alan
The machine that I am running the apache script on, is the machine that i am targeting with the the script.
i.e. uniquehost.foobar.com runs the following command succesfully:
Code: Select all
perl unix_apachestats.pl uniquehost.foobar.com
apache_total_hits:4536 apache_total_kbytes:17448 apache_busy_workers:17448 apache_idle_workers:17448
Code: Select all
uniquehost.foobar.com - - [18/May/2004:10:12:42 -0700] "GET /server-status?auto HTTP/1.0" 200 432 "-" "Lynx/2.8.4rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.6b"
Code: Select all
perl unix_apachestats.pl localhost
or
perl unix_apachestats.pl 127.0.0.1
both return
apache_total_hits: apache_total_kbytes: apache_busy_workers: apache_idle_workers:
Thanks,
Alan
-
- Posts: 42
- Joined: Wed Dec 10, 2003 7:19 am
Check httpd.conf?
Alan:
Quick question:
Does the logfile entry show up when you access it as localhost as well as unique.foobar.com - sorry for being so laborious about this?
Also - could you check what your permissions are set to in httpd.conf in terms of access to the server-status?
I've set mine to the following:
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from .foobar.com 127.0.0.1
</Location>
which should ensure that other hosts in my domain can query it, as well as a localhost query?
Another way to try to resolve this perhaps is to check that the "data source" under which the apache monitor is defined is pointing to the right hostname..
Let me know what further information you can garner for me?
Thanks,
Rolf.
Quick question:
Does the logfile entry show up when you access it as localhost as well as unique.foobar.com - sorry for being so laborious about this?
Also - could you check what your permissions are set to in httpd.conf in terms of access to the server-status?
I've set mine to the following:
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from .foobar.com 127.0.0.1
</Location>
which should ensure that other hosts in my domain can query it, as well as a localhost query?
Another way to try to resolve this perhaps is to check that the "data source" under which the apache monitor is defined is pointing to the right hostname..
Let me know what further information you can garner for me?
Thanks,
Rolf.
-
- Posts: 13
- Joined: Mon May 03, 2004 5:26 pm
httpd.conf
Rolf,
No problem it's my pleasure!
When I do this:
I get get no data, but I see entries in my httpd access_log:
Here is the relevant part of my httpd.conf file:
I imagine the reason why it doesn't work from localhost is that I haven't allowed it my httpd.conf file.
Alan
No problem it's my pleasure!
When I do this:
Code: Select all
perl /var/www/html/cacti/scripts/unix_apachestats.pl 127.0.0.1
perl /var/www/html/cacti/scripts/unix_apachestats.pl locahost
Code: Select all
localhost.localdomain - - [18/May/2004:13:04:42 -0700] "GET /server-status?auto HTTP/1.0" 403 292 "-" "Lynx/2.8.4rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.6b"
localhost.localdomain - - [18/May/2004:13:04:50 -0700] "GET /server-status?auto HTTP/1.0" 403 292 "-" "Lynx/2.8.4rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.6b"
Code: Select all
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from .foobar.com
</Location>
Alan
Running the script i get the following on cosnole:pbulteel wrote:I redid the code so it's completely written in perl. It requires LWP which should be already installed. Thanks for the original script and the modification! And although I didn't put it in there... it's GPL of course!
Code: Select all
#!/usr/bin/perl -w # # Taken from ftp://ftp.ora.com/published/oreilly/nutshell/web-client/ # # Modified by: Patrick Bulteel # Date: 02/16/2004 - (I love you hunny! It's my anniversary!) # # Modified so that it uses perl more extensively instead of running lynx. # Also modified so that it uses a wildcard for Busy and Idle servers instead # of having to hit the server twice, we can do it all in one swell swoop. # use strict; use LWP::UserAgent; use HTTP::Request; use HTTP::Response; my $ua = new LWP::UserAgent; # I added this to the original O'reilly code... my $fullurl = "http://" . $ARGV[0] . "/server-status?auto"; # I changed this from the original O'reilly code... my $request = new HTTP::Request('GET', $fullurl); my $response = $ua->request($request); if ($response->is_success) { # I grabbed this from the original unix_apachestats.pl $response->content =~ /Total Accesses: (.*)/; print "apache_total_hits:".$1." "; $response->content =~ /Total kBytes: (.*)/; print "apache_total_kbytes:".$1." "; # I wildcarded the Busy and Idle stats... =) $response->content =~ /Busy.*: (.*)/; print "apache_busy_workers:".$1." "; $response->content =~ /Idle.*: (.*)/; print "apache_idle_workers:".$1; } else { print $response->error_as_HTML; }
Code: Select all
# perl /home/htdocs/web1/html/cacti/scripts/unix_apachestats.pl localhost
Use of uninitialized value in concatenation (.) or string at /home/htdocs/web1/html/cacti/scripts/unix_apachestats.pl line 28.
Use of uninitialized value in concatenation (.) or string at /home/htdocs/web1/html/cacti/scripts/unix_apachestats.pl line 30.
Use of uninitialized value in concatenation (.) or string at /home/htdocs/web1/html/cacti/scripts/unix_apachestats.pl line 33.
Use of uninitialized value in concatenation (.) or string at /home/htdocs/web1/html/cacti/scripts/unix_apachestats.pl line 35.
apache_total_hits: apache_total_kbytes: apache_busy_workers: apache_idle_workers:p1000:/srv/www/htdocs #
Hello Cacti folks
The graphs did not work after importing templates.
On console it worked with both .pl scripts - original + 'pure perl' script with 'parameter' localhost.
So i did simply that:
Data Templates --> Unix - Apache2 Statistics --> Custom Data [data input: Unix - Apache Statistics] --> Host to be queried for "/server-status?auto" --> right field : inserted 'localhost' --> Save -FUN
The graphs did not work after importing templates.
On console it worked with both .pl scripts - original + 'pure perl' script with 'parameter' localhost.
So i did simply that:
Data Templates --> Unix - Apache2 Statistics --> Custom Data [data input: Unix - Apache Statistics] --> Host to be queried for "/server-status?auto" --> right field : inserted 'localhost' --> Save -FUN
[url=http://stef.funpic.de/index.html]Stef.s small Fan Page[/url]
Free your brain with trashing away MS - no pain, no torture, no troubles of learning Linux can compete with your Freedom using it.
Free your brain with trashing away MS - no pain, no torture, no troubles of learning Linux can compete with your Freedom using it.
-
- Posts: 42
- Joined: Wed Dec 10, 2003 7:19 am
Localhost and permissions:
Alan:
I think I can see what's wrong here - it seems to substitue either nothing or "localhost" and your httpd.conf doesn't allow for that.
To make it work, I would suggest adding "localhost" to your permissions i.e. "Allow .foobar.com [b]localhost[/b]".
That's a temporary fix though, I'll need to go and figure out why the script isn't passed the correct parameter!
Hope this works for you, if you don't want to use the "localhost" option let me know so that I speed up my investigation.
Thanks,
Rolf.
I think I can see what's wrong here - it seems to substitue either nothing or "localhost" and your httpd.conf doesn't allow for that.
To make it work, I would suggest adding "localhost" to your permissions i.e. "Allow .foobar.com [b]localhost[/b]".
That's a temporary fix though, I'll need to go and figure out why the script isn't passed the correct parameter!
Hope this works for you, if you don't want to use the "localhost" option let me know so that I speed up my investigation.
Thanks,
Rolf.
-
- Posts: 42
- Joined: Wed Dec 10, 2003 7:19 am
In response to Alan's questions:
Sorry that should read:
Allow .foobar.com localhost
Let me know if it works.
Thanks,
Rolf.
Allow .foobar.com localhost
Let me know if it works.
Thanks,
Rolf.
Re: In response to Alan's questions:
Rolf, just for your info - see my above posting - had a similar prob, because i defined "Allow from .servernet.com" and NOT additionally / only "localhost" , too.Rolf Poser wrote:Sorry that should read:
Allow .foobar.com localhost
Let me know if it works.
Thanks,
Rolf.
After changing it towards "Allow from localhost" + changed the Data Template value towards "localhost" all is working perfect !!
[url=http://stef.funpic.de/index.html]Stef.s small Fan Page[/url]
Free your brain with trashing away MS - no pain, no torture, no troubles of learning Linux can compete with your Freedom using it.
Free your brain with trashing away MS - no pain, no torture, no troubles of learning Linux can compete with your Freedom using it.
-
- Posts: 42
- Joined: Wed Dec 10, 2003 7:19 am
Apache config stuff.... Hmm
testest:
Thanks for pointing that out.
I thought I understood apache config directives.
Back to RTFM then!
Let's see the documentation then...
OK - having taken a look, my fears are being confirmed - you need to
enable access line-by-line if you want to enable access from more than one place, i.e.:
Allow from localhost
Allow from foobar.com
I don't have any means to test this right now, so if you don't mind confirming this for us? Otherwise I'll try at home tonight.
Thanks,
Rolf.
Thanks for pointing that out.
I thought I understood apache config directives.
Back to RTFM then!
Let's see the documentation then...
OK - having taken a look, my fears are being confirmed - you need to
enable access line-by-line if you want to enable access from more than one place, i.e.:
Allow from localhost
Allow from foobar.com
I don't have any means to test this right now, so if you don't mind confirming this for us? Otherwise I'll try at home tonight.
Thanks,
Rolf.
-
- Posts: 13
- Joined: Mon May 03, 2004 5:26 pm
httpd.conf changes
I changed my httpd.conf file to:
However, when I run the script via localhost or 127.0.0.1 I get no results. When I run the command with the localhost's hostname I get results.
Anyways, when cacti trys to generate the graph it uses the hostname of the server, and doesn't get any data points, even though when I run the same command manually it returns data points. Also I would be using cacti to measure webserver stats for other hosts than the cacti server. I.e my company's www servers.
Hope this helps,
Alan
Code: Select all
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from localhost
Allow from .foobar.com
</Location>
Anyways, when cacti trys to generate the graph it uses the hostname of the server, and doesn't get any data points, even though when I run the same command manually it returns data points. Also I would be using cacti to measure webserver stats for other hosts than the cacti server. I.e my company's www servers.
Hope this helps,
Alan
-
- Posts: 42
- Joined: Wed Dec 10, 2003 7:19 am
Grrr... Let's see whether this works:
Alan:
I've found that it seems to have much less to do with whether the allow clauses are on separate lines (they actually can be), but that the
<Location /server-status> directory will match only for queries to whatever your ServerName is set to. So that may explain why it works for testtest and not for us.
I've come up with an interesting alternative that I'd like you to try out.
Add the following:
<VirtualHost localhost>
ServerAlias 127.0.0.1
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
</VirtualHost>
Also - what are your "Listen" and "ServerName" settings?
Thanks,
Rolf.
I've found that it seems to have much less to do with whether the allow clauses are on separate lines (they actually can be), but that the
<Location /server-status> directory will match only for queries to whatever your ServerName is set to. So that may explain why it works for testtest and not for us.
I've come up with an interesting alternative that I'd like you to try out.
Add the following:
<VirtualHost localhost>
ServerAlias 127.0.0.1
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
</VirtualHost>
Also - what are your "Listen" and "ServerName" settings?
Thanks,
Rolf.
-
- Posts: 13
- Joined: Mon May 03, 2004 5:26 pm
It works!
Rolf,
My "Listen" settings are all commented out.
My "Servername" setting is commented out.
I added:
Thanks for all the help.
Alan
My "Listen" settings are all commented out.
My "Servername" setting is commented out.
I added:
and upgraded to apachestats 0.4 and how my graphs work (at least when I mesaure the machine that cacti runs on) ! I used the "high speed" version as other version you have provided use a module I don't have installed.<VirtualHost localhost>
ServerAlias 127.0.0.1
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
</VirtualHost>
Thanks for all the help.
Alan
Who is online
Users browsing this forum: No registered users and 1 guest