|
4 | 4 | # 2011 Copyright (C) Christian Garbs <mitch@cgarbs.de> |
5 | 5 | # Licensed under GNU GPL v3 or later. |
6 | 6 | # |
7 | | -# This script should be once a day.. |
| 7 | +# This script should be run once a day. |
8 | 8 | # |
9 | 9 |
|
10 | 10 | use strict; |
|
40 | 40 | if ( ! -e $datafile ) { |
41 | 41 | RRDs::create($datafile, |
42 | 42 | "--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", |
54 | 55 | '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', |
57 | 59 | ); |
58 | 60 | $ERR=RRDs::error; |
59 | 61 | die "ERROR while creating $datafile: $ERR\n" if $ERR; |
|
87 | 89 | $ERR=RRDs::error; |
88 | 90 | die "ERROR while updating $datafile: $ERR\n" if $ERR; |
89 | 91 |
|
| 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 | + |
90 | 128 | # draw pictures |
91 | 129 | foreach ( [604800, "week"], [31536000, "year"] ) { |
92 | 130 | my ($time, $scale) = @{$_}; |
93 | 131 | RRDs::graph($picbase . $scale . ".png", |
94 | 132 | "--start=-${time}", |
95 | 133 | '--lazy', |
96 | 134 | '--imgformat=PNG', |
| 135 | + '--upper-limit=0', |
| 136 | + '--lower-limit=-1000', |
97 | 137 | "--title=${hostname} usenet top1000 stats (last $scale)", |
98 | 138 | "--width=$conf{GRAPH_WIDTH}", |
99 | 139 | "--height=$conf{GRAPH_HEIGHT}", |
100 | 140 |
|
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, |
103 | 152 |
|
104 | | - 'LINE2:submit_min#FFD0D0:min submit', |
105 | | - 'LINE1:submit_avg#D0FFD0:avg submit', |
106 | 153 | 'COMMENT:\n', |
107 | 154 | ); |
108 | 155 | $ERR=RRDs::error; |
|
0 commit comments