<?php
/**
- * @copyright 2003-2013 PgPool Global Development Group
+ * @copyright 2003-2016 PgPool Global Development Group
*/
// Session
define('NODE_DOWN', 3);
define('NODE_NOT_LOADED', -1); // only for pgpoolAdmin
-// watchdog status in "pcp_watchdog_info" result
-define('WATCHDOG_INIT', 1);
-define('WATCHDOG_STANDBY', 2);
-define('WATCHDOG_ACTIVE', 3);
-define('WATCHDOG_DOWN', 4);
+// watchdog status in "pcp_watchdog_info" result (- 3.4)
+// (defined in $src/inclucde/watchdog/watchdog.h
+$g_watchdog_status_str_arr = array();
+if (_PGPOOL2_VERSION < 3.5) {
+ define('WATCHDOG_END', 0);
+ define('WATCHDOG_INIT', 1);
+ define('WATCHDOG_NORMAL', 2);
+ define('WATCHDOG_MASTER', 3);
+ define('WATCHDOG_DOWN', 4);
+ $g_watchdog_status_str_arr = array(
+ WATCHDOG_END => 'END',
+ WATCHDOG_INIT => 'INIT',
+ WATCHDOG_NORMAL => 'NORMAL',
+ WATCHDOG_MASTER => 'MASTER',
+ WATCHDOG_DOWN => 'DOWN',
+ );
+}
// timeout seconds
// (The parameter "pcp_timeout" existed till V3.0.)
* is" without express or implied warranty.
*
* @author Ryuma Ando <ando@ecomas.co.jp>
- * @copyright 2003-2015 PgPool Global Development Group
+ * @copyright 2003-2016 PgPool Global Development Group
* @version CVS: $Id$
*/
case 'PCP_WATCHDOG_INFO':
$cmd = _PGPOOL2_PCP_DIR . '/pcp_watchdog_info' . $args;
$ret = exec($cmd, $output, $return_var);
+ if (3.5 <= _PGPOOL2_VERSION) {
+ $ret = $output[2];
+ }
break;
default:
*/
function getWatchdogInfo($i = '')
{
- global $tpl;
+ global $tpl, $g_watchdog_status_str_arr;
- $result = execPcp('PCP_WATCHDOG_INFO', $i);
+ $result = execPcp('PCP_WATCHDOG_INFO',
+ (3.5 <= _PGPOOL2_VERSION) ? array('n' => $i) : array($i)
+ );
- if (!array_key_exists('SUCCESS', $result)) {
+ if (! array_key_exists('SUCCESS', $result)) {
$errorCode = 'e1013';
$tpl->assign('errorCode', $errorCode);
$tpl->display('innerError.tpl');
exit();
}
- $arr = explode(" ", $result['SUCCESS']);
- $rtn['hostname'] = $arr[0];
- $rtn['pgpool_port'] = $arr[1];
- $rtn['wd_port'] = $arr[2];
- $rtn['status'] = $arr[3];
+ $arr = explode(' ', $result['SUCCESS']);
+ if (3.5 <= _PGPOOL2_VERSION) {
+ // ex.) Linux_dhcp-177-180_9999 133.137.177.180 9999 9000 4 MASTER
+ $rtn['hostname'] = $arr[1];
+ $rtn['pgpool_port'] = $arr[2];
+ $rtn['wd_port'] = $arr[3];
+ $rtn['status'] = $arr[4];
+ $rtn['status_str'] = $arr[5];
+
+ } else {
+ // ex.) 133.137.177.180 9999 9000 3
+ $rtn['hostname'] = $arr[0];
+ $rtn['pgpool_port'] = $arr[1];
+ $rtn['wd_port'] = $arr[2];
+ $rtn['status'] = $arr[3];
+ $rtn['status_str'] = $g_watchdog_status_str_arr[$rtn['status']];
+ }
return $rtn;
}
exit();
}
}
-?>
* is" without express or implied warranty.
*
* @author Ryuma Ando <ando@ecomas.co.jp>
- * @copyright 2003-2013 PgPool Global Development Group
+ * @copyright 2003-2016 PgPool Global Development Group
* @version CVS: $Id$
*/
// get watchdog information
$watchdogInfo = array();
-for ($i = 0; $i < count($params['other_pgpool_hostname']); $i++) {
- $watchdogInfo[] = getWatchdogInfo($i);
-}
-$watchdogInfo['local'] = getWatchdogInfo();
+if (3.5 <= _PGPOOL2_VERSION) {
+ $watchdogInfo['local'] = getWatchdogInfo(0);
+ for ($i = 0; $i < count($params['other_pgpool_hostname']); $i++) {
+ $watchdogInfo[] = getWatchdogInfo($i + 1);
+ }
-foreach ($watchdogInfo as $key => $info) {
- switch ($info['status']) {
- case WATCHDOG_INIT:
- $watchdogInfo[$key]['status_str'] = $message['strWdInit'];
- break;
- case WATCHDOG_STANDBY:
- $watchdogInfo[$key]['status_str'] = $message['strWdStandby'];
- break;
- case WATCHDOG_ACTIVE:
- $watchdogInfo[$key]['status_str'] = $message['strWdActive'];
- break;
- case WATCHDOG_DOWN:
- $watchdogInfo[$key]['status_str'] = $message['strWdDown'];
- break;
- default:
- $watchdogInfo[$key]['status_str'] = $message['strUnknown'];
- break;
+} else {
+ $watchdogInfo['local'] = getWatchdogInfo();
+ for ($i = 0; $i < count($params['other_pgpool_hostname']); $i++) {
+ $watchdogInfo[] = getWatchdogInfo($i);
}
}
$tpl->assign('params', $params);
$tpl->assign('watchdogInfo', $watchdogInfo);
$tpl->display('innerWatchdog.tpl');
-
-?>