From 093043e9e66ec045e65fe8469fc8038c53efd4af Mon Sep 17 00:00:00 2001 From: Nozomi Anzai Date: Mon, 13 May 2013 15:05:24 +0900 Subject: [PATCH] Several improvement and refactoring, especially in status.php. Now in status.php we can add a new backend, remove a backend, stop/reload start PostgreSQL, and know each watchdog statuses. --- command.php | 48 +- common.php | 75 ++- innerLog.php | 1 + innerNodeServerStatus.php | 43 +- innerSystemCatalog.php | 22 +- innerWatchdog.php | 39 ++ lang/en.lang.php | 20 +- lang/ja.lang.php | 29 +- login.php | 43 +- nodeServerStatus.php | 15 +- nodeStatus.php | 150 +++-- pgconfig.php | 38 +- screen.css | 150 ++++- status.php | 664 +++++++++++++------- templates/elements/pgconfig_new_backend.tpl | 37 ++ templates/elements/status_js.tpl | 203 ++++++ templates/elements/status_nodeinfo.tpl | 174 +++++ templates/elements/status_options.tpl | 109 ++++ templates/elements/status_pgsql_buttons.tpl | 15 + templates/elements/status_pgsql_options.tpl | 47 ++ templates/elements/status_start_option.tpl | 51 ++ templates/elements/status_stop_option.tpl | 25 + templates/innerLog.tpl | 16 +- templates/innerNodeServerStatus.tpl | 51 +- templates/innerSummary.tpl | 10 + templates/innerSystemCatalog.tpl | 6 +- templates/innerWatchdog.tpl | 51 ++ templates/menu.tpl | 2 + templates/nodeServerStatus.tpl | 21 +- templates/nodeStatus.tpl | 81 +-- templates/pgconfig.tpl | 71 ++- templates/procInfo.tpl | 12 +- templates/status.tpl | 547 ++++------------ 33 files changed, 1886 insertions(+), 980 deletions(-) create mode 100644 innerWatchdog.php create mode 100644 templates/elements/pgconfig_new_backend.tpl create mode 100644 templates/elements/status_js.tpl create mode 100644 templates/elements/status_nodeinfo.tpl create mode 100644 templates/elements/status_options.tpl create mode 100644 templates/elements/status_pgsql_buttons.tpl create mode 100644 templates/elements/status_pgsql_options.tpl create mode 100644 templates/elements/status_start_option.tpl create mode 100644 templates/elements/status_stop_option.tpl create mode 100644 templates/innerWatchdog.tpl diff --git a/command.php b/command.php index ce64a80..bde8f10 100644 --- a/command.php +++ b/command.php @@ -19,16 +19,12 @@ * is" without express or implied warranty. * * @author Ryuma Ando - * @copyright 2003-2009 PgPool Global Development Group + * @copyright 2003-2013 PgPool Global Development Group * @version CVS: $Id$ */ require_once('common.php'); -// timeout seconds -// (The parameter "pcp_timeout" existed till V3.0.) -define('PCP_TIMEOUT', 10); - /** * Execute pcp command * @@ -170,4 +166,46 @@ function readPcpInfo() $params = readConfigParams(array('pcp_port')); return $params; } + +/** Get node count */ +function getNodeCount() +{ + global $tpl; + + $result = execPcp('PCP_NODE_COUNT'); + + if (!array_key_exists('SUCCESS', $result)) { + $errorCode = 'e1002'; + $tpl->assign('errorCode', $errorCode); + $tpl->display('innerError.tpl'); + exit(); + } + + return $result['SUCCESS']; +} + +/** Get info of the specified node */ +function getNodeInfo($i) +{ + global $tpl; + + // execute "pcp_node_info" command + // ex) host1 5432 1 1073741823.500000 + $result = execPcp('PCP_NODE_INFO', $i); + + if (!array_key_exists('SUCCESS', $result)) { + $errorCode = 'e1003'; + $tpl->assign('errorCode', $errorCode); + $tpl->display('innerError.tpl'); + exit(); + } + + $arr = explode(" ", $result['SUCCESS']); + $rtn['hostname'] = $arr[0]; + $rtn['port'] = $arr[1]; + $rtn['status'] = $arr[2]; + $rtn['weight'] = sprintf('%.3f', $arr[3]); + + return $rtn; +} ?> diff --git a/common.php b/common.php index 302fb30..1cddd7b 100644 --- a/common.php +++ b/common.php @@ -25,13 +25,9 @@ require_once('version.php'); require_once('libs/Smarty.class.php'); +require_once('bootstrap.php'); error_reporting(E_ALL); -define('SESSION_LOGIN_USER', 'loginUser'); -define('SESSION_LOGIN_USER_PASSWORD', 'md5pass'); -define('SESSION_LANG', 'lang'); -define('SESSION_MESSAGE', 'message'); - function versions() { return array('3.2', '3.1', '3.0', @@ -40,12 +36,6 @@ function versions() session_start(); -/** - * Smarty Parameter - */ -define('SMARTY_TEMPLATE_DIR', dirname(__FILE__) . '/templates' ); -define('SMARTY_COMPILE_DIR', dirname(__FILE__) . '/templates_c' ); - /** * Initialize Smartry */ @@ -269,13 +259,13 @@ function NodeStandby($num) return -1; } - $res = pg_query($conn, 'SELECT pg_is_in_recovery()'); - if (!pg_result_status($res) == PGSQL_TUPLES_OK) { + $result = pg_query($conn, 'SELECT pg_is_in_recovery()'); + if (!pg_result_status($result) == PGSQL_TUPLES_OK) { @pg_close($conn); return -1; } - $rr = pg_fetch_array($res); + $rr = pg_fetch_array($result); if ($rr[0][0] == 't') { $r = 1; @@ -283,7 +273,7 @@ function NodeStandby($num) $r = 0; } - @pg_free_result($res); + @pg_free_result($result); @pg_close($conn); return $r; } @@ -308,13 +298,13 @@ function conStr($num, $mode = NULL) $params['health_check_password'] : NULL; } - // backkend info + // backend info $params = readConfigParams(array('backend_hostname', 'backend_port', 'backend_weight')); $conStr = array(); if ($params['backend_hostname'][$num] != '') { - $conStr[] = "host={$params['backend_hostname'][$num]} "; + $conStr[] = "host='{$params['backend_hostname'][$num]}'"; } $conStr[] = "port='{$params['backend_port'][$num]}'"; $conStr[] = "dbname='template1'"; @@ -657,4 +647,53 @@ function paramExists($param) } return FALSE; } -?> + +/* Get if loginUser is super user */ +function isSuperUser($user_name) +{ + if (DoesPgpoolPidExist() && isset($_SESSION[SESSION_IS_SUPER_USER])) { + return $_SESSION[SESSION_IS_SUPER_USER]; + } + $conn = @pg_connect(conStrPgpool()); + + if ($conn == FALSE) { + @pg_close($conn); + return NULL; + } + + $result = pg_query($conn, "SELECT usesuper FROM pg_user WHERE usename = '{$user_name}'"); + + if (!pg_result_status($result) == PGSQL_TUPLES_OK) { + @pg_close($conn); + return NULL; + } + + $rr = pg_fetch_array($result); + $rtn = (isset($rr['usesuper']) && $rr['usesuper'] == 't'); + + @pg_free_result($result); + @pg_close($conn); + + $_SESSION[SESSION_IS_SUPER_USER] = $rtn; + return $rtn; +} + +function conStrPgpool() +{ + $params = readConfigParams(array('port')); + $conStr[] = "port='{$params['port']}'"; + $conStr[] = "dbname='template1'"; + $conStr[] = "user='{$_SESSION[SESSION_LOGIN_USER]}'"; + $conStr[] = "password='{$_SESSION[SESSION_LOGIN_USER_PASSWORD]}'"; + + $conStr = implode($conStr, ' '); + return $conStr; +} + +/* for debug */ +function pr($array) +{ + echo '
';
+    print_r($array);
+    echo '
'; +} diff --git a/innerLog.php b/innerLog.php index 54ed27b..9bac2fe 100644 --- a/innerLog.php +++ b/innerLog.php @@ -60,6 +60,7 @@ for ($i = 0; $i < count($logFile); $i++) { $logFile[$i]['message'] = trim($logFile[$i]['message']); } +$tpl->assign('refreshTimeLog', REFRESH_LOG_SECONDS); $tpl->assign('logFile', $logFile); $tpl->display('innerLog.tpl'); ?> diff --git a/innerNodeServerStatus.php b/innerNodeServerStatus.php index 12b6c98..f42db35 100644 --- a/innerNodeServerStatus.php +++ b/innerNodeServerStatus.php @@ -19,39 +19,56 @@ * is" without express or implied warranty. * * @author Ryuma Ando - * @copyright 2003-2012 PgPool Global Development Group + * @copyright 2003-2013 PgPool Global Development Group * @version CVS: $Id$ */ require_once('common.php'); +require_once('command.php'); +/* --------------------------------------------------------------------- */ +/* InnerNodeServerStatus.php */ +/* --------------------------------------------------------------------- */ + +// Check login status if (!isset($_SESSION[SESSION_LOGIN_USER])) { exit(); } -$params = readConfigParams('backend_hostname'); +// Get backend info +$params = readConfigParams(array('backend_hostname', 'backend_port')); if (isset($params['backend_hostname'])) { $backendHostName = $params['backend_hostname']; $backendPort = $params['backend_port']; } else { $backendHostName = array(); + $backendHostPort = array(); } -$result = array(); +$is_pgpool_active = DoesPgpoolPidExist(); +$nodeInfo = array(); foreach($backendHostName as $num => $hostname) { - $result[$num]['hostname'] = $backendHostName[$num]; - $result[$num]['port'] = $backendPort[$num]; + $nodeInfo[$num]['hostname'] = $backendHostName[$num]; + $nodeInfo[$num]['port'] = $backendPort[$num]; + $nodeInfo[$num]['is_active'] = NodeActive($num); - if (NodeActive($num)) { - $result[$num]['status'] = TRUE; - } else { - $result[$num]['status'] = FALSE; + if ($is_pgpool_active) { + $result = getNodeInfo($num); + $nodeInfo[$num]['status'] = $result['status']; } } -$tpl->assign('nodeServerStatus', $result); -$tpl->assign('nodeCount', count($result)); -$tpl->display('innerNodeServerStatus.tpl'); +// Get node num +$nodeNum = (isset($_GET['num'])) ? $_GET['num'] : NULL; -?> +// Set vars +$tpl->assign('pgpoolIsActive', $is_pgpool_active); +$tpl->assign('nodeServerStatus', $nodeInfo); +$tpl->assign('nodeCount', count($nodeInfo)); +$tpl->assign('nodeNum', $nodeNum); +$tpl->assign('refreshTime', (0 <= _PGPOOL2_STATUS_REFRESH_TIME) ? + _PGPOOL2_STATUS_REFRESH_TIME * 1000 : 5000); + +// Display +$tpl->display('innerNodeServerStatus.tpl'); diff --git a/innerSystemCatalog.php b/innerSystemCatalog.php index 0a67946..f1b3f72 100644 --- a/innerSystemCatalog.php +++ b/innerSystemCatalog.php @@ -19,16 +19,22 @@ * is" without express or implied warranty. * * @author Ryuma Ando - * @copyright 2003-2008 PgPool Global Development Group + * @copyright 2003-2013 PgPool Global Development Group * @version CVS: $Id$ */ require_once('common.php'); +/* --------------------------------------------------------------------- */ +/* InnerSystemCatalog.php */ +/* --------------------------------------------------------------------- */ + +// Check login status if (!isset($_SESSION[SESSION_LOGIN_USER])) { exit(); } +// Get node num $pgCatalog = pg_escape_string($_GET['catalog']); $nodeNum = $_GET['num']; @@ -37,10 +43,7 @@ if ($pgCatalog == '') { } // Set Parameters -$params = readConfigParams(); - -$tpl->assign('hostname', $params['backend_hostname'][$nodeNum]); -$tpl->assign('port', $params['backend_port'][$nodeNum]); +$params = readConfigParams(array('backend_hostname', 'backend_port')); // Get Data From Database $conn = @pg_connect(conStr($nodeNum)); @@ -68,8 +71,11 @@ $results = pg_fetch_all($rs); closeDBConnection($conn); -// Show +// Set vars +$tpl->assign('hostname', $params['backend_hostname'][$nodeNum]); +$tpl->assign('port', $params['backend_port'][$nodeNum]); $tpl->assign('results', $results); -$tpl->display('innerSystemCatalog.tpl'); +$tpl->assign('nodeNum', $nodeNum); -?> +// Display +$tpl->display('innerSystemCatalog.tpl'); diff --git a/innerWatchdog.php b/innerWatchdog.php new file mode 100644 index 0000000..cec0e2c --- /dev/null +++ b/innerWatchdog.php @@ -0,0 +1,39 @@ + + * @copyright 2003-2011 PgPool Global Development Group + * @version CVS: $Id$ + */ + +require_once('common.php'); + +if (!isset($_SESSION[SESSION_LOGIN_USER])) { + exit(); +} + +$params = readConfigParams(array('port', 'wd_hostname', 'wd_port', 'delegate_IP', + 'other_pgpool_hostname', 'other_pgpool_port', 'other_wd_port', + 'wd_interval', 'wd_life_point', 'wd_lifecheck_query')); + +$tpl->assign('params', $params); +$tpl->display('innerWatchdog.tpl'); + +?> diff --git a/lang/en.lang.php b/lang/en.lang.php index eb7d05b..a4be4bf 100644 --- a/lang/en.lang.php +++ b/lang/en.lang.php @@ -124,7 +124,8 @@ $message = array( 'descReplication_mode' => 'Set this to true if you are going to use replication functionality', 'descReplication_stop_on_mismatch' => 'Stop replication mode on data mismatch between master and secondary', 'descReplicate_select' => 'If true, replicate SELECT queries. If false, send only to master', - 'descReplication_timeout' => 'In non strict replication mode, there will be a risk of deadlock. Timeout in second for monitoring the deadlock', + 'descReplication_timeout' => 'In non strict replication mode, there will be a risk of deadlock. '. + 'Timeout in second for monitoring the deadlock', 'descReset_query_list' => 'Semicolon separated SQL commands to be issued at the end of session', 'descSsl' => 'The frontend connection', 'descSsl_ca_cert' => 'Path to the SSL private key file', @@ -169,7 +170,10 @@ $message = array( 'errShouldBeZeroOrMore' => 'This should be 0 or more', 'errSingleQuotation' => 'Please enclose the array element with a single quotation.', + 'msgAddBackend' => 'Do you really add this node as a new backend?', + 'msgAddBackendNg' => 'Invalid.', 'msgDeleteConfirm' => 'Do you really want to delete it?', + 'msgHasNotLoadedNode' => 'You have to reload pgpool to use the new backend node.', 'msgMasterDbConnectionError' => 'Master DB connection failed', 'msgPgpoolConfNotFound' => 'pgpool.conf not found', 'msgPleaseSetup' => 'No found configuration file. Please execute the setup.', @@ -178,15 +182,20 @@ $message = array( 'msgRestartPgpool' => 'Do you really want to restart pgpool?', 'msgSameAsPasswordFile' => 'The value is the same as item Password File', 'msgSameAsPgpoolFile' => 'The value is the same as item pgpool.conf File', + 'msgStartPgpool' => 'Do you really start pgpool?', 'msgStopPgpool' => 'Do you really want to stop pgpool?', 'msgUpdateComplete' => 'Update complete', + 'msgUpdateCompleteInfo' => 'You have to reload or restart pgpool to use new configuration.', 'msgUpdateFailed' => 'Update failed', 'msgDetachConfirm' => 'Do you really detach this node?', 'msgReturnConfirm' => 'Do you really make this node return?', 'msgRecoveryConfirm' => 'Do you really recover this node?', + 'msgRemoveBackend' => 'Do you really remove this backend node?', 'msgRPromoteConfirm' => 'Do you really make this node primary?', 'strAdd' => 'Add', + 'strAddBackend' => 'Add a new backend node', + 'strAddBackendNow' => 'Reload pgpool right after adding', 'strAdminPassword' => 'Password', 'strBack' => 'Back', 'strBackendPid' => 'Backend Pid', @@ -284,11 +293,15 @@ $message = array( 'strQueryCache' => 'Query Cache', 'strQueryStr' => 'Query', 'strReloadPgpool' => 'Reload', + 'strReloadPgsql' => 'Reload', 'strReplicationMode' => 'Replication Mode', 'strReset' => 'Reset', 'strRestart' => 'Restart', 'strRestartOption' => 'pgpool Restart Option', 'strRestartPgpool' => 'Restart pgpool', + 'strRestartPgsql' => 'Restart', + 'strRestartPgsqlOption' => 'Restart PostgreSQL Option', + 'strRemoveBackend' => 'Remove', 'strReturn' => 'Return', 'strRecovery' => 'Recovery', 'strSchemaName' => 'Schema Name', @@ -300,12 +313,17 @@ $message = array( 'strStandbyRunning' => 'Running as standby server', 'strStartOption' => 'Start Option', 'strStartPgpool' => 'Start pgpool', + 'strStartPgsql' => 'Start', 'strStatus' => 'Status', 'strStopOption' => 'pgpool Stop Option', 'strStopPgpool' => 'Stop pgpool', + 'strStopPgsql' => 'Stop', + 'strStopPgsqlOption' => 'Stop PostgreSQL Option', + 'strStoppingNow' => 'Not active', 'strStreamingRepMode' => 'Streaming Replication mode', 'strSummary' => 'Summary', 'strSystemDb' => 'Partitioning Rule', + 'strSystemCatalog' => 'System catalog', 'strTable' => 'Table', 'strTypeList' => 'Type List of Column', 'strUp' => 'Up', diff --git a/lang/ja.lang.php b/lang/ja.lang.php index 7be46d9..9791fd3 100644 --- a/lang/ja.lang.php +++ b/lang/ja.lang.php @@ -161,7 +161,10 @@ $message = array( 'errShouldBeZeroOrMore' => '0以上である必要があります', 'errSingleQuotation' => '配列要素をシングルクォーテーションで囲んでください。', + 'msgAddBackend' => 'バックエンドノードとして追加してよろしいですか?', + 'msgAddBackendNg' => 'バックエンドノード情報に不備があります。', 'msgDeleteConfirm' => '本当に削除してよいですか?', + 'msgHasNotLoadedNode' => '新しいノード情報を読み込むには pgpool の設定をリロードする必要があります。', 'msgMasterDbConnectionError' => 'マスターDBに接続できません', 'msgPgpoolConfNotFound' => 'pgpool.confが見つかりません', 'msgPleaseSetup' => '設定ファイルが見つかりません。セットアップを実行してください。', @@ -170,15 +173,20 @@ $message = array( 'msgRestartPgpool' => 'pgpoolを再起動してよろしいですか?', 'msgSameAsPasswordFile' => '値はパスワードファイルの設定値となります', 'msgSameAsPgpoolFile' => '値はpgpool.confファイルの設定値となります', - 'msgStopPgpool' => 'pgpoolを停止してよいですか?', - 'msgUpdateComplete' => '更新は正常に終了しました', - 'msgUpdateFailed' => '更新に失敗しました', - 'msgDetachConfirm' => 'このノードを切断してよいですか?', - 'msgReturnConfirm' => 'このノードを復帰させてよいですか?', + 'msgStartPgpool' => 'pgpoolを起動しますか?', + 'msgStopPgpool' => 'pgpoolを停止してよろしいですか?', + 'msgUpdateComplete' => '更新は正常に終了しました。', + 'msgUpdateCompleteInfo' => '設定を反映するには、pgpoolの設定リロードか再起動をする必要があります。', + 'msgUpdateFailed' => '更新に失敗しました。', + 'msgDetachConfirm' => 'このノードを pgpool-II の管理から切断してよいですか?', + 'msgReturnConfirm' => 'このノードを pgpool-II の管理下に復帰させてよいですか?', 'msgRecoveryConfirm' => 'このノードをリカバリしますか?', + 'msgRemoveBackend' => 'このバックエンドノードを削除してよろしいですか?', 'msgRPromoteConfirm' => 'このノードをマスタに昇格しますか?', 'strAdd' => '追加', + 'strAddBackend' => '新しいバックエンドを登録', + 'strAddBackendNow' => '即座に追加する(pgpool の設定をリロードします)', 'strAdminPassword' => '管理者パスワード', 'strBack' => '戻る', 'strBackendPid' => 'バックエンドプロセスID', @@ -277,27 +285,36 @@ $message = array( 'strQueryStr' => 'クエリ文字列', 'strReloadPgpool' => '設定リロード', 'strReplicationMode' => 'レプリケーションモード', + 'strReloadPgsql' => '設定リロード', 'strReset' => 'リセット', 'strRestart' => '再起動', 'strRestartOption' => 'pgpool再起動オプション', 'strRestartPgpool' => 'pgpool再起動', + 'strRestartPgsql' => '再起動', + 'strRestartPgsqlOption' => 'PostgreSQL再起動オプション', + 'strRemoveBackend' => '登録削除', 'strReturn' => '復帰', 'strRecovery' => 'リカバリ', 'strSchemaName' => 'スキーマ名', 'strSearch' => '検索', 'strSecondaryServer' => 'セカンダリサーバ', - 'strSetting' => '管理ツール設定', + 'strSetting' => 'pgpoolAdmin設定', 'strSetup' => 'セットアップ', 'strSlonyMode' => 'Slony-Iモード', 'strStandbyRunning' => 'スタンバイとして稼働中', 'strStartOption' => '起動オプション', 'strStartPgpool' => 'pgpool起動', + 'strStartPgsql' => '起動', 'strStatus' => 'ステータス', 'strStopOption' => 'pgpool停止オプション', 'strStopPgpool' => 'pgpool停止', + 'strStopPgsql' => '停止', + 'strStopPgsqlOption' => 'PostgreSQL停止オプション', + 'strStoppingNow' => '停止中', 'strStreamingRepMode' => 'Streaming Replicationモード', 'strSummary' => '概要', 'strSystemDb' => '分散ルール', + 'strSystemCatalog' => 'システムカタログ情報', 'strTable' => 'テーブル名', 'strTypeList' => '列データ型リスト', 'strUp' => 'アップ', diff --git a/login.php b/login.php index aae1e81..60b3164 100644 --- a/login.php +++ b/login.php @@ -19,15 +19,19 @@ * is" without express or implied warranty. * * @author Ryuma Ando - * @copyright 2003-2012 PgPool Global Development Group + * @copyright 2003-2013 PgPool Global Development Group * @version CVS: $Id$ */ require_once('common.php'); require_once('command.php'); -$success = FALSE; +/* --------------------------------------------------------------------- */ +/* login.php */ +/* --------------------------------------------------------------------- */ +// Check loginstatus +$success = FALSE; if (isset($_SESSION[SESSION_LOGIN_USER])) { $success = TRUE; } @@ -77,35 +81,6 @@ if ($success == FALSE) { } } -// If user has already logined, show nodeStatus page. -$tpl->assign('isLogin', TRUE); -$tpl->assign('viewPHP', 'nodeStatus.php'); - -$refreshTime = 5000; -if (_PGPOOL2_STATUS_REFRESH_TIME >= 0 ) { - $refreshTime = _PGPOOL2_STATUS_REFRESH_TIME * 1000; -} -if (DoesPgpoolPidExist()) { - $tpl->assign('pgpoolIsActive', TRUE); -} else { - $tpl->assign('pgpoolIsActive', FALSE); -} - -$tpl->assign('c', _PGPOOL2_CMD_OPTION_C); -$tpl->assign('D', _PGPOOL2_CMD_OPTION_LARGE_D); -$tpl->assign('d', _PGPOOL2_CMD_OPTION_D); -$tpl->assign('m', _PGPOOL2_CMD_OPTION_M); -$tpl->assign('n', _PGPOOL2_CMD_OPTION_N); -$tpl->assign('C', _PGPOOL2_CMD_OPTION_LARGE_C); - -$tpl->assign('pgpoolStatus', NULL); -$tpl->assign('pgpoolMessage', NULL); -$tpl->assign('pgpoolConf', _PGPOOL2_CONFIG_FILE); -$tpl->assign('pcpConf', _PGPOOL2_PASSWORD_FILE); -$tpl->assign('refreshTime', $refreshTime); -$tpl->assign('useSyslog', useSyslog()); -$tpl->assign('msgStopPgpool', $message['msgStopPgpool']); -$tpl->assign('help', 'status'); -$tpl->display('status.tpl'); - -?> +// If user has already logined, show status page. +header("Location: status.php"); +exit(); diff --git a/nodeServerStatus.php b/nodeServerStatus.php index b370245..0f41113 100644 --- a/nodeServerStatus.php +++ b/nodeServerStatus.php @@ -19,19 +19,26 @@ * is" without express or implied warranty. * * @author Ryuma Ando - * @copyright 2003-2008 PgPool Global Development Group + * @copyright 2003-2013 PgPool Global Development Group * @version CVS: $Id$ */ +/* --------------------------------------------------------------------- */ +/* nodeServerStatus.php */ +/* --------------------------------------------------------------------- */ + require_once('common.php'); -$tpl->assign('help', basename( __FILE__, '.php')); +// Check login status if (!isset($_SESSION[SESSION_LOGIN_USER])) { header('Location: login.php'); exit(); } -readConfigParams(); +// Set Vars +$tpl->assign('help', basename( __FILE__, '.php')); +// Display +$is_pgpool_active = DoesPgpoolPidExist(); +$tpl->assign('pgpoolIsActive', $is_pgpool_active); $tpl->display('nodeServerStatus.tpl'); -?> diff --git a/nodeStatus.php b/nodeStatus.php index 13580cd..c675f5e 100644 --- a/nodeStatus.php +++ b/nodeStatus.php @@ -19,122 +19,118 @@ * is" without express or implied warranty. * * @author Ryuma Ando - * @copyright 2003-2011 PgPool Global Development Group + * @copyright 2003-2013 PgPool Global Development Group * @version SVN: $Id$ */ require_once('common.php'); require_once('command.php'); -$tpl->assign('help', basename( __FILE__, '.php')); - -$MAX_VALUE = PHP_INT_MAX; -// node status in "pcp_node_info" result -define('NODE_ACTIVE_NO_CONNECT', 1); -define('NODE_ACTIVE_CONNECTED', 2); -define('NODE_DOWN', 3); +/* --------------------------------------------------------------------- */ +/* nodeStatus.php */ +/* --------------------------------------------------------------------- */ +// Check login status if (!isset($_SESSION[SESSION_LOGIN_USER])) { exit(); } -// cout nodes -$ret = execPcp('PCP_NODE_COUNT'); -if (!array_key_exists('SUCCESS', $ret)) { - $errorCode = 'e1002'; - $tpl->assign('errorCode', $errorCode); - $tpl->display('innerError.tpl'); - exit(); -} else { - $nodeCount = $ret['SUCCESS']; -} - -$tpl->assign('nodeCount', $nodeCount); - -$nodeInfo = array(); -$node_alive = FALSE; - -// get nodes' status -for ($i = 0; $i < $nodeCount; $i++) { - // execute "pcp_node_info" command - // ex) host1 5432 1 1073741823.500000 - $ret = execPcp('PCP_NODE_INFO', $i); - - if (!array_key_exists('SUCCESS', $ret)) { - $errorCode = 'e1003'; - $tpl->assign('errorCode', $errorCode); - $tpl->display('innerError.tpl'); - exit(); - - } else { - $ret = $ret['SUCCESS']; - } - - $nodeInfo[$i] = explode(" ", $ret); - - // load balance weight: normalize format - $nodeInfo[$i][3] = sprintf('%.3f', $nodeInfo[$i][3]); - - // node is active? - if ($nodeInfo[$i][2] != NODE_DOWN) { - $node_alive = TRUE; - } -} - // select buttons to each nodes depending on their status $isParallelMode = isParallelMode(); $isReplicationMode = isReplicationMode(); $isMasterSlaveMode = isMasterSlaveMode(); -for ($i = 0; $i < $nodeCount; $i++) { - if ($node_alive == FALSE) { - if (($isReplicationMode || $isMasterSlaveMode) && NodeActive($i)) { - array_push($nodeInfo[$i], 'return'); - } else { - array_push($nodeInfo[$i], 'none'); - } +$configValue = readConfigParams(array('backend_hostname', 'backend_port')); +if (!isset($configValue['backend_hostname'])) { return; } +$backends_in_conf = $configValue['backend_hostname']; - } elseif ($isParallelMode ) { - array_push($nodeInfo[$i], 'none'); +// Get nodes' status +$nodeCount = NULL; +$is_pgpool_active = DoesPgpoolPidExist(); +if ($is_pgpool_active) { + $nodeCount = getNodeCount(); +} +$has_not_loaded_node = FALSE; - } else { - switch($nodeInfo[$i][2]) { +// Merge backends in pgpool.conf and them in pgpool +// ex) when remove a backend but not reload yet +if (count($backends_in_conf) < $nodeCount) { + for ($i = 0; $i < $nodeCount; $i++) { + $backends_in_conf[$i] = array(); + } +} + +$nodeInfo = array(); +foreach ($backends_in_conf as $i => $backend) { + // Set buttons + $nodeInfo[$i]['return'] = FALSE; + $nodeInfo[$i]['disconnect'] = FALSE; + $nodeInfo[$i]['promote'] = FALSE; + $nodeInfo[$i]['recovery'] = FALSE; + + // The flag if postgres is active or sleeping + $nodeInfo[$i]['is_active'] = NodeActive($i); + + // nodes recognized by pgpool + if ($nodeCount != NULL/* && $i < $nodeCount*/) { + // Get info by pcp_node_info + $nodeInfo[$i] += getNodeInfo($i); + + // Get the result of "SELECT pg_is_in_recovery()" as integer(0, 1, -1) + // (If pgpool don't act in Master/Slave & SR mode, this value will be ignored.) + $nodeInfo[$i]['is_standby'] = NodeStandby($i); + + switch($nodeInfo[$i]['status']) { case NODE_ACTIVE_NO_CONNECT: case NODE_ACTIVE_CONNECTED: if ($isReplicationMode || $isMasterSlaveMode) { - array_push($nodeInfo[$i], 'disconnect'); - } else { - array_push($nodeInfo[$i], 'none'); + if ($nodeInfo[$i]['is_active']) { + $nodeInfo[$i]['disconnect'] = TRUE; + } } + // pcp_promote_node exists after V3.1 if (hasPcpPromote() && useStreaming()) { - array_push($nodeInfo[$i], 'promote'); + $nodeInfo[$i]['promote'] = TRUE; } break; case NODE_DOWN: if ($isReplicationMode || $isMasterSlaveMode) { - if (NodeActive($i)) { - array_push($nodeInfo[$i], 'return'); + if ($nodeInfo[$i]['is_active']) { + $nodeInfo[$i]['return'] = TRUE; } else { - array_push($nodeInfo[$i], 'recovery'); + $nodeInfo[$i]['recovery'] = TRUE; } - } else { - array_push($nodeInfo[$i], 'none'); } break; } - } - // result of "SELECT pg_is_in_recovery()" as integer(0, 1, -1) - // (If pgpool don't act in Master/Slave & SR mode, this value will be ignored.) - $nodeInfo[$i][6] = NodeStandby($i); + // nodes not working as backend (just written in pgpool.conf) + } else { + $has_not_loaded_node = TRUE; + $nodeInfo[$i]['hostname'] = $configValue['backend_hostname'][$i]; + $nodeInfo[$i]['port'] = $configValue['backend_port'][$i]; + $nodeInfo[$i]['weight'] = 0; + $nodeInfo[$i]['status'] = NODE_NOT_LOADED; + $nodeInfo[$i]['is_standby'] = NULL; + } } +// Set vars +$tpl->assign('help', basename( __FILE__, '.php')); + $tpl->assign('refreshTime', _PGPOOL2_STATUS_REFRESH_TIME * 1000); $tpl->assign('nodeInfo', $nodeInfo); $tpl->assign('parallelMode', $isParallelMode); $tpl->assign('msgStopPgpool', $message['msgStopPgpool']); -$tpl->display('nodeStatus.tpl'); +$tpl->assign('nodeCount', $nodeCount); +$tpl->assign('has_not_loaded_node', $has_not_loaded_node); +$tpl->assign('pgpoolIsActive', $is_pgpool_active); -?> +// Set params +$configValue = readConfigParams('recovery_1st_stage'); +$tpl->assign('params', $configValue); + +// Display +$tpl->display('nodeStatus.tpl'); diff --git a/pgconfig.php b/pgconfig.php index 0d21468..6aed56a 100644 --- a/pgconfig.php +++ b/pgconfig.php @@ -19,7 +19,7 @@ * is" without express or implied warranty. * * @author Ryuma Ando - * @copyright 2003-2012 PgPool Global Development Group + * @copyright 2003-2013 PgPool Global Development Group * @version CVS: $Id$ */ @@ -67,32 +67,32 @@ switch ($action) { if (isset($_POST['backend_hostname'])) { $configValue['backend_hostname'] = $_POST['backend_hostname']; } else { - $configValue['backend_hostname'] = array(); + $configValue['backend_hostname'][0] = NULL; } if (isset($_POST['backend_port'])) { $configValue['backend_port'] = $_POST['backend_port']; } else { - $configValue['backend_port'] = array(); + $configValue['backend_port'][0] = NULL; } if (isset($_POST['backend_weight'])) { $configValue['backend_weight'] = $_POST['backend_weight']; } else { - $configValue['backend_weight'] = array(); + $configValue['backend_weight'][0] = NULL; } if (isset($_POST['backend_data_directory'])) { $configValue['backend_data_directory'] = $_POST['backend_data_directory']; } else { - $configValue['backend_data_directory'] = array(); + $configValue['backend_data_directory'][0] = NULL; } if (paramExists('backend_flag')) { if (isset($_POST['backend_flag'])) { $configValue['backend_flag'] = $_POST['backend_flag']; } else { - $configValue['backend_flag'] = array(); + $configValue['backend_flag'][0] = NULL; } } @@ -100,20 +100,20 @@ switch ($action) { if (isset($_POST['other_pgpool_hostname'])) { $configValue['other_pgpool_hostname'] = $_POST['other_pgpool_hostname']; } else { - $configValue['other_pgpool_hostname'] = array(); + $configValue['other_pgpool_hostname'][0] = NULL; } if (isset($_POST['other_pgpool_port'])) { $configValue['other_pgpool_port'] = $_POST['other_pgpool_port']; } else { - $configValue['other_pgpool_port'] = array(); + $configValue['other_pgpool_port'][0] = NULL; } if (isset($_POST['other_wd_port'])) { $configValue['other_wd_port'] = $_POST['other_wd_port']; } else { - $configValue['other_wd_port'] = array(); + $configValue['other_wd_port'][0] = NULL; } $tpl->assign('params', $configValue); @@ -405,6 +405,20 @@ switch ($action) { default: } +if (!isset($configValue['backend_hostname'])) { + $configValue['backend_hostname'][0] = NULL; + $configValue['backend_port'][0] = NULL; + $configValue['backend_weight'][0] = NULL; + $configValue['backend_data_directory'][0] = NULL; + $configValue['backend_flag'][0] = NULL; +} + +if (!isset($configValue['other_pgpool_hostname'])) { + $configValue['other_pgpool_hostname'][0] = NULL; + $configValue['other_pgpool_port'][0] = NULL; + $configValue['other_wd_port'][0] = NULL; +} + $tpl->assign('params', $configValue); $tpl->assign('error', $error); @@ -646,7 +660,7 @@ function writeConfigFile($configValue, $pgpoolConfigParam) foreach ($pgpoolConfigParam as $key => $value) { $isWrite = FALSE; - for ($j = 0; $j - * @copyright 2003-2012 PgPool Global Development Group + * @copyright 2003-2013 PgPool Global Development Group * @version SVN: $Id$ */ require_once('common.php'); require_once('command.php'); -$tpl->assign('help', basename( __FILE__, '.php')); - -$viewPHP = 'nodeStatus.php'; -$refreshTime = 5000; -if (isset($_POST['nodeNumber'])) { - $nodeNumber = $_POST['nodeNumber']; -} else { - $nodeNumber = -1; -} +/* --------------------------------------------------------------------- */ +/* Status.php */ +/* --------------------------------------------------------------------- */ +// Check login status if (!isset($_SESSION[SESSION_LOGIN_USER])) { header('Location: login.php'); exit(); } -if (isset($_POST['action'])) { - $action = $_POST['action']; -} else { - $action = FALSE; -} - -/** - * Set pgpool command option - */ +$is_pgpool_active = DoesPgpoolPidExist(); + +// Do action +$nodeNumber = (isset($_POST['nodeNumber'])) ? $_POST['nodeNumber'] : -1; +$action = (isset($_POST['action'])) ? $_POST['action'] : FALSE; +$viewPHP = _doAction($action, $nodeNumber); + +// Set vars +setNodeInfoFromConf(); +$tpl->assign('action', $action); +$tpl->assign('pgpoolIsActive', $is_pgpool_active); +$tpl->assign('viewPHP', $viewPHP); +$tpl->assign('help', basename( __FILE__, '.php')); +$tpl->assign('pgpoolConf', _PGPOOL2_CONFIG_FILE); +$tpl->assign('pcpConf', _PGPOOL2_PASSWORD_FILE); +$tpl->assign('refreshTime', (0 <= _PGPOOL2_STATUS_REFRESH_TIME) ? + _PGPOOL2_STATUS_REFRESH_TIME * 1000 : 5000); +$tpl->assign('refreshTimeLog', REFRESH_LOG_SECONDS); +$tpl->assign('useSyslog', useSyslog()); +$tpl->assign('pipe', (isPipe(_PGPOOL2_LOG_FILE)) ? 1 : 0); +$tpl->assign('msgStopPgpool', $message['msgStopPgpool']); +$tpl->assign('login_user', $_SESSION[SESSION_LOGIN_USER]); +$tpl->assign('is_superuser', isSuperUser($_SESSION[SESSION_LOGIN_USER])); + +// Set params +$configValue = readConfigParams('use_watchdog'); +$tpl->assign('params', $configValue); + +// Set pgpool command option $tpl->assign('c', _PGPOOL2_CMD_OPTION_C); $tpl->assign('D', _PGPOOL2_CMD_OPTION_LARGE_D); $tpl->assign('d', _PGPOOL2_CMD_OPTION_D); @@ -57,269 +72,436 @@ $tpl->assign('m', _PGPOOL2_CMD_OPTION_M); $tpl->assign('n', _PGPOOL2_CMD_OPTION_N); $tpl->assign('C', _PGPOOL2_CMD_OPTION_LARGE_C); -if (isPipe(_PGPOOL2_LOG_FILE)) { - $tpl->assign('pipe', 1); -} else { - $tpl->assign('pipe', 0); -} +// Display +$tpl->display('status.tpl'); -$tpl->assign('pgpoolStatus', NULL); -$tpl->assign('pgpoolMessage', NULL); +/* --------------------------------------------------------------------- */ +/* Functions */ +/* --------------------------------------------------------------------- */ -switch ($action) { +/** Execute a command */ +function _doAction($action, $nodeNumber) +{ + global $tpl; - /* --------------------------------------------------------------------- */ - /* start */ - /* --------------------------------------------------------------------- */ + $viewPHP = 'nodeStatus.php'; + $tpl->assign('pgpoolStatus', NULL); + $tpl->assign('pgpoolMessage', NULL); - case 'start': - $args = ' '; + switch ($action) { + /* --------------------------------------------------------------------- */ + /* pgpool */ + /* --------------------------------------------------------------------- */ - if (isset($_POST['c'])) { - $args = $args . "-c "; - } - if (isset($_POST['D'])) { - $args = $args . "-D "; - } - if (isset($_POST['d'])) { - $args = $args . "-d "; - } - if (isset($_POST['C'])) { - $args = $args . "-C "; - } - if (isset($_POST['n'])) { - $pgpoolLog = _PGPOOL2_LOG_FILE; - if ($pgpoolLog == '') { - $logDir = readLogDir(); - $pgpoolLog = "$logDir/pgpool.log"; - } - if (isPipe($pgpoolLog)) { - $args = "$args -n 2>&1 $pgpoolLog "; - } else { - $args = "$args -n > $pgpoolLog "; - } - } + case 'startPgpool': + _startPgpool(); + break; - $ret = execPcp('PCP_START_PGPOOL', $args); - if (!array_key_exists('SUCCESS', $ret)) { - $tpl->assign('pgpoolStatus', 'pgpool start failed.'); - $tpl->assign('pgpoolMessage', $ret); - } else { - for ($i = 0; $i < 10; $i++) { - if (DoesPgpoolPidExist()) { - break; - } else { - sleep(1); - } - } + case 'stopPgpool': + _stopPgpool(); + break; - if (DoesPgpoolPidExist()) { - $tpl->assign('pgpoolStatus', 'pgpool start succeed'); - } else { - $tpl->assign('pgpoolStatus', 'pgpool start failed. pgpool.pid not found'); - } - $tpl->assign('pgpoolMessage', $ret['SUCCESS']); - } + case 'restartPgpool': + _restartPgpool(); + break; - break; + case 'reloadPgpool': + $args = ' '; + $result = execPcp('PCP_RELOAD_PGPOOL', $args); + break; - /* --------------------------------------------------------------------- */ - /* stop */ - /* --------------------------------------------------------------------- */ + /* --------------------------------------------------------------------- */ + /* other command */ + /* --------------------------------------------------------------------- */ - case 'stop': - $m = $_POST['stop_mode']; + case 'return': + if (_execPcp('PCP_ATTACH_NODE', $nodeNumber, 'e1010') === FALSE) { exit(); } + break; - $ret = execPcp('PCP_STOP_PGPOOL', $m); - if (!array_key_exists('SUCCESS', $ret)) { - $errorCode = 'e1006'; - $tpl->assign('errorCode', $errorCode); - $tpl->display('error.tpl'); - exit(); + case 'recovery': + if (_execPcp('PCP_RECOVERY_NODE', $nodeNumber, 'e1012') === FALSE) { exit(); } + break; - } else { - for ($i = 0; $i < 10; $i++) { - if (DoesPgpoolPidExist()) { - sleep(1); - } else { - break; - } - } + case 'detach': + if (_execPcp('PCP_DETACH_NODE', $nodeNumber, 'e1007') === FALSE) { exit(); } + break; - if (DoesPgpoolPidExist()) { - $tpl->assign('pgpoolStatus', 'pgpool stop failed. pgpool.pid exists.'); - } else { - $tpl->assign('pgpoolStatus', 'pgpool stop succeed'); - } - } + case 'promote': + if (_execPcp('PCP_PROMOTE_NODE', $nodeNumber, 'e1007') === FALSE) { exit(); } + break; - break; + /* --------------------------------------------------------------------- */ + /* PostgreSQL */ + /* --------------------------------------------------------------------- */ - /* --------------------------------------------------------------------- */ - /* restart */ - /* --------------------------------------------------------------------- */ + case 'startPgsql': + // ... + break; - case 'restart': - /** - * Stop pgpool - */ - $m = $_POST['restart_mode']; + case 'stopPgsql': + _doPgCtl($nodeNumber, 'stop'); + break; - $ret = execPcp('PCP_STOP_PGPOOL', $m); - if (!array_key_exists('SUCCESS', $ret)) { - $errorCode = 'e1006'; - $tpl->assign('errorCode', $errorCode); - $tpl->display('error.tpl'); - exit(); + case 'restartPgsql': + _doPgCtl($nodeNumber, 'restart'); + break; - } else { - for ($i = 0; $i < 10; $i++) { - if (DoesPgpoolPidExist()) { - sleep(1); - } else { - break; - } - } - } + case 'reloadPgsql': + $result = _doPgCtl($nodeNumber, 'reload'); + $tpl->assign('status', ($result) ? 'success' : 'fail'); + break; - if (DoesPgpoolPidExist()) { - $tpl->assign('pgpoolStatus', 'pgpool restart failed. pgpool.pid exists.'); + case 'addBackend': + $result = _addNewBackend(); + $tpl->assign('status', ($result) ? 'success' : 'fail'); break; - } - /** - * Start pgpool - */ - $args = ' '; + case 'removeBackend': + $result = _removeBackend(); + $tpl->assign('status', ($result) ? 'success' : 'fail'); + break; - if (isset($_POST['c'])) { - $args = $args . "-c "; - } - if (isset($_POST['D'])) { - $args = $args . "-D "; - } - if (isset($_POST['d'])) { - $args = $args . "-d "; - } - if (isset($_POST['n'])) { - $pgpoolLog = _PGPOOL2_LOG_FILE; - if ($pgpoolLog == '') { - $logDir = readLogDir(); - $pgpoolLog = "$logDir/pgpool.log"; - } - if (isPipe($pgpoolLog)) { - $args = "$args -n 2>&1 $pgpoolLog "; - } else { - $args = "$args -n > $pgpoolLog "; + /* --------------------------------------------------------------------- */ + /* other */ + /* --------------------------------------------------------------------- */ + + case 'summary': + $viewPHP = 'innerSummary.php'; + break; + + case 'proc': + $viewPHP = 'procInfo.php'; + break; + + case 'watchdog': + $viewPHP = 'innerWatchdog.php'; + break; + + case 'node': + $viewPHP = 'nodeStatus.php'; + break; + + case 'log': + $viewPHP = 'innerLog.php'; + break; + } + + return $viewPHP; +} + +/** Set node info from pgpool.conf when pgpool isn't active */ +function setNodeInfoFromConf() +{ + global $tpl; + global $is_pgpool_active; + + if (!$is_pgpool_active) { + $nodeInfo = array(); + + $configValue = readConfigParams(array('backend_hostname', 'backend_port')); + if (isset($configValue['backend_hostname'])) { + foreach ($configValue['backend_hostname'] as $i => $backend_hostname) { + $nodeInfo[$i]['backend_hostname'] = $backend_hostname; + $nodeInfo[$i]['backend_port'] = $configValue['backend_port'][$i]; + $nodeInfo[$i]['is_active'] = NodeActive($i); } } - if (isset($_POST['C'])) { - $args = $args . "-C "; + $tpl->assign('nodeInfo', $nodeInfo); + } + + $configValue = readConfigParams('backend_hostname'); + $tpl->assign('next_node_num', (isset($configValue['backend_hostname'])) ? + max(array_keys($configValue['backend_hostname'])) + 1 : 0); +} + +/** Modify start options */ +function _setStartArgs() +{ + $args = ' '; + + if (isset($_POST['c'])) { + $args = $args . "-c "; + } + if (isset($_POST['D'])) { + $args = $args . "-D "; + } + if (isset($_POST['d'])) { + $args = $args . "-d "; + } + if (isset($_POST['n'])) { + $pgpoolLog = _PGPOOL2_LOG_FILE; + if ($pgpoolLog == '') { + $logDir = readLogDir(); + $pgpoolLog = "$logDir/pgpool.log"; } + if (isPipe($pgpoolLog)) { + $args = "$args -n 2>&1 $pgpoolLog "; + } else { + $args = "$args -n > $pgpoolLog "; + } + } + if (isset($_POST['C'])) { + $args = $args . "-C "; + } - $ret = execPcp('PCP_START_PGPOOL', $args); - if (!array_key_exists('SUCCESS', $ret)) { - $tpl->assign('pgpoolStatus', 'pgpool restart failed.'); - $tpl->assign('pgpoolMessage', $ret); + return $args; +} +/** Wait to find pgpool.pid */ +function _waitForPidFile() +{ + for ($i = 0; $i < PGPOOL_WAIT_SECONDS; $i++) { + if (DoesPgpoolPidExist()) { + return TRUE; } else { - for ($i = 0; $i < 10; $i++) { - if (DoesPgpoolPidExist()) { - $tpl->assign('pgpoolStatus', 'pgpool restart succeed'); - break; - } else { - sleep(1); - } - } - if (!DoesPgpoolPidExist()) { - $tpl->assign('pgpoolStatus', 'pgpool restart failed. pgpool.pid not found'); - } - $tpl->assign('pgpoolMessage', $ret['SUCCESS']); + sleep(1); } - break; - - /* --------------------------------------------------------------------- */ - /* other */ - /* --------------------------------------------------------------------- */ - - case 'reload': - $args = ' '; - $ret = execPcp('PCP_RELOAD_PGPOOL', $args); - break; - - case 'return': - $ret = execPcp('PCP_ATTACH_NODE', $nodeNumber); - if (!array_key_exists('SUCCESS', $ret)) { - $errorCode = 'e1010'; - $tpl->assign('errorCode', $errorCode); - $tpl->display('error.tpl'); - exit(); + } + return FALSE; +} + +/** Wait that pgpool.pid disappears */ +function _waitForNoPidFile() +{ + for ($i = 0; $i < PGPOOL_WAIT_SECONDS; $i++) { + if (DoesPgpoolPidExist()) { + sleep(1); + } else { + return TRUE; } - break; - - case 'recovery': - $ret = execPcp('PCP_RECOVERY_NODE', $nodeNumber); - if (!array_key_exists('SUCCESS', $ret)) { - $errorCode = 'e1012'; - $tpl->assign('errorCode', $errorCode); - $tpl->display('error.tpl'); - exit(); + } + return FALSE; +} + +/** Start pgpool */ +function _startPgpool() +{ + global $tpl; + + $args = _setStartArgs(); + $result = execPcp('PCP_START_PGPOOL', $args); + if (!array_key_exists('SUCCESS', $result)) { + $pgpoolStatus = 'pgpool start failed.'; + $pgpoolMessage = $result; + + } else { + if (_waitForPidFile()) { + $pgpoolStatus = 'pgpool start succeed'; + } else { + $pgpoolStatus = 'pgpool start failed. pgpool.pid not found'; } - break; - - case 'detach': - $ret = execPcp('PCP_DETACH_NODE', $nodeNumber); - if (!array_key_exists('SUCCESS', $ret)) { - $errorCode = 'e1007'; - $tpl->assign('errorCode', $errorCode); - $tpl->display('error.tpl'); - exit(); + $pgpoolMessage = $result['SUCCESS']; + } + + $tpl->assign('pgpoolStatus', $pgpoolStatus); + $tpl->assign('pgpoolMessage', $pgpoolMessage); +} + +/** Stop pgpool */ +function _stopPgpool() +{ + global $_POST; + global $tpl; + + $m = $_POST['stop_mode']; + + $result = execPcp('PCP_STOP_PGPOOL', $m); + if (!array_key_exists('SUCCESS', $result)) { + $errorCode = 'e1006'; + $tpl->assign('errorCode', $errorCode); + $tpl->display('error.tpl'); + exit(); + + } else { + if (_waitForNoPidFile()) { + $pgpoolStatus = 'pgpool stop succeed'; + } else { + $pgpoolStatus = 'pgpool stop failed. pgpool.pid exists.'; } - break; - - case 'promote': - $ret = execPcp('PCP_PROMOTE_NODE', $nodeNumber); - if (!array_key_exists('SUCCESS', $ret)) { - $errorCode = 'e1007'; - $tpl->assign('errorCode', $errorCode); - $tpl->display('error.tpl'); - exit(); + $tpl->assign('pgpoolStatus', $pgpoolStatus); + } +} + +/** Restart pgpool */ +function _restartPgpool() +{ + global $_POST; + global $tpl; + + // Stop pgpool + $m = $_POST['stop_mode']; + + $result = execPcp('PCP_STOP_PGPOOL', $m); + if (!array_key_exists('SUCCESS', $result)) { + $errorCode = 'e1006'; + $tpl->assign('errorCode', $errorCode); + $tpl->display('error.tpl'); + exit(); + } + + if (_waitForNoPidFile()) { + // Start pgpool + $args = _setStartArgs(); + $result = execPcp('PCP_START_PGPOOL', $args); + if (!array_key_exists('SUCCESS', $result)) { + $pgpoolStatus = 'pgpool restart failed.'; + $pgpoolMessage = $result; + + } else { + if (_waitForPidFile()) { + $pgpoolStatus = 'pgpool restart succeed'; + } else { + $pgpoolStatus = 'pgpool restart failed. pgpool.pid not found'; + } + $pgpoolMessage = $result['SUCCESS']; } - break; - case 'summary': - $viewPHP = 'innerSummary.php'; - break; + } else { + $pgpoolStatus = 'pgpool restart failed. pgpool.pid exists.'; + } + + $tpl->assign('pgpoolStatus', $pgpoolStatus); + $tpl->assign('pgpoolMessage', $pgpoolMessage); +} + +/** Execute PCP command with node number */ +function _execPcp($pcp_command, $nodeNumber, $errorCode) +{ + global $tpl; - case 'proc': - $viewPHP = 'procInfo.php'; - break; + $result = execPcp($pcp_command, $nodeNumber); - case 'node': - $viewPHP = 'nodeStatus.php'; - break; + if (!array_key_exists('SUCCESS', $result)) { + $tpl->assign('errorCode', $errorCode); + $tpl->display('error.tpl'); + return FALSE; + } - case 'log': - $viewPHP = 'innerLog.php'; - break; + return TRUE; } -if (DoesPgpoolPidExist()) { - $tpl->assign('pgpoolIsActive', TRUE); -} else { - $tpl->assign('pgpoolIsActive', FALSE); +/** Add a new backend and reload conf */ +function _addNewBackend() +{ + global $is_pgpool_active; + global $_POST; + + // Check + if ($_POST['backend_hostname'][0] == NULL || $_POST['backend_port'][0] == NULL || + $_POST['backend_weight'][0] == NULL) + { + return FALSE; + } + + // Get next nodeNumber + $configValue = readConfigParams('backend_hostname'); + $i = (isset($configValue['backend_hostname'])) ? + max(array_keys($configValue['backend_hostname'])) + 1 : 0; + + // add + $lines[] = "backend_hostname{$i} = '{$_POST['backend_hostname'][0]}'\n"; + $lines[] = "backend_port{$i} = {$_POST['backend_port'][0]}\n"; + $lines[] = "backend_weight{$i} = {$_POST['backend_weight'][0]}\n"; + $lines[] = "backend_data_directory{$i} = '{$_POST['backend_data_directory'][0]}'\n"; + if (paramExists('backend_flag')) { + $lines[] = "backend_flag{$i}= '{$_POST['backend_flag'][0]}'\n"; + } + + // Write pgpool.conf + $outfp = fopen(_PGPOOL2_CONFIG_FILE, 'a'); + if (!$outfp) { return FALSE; } + foreach ($lines as $line) { + if (fputs($outfp, $line) === FALSE) { + return FALSE; + } + } + fclose($outfp); + + // Reload pgpool + $result = TRUE; + if (isset($_POST['reload_ok']) && $is_pgpool_active) { + $result = execPcp('PCP_RELOAD_PGPOOL', NO_ARGS); + } + + return $result; } -if (_PGPOOL2_STATUS_REFRESH_TIME >= 0 ) { - $refreshTime = _PGPOOL2_STATUS_REFRESH_TIME * 1000; +/** Remove a backend and reload conf */ +function _removeBackend() +{ + global $is_pgpool_active; + global $_POST; + + if (!isset($_POST['nodeNumber'])) { return FALSE; } + $nodeNumber = $_POST['nodeNumber']; + + // Read execept backend info of node $nodeNumber + $lines_to_write = array(); + $fd = fopen(_PGPOOL2_CONFIG_FILE, 'r'); + if (!$fd) { return FALSE; } + while (!feof($fd)) { + $line = fgets($fd); + + if (strpos($line, "backend_hostname") !== FALSE || + strpos($line, "backend_port") !== FALSE || + strpos($line, "backend_weight") !== FALSE || + strpos($line, "backend_data_directory") !== FALSE || + strpos($line, "backend_flag") !== FALSE) + { + continue; + } + $lines_to_write[] = $line; + } + fclose($fd); + + + // Get all the current backends' info + $params = readConfigParams(array('backend_hostname', 'backend_port', 'backend_weight', + 'backend_data_directory', 'backend_flag')); + $i = 0; + foreach ($params['backend_hostname'] as $old_i => $arr) { + if ($old_i == $nodeNumber) { continue; } + + $lines_to_write[] = "backend_hostname{$i} = '{$params['backend_hostname'][$old_i]}'\n"; + $lines_to_write[] = "backend_port{$i} = {$params['backend_port'][$old_i]}\n"; + $lines_to_write[] = "backend_weight{$i} = {$params['backend_weight'][$old_i]}\n"; + $lines_to_write[] = "backend_data_directory{$i} = '{$params['backend_data_directory'][$old_i]}'\n"; + if (paramExists('backend_flag')) { + $lines_to_write[] = "backend_flag{$i} = '{$params['backend_flag'][$old_i]}'\n"; + } + $i++; + } + + // Write editted lines + $fd = fopen(_PGPOOL2_CONFIG_FILE, 'w'); + if (!$fd) { return FALSE; } + foreach ($lines_to_write as $line) { + if (fputs($fd, $line) === FALSE) { + return FALSE; + } + } + fclose($fd); + + // Reload pgpool + $result = TRUE; + if ($is_pgpool_active) { + $result = execPcp('PCP_RELOAD_PGPOOL', NO_ARGS); + } + return $result; } -$tpl->assign('viewPHP', $viewPHP); -$tpl->assign('pgpoolConf', _PGPOOL2_CONFIG_FILE); -$tpl->assign('pcpConf', _PGPOOL2_PASSWORD_FILE); -$tpl->assign('refreshTime', $refreshTime); -$tpl->assign('useSyslog', useSyslog()); -$tpl->assign('msgStopPgpool', $message['msgStopPgpool']); -$tpl->display('status.tpl'); +/** Execute pg_ctl through pgpool_pgctl() */ +function _doPgCtl($nodeNumber, $pg_ctl_action) +{ + global $_POST; -?> + if (isSuperUser($_SESSION[SESSION_LOGIN_USER]) == FALSE) { return FALSE; } + + $conn = @pg_connect(conStr($nodeNumber)); + $query = sprintf("SELECT pgpool_pgctl('%s', '%s')", + $pg_ctl_action, + (isset($_POST['stop_mode'])) ? $_POST['stop_mode'] : NULL); + $result = execQuery($conn, $query); + + return $result; +} diff --git a/templates/elements/pgconfig_new_backend.tpl b/templates/elements/pgconfig_new_backend.tpl new file mode 100644 index 0000000..a58a289 --- /dev/null +++ b/templates/elements/pgconfig_new_backend.tpl @@ -0,0 +1,37 @@ + + +
backend_hostname{$smarty.section.num.index} (string) + + + + + + + +
backend_port{$smarty.section.num.index|escape} (integer) + + + + + +
backend_weight{$smarty.section.num.index|escape} (float) + + + + + +
backend_data_directory{$smarty.section.num.index|escape} (string) + + + +{if paramExists('backend_flag')} + + +
backend_flag{$smarty.section.num.index|escape} * + + + +{/if} diff --git a/templates/elements/status_js.tpl b/templates/elements/status_js.tpl new file mode 100644 index 0000000..f53be72 --- /dev/null +++ b/templates/elements/status_js.tpl @@ -0,0 +1,203 @@ + +{/literal} diff --git a/templates/elements/status_nodeinfo.tpl b/templates/elements/status_nodeinfo.tpl new file mode 100644 index 0000000..2161343 --- /dev/null +++ b/templates/elements/status_nodeinfo.tpl @@ -0,0 +1,174 @@ +

{$message.strNodeInfo|escape}

+ +{if $smarty.const._PGPOOL2_STATUS_REFRESH_TIME > 0} +
+ + Refresh info: {$smarty.const._PGPOOL2_STATUS_REFRESH_TIME} seconds + +
+
+{/if} + +{if $nodeCount > 0} + {if $has_not_loaded_node}

*) {$message.msgHasNotLoadedNode}

{/if} + + + + + + + + + {if $parallelMode == false} + + {/if} + + + + + + + {$i = 0} + {foreach from=$nodeInfo key=node_num item=v} + {$i = $i + 1} + + + {* ---------------------------------------------------------------------- *} + {* node info (IP address, port) *} + {* ---------------------------------------------------------------------- *} + + + + + + {* ---------------------------------------------------------------------- *} + {* status *} + {* ---------------------------------------------------------------------- *} + + {if $nodeInfo.$node_num.status != $smarty.const.NODE_NOT_LOADED} + + {else} + + {/if} + + + + {* ---------------------------------------------------------------------- *} + {* weight *} + {* ---------------------------------------------------------------------- *} + + {if $parallelMode == false} + {if $nodeInfo.$node_num.status != $smarty.const.NODE_NOT_LOADED} + + {else} + + {/if} + {/if} + + {* ---------------------------------------------------------------------- *} + {* buttons (attch, recovery, etc.) *} + {* ---------------------------------------------------------------------- *} + + + + {* ---------------------------------------------------------------------- *} + {* buttons (start, stop, etc.) *} + {* ---------------------------------------------------------------------- *} + + + + {/foreach} + + + + + + + +
node {$node_num}{$nodeInfo.$node_num.hostname|escape}{$nodeInfo.$node_num.port|escape} + {if $nodeInfo.$node_num.status == $smarty.const.NODE_ACTIVE_NO_CONNECT} + {$message.strNodeStatus1|escape} + {elseif $nodeInfo.$node_num.status == $smarty.const.NODE_ACTIVE_CONNECTED} + {$message.strNodeStatus2|escape} + {elseif $nodeInfo.$node_num.status == $smarty.const.NODE_DOWN} + {$message.strNodeStatus3|escape} + {/if} + + {if $nodeInfo.$node_num.is_standby == 1} + {$message.strStandbyRunning|escape} + {elseif $nodeInfo.$node_num.is_standby === 0} + {$message.strPrimaryRunning|escape} + {/if} + -postgres: + {if $nodeInfo.$node_num.is_active}{$message.strUp|escape} + {else}{$message.strDown|escape} + {/if} + {$nodeInfo.$node_num.weight|escape}- + {if $nodeInfo.$node_num.disconnect} + + + {elseif $nodeInfo.$node_num.return} + + + {elseif $nodeInfo.$node_num.recovery} + {if $params.recovery_1st_stage_command != NULL} + + {else} + + {/if} + {/if} + + {if $nodeInfo.$node_num.promote && $nodeInfo.$node_num.is_standby == 1} + + {/if} + {include file="elements/status_pgsql_buttons.tpl"}
+ +
+ +{else} + {$message.strNoNode|escape} +{/if} + + +

[ mode ] +{if $params.replication_mode == 'on'} + {$message.strReplicationMode|escape} +{elseif $params.master_slave_mode == 'on'} + {$message.strMasterSlaveMode|escape} +{/if} +{if $params.load_balance_mode == 'on'} / {$message.strLoadBalanceMode|escape}{/if} +{if $params.memory_cache_enabled == 'on'} / {$message.strQueryCache|escape} {$message.strOn|escape}{/if} +{if $params.use_watchdog == 'on'} / Watchdog {$message.strOn|escape}{/if} +

+

+[ healthcheck ] +every {$params.health_check_period} seconds / +retry upto {$params.health_check_max_retries} counts +

+ + +{* ---------------------------------------------------------------------- *} +{* Command form to execute a command without any option *} +{* ---------------------------------------------------------------------- *} + +
+
+ + +
+
diff --git a/templates/elements/status_options.tpl b/templates/elements/status_options.tpl new file mode 100644 index 0000000..79e8446 --- /dev/null +++ b/templates/elements/status_options.tpl @@ -0,0 +1,109 @@ +{* --------------------------------------------------------------------- *} +{* Start Options *} +{* --------------------------------------------------------------------- *} + +{if $pgpoolIsActive == false} +

{$message.strStartOption|escape}

+ +
+ + + + + + + {include file="elements/status_start_option.tpl"} + + + + +
{$message.strStartOption|escape}
+ +
+
+ +{else} + {* --------------------------------------------------------------------- *} + {* Command Buttons *} + {* --------------------------------------------------------------------- *} + +
+ + + +
+ + {* --------------------------------------------------------------------- *} + {* Stop Options *} + {* --------------------------------------------------------------------- *} + + + {* --------------------------------------------------------------------- *} + {* Restart Options *} + {* --------------------------------------------------------------------- *} + + +{/if} + +{* --------------------------------------------------------------------- *} +{* Start/Stop/Restart messages */ +{* --------------------------------------------------------------------- *} + +{if isset($pgpoolStatus)} +
+

Messages

+

{$pgpoolStatus|escape}

+

+ {foreach from=$pgpoolMessage item=lines} + {$lines|escape}
+ {/foreach} +

+
+{/if} diff --git a/templates/elements/status_pgsql_buttons.tpl b/templates/elements/status_pgsql_buttons.tpl new file mode 100644 index 0000000..431e7bf --- /dev/null +++ b/templates/elements/status_pgsql_buttons.tpl @@ -0,0 +1,15 @@ + + + + + +| + diff --git a/templates/elements/status_pgsql_options.tpl b/templates/elements/status_pgsql_options.tpl new file mode 100644 index 0000000..ca4532a --- /dev/null +++ b/templates/elements/status_pgsql_options.tpl @@ -0,0 +1,47 @@ +{* stop option *} + + +{* restart option *} + diff --git a/templates/elements/status_start_option.tpl b/templates/elements/status_start_option.tpl new file mode 100644 index 0000000..5c2ebaf --- /dev/null +++ b/templates/elements/status_start_option.tpl @@ -0,0 +1,51 @@ +{if hasMemqCache() == false} + {$message.strCmdC|escape} (-c) + {if $c == 1} + + {else} + + {/if} + +{/if} + +{$message.strCmdLargeD|escape} (-D) + {if $D == 1} + + {else} + + {/if} + + +{$message.strCmdN|escape} (-n) + {if $n == 1} + + {else} + + {/if} + + +{if hasMemqCache()} +{$message.strCmdLargeC|escape} (-C) + {if $C == 1} + + {else} + + {/if} + +{/if} + +{$message.strCmdD|escape} (-d) + {if $d == 1} + + {else} + + {/if} + + +{$message.strCmdPgpoolFile|escape} (-f) + {$pgpoolConf|escape} + + +{$message.strCmdPcpFile|escape} (-F) + {$pcpConf|escape} + diff --git a/templates/elements/status_stop_option.tpl b/templates/elements/status_stop_option.tpl new file mode 100644 index 0000000..513f56b --- /dev/null +++ b/templates/elements/status_stop_option.tpl @@ -0,0 +1,25 @@ +{$message.strCmdM|escape}(-m) + + + + + + diff --git a/templates/innerLog.tpl b/templates/innerLog.tpl index 9f071bf..ea7cf04 100644 --- a/templates/innerLog.tpl +++ b/templates/innerLog.tpl @@ -6,14 +6,26 @@ + +

{$message.strLog|escape}

+ +{if $smarty.const._PGPOOL2_STATUS_REFRESH_TIME > 0} +
+ + Refresh info: {$refreshTimeLog} seconds + +
+
+{/if} + {section name=num loop=$logFile} - {if $logFile[num][2] == 'ERROR:' } + {if $logFile[num]['level'] == 'ERROR:' } - {elseif ($smarty.section.num.index+1) % 2 == 0} + {elseif ($smarty.section.num.index + 1) % 2 == 0} {else} diff --git a/templates/innerNodeServerStatus.tpl b/templates/innerNodeServerStatus.tpl index 4750d15..4834b83 100644 --- a/templates/innerNodeServerStatus.tpl +++ b/templates/innerNodeServerStatus.tpl @@ -10,35 +10,52 @@
+ - + - {section name=num loop=$nodeServerStatus} - {if ($smarty.section.num.index+1) % 2 == 0} - - {else} - + {$i = 0} + {foreach from=$nodeServerStatus key=node_num item=v} + {$i = $i + 1} + + + + + - - - + {if $nodeServerStatus.$node_num.is_active} + + {else} - {$message.strDown|escape} - - + + + {/if} - {/section} + {/foreach}
node {$node_num}{$nodeServerStatus.$node_num.hostname|escape}{$nodeServerStatus.$node_num.port|escape} + {if $pgpoolIsActive} + {if $nodeServerStatus.$node_num.status == $smarty.const.NODE_ACTIVE_NO_CONNECT} + {$message.strNodeStatus1|escape} + {elseif $nodeServerStatus.$node_num.status == $smarty.const.NODE_ACTIVE_CONNECTED} + {$message.strNodeStatus2|escape} + {elseif $nodeServerStatus.$node_num.status == $smarty.const.NODE_DOWN} + {$message.strNodeStatus3|escape} + {/if} {/if} - {$nodeServerStatus[num].hostname|escape}{$nodeServerStatus[num].port|escape} - {if $nodeServerStatus[num].status == true} - {$message.strUp|escape} + postgres: {$message.strUp|escape} + + + postgres: {$message.strDown|escape} + +
{else} -{$message.strNoNode|escape} + {$message.strNoNode|escape} {/if} diff --git a/templates/innerSummary.tpl b/templates/innerSummary.tpl index dcc8b88..57411c1 100644 --- a/templates/innerSummary.tpl +++ b/templates/innerSummary.tpl @@ -15,6 +15,16 @@ td > img {

{$message.strPgpoolSummary|escape}

+ +{if $smarty.const._PGPOOL2_STATUS_REFRESH_TIME > 0} +
+ + Refresh info: {$smarty.const._PGPOOL2_STATUS_REFRESH_TIME} seconds + +
+
+{/if} + diff --git a/templates/innerSystemCatalog.tpl b/templates/innerSystemCatalog.tpl index 35f1bbe..03b68e6 100644 --- a/templates/innerSystemCatalog.tpl +++ b/templates/innerSystemCatalog.tpl @@ -6,7 +6,7 @@ -

{$message.strDetailInfo|escape}

+

{$message.strSystemCatalog|escape} (node {$nodeNum})

{$message.strReplicationMode|escape}
@@ -23,14 +23,14 @@
- {foreach from=$results[0] key=column item=value} + {foreach from=$results[0] key=column item=value} {/foreach} {section name=num loop=$results} - {if ($smarty.section.num.index+1) % 2 == 0} + {if ($smarty.section.num.index + 1) % 2 == 0} {else} diff --git a/templates/innerWatchdog.tpl b/templates/innerWatchdog.tpl new file mode 100644 index 0000000..ae69a85 --- /dev/null +++ b/templates/innerWatchdog.tpl @@ -0,0 +1,51 @@ +

Watchdog +{if $params.delegate_IP != NULL}(VIP: {$params.delegate_IP}){/if}

+ +{if $smarty.const._PGPOOL2_STATUS_REFRESH_TIME > 0} +
+ + Refresh info: {$smarty.const._PGPOOL2_STATUS_REFRESH_TIME} seconds + +
+
+{/if} + +
+
+ + + + + + + + + + + + + + + + + +{section name=num loop=$params.other_pgpool_hostname} +{if ($smarty.section.num.index) % 2 == 0}{else}{/if} + + + + + + +{/section} + + + + +
local{$params.wd_hostname}{$params.port}{$params.wd_port} ( XXX: no way exists to get status )
other {$smarty.section.num.index}{$params.other_pgpool_hostname[num]}{$params.other_pgpool_port[num]}{$params.other_wd_port[num]}
+ +

[ lifecheck ] + every{$params.wd_interval} seconds / + retry upto {$params.wd_life_point} counts / + by "{$params.wd_lifecheck_query}"

+ diff --git a/templates/menu.tpl b/templates/menu.tpl index e07b307..4b6b659 100644 --- a/templates/menu.tpl +++ b/templates/menu.tpl @@ -5,7 +5,9 @@ {if hasMemqCache() == false}
  • {$message.strQueryCache|escape}
  • {/if} + {if isParallelMode()}
  • {$message.strSystemDb|escape}
  • + {/if}
  • {$message.strPgConfSetting|escape}
  • {$message.strSetting|escape}
  • {$message.strChangePassword|escape}
  • diff --git a/templates/nodeServerStatus.tpl b/templates/nodeServerStatus.tpl index 49ff4bf..e20643d 100644 --- a/templates/nodeServerStatus.tpl +++ b/templates/nodeServerStatus.tpl @@ -7,20 +7,23 @@ -{/literal} +{include file="elements/status_js.tpl"} - + @@ -190,281 +15,173 @@ function changeView(chView){ -
    - -
    - - +
    + -

    pgpool-II Version

    -{$smarty.const._PGPOOL2_VERSION} + {* --------------------------------------------------------------------- *} + {* pgpool's version *} + {* --------------------------------------------------------------------- *} -{* --------------------------------------------------------------------- *} -{* Status Info Buttons *} -{* --------------------------------------------------------------------- *} +

    pgpool-II Version

    + {$smarty.const._PGPOOL2_VERSION} -

    {$message.strPgpoolStatus|escape}

    +

    login user: {$login_user}

    +

    is_superuser: {if $is_superuser}yes{else}no{/if}

    -{if $pgpoolIsActive == true} -

    - - - - {if $useSyslog == FALSE && $n == 1 && $pipe == 0} - - {/if} -

    -
    -

    - - - - {if $useSyslog == FALSE && $n == 1 && $pipe == 0} - - {/if} -

    -{else} -{$message.strStopPgpool|escape} -{/if} + {* --------------------------------------------------------------------- *} + {* Status Info Buttons *} + {* --------------------------------------------------------------------- *} -{* --------------------------------------------------------------------- *} +

    Backend info (PostgreSQL)

    -

    {$message.strPgpool|escape}

    + {if isset($complete_msg)}{$complete_msg}{/if} {* --------------------------------------------------------------------- *} - {* Start Options *} + {* Succeeed / Failed *} {* --------------------------------------------------------------------- *} - {if $pgpoolIsActive == false} - - - - - - - - {if hasMemqCache() == false} - - {if $c == 1} - - {else} - - {/if} + {if isset($status)} + {if $status == 'success'} +
    {$message.strStartOption|escape}
    - -
    {$message.strCmdC|escape} (-c)
    + + - {/if} - - - {if $D == 1} - - {else} - - {/if} +

    {$message.msgUpdateComplete|escape}

    {$message.strCmdLargeD|escape} (-D)
    + {elseif $status == 'fail'} + + + +

    {$message.msgUpdateFailed|escape}

    + {/if} + {/if} - {$message.strCmdN|escape} (-n) - {if $n == 1} - - {else} - - {/if} - + {if $pgpoolIsActive == true} +

    + - {if hasMemqCache()} - {$message.strCmdLargeC|escape} (-C) - {if $C == 1} - - {else} - - {/if} - + + + {if $params.use_watchdog == 'on'} + {/if} - {$message.strCmdD|escape} (-d) - {if $d == 1} - - {else} - - {/if} - + - {$message.strCmdPgpoolFile|escape} (-f) - {$pgpoolConf|escape} - + {if $useSyslog == FALSE && $n == 1 && $pipe == 0} + + {/if} +

    - {$message.strCmdPcpFile|escape} (-F) - {$pcpConf|escape} - +
    {* show elements/status_nodeinfo.tpl *} - - {else} + + + + + + + + + + + + + {if isset($params.backend_hostname)} + {$i = 0} + {foreach from=$params.backend_hostname key=node_num item=v} + {$i = $i + 1} + + + + + + + + {/foreach} - {* --------------------------------------------------------------------- *} - {* Command Buttons *} - {* --------------------------------------------------------------------- *} + {else} + + {/if} + + + + + +
    node {$node_num}{$params.backend_hostname.$node_num|escape}{$params.backend_port.$node_num|escape}postgres: + {if $nodeInfo.$node_num.is_active}{$message.strUp|escape} + {else}{$message.strDown|escape} + {/if} + {include file="elements/status_pgsql_buttons.tpl"}
    {$message.strNoNode|escape}
    + +
    + {/if} -
    - - - -
    + {* ---------------------------------------------------------------------- *} + {* Form to add a new backend *} + {* ---------------------------------------------------------------------- *} - {* --------------------------------------------------------------------- *} - {* Stop Options *} - {* --------------------------------------------------------------------- *} - +
    {* end div#content *}