rss2html/plot_stats

48 lines
1.1 KiB
Perl
Executable File

#!/usr/bin/perl
use warnings;
use strict;
use TimeSeries;
my $wanted_feed_id = shift;
my $current_feed_id = -1;
my $current_time;
my @updates_in_interval;
my $update_count;
my $ts = TimeSeries->new(style => 'points');
$ts->legend('raw', 'adjusted');
$ts->finalresolution(100);
my @files = glob("/var/log/roxen/hjp/cgi.????-??-??");
@files = @files[-7..-1];
for my $file (@files) {
open my $fh, '<', $file;
while (<$fh>) {
if (/: \d+\.\d+: feed: (\d+) .*/) {
$current_feed_id = $1;
$update_count = 0;
}
next unless $current_feed_id == $wanted_feed_id;
if (/: [ ]
\d\d\d\d-\d\d-\d\d [ ] \w\w\w [ ] \d\d:\d\d:\d\d
[ ][ ] \.\. [ ][ ]
(\d\d\d\d-\d\d-\d\d) [ ] \w\w\w [ ] (\d\d:\d\d:\d\d)
/x
) {
$current_time = "$1T$2";
}
if (/updates_in_interval: ([-+\d.e]+)/) {
$updates_in_interval[$update_count++] = $1;
if ($update_count == 3) {
#print "$current_time\t$updates_in_interval[1]\t$updates_in_interval[2]\n";
$ts->add_timestring($current_time, @updates_in_interval[1, 2]);
}
}
}
}
print $ts->plot;