function getCoordinatorNodeTable($strDB) { global $arrDBConns; $strTable = ''; if (testPort($arrDBConns[$strDB]['DBIP'], $arrDBConns[$strDB]['DBPort'], 0.5)) { $objConn = pg_connect('host=' . $arrDBConns[$strDB]['DBIP'] . ' port=' . $arrDBConns[$strDB]['DBPort'] . ' dbname=' . $arrDBConns[$strDB]['DBName'] . ' user='******'DBUser'] . ' password='******'DBPass']); if (!$objConn) { return '<div class="alert alert-error">Error connecting to <strong>' . $strDB . '</strong>!</div>'; } $strSQL = "SELECT *\n FROM pgxc_node\n ORDER BY node_type\n ,node_name"; $objResults = pg_exec($objConn, $strSQL); if (!$objResults) { return '<div class="alert alert-error">Error getting database list from <strong>' . $strDB . '</strong>!</div>'; } $intRows = pg_numrows($objResults); $intDatabases = $intRows; // Loop databases in the result set. for ($ri = 0; $ri < $intRows; $ri++) { $row = pg_fetch_array($objResults, $ri); // lets look into the enviroment and build a table // try to ping the server $strRowColor = 'success'; if (testPing($row['node_host'])) { $strPing = 'check'; } else { $strPing = 'exclamation'; $strRowColor = 'danger'; } // check the listed port to see if it responds if (testPort($row['node_host'], $row['node_port'])) { $strPort = 'check'; } else { $strPort = 'exclamation'; $strRowColor = 'danger'; } $strTable .= '<tr class="' . $strRowColor . '">' . "\n"; $strTable .= ' <td>' . $row['node_id'] . '</td>' . "\n"; $strTable .= ' <td>' . $row['node_name'] . '</td>' . "\n"; $strTable .= ' <td>'; if ($row['node_type'] == 'C') { $strTable .= 'Coordinator'; } if ($row['node_type'] == 'D') { $strTable .= 'Datanode'; } $strTable .= ' </td>' . "\n"; $strTable .= ' <td>' . $row['node_host'] . '</td>' . "\n"; $strTable .= ' <td align="center"><i class="fa fa-' . $strPing . '"></i> </td>' . "\n"; $strTable .= ' <td><i class="fa fa-' . $strPort . '"></i> ' . $row['node_port'] . '</td>' . "\n"; $strTable .= ' <td align="center">' . $row['nodeis_primary'] . '</td>' . "\n"; $strTable .= ' <td align="center">' . $row['nodeis_preferred'] . '</td>' . "\n"; $strTable .= '</tr>' . "\n"; } $strTableHeader = '<div class="table-responsive">' . "\n"; $strTableHeader .= '<table class="table table-hover table-condensed table-striped" width="100%">' . "\n"; $strTableHeader .= '<thead>' . "\n"; $strTableHeader .= '<th>ID</th>' . "\n"; $strTableHeader .= '<th>Node Name</th>' . "\n"; $strTableHeader .= '<th>Type</th>' . "\n"; $strTableHeader .= '<th>Hostname</th>' . "\n"; $strTableHeader .= '<th align="center">Ping</th>' . "\n"; $strTableHeader .= '<th align="center">Port</th>' . "\n"; $strTableHeader .= '<th align="center">Is Primary?</th>' . "\n"; $strTableHeader .= '<th align="center">Is Preferred?</th>' . "\n"; $strTableHeader .= '</thead>' . "\n"; $strTable .= '</table>' . "\n"; $strTable .= '</div>' . "\n"; return $strTableHeader . $strTable; } else { return '<div>Could not validate port is active on database server:' . $strDB . '. As a result, I could not connect and get your data.</div>'; } }
$intMaxConnections = getDBSystemParam($key, 'max_connections'); if ($intMaxConnections >= $intConnections && $intMaxConnections > 0) { $perConnections = round($intConnections / $intMaxConnections * 100, 0); } else { $intConnections = '?'; $intMaxConnections = '?'; $perConnections = '???'; $strPanelColor = 'warning'; } // display number of deadlocks $intDeadlocks = getDeadlocks($key); if ($intDeadlocks != '0') { $strPanelColor = 'warning'; } // try to ping the server if (testPing($value['DBIP'])) { $strPing = 'check'; } else { $strPing = 'exclamation'; $strPanelColor = 'danger'; } // check the listed port to see if it responds if (testPort($value['DBIP'], $value['DBPort'])) { $strPort = 'check'; } else { $strPort = 'exclamation'; $strPanelColor = 'danger'; } echo '<div class="col-xs-6 col-md-3 text-center">' . "\n"; echo ' <div class="panel panel-default panel-' . $strPanelColor . '" style="">' . "\n"; echo ' <div class="row">' . "\n";
echo ' <div class="row">' . "\n"; echo ' <div class="col-xs-7 text-right">Deadlocks:</div>' . "\n"; echo ' <div class="col-xs-5 text-left">' . $intDeadlocks . '</div>' . "\n"; echo ' </div>' . "\n"; echo ' </div>' . "\n"; echo '</div>' . "\n"; ?> </div> <div class="col-sm-12"> <h4>GTM Status</h4> <?php $strGTMHost = getDBSystemParam($strNode, 'gtm_host'); $strGTMPort = getDBSystemParam($strNode, 'gtm_port'); $strPanelColor = 'success'; // try to ping the server if (testPing($strGTMHost)) { $strPing = 'check'; } else { $strPing = 'exclamation'; $strPanelColor = 'danger'; } // check the listed port to see if it responds if (testPort($strGTMHost, $strGTMPort)) { $strPort = 'check'; } else { $strPort = 'exclamation'; $strPanelColor = 'danger'; } echo '<div class="col-xs-12 text-center">' . "\n"; echo ' <div class="panel panel-default panel-' . $strPanelColor . '" style="">' . "\n"; echo ' <div class="row">' . "\n";