root/BETAUTO.pl

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

auto bet insertion checks

git-svn-id: https://labs.omniti.com/resmon/trunk@13 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
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 -4 $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) && /Finish insert bets/ && ($state = 4);
29   }
30   close(TF);
31   if($state != 4 || $error) {
32     return set_status($arg, "BAD($error)");
33   }
34   return set_status($arg, "OK()");
35 });
36
37 1;
Note: See TracBrowser for help on using the browser.