function NodeSide_Process($nodeid, &$xmlobj) { // nodeid + takes a TNodeXML Object $alvl = 0; $this->Event("NodeSide_Process for " . $nodeid, 10, "Node", "Pull"); $q = "SELECT * FROM fnnstest WHERE nodeid=\"" . ss($nodeid) . "\""; $r = $this->DB->Query($q); $tests = array(); while ($row = $this->DB->Fetch_Array($r)) { $tests[$row['testtype']] = $row; if (isset($xmlobj->Catalogue[$row['testtype']])) { // this test is in the DB and catalogue $tests[$row['testtype']]['incat'] = true; if ($row['testenabled'] == 1) { if ($row['simpleeval'] == 1) { $level = $xmlobj->Catalogue[$row['testtype']]['ALERTLEVEL']; } else { $level = nats_eval("N" . $row['nstestid'], $xmlobj->Catalogue[$row['testtype']]['VALUE']); } $dbs = "Nodeside " . $row['testtype'] . " on " . $row['nodeid'] . " = " . $level; if ($level == 0) { $debuglev = 8; } else { if ($level > 0) { $debuglev = 5; } else { $debuglev = 2; } } $this->Event($dbs, $debuglev, "Node", "Process"); if ($level > $alvl) { $alvl = $level; } if ($row['testrecord'] == 1) { $testvalue = $xmlobj->Catalogue[$row['testtype']]['VALUE']; $testvalue = str_replace(",", ".", $testvalue); if (!is_numeric($testvalue)) { $testvalue = 0; } $iq = "INSERT INTO fnrecord(testid,alertlevel,recordx,nodeid,testvalue) VALUES("; $iq .= "\"N" . $row['nstestid'] . "\"," . $level . "," . time() . ",\"" . $row['nodeid'] . "\"," . $testvalue . ")"; $this->DB->Query($iq); if ($this->DB->Affected_Rows() <= 0) { $this->Event("Nodeside " . $row['testtype'] . " Failed to Record", 1, "Node", "Process"); } } // We don't do any alerting here - the tester will do that for us! $uq = "UPDATE fnnstest SET lastrunx=" . time() . ",lastvalue=\"" . ss($xmlobj->Catalogue[$row['testtype']]['VALUE']) . "\",alertlevel=" . $level . " "; $uq .= "WHERE nstestid=" . $row['nstestid']; $this->DB->Query($uq); if ($this->DB->Affected_Rows() <= 0) { $this->Event("Nodeside " . $row['testtype'] . " Failed to Update or Same Values", 5, "Node", "Process"); } } // check to see if the desc has changed if ($row['testdesc'] != $xmlobj->Catalogue[$row['testtype']]['DESC']) { $duq = "UPDATE fnnstest SET testdesc=\"" . ss($xmlobj->Catalogue[$row['testtype']]['DESC']) . "\" WHERE nstestid=" . $row['nstestid']; $this->DB->Query($duq); } } else { // test in the DB but NOT in the catalogue //$xmlobj->Catalogue[$row['testtype']]['incat']=false; if ($row['testenabled'] == 1) { // enabled so shown in lists etc // Update it to show failed status $this->Event("No nodeside data for test N" . $row['nstestid'], 3, "Node", "Process"); $uq = "UPDATE fnnstest SET alertlevel=2,lastvalue=-1 WHERE nstestid=" . $row['nstestid']; $this->DB->Query($uq); $alvl = 2; if ($row['testrecord'] == 1) { $testvalue = -1; $iq = "INSERT INTO fnrecord(testid,alertlevel,recordx,nodeid,testvalue) VALUES("; $iq .= "\"N" . $row['nstestid'] . "\",2," . time() . ",\"" . $row['nodeid'] . "\"," . $testvalue . ")"; $this->DB->Query($iq); if ($this->DB->Affected_Rows() <= 0) { $this->Event("Nodeside " . $row['testtype'] . " Failed to Record", 1, "Node", "Process"); } } } else { $this->DeleteTest("N" . $row['nstestid']); } } } $this->DB->Free($r); // and finally we look for new tests i.e. in the cat but not in the DB foreach ($xmlobj->Catalogue as $val) { $key = $val['NAME']; if (!isset($tests[$key])) { $q = "INSERT INTO fnnstest(nodeid,testtype,testdesc,lastvalue,lastrunx,alertlevel) "; $q .= "VALUES(\"" . ss($nodeid) . "\",\"" . $key . "\",\"" . ss($val['DESC']) . "\",\"" . ss($val['VALUE']) . "\"," . time() . "," . ss($val['ALERTLEVEL']) . ")"; //echo $q."<br>"; $this->DB->Query($q); } } $eventdata = array("nodeid" => $nodeid, "alertlevel" => $alvl); $this->EventHandler("nodeside_process", $eventdata); }
$lvl = nats_eval("L" . $lrow['localtestid'], $result); } db(" Eval: " . $lvl); // put in the custom retries based on attempts here - we KNOW dotests is on so don't need to worry about untested status $att = $lrow['attempts']; if ($lvl != 0 && is_numeric($att) && $att > 1) { for ($a = 2; $a <= $att; $a++) { test_sleep(); db(" Test: " . $lrow['testtype'] . " (" . $lrow['testparam'] . ") X" . $a); $NATS->Event("Tester " . $trid . " Node " . $row['nodeid'] . " X" . $a . " Doing " . $lrow['testtype'] . "(" . $lrow['testparam'] . ")", 10, "Tester", "Test"); $result = DoTest($lrow['testtype'], $lrow['testparam'], $row['hostname'], $lrow['timeout'], $params, $row['nodeid']); db(" Result: " . $result); if ($lrow['simpleeval'] == 1) { $lvl = SimpleEval($lrow['testtype'], $result); } else { $lvl = nats_eval("L" . $lrow['localtestid'], $result); } db(" Eval: " . $lvl); if ($lvl == 0) { $a = $att + 1; } // test passed } } // $lvl is now the last lvl regardless of where it came from if ($lvl > $alertlevel) { $alertlevel = $lvl; } if ($lvl > 0) { if ($lrow['testname'] == "") { $s = $lrow['testtype'] . "/" . substr($lrow['testparam'], 0, 5) . " ";