-
Notifications
You must be signed in to change notification settings - Fork 6
/
viking_reload.pl
executable file
·52 lines (34 loc) · 1.04 KB
/
viking_reload.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl
use DBI;
use strict;
sub Reload();
sub CheckSum($);
my $table_checksum = 0;
my $old_table_checksum = 0;
while(1){
$table_checksum = CheckSum("ws_customers");
$table_checksum += CheckSum("ws_providers");
$table_checksum += CheckSum("ws_routes");
print "Tables Checksum: $table_checksum \n";
if($old_table_checksum != $table_checksum){
Reload();
}
$old_table_checksum = $table_checksum;
$table_checksum=0;
sleep 10;
}
exit 0;
sub Reload(){
system("/home/freeswitch/freeswitch_reload_config.pl");
}
sub CheckSum($){
my $table_in = shift;
my $dbh = DBI->connect('DBI:mysql:viking;host=viking_db', 'viking', 'V1k1ng') || die "Could not connect to database: $DBI::errstr";
my $sth = $dbh->prepare('checksum table ' . $table_in . ';') or die "Couldn't prepare statement: " . $dbh->errstr;
$sth->execute();
while (my @data = $sth->fetchrow_array()) {
my $table = $data[0];
my $checksum = $data[1];
return $checksum;
}
}