root/lib/Resmon/Module/FRESHSVN.pm

Revision f57f044b8002489d9766fde62d97fbaa77e8650c, 1.9 kB (checked in by Sergey Ivanov <seriv@omniti.com>, 6 years ago)

fix according to recent false pages

git-svn-id: https://labs.omniti.com/resmon/trunk@58 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 @ISA = qw/Resmon::Module/;
6
7 sub handler {
8   my $arg = shift;
9   my $os = $arg->fresh_status();
10   return $os if $os;
11   my $dir = $arg->{'object'};
12   my $moutput = cache_command("/opt/omni/bin/svn info $dir", 60);
13   my @mlines = split (/\n/,$moutput);
14   my ($URL,$mr);
15   for(@mlines) {
16     if (/^URL:\s*(.*)$/) { $URL=$1; }
17     elsif (/^Revision:\s*(\d+)/) { $mr = $1; }
18   }
19   return ($arg->set_status("BAD(wrong URL, in conf:".$arg->{'URL'}.", checked out: $URL)")) if ($URL ne $arg->{'URL'});
20   my $uoutput = cache_command("/opt/omni/bin/svn info --username svnsync --password Athi3izo  --no-auth-cache --non-interactive $URL", 60);
21   my @ulines = split (/\n/,$uoutput);
22   my ($ur);
23   for(@ulines) {
24     if (/^Last Changed Rev:\s*(\d+)/) { $ur = $1; }
25   }
26   if($ur <= $mr){ return($arg->set_status("OK(rev:$ur)")); }
27   else{
28     my ($cY,$cM,$cD,$ch,$cm,$cs) = split (/ /, `date '+%Y %m %d %H %M %S'`);
29     my $cTime=$cs+60*($cm+60*($ch+24*($cD+31*($cM+12*$cY))));
30     my $dNow = "$cM/$cD/$cY $ch:$cm:$cs"; chomp $dNow;
31     my ($uY,$uM,$uD,$uh,$um,$us);
32     for(@ulines) {
33       if (/^Last Changed Date:\s*(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{2}):(\d{2})/) {
34         ($uY,$uM,$uD,$uh,$um,$us) = ($1,$2,$3,$4,$5,$6);
35       }
36     }
37     my $uTime = $us+60*($um+60*($uh+24*($uD+31*($uM+12*$uY))));
38     my $dCommitted = "$uM/$uD/$uY $uh:$um:$us";
39     my $lag=$cTime-$uTime;
40     my $maxlag=$arg->{'maxlag'}*60 || 330;
41     if ($lag <= $maxlag){
42       return($arg->set_status("OK(delay = $lag < $maxlag)"));
43     }
44     elsif ( ( ($us+60*($um+60*($uh+24*$uD))) < $maxlag )
45          && ( ($cs+60*($cm+60*($ch+24*$cD))) < 2 * $maxlag )
46           )
47     {
48       return($arg->set_status("WARNING(check unreliable, check later)"));
49     }
50     else {
51       return($arg->set_status("BAD(now $dNow, my rev:$mr, repo rev:$ur, committed: $dCommitted)"));
52     }
53   }
54 }
Note: See TracBrowser for help on using the browser.