if ($server['check'] == true) { // users may only see their own probes if ($_SESSION['user']->isUser()) { if ($_SESSION['user']->ownsProbe($server['id'])) { print "<tr>"; $sTest->setTitle($server['name']); $sTest->setServer($server['url']); $sTest->setFindstring($server['findstring']); $sTest->setVersion($version); $sTest->setHostname($hostname); try { $sTest->test(); if ($sTest->getStatus() == true) { $message = "<img src=\"img/good.png\" alt=\"ok\"/></td><td>" . $sTest->getBenchmark()->timeElapsed(); } else { $message = "<img src=\"img/bad.png\" alt=\"failed\"/></td><td>" . $sTest->getBenchmark()->timeElapsed() . "</td><td>" . htmlspecialchars(substr($sTest->getResult(), 0, $maxreplychars)); } print "<td><strong>" . $sTest->getTitle() . "</strong></td><td>" . $message . "</td>\n"; } catch (Exception $ex) { print "<td><strong><span class=\"badnews\">" . $sTest->getTitle() . ": " . $ex->getMessage() . "</span></strong></td>"; } print "</tr>"; } } else { print "<tr>"; $sTest->setTitle($server['name']); $sTest->setServer($server['url']); $sTest->setFindstring($server['findstring']); $sTest->setVersion($version); $sTest->setHostname($hostname); try {
if ($sTest->getStatus() == false) { $random = rand(1, 15); print " ... trying again in " . $random . " seconds to ensure we really have a problem\n"; sleep($random); $sTest->test(); } } catch (Exception $ex) { print "Exception occured for probe '" . $sTest->getTitle() . "': " . $ex->getMessage() . "\n"; } if ($sTest->getStatus() == false) { print " ... failed\n"; // send mail only if status in DB was true -> mail will only be sent once $status = $db->getProbeStatus($server['id']); if ($status == true) { // insert entry into events table $db->addProbeEvent('error', $sTest->getResult(), $server['id']); // mail it $text = "Service: " . $server['name'] . "\nURL: " . $server['url'] . "\nString: " . $server['findstring'] . "\nState: ERROR\n\nDate/Time: " . date($timeformat) . "\n\nAdditional Info: \n\n" . $sTest->getResult(); $status = $db->setProbeStatus($server['id'], 0); // print ("Error: Servertest for probe '" . $sTest->getTitle() ."' failed!\n"); $responsible = $db->getAllResponsible($server['id']); if (isset($responsible)) { foreach ($responsible as $recipient) { // mail it if (strtotime($startquietmode) <= time() && time() <= strtotime($endquietmode)) { echo "not sending mail because of quiet mode\n"; } else { echo "sending mail\n"; $mailer = new sendMail($recipient['email'], $mailfrom, $replyto); $mailer->send("PROBLEM: " . $sTest->getTitle() . " is CRITICAL", $text); }