Beispiel #1
0
<?php

$p->template('intranet', 'top');
?>

<div>
<?php 
unset($repmgr);
$repmgr = new repmgr($db_host, true);
if ($repmgr && $repmgr->initialized) {
    ?>
<fieldset><legend>Stats for Cluster '<?php 
    echo $repmgr_cluster_name;
    ?>
'</legend><?php 
    $nodes = $repmgr->get_nodes(true);
    $primary_nodes =& $nodes['primary'];
    $standby_nodes =& $nodes['standby'];
    $unused_nodes =& $nodes['unused'];
    /*
          foreach($nodes as $nods){
             foreach($nods as $nod){
                var_dump($nod['id'] . ' - ' . $repmgr->check_replication($nod['id']));
             } 
          }
    */
    if ($needs_cleanup = count($primary_nodes) > 1) {
        #this is indicative of a sloppy promote, so we should cleanup_repl_monitor
        ?>
<div id='general_error'><?php 
        ?>
Beispiel #2
0
<?php

unset($repmgr);
$repmgr = new repmgr($db_host, true);
if (!$repmgr || !$repmgr->initialized) {
    die('no cluster installed');
}
$params = count($_POST) ? $_POST : (count($_GET) ? $_GET : die('no parameters'));
switch ($params['func']) {
    case 'kill':
        $standby_node = $params['a'];
        $pid = $params['b'];
        $output = $repmgr->remote_kill($standby_node, $pid);
        $json = array('exit_status' => $exit_status = array_pop($output), 'success' => $exit_status == '0', 'output' => is_array($output) ? implode('\\n', $output) : $output, 'ps' => $repmgr->remote_ps($standby_node));
        echo json_encode($json);
        break;
    case 'start':
        $standby_node = $params['a'];
        $output = $repmgr->remote_start($standby_node);
        $json = array('exit_status' => $exit_status = array_pop($output), 'success' => $exit_status == '0', 'output' => is_array($output) ? implode('\\n', $output) : $output, 'ps' => $repmgr->remote_ps($standby_node));
        echo json_encode($json);
        break;
    case 'promote':
        #still experimental
        $new_primary_node = $params['a'];
        $output = $repmgr->promote($new_primary_node);
        $json = array('output' => $output);
        echo json_encode($json);
        break;
    case 'add_hard':
        $node = $params['a'];