summaryrefslogtreecommitdiff
path: root/command.php
diff options
context:
space:
mode:
Diffstat (limited to 'command.php')
-rw-r--r--command.php48
1 files changed, 43 insertions, 5 deletions
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 <ando@ecomas.co.jp>
- * @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;
+}
?>