[XML] ApacheStats version 0.4

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

pbulteel
Cacti User
Posts: 150
Joined: Fri Sep 05, 2003 9:20 am
Location: London
Contact:

Post by pbulteel »

Interesting - I found this for apache2

http://mod-apache-snmp.sourceforge.net/ ... /index.htm

I am trying it out now and will see what I get - so far no luck, but I just need some time to play with it.

-P
uname -a
Rolf Poser
Posts: 42
Joined: Wed Dec 10, 2003 7:19 am

Great !

Post by Rolf Poser »

Paul:

Thanks - I've been searching for something like this, so thanks for pointing it out. Will give it a spin...

Regards,
Rolf.
Rolf Poser
Posts: 42
Joined: Wed Dec 10, 2003 7:19 am

MIB looking good!

Post by Rolf Poser »

Judging by the MIB it has some additional information that I like. Again, thanks for pointing it out to me...

Will take this further for the release after version 0.6....

Let me finish the current documentation and then I'll get started on that one.

I'm hoping to churn out a new ApacheStats release about once a month or so.

Regards,
Rolf.
yacamor
Posts: 1
Joined: Thu Mar 24, 2005 2:33 pm

Post by yacamor »

I have an erreur after import template i have in Data Input Methods --> Input String

perl lt;path_cactigt;/scripts/ws_apachestats.pl lt;hostnamegt;

I must have

perl <path_cacti>/scripts/ws_apachestats.pl <hostname>

do you have a solution please ?


log of poller.php

Can't open perl script "lt": No such file or directory
sh: path_cactigt: not found
sh: /scripts/ws_apachestats.pl: not found
sh: hostnamegt: not found
Can't open perl script "lt": No such file or directory
sh: path_cactigt: not found
sh: /scripts/ws_apachestats.pl: not found
sh: hostnamegt: not found
Can't open perl script "lt": No such file or directory
sh: path_cactigt: not found
sh: /scripts/ws_apachestats.pl: not found
sh: hostnamegt: not found
Can't open perl script "lt": No such file or directory
sh: path_cactigt: not found
sh: /scripts/ws_apachestats.pl: not found
sh: hostnamegt: not found
Can't open perl script "lt": No such file or directory
sh: path_cactigt: not found
sh: /scripts/ws_apachestats.pl: not found
sh: hostnamegt: not found
seraph
Posts: 16
Joined: Thu Mar 31, 2005 9:38 am
Location: Zuerich
Contact:

Post by seraph »

sorry my englisch is very bad.
ich have ah problem, i use https and port 443

the error are:

Code: Select all

reanimation:/opt/cacti/scripts # perl ws_apachestats.pl localhost 443
Global symbol "$URL" requires explicit package name at ws_apachestats.pl line 48.
Global symbol "$fullURL" requires explicit package name at ws_apachestats.pl line 57.
Execution of ws_apachestats.pl aborted due to compilation errors.
the ws_apachestats.pl are:

Code: Select all

#
# YOU SHOULDN"T NEED TO CHANGE ANYTHING BEYOND THIS POINT..
#

# Ensure that we have access to the right modules:

use strict;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;

# First get hold of any supplied hostname, otherwise set to "localhost"

my ($hostname, $port);

if ($ARGV[0]) {
  $hostname = $ARGV[0];
  chomp $hostname;
} else {
  $hostname = 'localhost';
}

if ($ARGV[1]) {
  $port = $ARGV[1];
  chomp $port;
} else {
  $port = 443;
}

# Set the query URL:

$URL = "https:\/\/".$hostname.":".$port."\/server-status?auto";

# Define a user agent:

my $userAgent = new LWP::UserAgent;
$userAgent->agent("ApacheStats/0.4 ");

# Run the query:

my $request = new HTTP::Request('GET', $fullURL);
my $response = $userAgent->request($request);

# Parse the output and put out the stats to STDOUT:

if ($response->is_success) {
        $response->content =~ /Total Accesses: (.*)/;
        print "apache_total_hits:".$1." ";
        $response->content =~ /Total kBytes: (.*)/;
        print "apache_total_kbytes:".$1." ";
        $response->content =~ /Busy.*: (.*)/;
        print "apache_busy_workers:".$1." ";
        $response->content =~ /Idle.*: (.*)/;
        print "apache_idle_workers:".$1;
} else {
        print $response->error_as_HTML;
}

# FIN
in httpd.conf:
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 192.168.1.6
Allow from localhost
Allow from 127.0.0.1
Allow from foobar.com
</Location>
whats the problem?
User avatar
gninja
Cacti User
Posts: 371
Joined: Tue Aug 24, 2004 5:02 pm
Location: San Francisco, CA
Contact:

Post by gninja »

You have use strict; on. When you do that, you need to declare the scope of your variables.

change:

Code: Select all

$URL = "https:\/\/".$hostname.":".$port."\/server-status?auto";
to:

Code: Select all

my $URL = "https:\/\/".$hostname.":".$port."\/server-status?auto";
And a few lines later where you're making your request, change $fullURL, which you're neither declaring nor putting anything in, to $URL.

Should work then
FreeBSD/RHEL
cacti-0.8.7i, spine 0.8.7i, PIA 3.1+boost 5.1
MySQL 5.5/InnoDB
RRDtool 1.2.27, PHP 5.1.6
User avatar
gninja
Cacti User
Posts: 371
Joined: Tue Aug 24, 2004 5:02 pm
Location: San Francisco, CA
Contact:

Post by gninja »

Though, you should check the docs, I don't know that HTTP::Request can do ssl requests.
FreeBSD/RHEL
cacti-0.8.7i, spine 0.8.7i, PIA 3.1+boost 5.1
MySQL 5.5/InnoDB
RRDtool 1.2.27, PHP 5.1.6
seraph
Posts: 16
Joined: Thu Mar 31, 2005 9:38 am
Location: Zuerich
Contact:

Post by seraph »

the script running with the folling error:
reanimation:/opt/cacti/scripts # perl ws_apachestats.pl localhost 443
<HTML>
<HEAD><TITLE>An Error Occurred</TITLE></HEAD>
<BODY>
<H1>An Error Occurred</H1>
401 Authorization Required
</BODY>
</HTML>
reanimation:/opt/cacti/scripts # perl ws_apachestats.pl 127.0.0.1 443
<HTML>
<HEAD><TITLE>An Error Occurred</TITLE></HEAD>
<BODY>
<H1>An Error Occurred</H1>
401 Authorization Required
</BODY>
</HTML>
why?
User avatar
gninja
Cacti User
Posts: 371
Joined: Tue Aug 24, 2004 5:02 pm
Location: San Francisco, CA
Contact:

Post by gninja »

A 401 error typically means that a login is required. Try googling your error messages.
FreeBSD/RHEL
cacti-0.8.7i, spine 0.8.7i, PIA 3.1+boost 5.1
MySQL 5.5/InnoDB
RRDtool 1.2.27, PHP 5.1.6
seraph
Posts: 16
Joined: Thu Mar 31, 2005 9:38 am
Location: Zuerich
Contact:

Post by seraph »

okey, delete the .htaccess file ;-)
and this error:

Code: Select all

reanimation:/opt/cacti/scripts # perl ws_apachestats.pl 127.0.0.1 443
Use of uninitialized value in concatenation (.) or string at ws_apachestats.pl line 64.
Use of uninitialized value in concatenation (.) or string at ws_apachestats.pl line 66.
apache_total_hits: 
apache_total_kbytes: 
apache_busy_workers:1 
apache_idle_workers:5
reanimation:/opt/cacti/scripts #

the config:

Code: Select all

if ($response->is_success) {
	$response->content =~ /Total Accesses: (.*)/; 
	[b]print "apache_total_hits:".$1." "; [/b]
	$response->content =~ /Total kBytes: (.*)/; 
	[b]print "apache_total_kbytes:".$1." ";[/b]
	$response->content =~ /Busy.*: (.*)/;
	print "apache_busy_workers:".$1." ";
	$response->content =~ /Idle.*: (.*)/;
	print "apache_idle_workers:".$1;
} else {
	print $response->error_as_HTML;
[/quote]
rebel
Posts: 14
Joined: Sun Mar 13, 2005 7:52 am

ERROR: Could not parse color in ''

Post by rebel »

Hello,

i get this error when i turn on debug for "Apache Statistics - Bytes / Request". No graph is created. Same error for "Apache Statistics - Thread Details (%)"
I'm using cacti0.8.6d.

Another question is, where the hell is apachestats0.6? The sample screenshot looks cool. 8)
CactiPadawan
Posts: 23
Joined: Mon Jun 06, 2005 11:15 am

Post by CactiPadawan »

i am trying to use the apache template,
but i have these problems :

Apache Statistics - Bytes / Request :
not working -> RRDTool DEBUG -> ERROR: Could not parse color in ''


Apache Statistics - Hits / s :
working but i have no title nor legends ..

Apache Statistics - kBits / s120x500
working but i have no title nor legends ..

Apache Statistics - Thread Details
working but i have no title nor legends ..

Apache Statistics - Thread Details (%)
not working -> RRDTool DEBUG -> ERROR: Could not parse color in ''


i am sorry, maybe its because i dont use cacti correctly .. i am a beginner with it. But i would appreciate any answer. Thank you.
[My config :
Windows XP Service Pack 2
ActivePerl-5.8.6.811-MSWin32-x86-122208
cacti-0.8.6d
mysql-4.1.12-win32
php-5.0.4-Win32
rrdtool-cygwin-1.2.9
net-snmp-5.2.1
apache_2.0.54-win32-x86-no_ssl]
irishpadres
Posts: 9
Joined: Sat Sep 13, 2003 3:46 pm
Location: Los Angeles, CA

Post by irishpadres »

CactiPadawan and rebel,

Look in the Graph Template of the particular graph you are having problems with. Make sure you don't have any Area, Stack, Line1, Line2, or Line3 graph items configured with color as None. These types require that a color is defined.
Benfr
Posts: 2
Joined: Sat Jun 18, 2005 8:29 pm

Post by Benfr »

Hi all

Thanks for this code, it look great :) But I've a problem with LWP. I have errors when I want to install it, and I don't understadn what is the problem...

Here's my log when I try to install LWP using 'install Bundle::LWP' in perl CPAN shell :

Code: Select all

cpan> install Bundle::LWP
Running install for module MIME::Base64
Running make for G/GA/GAAS/MIME-Base64-3.05.tar.gz
  Is already unwrapped into directory /root/.cpan/build/MIME-Base64-3.05
  Has already been processed within this session
Running make test
  Can't test without successful make
Running make install
  make had returned bad status, install seems impossible
Digest::MD5 is up to date.
Running install for module URI
Running make for G/GA/GAAS/URI-1.35.tar.gz
  Is already unwrapped into directory /root/.cpan/build/URI-1.35
  Has already been processed within this session
Running make test
  Can't test without successful make
Running make install
  make had returned bad status, install seems impossible
Running install for module Net::FTP
Running make for G/GB/GBARR/libnet-1.19.tar.gz
  Is already unwrapped into directory /root/.cpan/build/libnet-1.19
  Has already been processed within this session
Running make test
  Can't test without successful make
Running make install
  make had returned bad status, install seems impossible
Running install for module HTML::Tagset
Running make for S/SB/SBURKE/HTML-Tagset-3.04.tar.gz
  Is already unwrapped into directory /root/.cpan/build/HTML-Tagset-3.04
  Has already been processed within this session
Running make test
  Can't test without successful make
Running make install
  make had returned bad status, install seems impossible
Running install for module HTML::Parser
Running make for G/GA/GAAS/HTML-Parser-3.45.tar.gz
  Is already unwrapped into directory /root/.cpan/build/HTML-Parser-3.45
  Has already been processed within this session
Running make test
---- Unsatisfied dependencies detected during [G/GA/GAAS/HTML-Parser-3.45.tar.gz] -----
    HTML::Tagset
Shall I follow them and prepend them to the queue
of modules we are processing right now? [yes]
Running make install
  make had returned bad status, install seems impossible
  Delayed until after prerequisites
Running install for module HTML::HeadParser
Running make for G/GA/GAAS/HTML-Parser-3.45.tar.gz
  Is already unwrapped into directory /root/.cpan/build/HTML-Parser-3.45
  Has already been processed within this session
  Delayed until after prerequisites
Running make test
  Can't test without successful make
  Delayed until after prerequisites
Running make install
  make had returned bad status, install seems impossible
  Delayed until after prerequisites
Running install for module LWP
Running make for G/GA/GAAS/libwww-perl-5.803.tar.gz
  Is already unwrapped into directory /root/.cpan/build/libwww-perl-5.803
  Has already been processed within this session
Running make test
---- Unsatisfied dependencies detected during [G/GA/GAAS/libwww-perl-5.803.tar.gz] -----
    URI
    Compress::Zlib
    HTML::Parser
Shall I follow them and prepend them to the queue
of modules we are processing right now? [yes]
Running make install
  make had returned bad status, install seems impossible
  Delayed until after prerequisites
Bundle summary: The following items in bundle Bundle::LWP had installation
problems:
  MIME::Base64 URI Net::FTP HTML::Tagset HTML::Parser HTML::HeadParser LWP
Running install for module URI
Running make for G/GA/GAAS/URI-1.35.tar.gz
  Is already unwrapped into directory /root/.cpan/build/URI-1.35
  Has already been processed within this session
Running make test
  Can't test without successful make
Running make install
  make had returned bad status, install seems impossible
Running install for module Compress::Zlib
Running make for P/PM/PMQS/Compress-Zlib-1.34.tar.gz
  Is already unwrapped into directory /root/.cpan/build/Compress-Zlib-1.34
  Has already been processed within this session
Running make test
  Can't test without successful make
Running make install
  make had returned bad status, install seems impossible
Running install for module HTML::Parser
Running make for G/GA/GAAS/HTML-Parser-3.45.tar.gz
  Is already unwrapped into directory /root/.cpan/build/HTML-Parser-3.45
  Has already been processed within this session
Running make test
  Can't test without successful make
Running make install
  make had returned bad status, install seems impossible
Running make for G/GA/GAAS/libwww-perl-5.803.tar.gz
  Is already unwrapped into directory /root/.cpan/build/libwww-perl-5.803
  Has already been processed within this session
Running make test
  Can't test without successful make
Running make install
  make had returned bad status, install seems impossible
Running install for module HTML::Tagset
Running make for S/SB/SBURKE/HTML-Tagset-3.04.tar.gz
  Is already unwrapped into directory /root/.cpan/build/HTML-Tagset-3.04
  Has already been processed within this session
Running make test
  Can't test without successful make
Running make install
  make had returned bad status, install seems impossible
Running make for G/GA/GAAS/HTML-Parser-3.45.tar.gz
  Is already unwrapped into directory /root/.cpan/build/HTML-Parser-3.45
  Has already been processed within this session
Running make test
  Can't test without successful make
Running make install
  make had returned bad status, install seems impossible
I don't undestand where is the problem, if anyone can help me... :)

Thanks :)
Benfr
Posts: 2
Joined: Sat Jun 18, 2005 8:29 pm

Post by Benfr »

Well, I didn't find what was the problem while installing LWP via perl, but a simple

Code: Select all

apt-get install libwww-perl
solve my problem :oops:

Thanks for this great code :)
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests