Add parameters for watchdog.
authorNozomi Anzai <anzai@sraoss.co.jp>
Fri, 13 Jul 2012 08:48:27 +0000 (17:48 +0900)
committerNozomi Anzai <anzai@sraoss.co.jp>
Fri, 13 Jul 2012 08:48:27 +0000 (17:48 +0900)
common.php
definePgpoolConfParam.php
lang/en.lang.php
lang/ja.lang.php
pgconfig.php
templates/pgconfig.tpl

index 49daf7cdb249cbbfe8a24d90a59d07cb27d8fe78..9bb2f04179368270889011d2e989055e43649599 100644 (file)
@@ -448,6 +448,7 @@ function readConfigParams($paramList = FALSE)
             $key = trim($key);
             $value = trim($value);
 
+            // params about backend nodes
             if (preg_match("/^backend_hostname/", $key)) {
                 $num = str_replace('backend_hostname', '', $key);
                 $configParam['backend_hostname'][$num] = str_replace("'", "", $value);
@@ -468,6 +469,19 @@ function readConfigParams($paramList = FALSE)
                 $num = str_replace('backend_flag', '', $key);
                 $configParam['backend_flag'][$num] =str_replace("'", "", $value);
 
+            // params about watchdog monitoring
+            } elseif (preg_match("/^other_pgpool_hostname/", $key)) {
+                $num = str_replace('other_pgpool_hostname', '', $key);
+                $configParam['other_pgpool_hostname'][$num] = str_replace("'", "", $value);
+
+            } elseif (preg_match("/^other_pgpool_port/", $key)) {
+                $num = str_replace('other_pgpool_port', '', $key);
+                $configParam['other_pgpool_port'][$num] = $value;
+
+            } elseif (preg_match("/^other_wd_port/", $key)) {
+                $num = str_replace('other_wd_port', '', $key);
+                $configParam['other_wd_port'][$num] = $value;
+
             } else {
                 $configParam[$key] = str_replace("'", "", $value);
             }
@@ -484,7 +498,11 @@ function readConfigParams($paramList = FALSE)
                    !preg_match("/^backend_port/",           $key) &&
                    !preg_match("/^backend_weight/",         $key) &&
                    !preg_match("/^backend_data_directory/", $key) &&
-                   !preg_match("/^backend_flag/",           $key))
+                   !preg_match("/^backend_flag/",           $key) &&
+                   !preg_match("/^other_pgpool_hostname/",  $key) &&
+                   !preg_match("/^other_pgpool_port/",      $key) &&
+                   !preg_match("/^other_wd_port/",          $key)
+                   )
                 {
                     if (isset($configParam[$key])) {
                         $results[$key] = $configParam[$key]['default'];
@@ -513,6 +531,11 @@ function isTrue($value)
 }
 
 /* check version */
+function hasWatchdog()
+{
+    return (3.2 <= _PGPOOL2_VERSION);
+}
+
 function hasMemqcache()
 {
     return (3.2 <= _PGPOOL2_VERSION);
@@ -532,6 +555,20 @@ function paramExists($param)
         // params added in 3.2
         case 'health_check_max_retries':
         case 'health_check_retry_delay':
+        case 'use_watchdog':
+        case 'trusted_servers':
+        case 'delegate_IP':
+        case 'wd_hostname':
+        case 'wd_port':
+        case 'wd_interval':
+        case 'ping_path':
+        case 'ifconfig_path':
+        case 'if_up_cmd':
+        case 'if_down_cmd':
+        case 'arping_path':
+        case 'arping_cmd':
+        case 'wd_life_point':
+        case 'wd_lifecheck_query':
         case 'memory_cache_enabled':
         case 'memqcache_method':
         case 'memqcache_memcached_host':
index 758fea0aa2caac13842fff85a7434ad05b9be2fb..251900dd954d5a6f46677df12aa4cde66a5f35bc 100644 (file)
@@ -515,7 +515,102 @@ $pgpoolConfigParam[$key]['min'] = (3.0 <= _PGPOOL2_VERSION) ? -1 : 0;
 $pgpoolConfigParam[$key]['max'] = NUM_MAX;
 
 #------------------------------------------------------------------------------
-# ON MEMORY QUERY CACHE 
+# WATCHDOG
+#------------------------------------------------------------------------------
+
+$key = 'use_watchdog';
+$pgpoolConfigParam[$key]['type'] = 'B';
+$pgpoolConfigParam[$key]['default'] = 'off';
+
+$key = 'trusted_servers';
+$pgpoolConfigParam[$key]['type'] = 'C';
+$pgpoolConfigParam[$key]['default'] = '';
+$pgpoolConfigParam[$key]['regexp'] = $anyelse;
+
+$key = 'delegate_IP';
+$pgpoolConfigParam[$key]['type'] = 'C';
+$pgpoolConfigParam[$key]['default'] = '';
+$pgpoolConfigParam[$key]['regexp'] = $addressreg;
+
+$key = 'wd_hostname';
+$pgpoolConfigParam[$key]['type'] = 'C';
+$pgpoolConfigParam[$key]['default'] = '';
+$pgpoolConfigParam[$key]['regexp'] = $addressreg;
+
+$key = 'wd_port';
+$pgpoolConfigParam[$key]['type'] = 'N';
+$pgpoolConfigParam[$key]['default'] = 9000;
+$pgpoolConfigParam[$key]['max'] = NUM_MAX;
+$pgpoolConfigParam[$key]['min'] = 1024;
+
+$key = 'wd_interval';
+$pgpoolConfigParam[$key]['type'] = 'N';
+$pgpoolConfigParam[$key]['default'] = 10;
+$pgpoolConfigParam[$key]['max'] = NUM_MAX;
+$pgpoolConfigParam[$key]['min'] = 0;
+
+$key = 'ping_path';
+$pgpoolConfigParam[$key]['type'] = 'C';
+$pgpoolConfigParam[$key]['default'] = '';
+$pgpoolConfigParam[$key]['regexp'] = $anyelse;
+
+$key = 'ifconfig_path';
+$pgpoolConfigParam[$key]['type'] = 'C';
+$pgpoolConfigParam[$key]['default'] = '';
+$pgpoolConfigParam[$key]['regexp'] = $anyelse;
+
+$key = 'if_up_cmd';
+$pgpoolConfigParam[$key]['type'] = 'C';
+$pgpoolConfigParam[$key]['default'] = '';
+$pgpoolConfigParam[$key]['regexp'] = $anyelse;
+
+$key = 'if_down_cmd';
+$pgpoolConfigParam[$key]['type'] = 'C';
+$pgpoolConfigParam[$key]['default'] = '';
+$pgpoolConfigParam[$key]['regexp'] = $anyelse;
+
+$key = 'arping_path';
+$pgpoolConfigParam[$key]['type'] = 'C';
+$pgpoolConfigParam[$key]['default'] = '';
+$pgpoolConfigParam[$key]['regexp'] = $anyelse;
+
+$key = 'arping_cmd';
+$pgpoolConfigParam[$key]['type'] = 'C';
+$pgpoolConfigParam[$key]['default'] = '';
+$pgpoolConfigParam[$key]['regexp'] = $anyelse;
+
+$key = 'wd_life_point';
+$pgpoolConfigParam[$key]['type'] = 'N';
+$pgpoolConfigParam[$key]['default'] = 3;
+$pgpoolConfigParam[$key]['max'] = NUM_MAX;
+$pgpoolConfigParam[$key]['min'] = 0;
+
+$key = 'wd_lifecheck_query';
+$pgpoolConfigParam[$key]['type'] = 'C';
+$pgpoolConfigParam[$key]['default'] = 'SELECT 1';
+$pgpoolConfigParam[$key]['regexp'] = $anyelse;
+
+# Other pgpool Connection Settings
+
+$key = 'other_pgpool_hostname';
+$pgpoolConfigWdOtherParam[$key]['type'] = 'C';
+$pgpoolConfigWdOtherParam[$key]['default'] = '';
+$pgpoolConfigWdOtherParam[$key]['regexp'] = $hostreg;
+
+$key = 'other_pgpool_port';
+$pgpoolConfigWdOtherParam[$key]['type'] = 'N';
+$pgpoolConfigWdOtherParam[$key]['default'] = 9999;
+$pgpoolConfigWdOtherParam[$key]['min'] = 1024;
+$pgpoolConfigWdOtherParam[$key]['max'] = NUM_MAX;
+
+$key = 'other_wd_port';
+$pgpoolConfigWdOtherParam[$key]['type'] = 'N';
+$pgpoolConfigWdOtherParam[$key]['default'] = 9000;
+$pgpoolConfigWdOtherParam[$key]['min'] = 1024;
+$pgpoolConfigWdOtherParam[$key]['max'] = NUM_MAX;
+
+#------------------------------------------------------------------------------
+# ON MEMORY QUERY CACHE
 #------------------------------------------------------------------------------
 
 $key = 'memory_cache_enabled';
index 951fc265dd194ee05131a7b4bd4907e4294d6fc7..3ffbc8aede1ee1c2f08a07188ab65301a85ff7c8 100644 (file)
@@ -27,6 +27,8 @@ $message = array(
     'lang' => 'en',
     'strLang' => 'English',
 
+    'descArping_path' => 'The path of a command to send an ARP request after the virtual IP is switched',
+    'descArping_cmd' => 'The ommand to send an ARP request after the virtual IP is switched',
     'descAuthentication_timeout' => 'Timeout in seconds to complete client authentication',
     'descBackend_flag' => 'Allow failover and detach or not',
     'descBackend_hostname' => 'The real PostgreSQL server name pgpool could connect',
@@ -34,6 +36,7 @@ $message = array(
     'descBackend_socket_dir' => 'The socket directory PostgreSQL could connect',
     'descBackend_weight' => 'Load balance weight when pgpool is running in the state of load balance mode',
     'descBackend_data_directory' => 'PostgreSQL database directory',
+    'descDelegate_IP' => 'The virtual IP address (VIP) of pgpool-II ',
     'descBlack_function_list' => 'Comma separated functions which write to database',
     'descBlack_memqcache_table_list' => 'Comma separated list of table names not to be cached',
     'descChild_life_time' => 'Life of an idle child process in seconds',
@@ -64,6 +67,9 @@ $message = array(
     'descHealth_check_max_retries' => 'The maximum number of times to retry a failed health check before'.
                                       ' giving up and initiating failover',
     'descHealth_check_retry_delay' => 'The amount of time (in seconds) to sleep between failed health check retries',
+    'descIfconfig_path' => 'The path of a command to switch the IP address',
+    'descIf_down_cmd' => 'The command to bring up the virtual IP',
+    'descIf_up_cmd' => 'The command to bring down the virtual IP',
     'descIgnore_leading_white_space' => 'If true, ignore leading white spaces of each query while pgpool judges '.
                                         'if the query is a SELECT so that it can be load balanced',
     'descInsert_lock' => ' If you replicate a table having SERIAL data type column, '.
@@ -96,7 +102,11 @@ $message = array(
     'descMemqcache_cache_block_size' => 'Cache block size in bytes',
     'descMemqcache_oiddir' => 'Temporary work directory to record table OIDs',
     'descNum_init_children' => 'Number of pgpool processes initially forked',
+    'descOther_pgpool_hostname' => 'The hostname pgpool-II server to be monitored',
+    'descOther_pgpool_port' => 'The port number for pgpool on pgpool-II server to be monitored',
+    'descOther_wd_port' => 'The port number for watchdog on pgpool-II server to be monitored',
     'descParallel_mode' => 'Run in parallel mode',
+    'descPing_path' => 'The path of ping command for monitoring connection to the upper servers',
     'descPcp_port' => 'The port number where pcp is running on',
     'descPcp_socket_dir' => 'The socket directory pcp could connect',
     'descPcp_timeout' => 'When there is no response in this time from client, it disconnects and stop',
@@ -132,6 +142,13 @@ $message = array(
     'descSystem_db_port' => 'The port number system database could connect',
     'descSystem_db_schema' => 'The schema name of system database',
     'descSystem_db_user' => 'The username when connection system database',
+    'descTrusted_servers' => 'The list of trusted servers to check the up stream connections',
+    'descUse_watchdog' => 'Enable watchdog',
+    'descWd_hostname' => 'The hostname or IP address in which pgpool-II works',
+    'descWd_interval' => 'The interval between life checks of pgpool-II in second',
+    'descWd_life_point' => 'The times to retry a failed life check of pgpool-II',
+    'descWd_lifecheck_query' => 'Actual query to check pgpool-II',
+    'descWd_port' => 'The port number on which pgpool-II works',
     'descWhite_function_list' => 'Comma separated functions those do not write to Database',
     'descWhite_memqcache_table_list' => 'Comma separated list of table names to be cached',
 
index f2e8c4b1650eb569b06f21897acdc46272f0445b..7bd1f44029151806055d7a74b95918b0af38d61a 100644 (file)
@@ -27,6 +27,8 @@ $message = array(
     'lang' => 'ja',
     'strLang' => '日本語',
 
+    'descArping_path' => 'IP アドレス切り替え後に ARP リクエストを送信するコマンドのパス',
+    'descArping_cmd' => 'IP アドレス切り替え後に ARP リクエストを送信するコマンド',
     'descAuthentication_timeout' => 'クライアント認証のタイムアウト時間(秒)',
     'descBackend_flag' => 'フェイルオーバやデタッチの可否',
     'descBackend_hostname' => 'pgpoolが接続するPostgreSQLサーバ(postmaster)が動いているホスト名',
@@ -45,6 +47,7 @@ $message = array(
     'descConnection_life_time' => 'コネクションプール中のコネクションの有効期間(秒)',
     'descDebug_level' => 'デバッグメッセージの詳細レベル(0は無効)',
     'descDelay_threshold' => '許容するスタンバイサーバの遅延(バイト)',
+    'descDelegate_IP' => '仮想 IP アドレス',
     'descEnable_pool_hba' => 'クライアント認証機能の有無',
     'descEnable_query_cache' => 'クエリキャッシュ機能の有無',
     'descFailover_command' => 'ノード切り離し時に起動するコマンド',
@@ -58,6 +61,9 @@ $message = array(
     'descHealth_check_password' => 'ヘルスチェックを行うためのPostgreSQLパスワード',
     'descHealth_check_max_retries' => 'ヘルスチェックに失敗した後にリトライする回数',
     'descHealth_check_retry_delay' => 'ヘルスチェックのリトライの間の間隔(秒)',
+    'descIfconfig_path' => 'ifconfig コマンドのパス',
+    'descIf_down_cmd' => '仮想 IP を停止するために実行するコマンド',
+    'descIf_up_cmd' => '仮想 IP を起動するために実行するコマンド',
     'descIgnore_leading_white_space' => 'load balance時のSQL文行頭の空白を無視',
     'descInsert_lock' => 'INSERT時に自動的にトランザクションの開始,テーブルロック,トランザクションの終了',
     'descListen_addresses' => 'TCP/IPコネクションを受け付けるアドレス',
@@ -87,11 +93,15 @@ $message = array(
     'descMemqcache_oiddir' => 'テーブルOIDを格納するディレクトリ',
     'descNum_init_children' => 'Number of pgpool processes initially forked',
     'descNum_init_children' => 'preforkするpgpoolのサーバプロセス数',
+    'descOther_pgpool_hostname' => '監視する pgpool-II が稼働するホスト名',
+    'descOther_pgpool_port' => '監視する pgpool-II が稼働するポート番号',
+    'descOther_wd_port' => '監視する watchdog が稼働するポート番号',
     'descParallel_mode' => 'パラレルモードでpgpoolを運転',
     'descPcp_port' => 'pgpool-IIが受け付けているポート番号',
     'descPcp_socket_dir' => 'pcpがコネクションを受け付けるUnix domain socketディレクトリ',
     'descPcp_timeout' => 'この時間内にクライアントから応答がない場合はコネクションを切断して終了',
     'descPgpool2_hostname' => 'pgpool2 が動作しているホスト名',
+    'descPing_path' => 'ping コマンドのパス',
     'descPort' => 'pgpoolがコネクションを受け付けるポート番号',
     'descPrint_timestamp' => 'pgpoolのログにタイムスタンプを追加',
     'descRecovery_user' => 'リカバリを行うためのPostgreSQLユーザ',
@@ -124,6 +134,13 @@ $message = array(
     'descSystem_db_port' => 'System DBに接続するためのポート番号',
     'descSystem_db_schema' => 'System DBのスキーマ',
     'descSystem_db_user' => 'System DBに接続するときのユーザ名',
+    'descTrusted_servers' => '上位サーバのコンマ区切りのリスト',
+    'descUse_watchdog' => 'watchdog 機能の有無',
+    'descWd_hostname' => 'watchdog プロセスが相互監視を受信するためのホスト名',
+    'descWd_interval' => '死活監視の間隔(秒)',
+    'descWd_life_point' => '死活監視のリトライ回数',
+    'descWd_lifecheck_query' => '死活監視で実行するクエリ',
+    'descWd_port' => 'watchdog プロセスが相互監視を受信するためのポート番号',
     'descWhite_function_list' => 'データベースに書き込みを行なわないカンマ区切りの関数のリスト',
     'descWhite_memqcache_table_list' => 'SELECT結果をキャッシュしたいテーブル名のカンマ区切りのリスト',
 
index 42cef69c5982072a702ee4281465bceda4bfa685..abeac98d1be28f95816983573e365751d67df7de 100644 (file)
@@ -19,7 +19,7 @@
  * is" without express or implied warranty.
  *
  * @author     Ryuma Ando <ando@ecomas.co.jp>
- * @copyright  2003-2011 PgPool Global Development Group
+ * @copyright  2003-2012 PgPool Global Development Group
  * @version    CVS: $Id$
  */
 
@@ -48,6 +48,7 @@ if (isset($_POST['action'])) {
 
 switch ($action) {
     case 'add':
+    case 'add_wd':
 
         // Boolean value
         foreach ($pgpoolConfigParam as $key => $value) {
@@ -95,13 +96,35 @@ switch ($action) {
             }
         }
 
+        // watchdog settings
+        if (isset($_POST['other_pgpool_hostname'])) {
+            $configValue['other_pgpool_hostname'] = $_POST['other_pgpool_hostname'];
+        } else {
+            $configValue['other_pgpool_hostname'] = array();
+
+        }
+
+        if (isset($_POST['other_pgpool_port'])) {
+            $configValue['other_pgpool_port'] = $_POST['other_pgpool_port'];
+        } else {
+            $configValue['other_pgpool_port'] = array();
+        }
+
+        if (isset($_POST['other_wd_port'])) {
+            $configValue['other_wd_port'] = $_POST['other_wd_port'];
+        } else {
+            $configValue['other_wd_port'] = array();
+        }
+
         $tpl->assign('params', $configValue);
-        $tpl->assign('isAdd', TRUE);
+        $tpl->assign('isAdd', ($action == 'add'));
+        $tpl->assign('isAddWd', ($action == 'add_wd'));
         $tpl->display('pgconfig.tpl');
 
         return;
 
     case 'cancel':
+    case 'cancel_wd':
 
         // Boolean value
         foreach ($pgpoolConfigParam as $key => $value) {
@@ -129,17 +152,32 @@ switch ($action) {
         if (isset($_POST['backend_data_directory'])) {
             $configValue['backend_data_directory'] = $_POST['backend_data_directory'];
         }
-        if (isset($_POST['backend_flag'])) {
+        if (paramExists('backend_flag') && isset($_POST['backend_flag'])) {
             $configValue['backend_flag'] = $_POST['backend_flag'];
         }
-
         array_pop($configValue['backend_hostname']);
         array_pop($configValue['backend_port']);
         array_pop($configValue['backend_weight']);
         array_pop($configValue['backend_data_directory']);
         array_pop($configValue['backend_flag']);
+
+        // watchdog settings
+        if (isset($_POST['other_pgpool_hostname'])) {
+            $configValue['other_pgpool_hostname'] = $_POST['other_pgpool_hostname'];
+        }
+        if (isset($_POST['other_pgpool_port'])) {
+            $configValue['other_pgpool_port'] = $_POST['other_pgpool_port'];
+        }
+        if (isset($_POST['other_wd_port'])) {
+            $configValue['other_wd_port'] = $_POST['other_wd_port'];
+        }
+        array_pop($configValue['other_pgpool_hostname']);
+        array_pop($configValue['other_pgpool_port']);
+        array_pop($configValue['other_wd_port']);
+
         $tpl->assign('params', $configValue);
-        $tpl->assign('isAdd', FALSE);
+        $tpl->assign('isAdd', !($action == 'cancel'));
+        $tpl->assign('isAddWd', !($action == 'cancel_wd'));
         $tpl->display('pgconfig.tpl');
 
         return;
@@ -192,6 +230,7 @@ switch ($action) {
                 $configValue[$key] = $_POST[$key];
             }
         }
+
         /**
          * check backend value
          */
@@ -240,6 +279,44 @@ switch ($action) {
             }
         }
 
+        /**
+         * copy backend value from POST data to $configValue
+         */
+        foreach ($pgpoolConfigWdOtherParam as $key => $value) {
+            if (isset($_POST[$key])) {
+                $configValue[$key] = $_POST[$key];
+            }
+        }
+
+        /**
+         * check other watchdog value
+         */
+        if (isset($configValue['other_pgpool_hostname'])) {
+            for ($i = 0; $i < count($configValue['other_pgpool_hostname']); $i++) {
+                $result = FALSE;
+
+                // other_pgpool_hostname
+                $result = checkString($configValue['other_pgpool_hostname'][$i],
+                                      $pgpoolConfigWdOtherParam['other_pgpool_hostname']['regexp']);
+                if (!$result) {
+                    $error['other_pgpool_hostname'][$i] = TRUE;
+                }
+
+                // other_pgpool_port
+                $result = checkInteger($configValue['other_pgpool_port'][$i],
+                                       $pgpoolConfigWdOtherParam['other_pgpool_port']['min'],
+                                       $pgpoolConfigWdOtherParam['other_pgpool_port']['max']);
+
+                // other_wd_port
+                $result = checkInteger($configValue['other_wd_port'][$i],
+                                       $pgpoolConfigWdOtherParam['other_wd_port']['min'],
+                                       $pgpoolConfigWdOtherParam['other_wd_port']['max']);
+            }
+        }
+
+        /*
+         * Chek if there is errors
+         */
         $isError = FALSE;
         foreach ($error as $key => $value) {
             if (preg_match("/^backend_hostname/",       $key) ||
@@ -254,15 +331,27 @@ switch ($action) {
                     }
                 }
 
-            } else {
-                if ($value == TRUE) {
-                    $isError = TRUE;
+            } elseif (
+                preg_match("/^other_pgpool_hostname/", $key) ||
+                preg_match("/^other_pgpool_port/",     $key) ||
+                preg_match("/^other_wd_port/",         $key))
+            {
+                for ($i = 0; $i < count($value); $i++) {
+                    if ($value[$i] == TRUE) {
+                        $isError = TRUE;
+                    }
                 }
+
+            } elseif ($value == TRUE) {
+                $isError = TRUE;
             }
 
             if ($isError) { break; }
         }
 
+        /**
+         * Display
+         */
         if (!$isError) {
             if (is_writable(_PGPOOL2_CONFIG_FILE)) {
                 writeConfigFile($configValue, $pgpoolConfigParam);
@@ -282,8 +371,15 @@ switch ($action) {
         break;
 
     case 'delete':
+    case 'delete_wd':
         $num = $_POST['num'];
-        deleteBackendHost($num, $configValue);
+
+        switch ($action) {
+            case 'delete':
+                deleteBackendHost($num, $configValue); break;
+            case 'delete_wd':
+                deleteWdOther($num, $configValue); break;
+        }
 
         if (is_writable(_PGPOOL2_CONFIG_FILE)) {
             writeConfigFile($configValue, $pgpoolConfigParam);
@@ -439,8 +535,7 @@ function writeConfigFile($configValue, $pgpoolConfigParam)
 {
     $configFile = @file(_PGPOOL2_CONFIG_FILE);
 
-    $removeBackendConfigFile = array();
-
+    $tmpConfigFile = array();
     for ($i = 0; $i < count($configFile); $i++) {
         $line = $configFile[$i];
 
@@ -452,17 +547,20 @@ function writeConfigFile($configValue, $pgpoolConfigParam)
                 !preg_match("/^backend_port/",           $key) &&
                 !preg_match("/^backend_weight/",         $key) &&
                 !preg_match("/^backend_data_directory/", $key) &&
-                !preg_match("/^backend_flag/",           $key))
+                !preg_match("/^backend_flag/",           $key) &&
+                !preg_match("/^other_pgpool_hostname/",  $key) &&
+                !preg_match("/^other_pgpool_port/",      $key) &&
+                !preg_match("/^other_wd_port/",          $key)
+                )
             {
-                $removeBackendConfigFile[] =  $line;
+                $tmpConfigFile[] =  $line;
             }
 
         } else {
-            $removeBackendConfigFile[] =  $line;
+            $tmpConfigFile[] =  $line;
         }
     }
-
-    $configFile = $removeBackendConfigFile;
+    $configFile = $tmpConfigFile;
 
     foreach ($pgpoolConfigParam as $key => $value) {
         $isWrite = FALSE;
@@ -493,25 +591,25 @@ function writeConfigFile($configValue, $pgpoolConfigParam)
     if (isset($configValue['backend_hostname'])) {
         for ($i = 0; $i < count($configValue['backend_hostname']); $i++) {
 
-            $line = "backend_hostname$i = '" . $configValue['backend_hostname'][$i] . "'\n";
-            $configFile[] = $line;
-
-            $line = "backend_port$i = " . $configValue['backend_port'][$i] . "\n";
-            $configFile[] = $line;
-
-            $line = "backend_weight$i = " . $configValue['backend_weight'][$i] . "\n";
-            $configFile[] = $line;
-
-            $line = "backend_data_directory$i = '" . $configValue['backend_data_directory'][$i] . "'\n";
-            $configFile[] = $line;
+            $configFile[] = "backend_hostname$i = '" . $configValue['backend_hostname'][$i] . "'\n";
+            $configFile[] = "backend_port$i = " . $configValue['backend_port'][$i] . "\n";
+            $configFile[] = "backend_weight$i = " . $configValue['backend_weight'][$i] . "\n";
+            $configFile[] = "backend_data_directory$i = '" . $configValue['backend_data_directory'][$i] . "'\n";
 
             if (paramExists('backend_flag')) {
-                $line = "backend_flag$i= '" . $configValue['backend_flag'][$i] . "'\n";
-                $configFile[] = $line;
+                $configFile[] = "backend_flag$i= '" . $configValue['backend_flag'][$i] . "'\n";
             }
         }
     }
 
+    if (isset($configValue['other_pgpool_hostname'])) {
+        for ($i = 0; $i < count($configValue['other_pgpool_hostname']); $i++) {
+            $configFile[] = "other_pgpool_hostname$i = '" . $configValue['other_pgpool_hostname'][$i] . "'\n";
+            $configFile[] = "other_pgpool_port$i = " . $configValue['other_pgpool_port'][$i] . "\n";
+            $configFile[] = "other_wd_port$i = " . $configValue['other_wd_port'][$i] . "\n";
+        }
+    }
+
     $outfp = fopen(_PGPOOL2_CONFIG_FILE, 'w');
     foreach ($configFile as $line) {
         fputs($outfp, $line);
@@ -545,4 +643,18 @@ function deleteBackendHost($num, &$configValue)
     }
 }
 
+/**
+ * Delete an other watchdog
+ */
+function deleteWdOther($num, &$configValue)
+{
+    unset($configValue['other_pgpool_hostname'][$num]);
+    $configValue['other_pgpool_hostname'] = array_values($configValue['other_pgpool_hostname']);
+
+    unset($configValue['other_pgpool_port'][$num]);
+    $configValue['other_pgpool_port'] = array_values($configValue['other_pgpool_port']);
+
+    unset($configValue['other_wd_port'][$num]);
+    $configValue['other_wd_port'] = array_values($configValue['other_wd_port']);
+}
 ?>
index d4978de31a110835d276db8aee30f4d246e4e218..7fd9deb793681323e50f4fdf5fcc0be0f0ec52ee 100644 (file)
@@ -36,6 +36,24 @@ function cancelNode() {
     document.pgconfig.submit();
 }
 
+function addOtherWatchdog() {
+    document.pgconfig.action.value= "add_wd";
+    document.pgconfig.submit();
+}
+
+function cancelOtherWatchdog() {
+    document.pgconfig.action.value= "cancel_wd";
+    document.pgconfig.submit();
+}
+function delOtherWatchdog(num){
+    if(window.confirm(msgDeleteConfirm)){
+        document.pgconfig.action.value= "delete_wd";
+        document.pgconfig.num.value = num;
+        document.pgconfig.submit();
+    }
+}
+
+
 // -->
 </script>
 {/literal}
@@ -90,6 +108,9 @@ function cancelNode() {
       <li><a href="#health-check">Health Check</a></li>
       <li><a href="#failover">Failover and Failback</a></li>
       <li><a href="#recovery">Online Recovery</a></li>
+      {if hasWatchdog()}
+      <li><a href="#watchdog">Watchdog</a></li>
+      {/if}
       {if hasMemqcache()}
       <li><a href="#memqcache">On Memory Query Cache</a></li>
       {/if}
@@ -1179,6 +1200,195 @@ function cancelNode() {
       </tbody>
     </table>
 
+    {if hasMemqcache()}
+    {* --------------------------------------------------------------------- *
+     * Watchdog                                                              *
+     * --------------------------------------------------------------------- *}
+    <h3><a name="watchdog" id="watchdog">Watchdog</a></h3>
+
+    <table>
+      <thead>
+        <tr>
+          <th>{$message.strParameter|escape}</th>
+          <th colspan="2">{$message.strValue|escape}</th>
+        </tr>
+      </thead>
+      <tbody>
+
+        <tr>
+        <th{if isset($error.use_watchdog)} class="error"{/if}>
+        <label>{$message.descUse_watchdog|escape}</label>
+        <br />use_watchdog (bool)</th>
+        <td colspan="2"><input type="checkbox" name="use_watchdog" id="use_watchdog" value="true"
+            {if $params.use_watchdog== 'on'}checked="checked"{/if} /></td>
+        </tr>
+
+        <tr><th class="category" colspan="3">Connection to up stream servers</th></tr>
+
+        <tr>
+        <th{if isset($error.trusted_servers)} class="error"{/if}>
+        <label>{$message.descTrusted_servers|escape}</label>
+        <br />trusted_servers (string) *</th>
+        <td colspan="2"><input type="text" name="trusted_servers" value="{$params.trusted_servers|escape}"/></td>
+        </tr>
+
+        <tr>
+        <th{if isset($error.ping_path)} class="error"{/if}>
+        <label>{$message.descPing_path|escape}</label>
+        <br />ping_path (string) *</th>
+        <td colspan="2"><input type="text" name="ping_path" value="{$params.ping_path|escape}"/></td>
+        </tr>
+
+        <tr><th class="category" colspan="3">Lifecheck of pgpol-II</th></tr>
+
+        <tr>
+        <th{if isset($error.wd_interval)} class="error"{/if}>
+        <label>{$message.descWd_interval|escape}</label>
+        <br />wd_interval (integer)</th>
+        <td colspan="2"><input type="text" name="wd_interval" value="{$params.wd_interval|escape}"/></td>
+        </tr>
+
+        <tr>
+        <th{if isset($error.wd_life_point)} class="error"{/if}>
+        <label>{$message.descWd_life_point|escape}</label>
+        <br />wd_life_point(integer)</th>
+        <td colspan="2"><input type="text" name="wd_life_point" value="{$params.wd_life_point|escape}"/></td>
+        </tr>
+
+        <tr>
+        <th{if isset($error.wd_lif_check_query)} class="error"{/if}>
+        <label>{$message.descWd_lifecheck_query|escape}</label>
+        <br />wd_lifecheck_query (string)</th>
+        <td colspan="2"><input type="text" name="wd_lifecheck_query" value="{$params.wd_lifecheck_query|escape}"/></td>
+        </tr>
+
+        <tr><th class="category" colspan="3">Virtual IP address</th></tr>
+
+        <tr>
+        <th{if isset($error.delegate_IP)} class="error"{/if}>
+        <label>{$message.descDelegate_IP|escape}</label>
+        <br />delegate_IP (string)</th>
+        <td colspan="2"><input type="text" name="delegate_IP" value="{$params.delegate_IP|escape}"/></td>
+        </tr>
+
+        <tr>
+        <th{if isset($error.ifconfig_path)} class="error"{/if}>
+        <label>{$message.descIfconfig_path|escape}</label>
+        <br />ifconfig_path (string)</th>
+        <td colspan="2"><input type="text" name="ifconfig_path" value="{$params.ifconfig_path|escape}"/></td>
+        </tr>
+
+        <tr>
+        <th{if isset($error.if_up_cmd)} class="error"{/if}>
+        <label>{$message.descIf_up_cmd|escape}</label>
+        <br />if_up_cmd (string)</th>
+        <td colspan="2"><input type="text" name="if_up_cmd" value="{$params.if_up_cmd|escape}"/></td>
+        </tr>
+
+        <tr>
+        <th{if isset($error.if_down_cmd)} class="error"{/if}>
+        <label>{$message.descIf_down_cmd|escape}</label>
+        <br />if_down_cmd (string)</th>
+        <td colspan="2"><input type="text" name="if_down_cmd" value="{$params.if_down_cmd|escape}"/></td>
+        </tr>
+
+        <tr>
+        <th{if isset($error.arping_path)} class="error"{/if}>
+        <label>{$message.descArping_path|escape}</label>
+        <br />arping_path (string)</th>
+        <td colspan="2"><input type="text" name="arping_path" value="{$params.arping_path|escape}"/></td>
+        </tr>
+
+        <tr>
+        <th{if isset($error.arping_cmd)} class="error"{/if}>
+        <label>{$message.descArping_cmd|escape}</label>
+        <br />arping_cmd (string)</th>
+        <td colspan="2"><input type="text" name="arping_cmd" value="{$params.arping_cmd|escape}"/></td>
+        </tr>
+
+        <tr><th class="category" colspan="3">Server itself to be monitored</th></tr>
+
+        <tr>
+        <th{if isset($error.wd_hostname)} class="error"{/if}>
+        <label>{$message.descWd_hostname|escape}</label>
+        <br />wd_hostname (string)</th>
+        <td colspan="2"><input type="text" name="wd_hostname" value="{$params.wd_hostname|escape}"/></td>
+        </tr>
+
+        <tr>
+        <th{if isset($error.wd_port)} class="error"{/if}>
+        <label>{$message.descWd_port|escape}</label>
+        <br />arping_cmd (integer)</th>
+        <td colspan="2"><input type="text" name="wd_port" value="{$params.wd_port|escape}"/></td>
+        </tr>
+
+        <tr><th class="category" colspan="3">Servers to monitor</th></tr>
+
+          {section name=num loop=$params.other_pgpool_hostname}
+          <tr>
+          <th{if isset($error.other_pgpool_hostname[num])} class="error"{/if}>
+          <label>{$message.descOther_pgpool_hostname|escape}</label>
+          <br />other_pgpool_hostname{$smarty.section.num.index} (string)</th>
+          <td><input type="text" name="other_pgpool_hostname[]" value="{$params.other_pgpool_hostname[num]|escape}" /></td>
+          <td rowspan="3">
+          <input type="button" name="delete" value="{$message.strDelete|escape}"
+          onclick="delOtherWatchdog({$smarty.section.num.index})" /></td>
+          </tr>
+
+          <tr>
+          <th{if isset($error.other_pgpool_port[num])} class="error"{/if}>
+          <label>{$message.descOther_pgpool_port|escape}</label>
+          <br />other_pgpool_port{$smarty.section.num.index|escape} (integer)</th>
+          <td><input type="text" name="other_pgpool_port[]" value="{$params.other_pgpool_port[num]|escape}" /></td>
+          </tr>
+
+          <tr>
+          <th{if isset($error.other_wd_port[num])} class="error"{/if}>
+          <label>{$message.descOther_wd_port|escape}</label>
+          <br />other_wd_port{$smarty.section.num.index|escape} (integer)</th>
+          <td><input type="text" name="other_wd_port[]" value="{$params.other_wd_port[num]|escape}" /></td>
+          </tr>
+          {/section}
+
+          {if isset($isAddWd) && $isAddWd == true}
+              <tr>
+              <th><label>{$message.descOther_pgpool_hostname|escape}</label>
+              <br />other_pgpool_hostname{$smarty.section.num.index} (string)</th>
+              <td><input type="text" name="other_pgpool_hostname[]" value="" /></td>
+              </tr>
+
+              <tr>
+              <th><label>{$message.descOther_pgpool_port|escape}</label>
+              <br />other_pgpool_port{$smarty.section.num.index|escape} (integer)</th>
+              <td><input type="text" name="other_pgpool_port[]" value="" /></td>
+              </tr>
+
+              <tr>
+              <th><label>{$message.descOther_wd_port|escape}</label>
+              <br />other_wd_port{$smarty.section.num.index|escape} (integer)</th>
+              <td><input type="text" name="other_wd_port[]" value="" /></td>
+              </tr>
+          {/if}
+
+      </tbody>
+      {if isset($isAddWd) && $isAddWd == true}
+          <tfoot>
+            <tr>
+               <td colspan="3">
+               <input type="button" name="cancel" value="{$message.strCancel|escape}" onclick="cancelOtherWatchdog()" /></td>
+            </tr>
+          </tfoot>
+      {else}
+          <tfoot>
+            <tr>
+              <td colspan="3">
+              <input type="button" name="add" value="{$message.strAdd|escape}" onclick="addOtherWatchdog()" /></td>
+            </tr>
+          </tfoot>
+      {/if}
+    </table>
+    {/if}
+
     {if hasMemqcache()}
     {* --------------------------------------------------------------------- *
      * On Memory Query Cache                                                 *