Skip to content

Commit c4cf79f

Browse files
committed
fix top1000.org script
1 parent 2e9d867 commit c4cf79f

1 file changed

Lines changed: 65 additions & 18 deletions

File tree

‎top1000.pl‎

Lines changed: 65 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# 2011 Copyright (C) Christian Garbs <mitch@cgarbs.de>
55
# Licensed under GNU GPL v3 or later.
66
#
7-
# This script should be once a day..
7+
# This script should be run once a day.
88
#
99

1010
use strict;
@@ -40,20 +40,22 @@
4040
if ( ! -e $datafile ) {
4141
RRDs::create($datafile,
4242
"--step=86400",
43-
"DS:submitted:ABSOLUTE:150000:0:U",
44-
"DS:site0:ABSOLUTE:150000:0:1000",
45-
"DS:site1:ABSOLUTE:150000:0:1000",
46-
"DS:site2:ABSOLUTE:150000:0:1000",
47-
"DS:site3:ABSOLUTE:150000:0:1000",
48-
"DS:site4:ABSOLUTE:150000:0:1000",
49-
"DS:site5:ABSOLUTE:150000:0:1000",
50-
"DS:site6:ABSOLUTE:150000:0:1000",
51-
"DS:site7:ABSOLUTE:150000:0:1000",
52-
"DS:site8:ABSOLUTE:150000:0:1000",
53-
"DS:site9:ABSOLUTE:150000:0:1000",
43+
"--start=1302345000",
44+
"DS:submitted:COUNTER:160000:0:U",
45+
"DS:site0:GAUGE:160000:0:1000",
46+
"DS:site1:GAUGE:160000:0:1000",
47+
"DS:site2:GAUGE:160000:0:1000",
48+
"DS:site3:GAUGE:160000:0:1000",
49+
"DS:site4:GAUGE:160000:0:1000",
50+
"DS:site5:GAUGE:160000:0:1000",
51+
"DS:site6:GAUGE:160000:0:1000",
52+
"DS:site7:GAUGE:160000:0:1000",
53+
"DS:site8:GAUGE:160000:0:1000",
54+
"DS:site9:GAUGE:160000:0:1000",
5455
'RRA:AVERAGE:0.5:1:370',
55-
'RRA:AVERAGE:0.5:7:370',
56-
'RRA:MIN:0.5:288:797'
56+
'RRA:AVERAGE:0.5:7:288',
57+
'RRA:MIN:0.5:1:370',
58+
'RRA:MIN:0.5:7:288',
5759
);
5860
$ERR=RRDs::error;
5961
die "ERROR while creating $datafile: $ERR\n" if $ERR;
@@ -87,22 +89,67 @@
8789
$ERR=RRDs::error;
8890
die "ERROR while updating $datafile: $ERR\n" if $ERR;
8991

92+
# set up colorspace
93+
my $drawn = 0;
94+
my @colors = qw(
95+
00F0F0
96+
F0F040
97+
F000F0
98+
00F000
99+
0000F0
100+
000000
101+
AAAAAA
102+
F00000
103+
F09000
104+
C0C0C0
105+
009000
106+
FF0000
107+
000090
108+
900090
109+
009090
110+
909000
111+
E00070
112+
2020F0
113+
FF00FF
114+
);
115+
116+
# draw which values?
117+
my (@def, @line);
118+
foreach my $site (@sites) {
119+
if (defined $site) {
120+
my $color = $colors[$drawn];
121+
push @def, sprintf 'DEF:site%d_=%s:site%d:AVERAGE', $drawn, $datafile, $drawn;
122+
push @def, sprintf 'CDEF:site%d=0,site%d_,-', $drawn, $drawn;
123+
push @line, sprintf 'LINE2:site%d#%s:%s', $drawn, $color, $site;
124+
$drawn ++;
125+
}
126+
}
127+
90128
# draw pictures
91129
foreach ( [604800, "week"], [31536000, "year"] ) {
92130
my ($time, $scale) = @{$_};
93131
RRDs::graph($picbase . $scale . ".png",
94132
"--start=-${time}",
95133
'--lazy',
96134
'--imgformat=PNG',
135+
'--upper-limit=0',
136+
'--lower-limit=-1000',
97137
"--title=${hostname} usenet top1000 stats (last $scale)",
98138
"--width=$conf{GRAPH_WIDTH}",
99139
"--height=$conf{GRAPH_HEIGHT}",
100140

101-
"DEF:submit_avg=${datafile}:submitted:AVERAGE",
102-
"DEF:submit_min=${datafile}:submitted:MIN",
141+
# "DEF:submit_avg_=${datafile}:submitted:AVERAGE",
142+
# "DEF:submit_min_=${datafile}:submitted:MIN",
143+
# 'CDEF:submit_avg=submit_avg_,10,/',
144+
# 'CDEF:submit_min=submit_min_,10,/',
145+
146+
@def,
147+
148+
# 'LINE2:submit_min#FFD0D0:min submit',
149+
# 'LINE1:submit_avg#D0FFD0:avg submit',
150+
151+
@line,
103152

104-
'LINE2:submit_min#FFD0D0:min submit',
105-
'LINE1:submit_avg#D0FFD0:avg submit',
106153
'COMMENT:\n',
107154
);
108155
$ERR=RRDs::error;

0 commit comments

Comments
 (0)