root/lib/Resmon/Module/FRESHSVN.pm

Revision c5ad4a81040e6fc1a5f1fc168e3651d038ee71d2, 2.0 kB (checked in by Mark Harrison <mark@omniti.com>, 5 years ago)

Fixed compilation error in FRESHSVN module

git-svn-id: https://labs.omniti.com/resmon/trunk@148 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

  • Property mode set to 100644
Line 
1 package Resmon::Module::FRESHSVN;
2 use strict;
3 use Resmon::ExtComm qw/cache_command/;
4 use vars qw/@ISA/;
5 use File::Find;
6
7 @ISA = qw/Resmon::Module/;
8
9 sub handler {
10   # Find location of subversion binary
11   my $svn = 'svn';
12   for my $path (qw(/usr/local/bin /opt/omni/bin)) {
13     if (-x "$path/svn") {
14       $svn = "$path/svn";
15       last;
16     }
17   }
18
19   my $arg = shift;
20   my $dir = $arg->{'object'};
21   my $moutput = cache_command("$svn info $dir", 60);
22   my @mlines = split (/\n/,$moutput);
23   my ($URL,$mr);
24   for(@mlines) {
25     if (/^URL:\s*(.*)$/) { $URL=$1; }
26     elsif (/^Revision:\s*(\d+)/) { $mr = $1; }
27   }
28   return ("BAD(wrong URL, in conf:".$arg->{'URL'}.", checked out: $URL)") if ($URL ne $arg->{'URL'});
29   my $uoutput = cache_command("$svn info --username svnsync --password Athi3izo  --no-auth-cache --non-interactive $URL", 60);
30   my @ulines = split (/\n/,$uoutput);
31   my ($ur);
32   for(@ulines) {
33     if (/^Last Changed Rev:\s*(\d+)/) { $ur = $1; }
34   }
35   if(!$ur){ return "BAD(Unable to determine latest revision in repository)"; }
36   if($ur <= $mr){ return "OK(rev:$ur)"; }
37   else{
38     my ($cY,$cM,$cD,$ch,$cm,$cs) = split (/ /, `date '+%Y %m %d %H %M %S'`);
39     my $cTime=$cs+60*($cm+60*($ch+24*($cD+31*($cM+12*$cY))));
40     my $dNow = "$cM/$cD/$cY $ch:$cm:$cs"; chomp $dNow;
41     my ($uY,$uM,$uD,$uh,$um,$us);
42     for(@ulines) {
43       if (/^Last Changed Date:\s*(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{2}):(\d{2})/) {
44         ($uY,$uM,$uD,$uh,$um,$us) = ($1,$2,$3,$4,$5,$6);
45       }
46     }
47     my $uTime = $us+60*($um+60*($uh+24*($uD+31*($uM+12*$uY))));
48     my $dCommitted = "$uM/$uD/$uY $uh:$um:$us";
49     my $lag=$cTime-$uTime;
50     my $maxlag=$arg->{'maxlag'}*60 || 330;
51     if ($lag <= $maxlag){
52       return "OK(delay = $lag < $maxlag)";
53     }
54     elsif ( ( ($us+60*($um+60*($uh+24*$uD))) < $maxlag )
55          && ( ($cs+60*($cm+60*($ch+24*$cD))) < 2 * $maxlag )
56           )
57     {
58       return("WARNING(check unreliable, check later)");
59     }
60     else {
61       return("BAD(now $dNow, my rev:$mr, repo rev:$ur, committed: $dCommitted)");
62     }
63   }
64 }
65 1;
Note: See TracBrowser for help on using the browser.