function email_plugin_notify_master($check, $check_result, $subscription, $alt_email = false) { global $status_array; $user = new User($subscription->getUserId()); $email = new fEmail(); // This sets up fSMTP to connect to the gmail SMTP server // with a 5 second timeout. Gmail requires a secure connection. $smtp = new fSMTP(sys_var('smtp_server'), sys_var('smtp_port'), sys_var('require_ssl') === 'true' ? TRUE : FALSE, 5); if (sys_var('require_auth') === 'true') { $smtp->authenticate(sys_var('smtp_user'), sys_var('smtp_pass')); } if ($alt_email) { $email_address = usr_var('alt_email', $user->getUserId()); } else { $email_address = $user->getEmail(); } $email->addRecipient($email_address, $user->getUsername()); // Set who the email is from $email->setFromEmail(sys_var('email_from'), sys_var('email_from_display')); $state = $status_array[$check_result->getStatus()]; // Set the subject include UTF-8 curly quotes if ($state == 'OK') { $email->setSubject(str_replace('{check_name}', $check->prepareName(), sys_var('email_end_alert_subject'))); } else { $email->setSubject(str_replace('{check_name}', $check->prepareName(), sys_var('email_subject'))); } // Set the body to include a string containing UTF-8 $check_type = ''; if ($check->getType() == 'threshold') { $check_type = ' Threshold'; } elseif ($check->getType() == 'predictive') { $check_type = ' Standard Deviation'; } $state_email_injection = $state . " Alert "; if ($state == 'OK') { $state_email_injection = "Everything's back to normal "; } // Remind : ('0' => 'OK', '1' => 'Error', '2' => 'Warning'); $state_int = $check_result->getStatus(); if ($state_int == 0) { $color = "green"; } else { if ($state_int == 2) { $color = "orange"; } else { $color = "red"; } } $html_body = "<p style='color:" . $color . ";'>" . $state_email_injection . "for {$check->prepareName()} </p>" . "<p>The check returned {$check_result->getValue()}</p>" . "<p>Warning" . $check_type . " is : " . $check->getWarn() . "</p>" . "<p>Error" . $check_type . " is : " . $check->getError() . "</p>" . "<p>View Alert Details : <a href='" . $GLOBALS['TATTLE_DOMAIN'] . '/' . CheckResult::makeURL('list', $check_result) . "'>" . $check->prepareName() . "</a></p>"; $email->setHTMLBody($html_body); $email->setBody("\n {$state} Alert for {$check->prepareName()}\nThe check returned {$check_result->getValue()}\nWarning" . $check_type . " is : " . $check->getWarn() . "\nError" . $check_type . " is : " . $check->getError() . "\n "); try { $message_id = $email->send($smtp); } catch (fConnectivityException $e) { fCore::debug($e, FALSE); fCore::debug("email send failed", FALSE); $e->printMessage(); $e->printTrace(); } }
function email_plugin_notify($check,$check_result,$subscription,$alt_email=false) { global $status_array; $user = new User($subscription->getUserId()); $email = new fEmail(); // This sets up fSMTP to connect to the gmail SMTP server // with a 5 second timeout. Gmail requires a secure connection. $smtp = new fSMTP(sys_var('smtp_server'), sys_var('smtp_port'), TRUE, 5); $smtp->authenticate(sys_var('smtp_user'), sys_var('smtp_pass')); if ($alt_email) { $email_address = usr_var('alt_email',$user->getUserId()); } else { $email_address = $user->getEmail(); } $email->addRecipient($email_address, $user->getUsername()); // Set who the email is from $email->setFromEmail(sys_var('email_from'), sys_var('email_from_display')); // Set the subject include UTF-8 curly quotes $email->setSubject(str_replace('{check_name}', $check->prepareName(), sys_var('email_subject'))); // Set the body to include a string containing UTF-8 $state = $status_array[$check_result->getStatus()]; $email->setHTMLBody("<p>$state Alert for {$check->prepareName()} </p><p>The check returned {$check_result->prepareValue()}</p><p>Warning Threshold is : ". $check->getWarn() . "</p><p>Error Threshold is : ". $check->getError() . '</p><p>View Alert Details : <a href="' . fURL::getDomain() . '/' . CheckResult::makeURL('list',$check_result) . '">'.$check->prepareName()."</a></p>"); $email->setBody(" $state Alert for {$check->prepareName()} The check returned {$check_result->prepareValue()} Warning Threshold is : ". $check->getWarn() . " Error Threshold is : ". $check->getError() . " "); try { $message_id = $email->send($smtp); } catch ( fConnectivityException $e) { fCore::debug("email send failed",FALSE); } }
function email_notify($check,$check_result,$subscription) { global $status_array; $user = new User($subscription->getUserId()); echo 'email plugin!'; $email = new fEmail(); // This sets up fSMTP to connect to the gmail SMTP server // with a 5 second timeout. Gmail requires a secure connection. $smtp = new fSMTP('smtp.gmail.com', 465, TRUE, 5); $smtp->authenticate('*****@*****.**', 'example'); $email->addRecipient($user->getEmail(), $user->getUsername()); // Set who the email is from $email->setFromEmail('*****@*****.**','Tattle'); // Set the subject include UTF-8 curly quotes $email->setSubject('Tattle : Alert for ' . $check->prepareName()); // Set the body to include a string containing UTF-8 $state = $status_array[$check_result->getStatus()]; $email->setHTMLBody("<p>$state Alert for {$check->prepareName()} </p><p>The check returned {$check_result->prepareValue()}</p><p>Warning Threshold is : ". $check->getWarn() . "</p><p>Error Threshold is : ". $check->getError() . '</p><p>View Alert Details : <a href="' . $fURL::getDomain() . '/' . CheckResult::makeURL('list',$check_result) . '">'.$check->prepareName()."</a></p>"); $email->setBody(" $state Alert for {$check->prepareName()} The check returned {$check_result->prepareValue()} Warning Threshold is : ". $check->getWarn() . " Error Threshold is : ". $check->getError() . " "); try { $message_id = $email->send($smtp); } catch ( fConnectivityException $e) { fCore::debug("email send failed",FALSE); } }
/** * Execute the console command. * * @return mixed */ public function fire() { $checks = Check::where('paused', '=', 0)->get(); foreach ($checks as $check) { $hasChecked = CheckResult::where('check_id', '=', $check->id)->where('created_at', '>', date('Y-m-d H:i:s', time() - $check->interval * 60))->count(); if ($hasChecked == 0) { Queue::push('CheckWebsite', $check->id); } } }
static public function acknowledgeCheck($check=NULL,$result=NULL,$ackAll=false) { if (!is_null($check)) { if ($ackAll === true) { $check_results = CheckResult::findAll($check->getCheckId()); } elseif (!is_null($result)) { $check_results = CheckResult::build($result->getResultId()); } foreach ($check_results as $check_result) { $check_result->setAcknowledged(1); $check_result->store(); } } }
function pushover_plugin_notify($check, $check_result, $subscription) { $user = new User($subscription->getUserId()); global $status_array; $check_status = $status_array[$check_result->getStatus()]; $check_name = $check->prepareName(); $check_value = $check_result->prepareValue(); $check_warning_level = $check->getWarn(); $check_error_level = $check->getError(); $check_type = $check->getType(); $title = "{$check_status} for {$check_name}"; $message = "Check returned: {$check_value}\n" . "Warning {$check_type} is: {$check_warning_level}\n" . "Error {$check_type} is: {$check_error_level}"; $data = array('token' => sys_var('pushover_plugin_application_token'), 'user' => usr_var('pushover_plugin_user_key', $user->getUserId()), 'message' => $message, 'title' => $title, 'url' => $GLOBALS['TATTLE_DOMAIN'] . '/' . CheckResult::makeURL('list', $check_result)); $options = array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data))); $result = file_get_contents("https://api.pushover.net/1/messages.json", false, stream_context_create($options)); }
public function fire(Illuminate\Queue\Jobs\Job $job, $data) { $check = Check::findOrFail($data); $headers = array(); $options = array(); if (!empty($check->username)) { $options['auth'] = array($check->username, $check->password); } try { $latencyStart = microtime(true); $response = Requests::get($check->url, $headers, $options); $latency = round((microtime(true) - $latencyStart) * 1000); } catch (Requests_Exception $e) { $latency = round((microtime(true) - $latencyStart) * 1000); if (CheckResult::create(array('check_id' => $check->id, 'status_code' => 0, 'success' => false, 'latency' => $latency, 'content' => trans('check.errors.resolve-host', array('host' => $check->url))))) { $job->delete(); } else { $job->release(); } return true; } $lastCheck = CheckResult::where('check_id', '=', $check->id)->orderBy('created_at', 'desc')->first(); if ($response->success) { if (isset($lastCheck) && !$lastCheck->success) { Mail::queue('email.check.online', array('id' => $check->id, 'title' => $check->title), function ($message) use($check) { $message->to($check->theUser->email)->subject(trans('check.job.email.online.subject', array('title' => $check->title))); }); } if (CheckResult::create(array('check_id' => $check->id, 'status_code' => $response->status_code, 'success' => true, 'latency' => $latency))) { $job->delete(); } else { $job->release(); } } else { if (isset($lastCheck) && $lastCheck->success) { Mail::queue('email.check.offline', array('id' => $check->id, 'title' => $check->title, 'statusCode' => $response->status_code), function ($message) use($check) { $message->to($check->theUser->email)->subject(trans('check.job.email.offline.subject', array('title' => $check->title))); }); } if (CheckResult::create(array('check_id' => $check->id, 'status_code' => $response->status_code, 'success' => false, 'content' => $response->body, 'headers' => json_encode($response->headers), 'latency' => $latency))) { $job->delete(); } else { $job->release(); } } }
function hipchat_master_notify($check, $check_result, $subscription, $toUser = true) { global $status_array; global $debug; if (!is_callable('curl_init')) { fCore::debug("!!! WARNING !!! function curl_init() not found, probably php-curl is not installed"); } $state = $status_array[$check_result->getStatus()]; if (strtolower($state) == 'ok') { $color = sys_var('hipchat_ok_color'); } elseif (strtolower($state) == 'warning') { $color = sys_var('hipchat_warning_color'); } elseif (strtolower($state) == 'error') { $color = sys_var('hipchat_error_color'); } $url = $GLOBALS['TATTLE_DOMAIN'] . '/' . CheckResult::makeURL('list', $check_result); $data = array('color' => $color, 'notify' => sys_var('hipchat_notify') == 'true' ? true : false, 'message_format' => 'html', 'message' => "<b>" . $check->prepareName() . "</b><br />The check returned: {$check_result->getValue()}<br />View Alert Details : <a href=\"" . $url . "\">" . $url . "</a>"); if ($debug && $toUser == false) { $url = 'https://api.hipchat.com/v2/room?auth_token=' . sys_var('hipchat_apikey'); $c = curl_init(); curl_setopt($c, CURLOPT_URL, $url); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); fCore::debug("Rooms: " . curl_exec($c) . "\n", FALSE); fCore::debug("URL: " . 'https://api.hipchat.com/v2/room/' . strtolower(sys_var('hipchat_room')) . '/notification?auth_token=' . sys_var('hipchat_apikey') . "\n", FALSE); fCore::debug("Data: " . print_r($data, true) . "\n", FALSE); } if ($toUser == false) { $url = 'https://api.hipchat.com/v2/room/' . strtolower(sys_var('hipchat_room')) . '/notification?auth_token=' . sys_var('hipchat_apikey'); } else { $url = 'https://api.hipchat.com/v2/user/' . usr_var('hipchat_user', $subscription->getUserId()) . '/message?auth_token=' . sys_var('hipchat_apikey'); } fCore::debug("HipChat Calling: {$url}", FALSE); $c = curl_init(); curl_setopt($c, CURLOPT_URL, $url); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_setopt($c, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen(json_encode($data)))); curl_setopt($c, CURLOPT_POSTFIELDS, json_encode($data)); $response = curl_exec($c); if ($response === false) { fCore::debug("Curl error: " . curl_error($c) . "\n", FALSE); } echo "\n\nResponse: " . curl_getinfo($c, CURLINFO_HTTP_CODE) . ' - ' . $response . "\n\n"; }
/** * Run the user seeds. * * @return void */ public function run() { DB::table('checks')->delete(); $check = Check::create(array('url' => 'http://www.example.com', 'user_id' => 1, 'company_id' => 1, 'port' => 80, 'interval' => 5)); $start = \Carbon\Carbon::now()->subDays(3); $now = \Carbon\Carbon::now(); while ($start->diffInSeconds($now, false) > 0) { $success = rand(0, 100) != 0; CheckResult::create(array('check_id' => $check->id, 'status_code' => $success ? 200 : 500, 'latency' => $success ? rand(100, 4000) : rand(10000, 60000), 'success' => $success, 'created_at' => $start)); $start->addMinutes(5); } $check = Check::create(array('url' => 'http://www.example.org', 'user_id' => 2, 'company_id' => 2, 'port' => 8080, 'interval' => 15)); $start = \Carbon\Carbon::now()->subDays(1); $now = \Carbon\Carbon::now(); while ($start->diffInSeconds($now, false) > 0) { $success = rand(0, 100) != 0; CheckResult::create(array('check_id' => $check->id, 'status_code' => $success ? 200 : 500, 'latency' => $success ? rand(100, 4000) : rand(10000, 60000), 'success' => $success, 'created_at' => $start)); $start->addMinutes(15); } }
<th><?=fCRUD::printSortableColumn('name','Name'); ?></th> <th><?=fCRUD::printSortableColumn('target','Target'); ?></th> <th><?=fCRUD::printSortableColumn('warn','Warn'); ?></th> <th><?=fCRUD::printSortableColumn('error','Error'); ?></th> <th><?=fCRUD::printSortableColumn('sample','Sample'); ?></th> <th><?=fCRUD::printSortableColumn('baseline','Baseline'); ?></th> <th><?=fCRUD::printSortableColumn('over_under','Over/Under'); ?></th> <th><?=fCRUD::printSortableColumn('visiblity','Visibility'); ?></th> <th>Action</th> </tr></thead><tbody> <?php $first = TRUE; foreach ($checks as $check) { ?> <tr> <td><?='<a href="' . CheckResult::makeUrl('list',$check) . '">' . $check->prepareName(); ?></a></td> <td><?=$check->prepareTarget(); ?></td> <td><?=$check->prepareWarn(); ?></td> <td><?=$check->prepareError(); ?></td> <td><?=$check->prepareSample(); ?></td> <td><?=$check->prepareBaseline(); ?></td> <td><?=$over_under_array[$check->getOver_Under()]; ?></td> <td><?=$visibility_array[$check->getVisibility()]; ?></td> <td><?php if (fSession::get('user_id') == $check->getUserId()) { echo '<a href="' . Check::makeURL('edit', $check) . '">Edit</a> |'; } ?> <a href="<?=Subscription::makeURL('add', $check); ?>">Subscribe</a></td> </tr> <?php } ?> </tbody></table> <?
private function statusCount($success, $hours) { return CheckResult::where('check_id', '=', $this->id)->where('success', '=', $success)->where('created_at', '>=', DB::raw(sprintf('DATE_SUB(NOW(), INTERVAL %s HOUR)', $hours)))->count(); }
</div> </div> </fieldset> <fieldset> <div class="form-group actions"> <div class="controls"> <input class="btn btn-primary" type="submit" value="Save" /> <?php if ($action == 'edit') { ?> <a href="<?php echo Check::makeURL('delete', $check_type, $check); ?> " class="btn btn-default" >Delete</a> <a href="<?php echo CheckResult::makeURL("list", $check); ?> " class="btn btn-default">View</a> <a href="<?php echo Subscription::makeURL('add', $check); ?> " class="btn btn-default">Subscribe</a> <?php } ?> <div class="required"><em>*</em> Required field</div> <input type="hidden" name="token" value="<?php echo fRequest::generateCSRFToken(); ?> " /> <?php
protected function writeOutputWeb(CheckResult $res, $severity) { $str = "<div>{$res->check->name}: "; if ($res->success()) { $str .= "<span style=\"color: #00FF00\">PASSED</span>"; } else { if ($severity === self::RES_FAILED) { $str .= "<span style=\"color: #FF0000\">FAILURE: </span>{$res->message}"; } else { $str .= "<span style=\"color: #FFFF00\">WARNING: </span>{$res->message}"; } } echo "{$str}</div>"; }
$next_check = new fTimestamp(); fCore::debug("is null?\n", FALSE); } else { $next_check = $check->getLastCheckTime()->adjust('+' . $check->getRepeatDelay() . ' minutes'); } $end = new fTimestamp(); if ($next_check->lt($end)) { fCore::debug("next check is lt then now\n", FALSE); } else { fCore::debug("not less then now\n", FALSE); } // If It's been more then the Repeat Delay or the Status has changed if ($next_check->lt($end) || $check->getLastCheckStatus() != $result) { fCore::debug("Send Notification \n", FALSE); fCore::debug("State :" . $result . ":\n", FALSE); $check_result = new CheckResult(); $check_result->setCheckId($check->getCheckId()); $check_result->setStatus($result); $check_result->setValue($check_value); $check_result->setState(0); $check->setLastCheckStatus($result); $check->setLastCheckValue($check_value); $check->setLastCheckTime($end); $check_result->store(); $check->store(); $subscriptions = Subscription::findAll($check->getCheckId()); foreach ($subscriptions as $subscription) { $notify_function = $subscription->getMethod() . '_notify'; if (function_exists($notify_function)) { $notify_result = $notify_function($check, $check_result, $subscription); }
foreach ($subscriptions as $sub) { $user_id = $sub['user_id']; if (!in_array($user_id, $alt_ids) && $user_id != $id_user_session) { $user = new User($sub['user_id']); $recipients[] = array("mail" => $user->getEmail(), "name" => $user->getUsername()); } } if (!empty($recipients)) { // Send the mail to everybody notify_multiple_users($user_session, $recipients, $subject_mail, $content_mail); fMessaging::create('success', fURL::get(), 'The mail "' . $subject_mail . '" was successfully sent to all the users who subscribe to "' . $check->getName() . '"'); } else { fMessaging::create('error', fURL::get(), "Nobody subscribe to this check"); } } } } catch (fNotFoundException $e) { fMessaging::create('error', $manage_url, 'The check requested, ' . fHTML::encode($check_id) . ', could not be found'); fURL::redirect($manage_url); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } $page_num = fRequest::get('page', 'int', 1); $url_redirect = CheckResult::makeURL('list', $check) . "&page=" . $page_num; fURL::redirect($url_redirect); } else { $page_num = fRequest::get('page', 'int', 1); $check_results = CheckResult::findAll($check_id, false, $GLOBALS['PAGE_SIZE'], $page_num); include VIEW_PATH . '/list_check_results.php'; } }
</div> <a class="btn btn-default" href="<?php echo Check::makeURL('edit', $check->getType(), $check); ?> ">Edit check</a> <a href="<?php echo Subscription::makeURL('add', $check); ?> " class="btn btn-default">Subscribe</a> <?php try { $check_results->tossIfEmpty(); $affectd = fMessaging::retrieve('affected', fURL::get()); ?> <a class="btn small btn-primary" href="<?php echo CheckResult::makeURL('ackAll', $check = new Check($check_id)); ?> ">Clear All</a> <table class="table table-bordered table-striped"> <tr> <th>Status</th> <th>Value</th> <th>Error</th> <th>Warn</th> <th>State</th> <th>Time</th> </tr> <?php $first = TRUE; foreach ($check_results as $check_result) { $check = new Check($check_result->getCheck_Id());
function check_awl_version() { global $c; if (!function_exists('awl_version')) { return new CheckResult(false); } $result = new CheckResult($c->want_awl_version == awl_version()); if (!$result->getOK()) { $result->setDescription(sprintf(i18n('Want: %s, Currently: %s'), $c->want_awl_version, awl_version())); if ($c->want_awl_version < awl_version()) { $result->setClass('dep_warning'); } } return $result; }
<thead> <tr> <th>Check</th> <th>Latest Status</th> <th>Alert Count</th> <th>Action</th> </tr></thead><tbody> <?php $first = TRUE; foreach ($results as $row) { $check = new Check($row['check_id']); ?> <tr> <td><?php echo $row['name'] ?></td> <td><?php echo ($row['status'] == 2 ? 'Warning' : 'Error'); ?></td> <td><?php echo $row['count'] ?></td> <td><a href="<?php echo CheckResult::makeURL('list', $check) ?>">View</a> </td> </tr> <?php } ?> </tbody></table></span> <? } catch (fNoRowsException $e) { ?> <p class="info">There are currently no Alerts based on your subscriptions. Smile, looks like everything is happy!</p> <?php } ?> </div> <?php $tmpl->place('footer') ?>
?> </th> <th class="masterTooltip" title="Public checks can be subscribed to by any user while private checks remain hidden from other users"><?php echo fCRUD::printSortableColumn('visiblity', 'Visibility'); ?> </th> <th>Action</th> </tr></thead> <tbody> <?php $first = TRUE; foreach ($checks as $check) { ?> <tr> <td><?php echo '<a href="' . CheckResult::makeUrl('list', $check) . '">' . $check->prepareName(); ?> </a></td> <td style="max-width:300px; overflow:scroll;"><?php echo $check->prepareTarget(); ?> </td> <td><?php echo $check->prepareWarn(); ?> </td> <td><?php echo $check->prepareError(); ?> </td> <td><?php
<span id="warn_threshold"><?php echo $check->prepareWarn();?></span> <span id="check_id"><?php echo $check->prepareCheckId();?></span> </div> </div> </div> <!--<span><?php echo Check::showGraph($check); ?></span> <span><?php echo Check::showGraph($check,true,'-24Hours',320,true); ?></span> --> </fieldset> <?php try { $check_results->tossIfEmpty(); $affectd = fMessaging::retrieve('affected',fURL::get()); ?> <a class="btn small primary" href="<?php echo CheckResult::makeURL('ackAll', $check = new Check($check_id)) ?>">Clear All</a> <table class="zebra-striped"> <tr> <th>Status</th> <th>Value</th> <th>Error</th> <th>Warn</th> <th>State</th> <th>Time</th> </tr> <?php $first = TRUE; foreach ($check_results as $check_result) { $check = new Check($check_result->getCheck_Id()); ?> <tr>
?> <tr> <td><?php echo $row['name']; ?> </td> <td><?php echo $status_array[$row['status']]; ?> </td> <td><?php echo $row['count']; ?> </td> <td><a href="<?php echo CheckResult::makeURL('list', $check); ?> ">View</a> </td> </tr> <?php } ?> </tbody></table></span> <?php } catch (fNoRowsException $e) { ?> <p class="info">There are currently no Alerts based on your subscriptions. Smile, looks like everything is happy!</p> <?php } ?>
<th>Latest Status</th> <th>Last Alert</th> <th>Alert Count</th> <th>Action</th> </tr></thead><tbody> <?php $first = TRUE; foreach ($results as $row) { $check = new Check($row['check_id']); ?> <tr> <td><?=$row['name']; ?></td> <td><?=($row['status'] == 2 ? 'Warning' : 'Error'); ?></td> <td><?=$row['timestamp']; ?></td> <td><?=$row['count']; ?></td> <td><a href="<?=CheckResult::makeURL('list', $check); ?>">View</a> | <a href="<?=CheckResult::makeURL('ackAll', $check); ?>">Clear</a> </td> </tr> <?php } //check to see if paging is needed $total_pages = ceil($alert_count / $GLOBALS['PAGE_SIZE']); if ($total_pages > 1) { $prev_class = 'previous'; $prev_link = fURL::get() . '?page=' . ($page_num - 1); $next_class = 'next'; $next_link = fURL::get() . '?page=' . ($page_num + 1); if ($page_num == 1) { $prev_class .= ' disabled'; $prev_link = '#'; } elseif ($page_num == $total_pages) { $next_class .= ' disabled';
echo $status_array[$row['status']]; ?> </td> <td><?php echo $row['timestamp']; ?> </td> <td><?php echo $row['count']; ?> </td> <td><a href="<?php echo CheckResult::makeURL('list', $check); ?> ">View</a> | <a href="<?php echo CheckResult::makeURL('ackAll', $check); ?> ">Clear</a> </td> </tr> <?php } //if paging is needed if ($total_pages > 1) { ?> </tbody></table> <div class="pagination"> <ul class="pager"> <li class="<?php echo $prev_class; ?>
<?php include '../inc/init.php'; fAuthorization::requireLoggedIn(); header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Content-type: application/json'); $check_id = fRequest::get('check_id', 'integer'); $page_id = fRequest::get('page_id', 'integer'); /*------------------------------------*/ $check_results = CheckResult::findAll($check_id); $check_results_json = array(); foreach ($check_results as $check_result) { $check = new Check($check_result->getCheck_Id()); $timestamp = $check_result->getTimestamp(); $check_results_json[] = array('what' => $status_array[$check_result->getStatus()] . ' : ' . $check_result->prepareValue(), 'data' => $check_result->prepareValue(), 'when' => strtotime($timestamp->__toString()), 'id' => $check_result->getResultId(), 'tags' => 'alerts'); } $encoded_content = json_encode($check_results_json); print $encoded_content;