From acf1c4723fcc6b51b78494afbaa8b5cea1518b5f Mon Sep 17 00:00:00 2001 From: xzilla Date: Thu, 14 Sep 2006 20:54:27 +0000 Subject: [PATCH] applied my refactored patch of bill morans healthy slon patch. with some bugfixes after I tested it. --- classes/Misc.php | 16 ++++++++++++++-- classes/plugins/Slony.php | 13 ++++++++++--- lang/english.php | 7 ++++++- lang/recoded/english.php | 7 ++++++- plugin_slony.php | 7 ++++++- 5 files changed, 42 insertions(+), 8 deletions(-) diff --git a/classes/Misc.php b/classes/Misc.php index 62c52641..2cdb75db 100644 --- a/classes/Misc.php +++ b/classes/Misc.php @@ -2,7 +2,7 @@ /** * Class to hold various commonly used functions * - * $Id: Misc.php,v 1.133 2006/08/09 21:19:44 xzilla Exp $ + * $Id: Misc.php,v 1.134 2006/09/14 20:54:27 xzilla Exp $ */ class Misc { @@ -202,7 +202,19 @@ } } } - break; + break; + case 'slonystatus': + switch ($str) { + case 'insync': + $out = $lang['strhealthy']; + break; + case 'outofsync': + $out = $lang['stroutofsync']; + break; + default: + $out = $lang['strunknown']; + } + break; default: // If the string contains at least one instance of >1 space in a row, a tab // character, a space at the start of a line, or a space at the start of diff --git a/classes/plugins/Slony.php b/classes/plugins/Slony.php index f8666b81..91a4aaf8 100755 --- a/classes/plugins/Slony.php +++ b/classes/plugins/Slony.php @@ -3,7 +3,7 @@ /** * A class that implements the Slony 1.0.x support plugin * - * $Id: Slony.php,v 1.9 2005/11/16 08:01:18 chriskl Exp $ + * $Id: Slony.php,v 1.10 2006/09/14 20:54:27 xzilla Exp $ */ include_once('./classes/plugins/Plugin.php'); @@ -277,8 +277,15 @@ class Slony extends Plugin { $schema = $this->slony_schema; $data->fieldClean($schema); - $sql = "SELECT * FROM \"{$schema}\".sl_node ORDER BY no_comment"; - + // We use 10 seconds as the default check time since that is the + // the default in Slony, and it gives no mechanism to look it up + $sql = "SELECT no_id, no_active, no_comment, no_spool, ". + "CASE WHEN st_lag_time > '10 seconds'::interval ". + "THEN 'outofsync' ELSE 'insync' END AS no_status ". + "FROM \"{$schema}\".sl_node ". + "LEFT JOIN \"{$schema}\".sl_status ON (no_id =st_received) ". + "ORDER BY no_comment"; + return $data->selectSet($sql); } diff --git a/lang/english.php b/lang/english.php index 5eab614d..a9251240 100755 --- a/lang/english.php +++ b/lang/english.php @@ -4,7 +4,7 @@ * English language file for phpPgAdmin. Use this as a basis * for new translations. * - * $Id: english.php,v 1.195 2006/08/13 15:31:13 xzilla Exp $ + * $Id: english.php,v 1.196 2006/09/14 20:54:27 xzilla Exp $ */ // Language and character set @@ -748,6 +748,11 @@ $lang['strfailover'] = 'Failover'; $lang['strnodefailedover'] = 'Node failed over.'; $lang['strnodefailedoverbad'] = 'Node failover failed.'; + $lang['strstatus'] = 'Status'; + $lang['strhealthy'] = 'Healthy'; + $lang['stroutofsync'] = 'Out of Sync'; + $lang['strunknown'] = 'Unknown'; + // Slony paths $lang['strpaths'] = 'Paths'; diff --git a/lang/recoded/english.php b/lang/recoded/english.php index 7834f9d1..2d13005e 100644 --- a/lang/recoded/english.php +++ b/lang/recoded/english.php @@ -4,7 +4,7 @@ * English language file for phpPgAdmin. Use this as a basis * for new translations. * - * $Id: english.php,v 1.148 2006/08/13 15:31:13 xzilla Exp $ + * $Id: english.php,v 1.149 2006/09/14 20:54:27 xzilla Exp $ */ // Language and character set @@ -748,6 +748,11 @@ $lang['strfailover'] = 'Failover'; $lang['strnodefailedover'] = 'Node failed over.'; $lang['strnodefailedoverbad'] = 'Node failover failed.'; + $lang['strstatus'] = 'Status'; + $lang['strhealthy'] = 'Healthy'; + $lang['stroutofsync'] = 'Out of Sync'; + $lang['strunknown'] = 'Unknown'; + // Slony paths $lang['strpaths'] = 'Paths'; diff --git a/plugin_slony.php b/plugin_slony.php index a71dbd7c..f03ee3c2 100755 --- a/plugin_slony.php +++ b/plugin_slony.php @@ -3,7 +3,7 @@ /** * Slony database tab plugin * - * $Id: plugin_slony.php,v 1.10 2006/08/07 18:11:15 xzilla Exp $ + * $Id: plugin_slony.php,v 1.11 2006/09/14 20:54:27 xzilla Exp $ */ // Include application functions @@ -603,6 +603,11 @@ 'title' => $lang['strname'], 'field' => 'no_comment' ), + 'no_status' => array( + 'title' => $lang['strstatus'], + 'field' => 'no_status', + 'type' => 'slonystatus', + ), 'actions' => array( 'title' => $lang['stractions'], ), -- 2.39.5