From 1600dbdf6606178e5aaff8af580213159349996d Mon Sep 17 00:00:00 2001 From: mattf Date: Thu, 20 Jul 2006 15:49:40 +0000 Subject: [PATCH] added MySQL keepalive to DBI-version of AST_manager_listen.pl git-svn-id: svn://192.168.202.10@91 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_1-X/trunk/DBI-scripts/AST_manager_listen.pl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/agc_1-X/trunk/DBI-scripts/AST_manager_listen.pl b/agc_1-X/trunk/DBI-scripts/AST_manager_listen.pl index e2064a10..23948be0 100644 --- a/agc_1-X/trunk/DBI-scripts/AST_manager_listen.pl +++ b/agc_1-X/trunk/DBI-scripts/AST_manager_listen.pl @@ -35,6 +35,7 @@ # 51222-1553 - fixed parentheses bug in manager output # 60403-1230 - Added SVN/1.4 support for different output # 60718-0909 - changed to DBI by Marin Blu +# 60720-1142 - added keepalive to MySQL connection every 50 seconds # # constants @@ -137,7 +138,7 @@ while ($sthArows > $rec_count) if ($DBext_context) {$ext_context = $DBext_context;} $rec_count++; } - $sthA->finish(); +$sthA->finish(); if (!$telnet_port) {$telnet_port = '5038';} @@ -475,15 +476,25 @@ while($one_day_interval > 0) } ### run a keepalive command to flush whatever is in the buffer through and to keep the connection alive + ### Also, keep the MySQL connection alive by selecting the server_updater time for this server if ($endless_loop =~ /00$|50$/) { &get_time_now; + ### Grab Server values to keep DB connection alive + $stmtA = "SELECT last_update FROM server_updater where server_ip = '$server_ip';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + @aryA = $sthA->fetchrow_array; + $last_update = "$aryA[0]"; + $sthA->finish(); + @list_lines = $tn->cmd(String => "Action: Command\nCommand: show uptime\n\n", Prompt => '/--END COMMAND--.*/', Errmode => Return, Timeout => 1); if($DB){print "input lines: $#list_lines\n";} - if($DB){print "+++++++++++++++++++++++++++++++sending keepalive transmit line $endless_loop|$now_date|\n";} + if($DB){print "+++++++++++++++++++++++++++++++sending keepalive transmit line $endless_loop|$now_date|$last_update|\n";} $keepalive_count_loop=0; + }