root/BETAUTO.pl

Revision a141f475cb3a0e6ef6406dfc7d03920473578af9, 1.0 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 12 years ago)

betauto for FEW

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

  • Property mode set to 100644
Line 
1 #!/data/bin/perl
2
3 use POSIX;
4
5 register_monitor('BETAUTO', sub {
6   my $arg = shift;
7   my $os = fresh_status($arg);
8   return $os if $os;
9   my $file1 = '/data/logs/subscription/insert_bets.log';
10
11   my $thistime = time()-int(86400*(16.5/24));
12   my $error;
13   my $datematcher = POSIX::strftime("%b %d", localtime($thistime));
14   $datematcher =~ s/ 0/  /g;
15   $datematcher .= ' \d\d:\d\d:\d\d ';
16   $datematcher .= POSIX::strftime("%Y", localtime($thistime));
17
18   open(TF, "tail -5 $file1|");
19   my $state = 0;
20   while(<TF>) {
21     chomp;
22     unless(/$datematcher/) {
23       $error = $_;
24     }
25     ($state==0) && /Start insert bets/ && ($state = 1);
26     ($state==1) && /sublotto/ && ($state = 2);
27     ($state==2) && /fwlotto/ && ($state = 3);
28     ($state==3) && /flezwin/ && ($state = 4);
29     ($state==4) && /Finish insert bets/ && ($state = 5);
30   }
31   close(TF);
32   if($state != 5 || $error) {
33     return set_status($arg, "BAD($error)");
34   }
35   return set_status($arg, "OK(log line expected)");
36 });
37
38 1;
Note: See TracBrowser for help on using the browser.