コード例 #1
0
ファイル: process_setup.php プロジェクト: intfrr/orvfms
function processSetup($mac, &$s20Table, $actionValue)
{
    if ($actionValue == "procSetup") {
        $oldName = $s20Table[$mac]['name'];
        if (isset($_POST["newName"])) {
            $newName = $_POST["newName"];
            if ($newName != $oldName) {
                $newName = setName($mac, $newName, $s20Table);
                if ($newName != "") {
                    $s20Table[$mac]['name'] = $newName;
                    $_SESSION['s20Table'] = $s20Table;
                    writeDataFile($s20Table);
                }
            }
        }
        $nnext = (int) $_POST['numberOfNextEvents'];
        $s20Table[$mac]['next'] = $nnext;
        writeDataFile($s20Table);
        $_SESSION['s20Table'] = $s20Table;
    } else {
        if ($actionValue == "procSetupCancel") {
            // OK, nothing here
        } else {
            if ($actionValue == "procSetupDel") {
                unset($s20Table[$mac]);
                writeDataFile($s20Table);
                $_SESSION['s20Table'] = $s20Table;
            } else {
                error_log("process setup: unknow action: >" . $actionValue . "<\n");
            }
        }
    }
}
コード例 #2
0
ファイル: gs-cluster-watchdog.php プロジェクト: rkania/GS3
            write_log("*** Node {$node_id} is not alive with status " . $node[$node_id]['status'] . ". Tried " . $node[$node_id]['tries'] . " times.");
            if ($node[$node_id]['tries'] == RETRY) {
                if ($node_id > 0) {
                    if ($active < 3) {
                        stonith($node_id);
                        takeOverIP($node_id);
                        sendArp($node_id);
                        writeIPFile(IPFILE, $node[$node_id]['dynamic_ip']);
                        restartLocalAsterisk();
                        sendAlarm($node_id);
                    }
                    $node[$node_id]['status'] = STAT_TAKEN;
                    $node[$node_id]['timestamp'] = time();
                    write_log("Set status of node {$node_id} to " . $node[$node_id]['status']);
                    writeDataFile(DATAFILE);
                } else {
                    sendAlarm($node_id);
                }
            }
            $node[$node_id]['tries']++;
            writeDataFile(DATAFILE);
        } else {
            if ($active > 1) {
                write_log("Node {$node_id} alive with status " . $node[$node_id]['status']);
            }
        }
    }
    if (time() < $endtime) {
        sleep(SLEEP_SECONDS);
    }
}
コード例 #3
0
ファイル: orvfms.php プロジェクト: sfrias/orvfms
function updateAllStatus(&$s20Table)
{
    //
    // This function updates the power status of all S20 in $allAllS20Data.
    //
    // InitS20Data also fills the power status when it is called.
    // However, this function is more efficient if the $s20Table
    // was already initialized and one just wants to update the
    // power status of all S20s
    //
    foreach ($s20Table as $mac => $devData) {
        if (!array_key_exists('off', $s20Table[$mac])) {
            $s20Table[$mac]['st'] = checkStatus($mac, $s20Table);
        } else {
            $offTime = $s20Table[$mac]['off'];
            if ($offTime - time() > 300) {
                // if last time checked more than 5 minutes ago, try again
                $st = checkStatus($mac, $s20Table);
                if ($st >= 0) {
                    unset($s20Table[$mac]['off']);
                    $s20Table[$mac]['st'] = $st;
                }
            }
        }
    }
    updTableTimers($s20Table);
    writeDataFile($s20Table);
    return $s20Table;
}