PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : queuegraph zeigt keine werte an



Manfred Werner
29.04.08, 16:34
Hallo Forum,
habe queuegrah auf meinem System installiert. Die Tabellen werden auch angezeigt, allerdings sind diese leer.
Meine queuegraph-rrd.sh sieht so aus:

#!/bin/sh

# output the number of messages in the incoming, active, and deferred
# queues of postfix one per line suitable for use with snmpd/cricket/rrdtool
#
# 2003/01/24 Mike Saunders <method at method DOT cx>
# mailqsize was originally written by Vivek Khera. All I did was
# make it update an rrd.
# 2003/04/14 Ralf Hildebrandt <ralf.hildebrandt at charite DOT de>
# I bundled this with a modified mailgraph
# 2007/07/28 Ralf Hildebrandt <ralf.hildebrandt at charite DOT de>
# find rrdtool using "which"

# change this to the location of rrdtool
RRDTOOL=/usr/bin/rrdtool

# change this to the location you want to store the rrd
RRDFILE=/etc/postfix/mailqueues.rrd

if test ! -x $RRDTOOL ; then
echo "ERROR: $RRDTOOL does not exist or is not executable"
exit
fi

if test ! -f $RRDFILE ; then
echo "Creating RRD file $RRDFILE"

$RRDTOOL create $RRDFILE --step 60 \
DS:active:GAUGE:900:0:U \
DS:deferred:GAUGE:900:0:U \
RRA:AVERAGE:0.5:1:20160 \
RRA:AVERAGE:0.5:30:2016 \
RRA:AVERAGE:0.5:60:105120 \
RRA:MAX:0.5:1:1440 \
RRA:MAX:0.5:30:2016 \
RRA:MAX:0.5:60:105120
fi

#set -x
qdir=`/usr/sbin/postconf -h queue_directory`
active=`find $qdir/incoming $qdir/active $qdir/maildrop -type f -print | wc -l | awk '{print $1}'`
deferred=`find $qdir/deferred -type f -print | wc -l | awk '{print $1}'`
#printf "active: %d\ndeferred: %d\n" $active $deferred

$RRDTOOL update $RRDFILE "N:$active:$deferred"


Die queuegraph.cgi so:


#!/usr/bin/perl -w

# queuegraph -- a postfix queue statistics rrdtool frontend
# based on mailgraph, which is
# copyright (c) 2000-2002 David Schweikert <dws@ee.ethz.ch>
# released under the GNU General Public License

use RRDs;
use POSIX qw(uname);

my $VERSION = "1.1";

my $host = (POSIX::uname())[1];
my $scriptname = 'queuegraph.cgi';
my $xpoints = 800;
my $points_per_sample = 3;
my $ypoints = 160;
my $ypoints_err = 80;
my $rrd = '/etc/postfix/mailqueues.rrd'; # path to where the RRD database is
my $tmp_dir = '/var/lib/queuegraph/img'; # temporary directory where to store the images
my $rrdtool_1_0 = ($RRDs::VERSION < 1.199908);

my @graphs = (
{ title => 'Day Graph', seconds => 3600*24, },
{ title => 'Week Graph', seconds => 3600*24*7, },
{ title => 'Month Graph', seconds => 3600*24*31, },
{ title => 'Year Graph', seconds => 3600*24*365, },
);

my %color = (
sent => '000099', # rrggbb in hex
received => '00FF00',
rejected => '999999',
bounced => '993399',
virus => 'FFFF00',
spam => 'FF0000',
);

sub graph($$$)
{
my $range = shift;
my $file = shift;
my $title = shift;
my $step = $range*$points_per_sample/$xpoints;
my $date = localtime(time);
$date =~ s|:|\\:|g unless $rrdtool_1_0;

my ($graphret,$xs,$ys) = RRDs::graph($file,
'--imgformat', 'PNG',
'--width', $xpoints,
'--height', $ypoints,
'--start', "-$range",
'--end', "-".int($range*0.01),
'--vertical-label', 'queuefiles',
'--title', $title,
'--lazy',
$rrdtool_1_0 ? () : (
'--slope-mode'
),

"DEF:active=$rrd:active:AVERAGE",
"DEF:deferred=$rrd:deferred:AVERAGE",

'LINE2:active#00ff00:Active+Incoming+Maildrop\:',
'GPRINT:active:MAX:Maximum\: %0.0lf ',
'GPRINT:active:AVERAGE:Average\: %0.0lf/min\n',

'LINE1:deferred#0000ff:Deferred\:',
'GPRINT:deferred:MAX:Maximum\: %0.0lf ',
'GPRINT:deferred:AVERAGE:Average\: %0.0lf/min\l',

'HRULE:0#000000',
'COMMENT:\n',
'COMMENT:['.$date.']\r',
);
my $ERR=RRDs::error;
die "ERROR: $ERR\n" if $ERR;
}

sub print_html()
{
print "Content-Type: text/html\n\n";

print <<HEADER;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>Queue Statistics for $host</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
HEADER

print "<H1>Postfix Queue Statistics for $host</H1>\n";
for my $n (0..$#graphs) {
print "<H2>$graphs[$n]{title}</H2>\n";
print "<P><IMG BORDER=\"0\" SRC=\"$scriptname/queuegraph_${n}.png\" ALT=\"queuegraph\">\n";
}

print <<FOOTER;
<table border="0" width="400"><tr><td align="left">
<A href="http://www.arschkrebs.de/postfix/queuegraph">queuegraph</A> $VERSION
by <A href="http://www.arschkrebs.de/">Ralf Hildebrandt</A>,
based on <A href="http://mailgraph.schweikert.ch/">mailgraph</A>
by <A href="http://david.schweikert.ch/">David Schweikert</A></td>
<td ALIGN="right">
<a HREF="http://oss.oetiker.ch/rrdtool/"><img border="0" src="http://tobi.oetiker.ch/webtools/rrdtool/.pics/rrdtool.gif" alt="rrdtool" width="120" height="34"></a>
</td></tr></table>
</BODY>
FOOTER
}

sub send_image($)
{
my $file = shift;
-r $file or do {
print "Content-Type: text/plain\n\nERROR: can't find $file\n";
exit 1;
};

print "Content-Type: image/png\n";
print "Content-Length: ".((stat($file))[7])."\n";
print "\n";
open(IMG, $file) or die;
my $data;
print $data while read IMG, $data, 1;
}

sub main()
{
if($ENV{PATH_INFO}) {
my $uri = $ENV{REQUEST_URI};
$uri =~ s/\/[^\/]+$//;
$uri =~ s/\//,/g;
$uri =~ s/\~/tilde,/g;
mkdir $tmp_dir, 0777 unless -d $tmp_dir;
mkdir "$tmp_dir/$uri", 0777 unless -d "$tmp_dir/$uri";
my $file = "$tmp_dir/$uri$ENV{PATH_INFO}";
if($ENV{PATH_INFO} =~ /^\/queuegraph_(\d+)\.png$/) {
graph($graphs[$1]{seconds}, $file, $graphs[$1]{title});
}
else {
print "Content-Type: text/plain\n\nERROR: unknown image $ENV{PATH_INFO}\n";
exit 1;
}
send_image($file);
}
else {
print_html;
}
}

main;


Das ebenfalls installierte Mailgraph zeigt einwandfrei alle Werte an.
Die queuegraph-rrd.sh habe ich wie in der Anleitung beschrieben in die Crontab eingetragen und die Pfade geändert.
In meinem tmp Verzeichnis legt mir Queuegrapgh einen Ordner names
,cgi-bin,queuegraph.cgi an. Warum kann ich aber nicht nachvollziehen.
In diesem liegen auch die Dateien queuegraph_0.png bis *_03.png. Dies sind aber auch nur leere Tabellen.

Irgendwo sit aber noch der Wurm drin. :mad:

Wäre duper wenn jemand einen Tipp hätte

Manni

unlimitopen
30.04.08, 00:32
Hallo,

ich habe beide am rennen queuegraph & mailgraph

beide liegen bei mir in der //webserver/cgi-bin/

hier meine config..

im ersten teil

#!/bin/sh

# output the number of messages in the incoming, active, and deferred
# queues of postfix one per line suitable for use with snmpd/cricket/rrdtool
#
# 2003/01/24 Mike Saunders <method at method DOT cx>
# mailqsize was originally written by Vivek Khera. All I did was
# make it update an rrd.
# 2003/04/14 Ralf Hildebrandt <ralf.hildebrandt at charite DOT de>
# I bundled this with a modified mailgraph
# 2007/07/28 Ralf Hildebrandt <ralf.hildebrandt at charite DOT de>
# find rrdtool using "which"

# change this to the location of rrdtool
RRDTOOL=`which rrdtool`

# change this to the location you want to store the rrd
RRDFILE=/etc/postfix/mailqueues.rrd
sieht ja gleich aus.....

Dateiberechtigung?

Grüße

Manfred Werner
30.04.08, 09:24
Hallo guten Morgen, :D

hier die Berechtigungen. Wie sehen diese bei Dir aus?

die queuegraph-rd.ssh


Mailserver:~ # ls -al /usr/local/bin/queuegraph-rrd.sh
-rwxr-xr-x 1 root root 1463 Apr 30 09:11 /usr/local/bin/queuegraph-rrd.sh

die mailqueues.rrd


Mailserver:~ # ls -al /etc/postfix/mailqueues.rrd
-rw-r--r-- 1 root root 3776168 Apr 30 09:15 /etc/postfix/mailqueues.rrd

die queuegraph.cgi


Mailserver:~ # ls -al /srv/www/cgi-bin/queuegraph.cgi
-rwxr-xr-x 1 root root 4033 Apr 29 16:26 /srv/www/cgi-bin/queuegraph.cgi
und das tmp-verzeichnis


Mailserver:~ # ls -al /var/lib/queuegraph/
total 1
drwxr-xr-x 3 root root 72 Apr 29 16:23 .
drwxr-xr-x 56 root root 1472 Apr 29 17:17 ..
drwxr-xr-x 3 wwwrun www 88 Apr 29 16:26 img


Manfred

Manfred Werner
09.11.09, 11:04
Hallo Forum hatte endlich mal wieder ein wenig Zeit mich mit diesem Thema zu beschäftigen und habe eine Lösung.
ich habe mit
ln -s /var/lib/queuegraph/img/,cgi-bin,queuegraph.cgi/queuegraph_0.png /var/lib/queuegraph/img/queuegraph_0.png,
ln -s /var/lib/queuegraph/img/,cgi-bin,queuegraph.cgi/queuegraph_1.png /var/lib/queuegraph/img/queuegraph_1.png
ln -s /var/lib/queuegraph/img/,cgi-bin,queuegraph.cgi/queuegraph_2.png /var/lib/queuegraph/img/queuegraph_2.png
ln -s /var/lib/queuegraph/img/,cgi-bin,queuegraph.cgi/queuegraph_3.png /var/lib/queuegraph/img/queuegraph_3.png

3 Links auf die Image-Dateien gelegt und dann mit

chgrp -R www img und

chown -R wwwrun img
die Gruppen und Eigentümerrechten nochmal rekursiv überschrieben
Jetzt geht´s :D

Manfred