Index: trunk/ippMonitor/czartool/czartool/CzarDb.pm
===================================================================
--- trunk/ippMonitor/czartool/czartool/CzarDb.pm	(revision 40877)
+++ trunk/ippMonitor/czartool/czartool/CzarDb.pm	(revision 40878)
@@ -40,4 +40,5 @@
 use czartool::StageMetrics;
 
+
 ###########################################################################
 #
@@ -54,4 +55,23 @@
 
     return $self;
+}
+
+###########################################################################
+#
+# Gets last czarpoll iteration time
+#
+###########################################################################
+sub getPollDate {
+    my ($self,$polldate) = @_;
+
+    my $query = $self->{_db}->prepare(<<SQL);
+    SELECT timestamp FROM chip ORDER BY timestamp DESC LIMIT 1
+SQL
+
+    $query->execute;
+
+    $polldate = $query->fetchrow_array();
+
+    return $polldate;
 }
 
@@ -281,5 +301,18 @@
 SQL
 
-       $query->execute;
+        #execute the query, but check for deadlocks
+        my $db_res=0;
+        while($db_res==0)
+        {
+            $db_res=1;
+            my $result = eval{$query->execute;};
+            unless($result) {
+                 if(/DBD::mysql::st execute failed: Deadlock found when trying to get lock; try restarting transaction/){
+                     $db_res=0;
+                     sleep 3;
+                 } 
+            }
+        }
+        
     }
 }
