Leser: 2
|< 1 2 >| | 11 Einträge, 2 Seiten |
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
sub send_image($)
{
my ($file)= @_;
-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, 16384)>0;
}
sub main()
{
my $uri = $ENV{REQUEST_URI} || '';
$uri =~ s/\/[^\/]+$//;
$uri =~ s/\//,/g;
$uri =~ s/(\~|\%7E)/tilde,/g;
mkdir $tmp_dir, 0777 unless -d $tmp_dir;
mkdir "$tmp_dir/$uri", 0777 unless -d "$tmp_dir/$uri";
my $img = $ENV{QUERY_STRING};
if(defined $img and $img =~ /\S/) {
if($img =~ /^(\d+)-n$/) {
my $file = "$tmp_dir/$uri/mailgraph_$1.png";
graph($graphs[$1]{seconds}, $file);
send_image($file);
}
elsif($img =~ /^(\d+)-e$/) {
my $file = "$tmp_dir/$uri/mailgraph_$1_err.png";
graph_err($graphs[$1]{seconds}, $file);
send_image($file);
}
else {
die "ERROR: invalid argument\n";
}
}
else {
print_html;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
my $img = $ENV{QUERY_STRING};
if(defined $img and $img =~ /\S/) {
if($img =~ /^(\d+)-n$/) {
my $file = "$tmp_dir/$uri/mailgraph_$1.png";
graph($graphs[$1]{seconds}, $file);
send_image($file);
}
elsif($img =~ /^(\d+)-e$/) {
my $file = "$tmp_dir/$uri/mailgraph_$1_err.png";
graph_err($graphs[$1]{seconds}, $file);
send_image($file);
}
else {
die "ERROR: invalid argument\n";
}
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
sub graph($$)
{
my ($range, $file) = @_;
my $step = $range*$points_per_sample/$xpoints;
rrd_graph($range, $file, $ypoints,
"DEF:sent=$rrd:sent:AVERAGE",
"DEF:msent=$rrd:sent:MAX",
"CDEF:rsent=sent,60,*",
"CDEF:rmsent=msent,60,*",
"CDEF:dsent=sent,UN,0,sent,IF,$step,*",
"CDEF:ssent=PREV,UN,dsent,PREV,IF,dsent,+",
"AREA:rsent#$color{sent}:Sent ",
'GPRINT:ssent:MAX:total\: %8.0lf msgs',
'GPRINT:rsent:AVERAGE:avg\: %5.2lf msgs/min',
'GPRINT:rmsent:MAX:max\: %4.0lf msgs/min\l',
"DEF:recv=$rrd:recv:AVERAGE",
"DEF:mrecv=$rrd:recv:MAX",
"CDEF:rrecv=recv,60,*",
"CDEF:rmrecv=mrecv,60,*",
"CDEF:drecv=recv,UN,0,recv,IF,$step,*",
"CDEF:srecv=PREV,UN,drecv,PREV,IF,drecv,+",
"LINE2:rrecv#$color{received}:Received",
'GPRINT:srecv:MAX:total\: %8.0lf msgs',
'GPRINT:rrecv:AVERAGE:avg\: %5.2lf msgs/min',
'GPRINT:rmrecv:MAX:max\: %4.0lf msgs/min\l',
);
}
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
#!/usr/bin/perl
use strict;
use warnings;
use RRDs;
my @graphs = (
{ title => 'Day Graphs', seconds => 3600*24, },
{ title => 'Week Graphs', seconds => 3600*24*7, },
{ title => 'Month Graphs', seconds => 3600*24*31, },
{ title => 'Year Graphs', seconds => 3600*24*365, },
my ($number,$option) = $ARGV[0] =~ /^(\d+)-(\w)$/;
my $uri = $ARGV[1];
my ($xpoints,$ypoints,$points_per_sample) = (); # werte musst Du noch eintragen
# hier noch variablen wie $rrd, %colors,etc. definieren
die "Falscher Aufruf" unless($number && $option && $uri);
my $path = '/meineBilder/';
my $filepath = $path.$uri.'/mailgraph-'.$number.'.png';
if($option eq 'n'){
my $filepath = $path.$uri.'/mailgraph-'.$number.'.png';
graph($filepath,$graphs[$number]->{seconds});
}
elsif($option eq 'e'){
my $filepath = $path.$uri.'/mailgraph-'.$number.'_error.png';
graph_err($filepath,$graphs[$number]->{seconds});
}
#hier die sub graph_err einfuegen
sub graph{
my ($range, $file) = @_;
my $step = $range*$points_per_sample/$xpoints;
rrd_graph($range, $file, $ypoints,
"DEF:sent=$rrd:sent:AVERAGE",
"DEF:msent=$rrd:sent:MAX",
"CDEF:rsent=sent,60,*",
"CDEF:rmsent=msent,60,*",
"CDEF:dsent=sent,UN,0,sent,IF,$step,*",
"CDEF:ssent=PREV,UN,dsent,PREV,IF,dsent,+",
"AREA:rsent#$color{sent}:Sent ",
'GPRINT:ssent:MAX:total\: %8.0lf msgs',
'GPRINT:rsent:AVERAGE:avg\: %5.2lf msgs/min',
'GPRINT:rmsent:MAX:max\: %4.0lf msgs/min\l',
"DEF:recv=$rrd:recv:AVERAGE",
"DEF:mrecv=$rrd:recv:MAX",
"CDEF:rrecv=recv,60,*",
"CDEF:rmrecv=mrecv,60,*",
"CDEF:drecv=recv,UN,0,recv,IF,$step,*",
"CDEF:srecv=PREV,UN,drecv,PREV,IF,drecv,+",
"LINE2:rrecv#$color{received}:Received",
'GPRINT:srecv:MAX:total\: %8.0lf msgs',
'GPRINT:rrecv:AVERAGE:avg\: %5.2lf msgs/min',
'GPRINT:rmrecv:MAX:max\: %4.0lf msgs/min\l',
);
}
|< 1 2 >| | 11 Einträge, 2 Seiten |