Medium sized Internalization made by flattener against megalog-2018-03-11
[andk-cpan-tools.git] / munin / maxid-age
bloba7e4fe41891aa966714ba0a73cc61c208036a80e
1 #!/usr/bin/perl
2 # Parameters understood:
4 # config (required)
5 # autoconf (optional - used by munin-config)
7 # Magic markers - optional - used by installation scripts and
8 # munin-config:
10 #%# family=auto
11 #%# capabilities=autoconf
13 use strict;
14 use DBI;
15 use Time::Local qw(timegm);
16 my $sql = "select fulldate from cpanstats where id=(select max(id) from cpanstats)";
17 my($pgdbh,$pgsth,$pgmaxid,$nextid);
18 $pgdbh = DBI->connect("dbi:Pg:dbname=analysis") or die "Could not connect to 'analysis': $DBI::err";
19 $pgsth = $pgdbh->prepare($sql);
20 $pgsth->execute;
21 my($fulldate) = $pgsth->fetchrow_array;
22 my($y,$mon,$d,$h,$min) = $fulldate =~ /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/;
23 $mon--;
24 my $pgepoch = timegm(0,$min,$h,$d,$mon,$y);
25 my $age = time - $pgepoch;
26 die "Seems like somebody is doing postprocessing: fulldate=$fulldate, age=$age > 1M" if $age > 1_000_000;
28 if ($ARGV[0] eq "autoconf"){
29 if ( $fulldate
31 print "yes\n";
32 exit 0;
33 } else {
34 print "no\n";
35 exit 1;
39 if ( $ARGV[0] eq "config" ){
40 print <<EOF;
41 graph_title time since maxid in cpanstats
42 graph_args -r
43 graph_vlabel seconds
44 graph_scale yes
45 graph_info Age of highest record in DB
46 graph_category cpantesters
47 EOF
49 for my $c ("age"){
50 #my $draw = "??/";
51 print <<EOF;
52 maxid$c.label $c
53 maxid$c.min 0
54 maxid$c.type GAUGE
55 EOF
57 exit 0;
61 printf "maxidage.value %d\n", $age;
64 # Local Variables:
65 # mode: cperl
66 # cperl-indent-level: 4
67 # indent-tabs-mode: nil
68 # End:
69 # vim:sw=4:ts=8:sta:et