HHF Website Monitor
$class) { if(substr($incident_filename, 0, 5) == 'post_') $incident_filename = substr($incident_filename, 5); $Parsedown = new Parsedown(); echo '';
echo $Parsedown->text(file_get_contents(PATH.'/incidents/'.$incident_filename));
echo '
';
}
$monitors = json_decode(file_get_contents(PATH.'/monitors.json'));
$i = 0;
foreach($monitors as $monitor => $url) {
$log = json_decode(file_get_contents(PATH.'/monitors/'.$monitor), TRUE);
$last = $log[array_key_last($log)];
if(is_numeric($last['response'])) {
$last = ' HTTP/1.1 '.$last['response'].'';
$class = 'good';
$graph_color = '#51cf66';
}
else {
$last = ' HTTP/1.1 '.$last['response'].'';
$class = 'bad';
$graph_color = '#fa5252';
}
echo '⬤ '.$monitor.$last.'
'; if(file_exists(PATH.'/updates/'.$monitor.'.md')) { $Parsedown = new Parsedown(); echo $Parsedown->text(file_get_contents(PATH.'/updates/'.$monitor.'.md')); } $labels = array(); $data = array(); $const = 'ctx'.$i; $const_chart = $const.'_'.$const; echo '';
// do we need bloop padding?
if(count($log) < 60) {
$diff = 59 - count($log);
for ($x = 0; $x <= $diff; $x++) {
echo '';
}
}
foreach($log as $arr) {
$labels[] = "'".date("H:i", $arr['timestamp'])."'";
$data[] = @$arr['time'];
if(@$arr['time'] > 0) {
echo '';
}
else {
echo '';
}
}
$min = min($data);
$max = max($data);
$diff = $max - $min;
$max += ($diff / 3);
$min -= ($diff / 3);
if($min < 0) $min = 0;
echo '
';
$chart_id = str_replace('.', '-', $monitor);
$labels = implode(', ', $labels);
$data = implode(', ', $data);
$out = <<