Add the hostname on which pgpoolAdmin is working.
authorNozomi Anzai <anzai@sraoss.co.jp>
Mon, 8 Jul 2013 02:24:06 +0000 (11:24 +0900)
committerNozomi Anzai <anzai@sraoss.co.jp>
Mon, 8 Jul 2013 02:24:06 +0000 (11:24 +0900)
Fix is_superuser's value is not "no" but "unknown" if no backend nodes is active.

bootstrap.php
status.php
templates/status.tpl

index 921a7b9bc08ea5883f56cd8c19039a6cd1391f8b..d06b2e3e0462c503d1cf3a75c348222cfdff4cad 100644 (file)
@@ -17,6 +17,9 @@ define('SMARTY_COMPILE_DIR',  dirname(__FILE__) . '/templates_c' );
 // pgpool-II
 define('PGPOOL_OFFICIAL_SITE', 'http://www.pgpool.net/');
 
+// pgpoolAdmin
+define('PGPOOLADMIN_HOST', exec('hostname -f'));
+
 // node status in "pcp_node_info" result
 // http://www.pgpool.net/pgpool-web/pgpool-II/doc/pgpool-ja.html#pcp_node_info
 define('NODE_ACTIVE_NO_CONNECT', 1);
index 785c61298a138f6d31f1ac1f438b43b43184728e..e8122b67d6c4c20752ef7969a7a43226ceb13c28 100644 (file)
@@ -94,15 +94,21 @@ function _doAction($action, $nodeNumber)
         /* --------------------------------------------------------------------- */
 
         case 'startPgpool':
-            _startPgpool();
+            if (_startPgpool()) {
+                header("Location: " . $_SERVER['PHP_SELF']);
+            }
             break;
 
         case 'stopPgpool':
-            _stopPgpool();
+            if (_stopPgpool()) {
+                header("Location: " . $_SERVER['PHP_SELF']);
+            }
             break;
 
         case 'restartPgpool':
-            _restartPgpool();
+            if (_restartPgpool()) {
+                header("Location: " . $_SERVER['PHP_SELF']);
+            }
             break;
 
         case 'reloadPgpool':
@@ -277,6 +283,7 @@ function _waitForNoPidFile()
 function _startPgpool()
 {
     global $tpl;
+    $rtn = FALSE;
 
     $args = _setStartArgs();
     $result = execPcp('PCP_START_PGPOOL', $args);
@@ -287,6 +294,7 @@ function _startPgpool()
     } else {
         if (_waitForPidFile()) {
             $pgpoolStatus = 'pgpool start succeed';
+            $rtn = TRUE;
         } else {
             $pgpoolStatus = 'pgpool start failed. pgpool.pid not found';
         }
@@ -295,6 +303,8 @@ function _startPgpool()
 
     $tpl->assign('pgpoolStatus', $pgpoolStatus);
     $tpl->assign('pgpoolMessage', $pgpoolMessage);
+
+    return $rtn;
 }
 
 /** Stop pgpool */
@@ -302,6 +312,7 @@ function _stopPgpool()
 {
     global $_POST;
     global $tpl;
+    $rtn = FALSE;
 
     $m = $_POST['stop_mode'];
 
@@ -315,11 +326,14 @@ function _stopPgpool()
     } else {
         if (_waitForNoPidFile()) {
             $pgpoolStatus = 'pgpool stop succeed';
+            $rtn = TRUE;
         } else {
             $pgpoolStatus = 'pgpool stop failed. pgpool.pid exists.';
         }
         $tpl->assign('pgpoolStatus', $pgpoolStatus);
     }
+
+    return $rtn;
 }
 
 /** Restart pgpool */
@@ -327,6 +341,7 @@ function _restartPgpool()
 {
     global $_POST;
     global $tpl;
+    $rtn = FALSE;
 
     // Stop pgpool
     $m = $_POST['stop_mode'];
@@ -350,6 +365,7 @@ function _restartPgpool()
         } else {
             if (_waitForPidFile()) {
                 $pgpoolStatus = 'pgpool restart succeed';
+                $rtn = TRUE;
             } else {
                 $pgpoolStatus = 'pgpool restart failed. pgpool.pid not found';
             }
@@ -362,6 +378,8 @@ function _restartPgpool()
 
     $tpl->assign('pgpoolStatus', $pgpoolStatus);
     $tpl->assign('pgpoolMessage', $pgpoolMessage);
+
+    return $rtn;
 }
 
 /** Execute PCP command with node number */
index 7c6c6ad60b88cbae1505fcb2bc0300c2596f6cc4..2051345151d0bf36ec054453cafc282678390d48 100644 (file)
     {* pgpool's version                                                      *}
     {* --------------------------------------------------------------------- *}
 
-    <h2>pgpool-II Version</h2>
-    {$smarty.const._PGPOOL2_VERSION}
-
-    <p>login user: {$login_user}</p>
-    <p>is_superuser: {if $is_superuser}yes{else}no{/if}</p>
+    <h2>pgpoolAdmin</h2>
+    <ul>
+    <li>This is pgpoolAdmin on {$smarty.const.PGPOOLADMIN_HOST}</li>
+    <li>For pgpool-II {$smarty.const._PGPOOL2_VERSION}.</li>
+    <li>Login
+        <ul>
+        <li>login user: {$login_user}</li>
+        <li>superuser: {if $is_superuser == NULL}unknown (Connection error)
+                       {elseif $is_superuser == TRUE}yes{else}no{/if}
+        </li>
+        </ul>
+    </li>
+    </ul>
 
     {* --------------------------------------------------------------------- *}
     {* Status Info Buttons                                                   *}