chiark / gitweb /
smoother and better news graphs
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 28 Jun 2010 00:33:38 +0000 (01:33 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 28 Jun 2010 00:33:38 +0000 (01:33 +0100)
cgi
newstailer

diff --git a/cgi b/cgi
index 81cd9a389b39d307350b0f6fc0e309b4f3454cde..d6193adfab855856b43360b372c0f03afd77f687 100755 (executable)
--- a/cgi
+++ b/cgi
@@ -25,7 +25,7 @@ sub graph_of_group ($$$$$) {
     my ($section, $group, $elem, $basis, $args) = @_;
     $basis->{Args}= $args;
     $basis->{Slower}= 0 unless exists $basis->{Slower};
-
+    $basis->{TimeRanges} ||= \@timeranges;
     $graphs{$section,$group,$elem}= $basis;
     if (!exists $group_elems{$section,$group}) {
        # new group then
@@ -175,8 +175,8 @@ foreach my $src (sort { news_name_sortkey($a) cmp news_name_sortkey($b) }
     next if $site eq '-';
     graph_of_group("News", $site, $inout,
          {
-               Slower => 1,
-               Units => '[art/s]'
+               Units => '[art/s]',
+               TimeRanges => [ map { $_*86400 } qw(1 7 31), 366, 366*3 ]
            }, $inout eq 'out' ?
          [
           (map { "DEF:$_=$src:$_:AVERAGE" }
@@ -197,8 +197,9 @@ foreach my $src (sort { news_name_sortkey($a) cmp news_name_sortkey($b) }
           "AREA:rejected#f00:rej:STACK",
           "AREA:duplicate#000:dupe:STACK",
           "AREA:refused#aaa:unw:STACK",
+          "CDEF:kb_accepted_smooth=kb_accepted,<interval/60>,TREND",
           "LINE:kb_duplicate#ff0:kb dupe",
-          "LINE:kb_accepted#008:kb",
+          "LINE:kb_accepted_smooth#008:~kb",
           ]);
 }
 
@@ -246,16 +247,17 @@ if (defined $elem) {
     my $g= $graphs{$section,$group,$elem};
     die unless $g;
 
-    my @args= @{ $g->{Args} };
-
     my $width= num_param('w',370,100,1600);
     my $height= num_param('h',200,100,1600);
 
     my $sloth= param('sloth');
     die unless defined $sloth;
     $sloth =~ m/^(\d+)$/ or die;
-    my $end= $timeranges[$sloth];
+    my $end= $g->{TimeRanges}[$sloth];
     die unless defined $end;
+
+    my @args= @{ $g->{Args} };
+    s,\<interval/(\d+)\>, $end/$1 ,ge foreach @args;
     unshift @args, qw(--end now --start), "end-${end}s";
     
     if (param('debug')) {
@@ -268,7 +270,7 @@ if (defined $elem) {
 
     $title .= " $g->{Units}" if $g->{Units};
     unshift @args, '-t', $title;
-    
+
     exec (qw(rrdtool graph - -a PNG --full-size-mode),
          '-w',$width, '-h',$height,
          @args);
index e3aba619cd8763b4d7b486af55e1ec5f53c3b04d..15f8b6d42fd5e302b300ae71163567cfb1628c83 100755 (executable)
@@ -1,5 +1,10 @@
 #!/usr/bin/perl -w
 
+# killall newstailer
+# with-lock-ex -f data/news/lock sh -xc \
+# "rm data/news/*.rrd; ./newstailer -Odata/news/ -D \
+# /var/log/news/news.notice.{6,5,4,3,2,1}.gz /var/log/news/news.notice{.0,} ''"
+
 use strict qw(refs vars);
 use POSIX;
 
@@ -49,10 +54,12 @@ our @detail_defaults=
      Step => 60,
      DstArguments => "7200:0:U",
      Xff => 0.5,
-     Archives => [ [ 3600*4,           60 ],   # 4hr, 1min resolution
-                  [ 3600*25,         180 ],   # 25h, 3min resolution
-                  [ 86400*14*5,      3600 ],  # 14wks, 1hr resolution
-                  [ 86400*370*2, 3600*24 ] ], # 2yr+, 1day resolution
+     Archives => [ [ 3600*4,            60 ],   # 4hr, 1min resolution
+                  [ 3600*25,          180 ],   # 25h, 3min resolution
+                  [ 86400*8,          600 ],   #  8d, 10min resolution
+                  [ 86400*7*14,    3600*2 ],   # 14wks, 2hr resolution
+                  [ 86400*366,     3600*6 ],   # 1yr, 6hr resolution
+                  [ 86400*366*3,   3600*24 ] ], # 3yr, 1d resolution
      );
 
 our @fields_in= qw(seconds accepted refused rejected duplicate