From: Tatsuo Ishii Date: Mon, 16 Aug 2010 10:06:42 +0000 (+0000) Subject: Add primary/standby mode info to node status. X-Git-Tag: V3_0_0_BETA1~2 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=42d836a49708784fac4ae6f7217409bde455abfb;p=pgpooladmin.git Add primary/standby mode info to node status. --- diff --git a/common.php b/common.php index 4b2d887..274439d 100644 --- a/common.php +++ b/common.php @@ -247,6 +247,55 @@ function NodeActive($num) { } } +/** + * Confirmation whether node is act as a standby server + * + * @return integer + */ +function NodeStandby($num) { + + $params = readConfigParams(array('master_slave_mode','master_slave_sub_mode')); + + if ($params['master_slave_mode'] != 'true' || $params['master_slave_sub_mode'] != 'stream') + return -1; + + $healthCheckDb = 'template1'; + + $params = readHealthCheckParam(); + + $healthCheckUser = $params['health_check_user']; + $backendHostName = $params['backend_hostname'][$num]; + $backendPort = $params['backend_port'][$num]; + if($backendHostName != '') { + $conStr = "dbname=$healthCheckDb user=$healthCheckUser host=$backendHostName port=$backendPort" ; + } else { + $conStr = "dbname=$healthCheckDb port=$backendPort user=$healthCheckUser" ; + } + + $conn = @pg_connect($conStr); + + if($conn == FALSE) { + @pg_close($conn); + return -1; + } + + $res = pg_query($conn, 'SELECT pg_is_in_recovery()'); + if(!pg_result_status($res) == PGSQL_TUPLES_OK) { + return -1; + } + + $rr = pg_fetch_array($res); + + if ($rr[0][0] == 't') + $r = 1; + else + $r = 0; + + @pg_free_result($res); + @pg_close($conn); + return $r; +} + /** * Read parameter from pgpool.conf using health check * diff --git a/lang/en.lang.php b/lang/en.lang.php index 89864ad..57c9de9 100644 --- a/lang/en.lang.php +++ b/lang/en.lang.php @@ -181,8 +181,8 @@ $message = array( 'strMeasures' => 'Measures', 'strNodeInfo' => 'Node Info.', 'strNodeStatus' => 'Node Status', - 'strNodeStatus1' => 'Up. Disconnect', - 'strNodeStatus2' => 'Up. Connected', + 'strNodeStatus1' => 'Up. Disconnect.', + 'strNodeStatus2' => 'Up. Connected.', 'strNodeStatus3' => 'Down', 'strNoNode' => 'There is no node', 'strOff' => 'Off', @@ -211,6 +211,7 @@ $message = array( 'strPgpoolSummary' => 'Summary', 'strPleaseWait' => 'Please wait...', 'strPort' => 'Port', + 'strPrimaryRunning' => 'Running as primary server', 'strProcId' => 'Process ID', 'strProcInfo' => 'Process Info.', 'strProcTime' => 'Process Start Time', @@ -232,6 +233,7 @@ $message = array( 'strSetting' => 'pgpoolAdmin Setting', 'strSetup' => 'Setup', 'strSlonyMode' => 'Slony-I mode', + 'strStandbyRunning' => 'Running as standby server', 'strStartOption' => 'Start Option', 'strStartPgpool' => 'Start pgpool', 'strStatus' => 'Status', diff --git a/lang/ja.lang.php b/lang/ja.lang.php index 7f84eeb..d2c70fa 100644 --- a/lang/ja.lang.php +++ b/lang/ja.lang.php @@ -181,8 +181,8 @@ $message = array( 'strMeasures' => '対策', 'strNodeInfo' => 'ノード情報', 'strNodeStatus' => 'ノードステータス', - 'strNodeStatus1' => 'ノード稼働中。接続無し', - 'strNodeStatus2' => 'ノード稼働中。接続有り', + 'strNodeStatus1' => 'ノード稼働中。接続無し。', + 'strNodeStatus2' => 'ノード稼働中。接続有り。', 'strNodeStatus3' => 'ノードダウン', 'strNoNode' => 'ノードがありません', 'strOff' => 'オフ', @@ -211,6 +211,7 @@ $message = array( 'strPgpoolSummary' => 'サマリー', 'strPleaseWait' => 'しばらくお待ちください・・・', 'strPort' => 'ポート', + 'strPrimaryRunning' => 'プライマリとして稼働中', 'strProcId' => 'プロセスID', 'strProcInfo' => 'プロセス情報', 'strProcTime' => 'プロセススタート時刻', @@ -232,6 +233,7 @@ $message = array( 'strSetting' => '管理ツール設定', 'strSetup' => 'セットアップ', 'strSlonyMode' => 'Slony-Iモード', + 'strStandbyRunning' => 'スタンバイとして稼働中', 'strStartOption' => '起動オプション', 'strStartPgpool' => 'pgpool起動', 'strStatus' => 'ステータス', diff --git a/nodeStatus.php b/nodeStatus.php index f6f861f..4a5af3c 100644 --- a/nodeStatus.php +++ b/nodeStatus.php @@ -67,6 +67,8 @@ for($i=0; $i<$nodeCount; $i++) { /* node is active? */ if ($nodeInfo[$i][2] != 3) $node_alive = true; + + $nodeInfo[$i][5] = NodeStandby($i); } for ($i = 0; $i < $nodeCount; $i++) { diff --git a/templates/nodeStatus.tpl b/templates/nodeStatus.tpl index 45f0c60..da07cbc 100644 --- a/templates/nodeStatus.tpl +++ b/templates/nodeStatus.tpl @@ -35,6 +35,11 @@ {$message.strNodeStatus2|escape} {elseif $nodeInfo[num][2] == 3} {$message.strNodeStatus3|escape} + {/if} + {if $nodeInfo[num][5] == 1} + {$message.strStandbyRunning|escape} + {elseif $nodeInfo[num][5] == 0} + {$message.strPrimaryRunning|escape} {/if} {if $parallelMode == false}