Beispiel #1
0
        echo "<select name=testhour>";
        echo "<option value=" . $hour . ">" . $hour . "</option>";
        for ($a = 0; $a < 24; $a++) {
            echo "<option value=" . $a . ">" . tt($a) . "</option>";
        }
        echo "</select>:<select name=testmin>";
        echo "<option value=" . $min . ">" . $min . "</option>";
        for ($a = 0; $a < 60; $a++) {
            echo "<option value=" . $a . ">" . tt($a) . "</option>";
        }
        echo "</select>";
        echo " <input type=submit value=\"Test\">";
        echo "</form><br>";
        // mktime(hr mi se mo do yr
        if (isset($_REQUEST['test_schedule'])) {
            $tx = mktime($_REQUEST['testhour'], $_REQUEST['testmin'], 0, $_REQUEST['testmonth'], $_REQUEST['testday'], $_REQUEST['testyear']);
            echo "Testing " . date("Y-m-d H:i", $tx) . "... ";
            $wouldrun = run_x_in_schedule($tx, $_REQUEST['scheduleid']);
            echo "<b>";
            if ($wouldrun) {
                echo "Yes - TESTS WOULD RUN";
            } else {
                echo "No - TESTS WOULD NOT RUN";
            }
            echo "</b><br>";
        }
    } else {
        echo "Error fetching schedule information";
    }
}
Screen_Footer();
Beispiel #2
0
 function AlertAction($nodeid, $alertlevel, $change, $alerttext)
 {
     //echo "Called for node: ".$nodeid."\n";
     if ($change == 0) {
         return false;
     }
     // no change
     if (trim($alerttext) == "") {
         return false;
     }
     // no text so a bogus event i.e. -1 to 0
     //echo $nodeid.":".$alertlevel.":".$change.":".$alerttext."\n";
     // get all the alertactions for this node id
     $q = "SELECT aaid FROM fnnalink WHERE nodeid=\"" . ss($nodeid) . "\"";
     $r = $this->DB->Query($q);
     while ($arow = $this->DB->Fetch_Array($r)) {
         // get details for this alert action
         $aq = "SELECT * FROM fnalertaction WHERE aaid=" . $arow['aaid'] . " LIMIT 0,1";
         $ar = $this->DB->Query($aq);
         $aa = $this->DB->Fetch_Array($ar);
         $this->DB->Free($ar);
         // UGGGGGGGG continue!!
         // if the type is blank or disabled skip
         if ($aa['atype'] == "" || $aa['atype'] == "Disabled") {
             continue;
         }
         // if warnings aren't set and it is a warning skip
         if ($aa['awarnings'] == 0 && $alertlevel == 1) {
             continue;
         }
         // if decreases aren't set and it is a decrease skip
         if ($aa['adecrease'] == 0 && $change < 1) {
             continue;
         }
         // if has a schedule and it dictates not to run now then skip
         if ($aa['scheduleid'] != 0 && !run_x_in_schedule(time(), $aa['scheduleid'])) {
             continue;
         }
         // made it this far
         $ndata = $nodeid . ": " . $alerttext;
         $this->ActionAddData($arow['aaid'], $ndata);
         /* // spun to ActionAddData
         		if ($aa['mdata']!="") $ndata=$aa['mdata']."\n".$nodeid.": ".$alerttext;
         		else $ndata=$nodeid.": ".$alerttext;
         		$uq="UPDATE fnalertaction SET mdata=\"".ss($ndata)."\" WHERE aaid=".$arow['aaid'];
         		//echo $uq."\n";
         		$this->DB->Query($uq);
         		*/
     }
 }
Beispiel #3
0
if ($nfilter != "") {
    $q .= " AND nodeid=\"" . ss($nfilter) . "\"";
}
$q .= " AND nextrunx<=" . time();
$r = $NATS->DB->Query($q);
while ($row = $NATS->DB->Fetch_Array($r)) {
    $dotests = true;
    $alertlevel = 0;
    $alerts = array();
    $alertc = 0;
    db("NodeID: " . $row['nodeid']);
    $NATS->Event("Tester " . $trid . " Node " . $row['nodeid'], 10, "Tester", "Node");
    // Scheduling Test In Here - sets dotests to false and alertlevel to -1 untested
    if ($row['scheduleid'] != 0) {
        db(" Has Schedule: Yes - Checking");
        $run = run_x_in_schedule(time(), $row['scheduleid']);
        if (!$run) {
            db(" In Schedule: No - Skipping Tests");
            $NATS->Event("Tester " . $trid . " Skipped by Schedule", 5, "Tester", "Node");
            $dotests = false;
            $alertlevel = -1;
        } else {
            db(" In Schedule: Yes");
        }
    }
    $eventdata = array("nodeid" => $row['nodeid'], "in_schedule" => $dotests);
    $NATS->EventHandler("node_test_start", $eventdata);
    $ptr = 0;
    $pal = 0;
    // Update lastrun and nextrun regardless of dotests
    $q = "UPDATE fnnode SET lastrunx=" . time() . ",nextrunx=" . next_run_x($row['testinterval']) . " WHERE nodeid=\"" . ss($row['nodeid']) . "\"";