Ik heb het volgende probleem. Heb mod_watch (zoals het moet) geinstalleerd, en dit werkt ook. Zodra ik van mod_watch een grafiekje wil laten maken in MRTG gaat het fout:
De grafiekjes maakt MRTG keurig aan in de workdir. Echter komt er geen informatie (lijnen) in te staan.
De inhoud van web.cfg:
Inhoud mod_watch.pl:
http://www.rutgerlan.com/watch-info werkt ook wel. Ik snap er niets meer van, waar kan die fout zitten? Iemand een idee
OS: Debian 3.0r2
code:
1
2
3
4
5
6
7
| # mrtg /etc/mrtg/web.cfg
WARNING: Problem with External get '/usr/local/sbin/mod_watch.pl http://www.rutgerlan.com/watch-info': Expected a Number for 'in' but got ''
WARNING: Problem with Externale get '/usr/local/sbin/mod_watch.pl http://www.rutgerlan.com/watch-info': Expected a Number for 'out' but got ''
ERROR: Target[www.rutgerlan.com][_IN_] ' $target->[0]{$mode} ' did not eval into defined data
ERROR: Target[www.rutgerlan.com][_OUT_] ' $target->[0]{$mode} ' did not eval into defined data |
De grafiekjes maakt MRTG keurig aan in de workdir. Echter komt er geen informatie (lijnen) in te staan.
De inhoud van web.cfg:
code:
1
2
3
4
5
6
| WorkDir: /var/www/stats/mrtg/mod_watch WriteExpires: Yes Title[www.rutgerlan.com]: www.rutgerlan.com Data Traffic Target[www.rutgerlan.com]: `/usr/local/sbin/mod_watch.pl http://www.rutgerlan.com/watch-info` MaxBytes[www.rutgerlan.com]: 1250000 PageTop[www.rutgerlan.com]: <h2><a href="http://www.rutgerlan.com/">www.rutgerlan.com</a> Data Traffic</h2> |
Inhoud mod_watch.pl:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
| #!/usr/bin/perl
#
# mod_watch.pl
#
# Interface for Apache mod_watch and MRTG
#
# Copyright 2001, 2002 by Anthony Howe. All rights reserved.
#
# usage: mod_watch.pl [-f a,b] url
#
# Fetch the current counters associated with the given URL. The URL refers
# to either a virtual host, file owner, or the SERVER.
#
# http://www.snert.com/watch-info
# http://www.snert.com/~achowe/watch-info
# http://www.snert.com/~SERVER/watch-info
#
# The mod_watch handler "watch-info" returns a line of plain text
# containing the following space separated fields:
#
# ifName ifUptime ifInOctets ifOutOctets ifRequests ifDocuments ifAvgRate ifActive
#
# This script returns output suitable for MRTG's target script command
# directive: line with the input bytes, line with the output bytes, line
# with the web server uptime, and the target name.
#
##########################################################################
# Nothing to be configured below this point.
##########################################################################
$VERSION = '2.6';
$AUTHOR = 'achowe@snert.com';
use Socket;
use Getopt::Std;
use Sys::Hostname;
use AnyDBM_File;
my $usage = "usage: mod_watch.pl [-f a,b] url\n";
die($usage) unless getopts('f:');
die($usage) unless @ARGV == 1;
#########################################################################
# Open connection to URL.
#########################################################################
# Figure out who we have to call.
($host, $port, $path) = ($ARGV[0] =~ m!http://([^:/]+)(?:\:(\d*))?(/.*)!);
$port = 80 unless defined $port;
# Get a socket...
#
# TODO add Timeout support, eg.
#
#$sock = IO::Socket::INET->new(PeerAddr => 'www.vhost.com', PeerPort => 'http(80)', Proto => 'tcp', Timeout => 10);
#
unless (socket(HTTP, PF_INET, SOCK_STREAM, getprotobyname('tcp'))) {
# print("0\n0\n0\n$host:$port ($!)\n");
print("\n\n\n$host:$port ($!)\n");
exit(0);
}
# ...set socket to be line buffered...
select( (select(HTTP), $| = 1)[0] );
# .. make the connection.
unless (connect(HTTP, sockaddr_in($port, inet_aton($host)))) {
# print("0\n0\n0\n$host:$port ($!)\n");
print("\n\n\n$host:$port ($!)\n");
exit(0);
}
#########################################################################
# Make the HTTP request.
#########################################################################
# Proxy request style.
#print HTTP "GET $ARGV[0] HTTP/1.0\n\n";
print HTTP "GET $path HTTP/1.0\nHost: $host\n\n";
$answer = <HTTP>;
($status, $reason) = ($answer =~ m!HTTP/1.[01] (\d+) (.*)!);
unless ($status == 200) {
# print("0\n0\n0\n$host:$port ($reason)\n");
print("\n\n\n$host:$port ($!)\n");
exit(0);
}
# Discard remaining HTTP headers.
while (<HTTP>) {
last if /^\s*$/;
}
#########################################################################
# Parse the information line.
#########################################################################
# Field names in order.
@fieldnames = qw(ifName ifUptime ifInOctets ifOutOctets ifRequests ifDocuments ifActive ifOutRate);
# Default fields to return.
($a, $b) = qw(ifInOctets ifOutOctets);
# User wants other fields?
($a, $b) = ($opt_f =~ m!(\w+),(\w+)!) if defined $opt_f;
# Get the information line.
my $line = <HTTP>;
close(HTTP);
# Select the fields to return.
($in, $out) = (0, 0);
#if ($line =~ /^\S+\s\d+\s\d+\s\d+\s\d+\s\d+\s\d+\s\d+/) {
if ($line =~ /^\S+\s\d+\s\d+\s\d+\s\d+\s\d+/) {
@counters{@fieldnames} = split(/\s+/, $line);
($in, $out) = ($counters{$a}, $counters{$b});
}
#########################################################################
# Write MRTG output.
#########################################################################
sub ml_elapsed_time {
my ($s) = @_;
my ($d, $h, $m);
$d = int($s / 86400);
$s %= 86400;
$h = int($s / 3600);
$s %= 3600;
$m = int($s / 60);
$s %= 60;
return sprintf("%lu+%02d:%02d.%02d", $d, $h, $m, $s) if 0 < $d;
return sprintf("%d:%02d.%02d", $h, $m, $s) if 0 < $h;
return sprintf("%d.%02d", $m, $s) if 0 < $m;
return sprintf("%d", $s);
}
print "$in\n$out\n" . ml_elapsed_time($counters{ifUptime}) . "\n$counters{ifName}\n";
exit 0;
#########################################################################
#
#########################################################################
__END__ |
http://www.rutgerlan.com/watch-info werkt ook wel. Ik snap er niets meer van, waar kan die fout zitten? Iemand een idee
OS: Debian 3.0r2
[ Voor 5% gewijzigd door RutgerLAN op 02-05-2005 12:01 ]
