Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Observium report page
<?php
function secondsToTime($seconds) {
$dtF = new DateTime("@0");
$dtT = new DateTime("@$seconds");
return $dtF->diff($dtT)->format('%a days, %h hours, %i minutes and %s seconds');
}
// HIGHEST UPTIMES
$query = "select * from devices
order by uptime desc
limit 15;"
?>
<h1>15 Highest network uptimes </h1>
<table class="table table-hover table-striped table-bordered table-condensed table-rounded" style="margin-top: 10px;">
<thead>
<tr>
<th></th>
<th></th>
<th>Uptime</th>
<th>Hostname</th>
<th>Location</th>
</tr>
</thead>
<tbody>
<?php
foreach (dbFetchRows($query) as $device)
{
humanize_device($device);
echo('<tr class="'.$device['html_row_class'].'"><td style="width: 1px; background-color: '.$device['html_tab_colour'].'; margin: 0px; padding: 0px"></td><td>'.getImage($device).'</td><td>'.secondsToTime($device["uptime"]).'</td><td>'.$device["hostname"].'</td><td>'.$device["location"].'</td></tr>');
}
?>
</tbody>
</table>
<?php
// MOST FREQUENT EVENTLOG MESSAGES THIS WEEK
$query = "select count(*) as count, d.*, e.message as message
from eventlog as e, devices as d
where timestamp >= DATE(NOW() - INTERVAL 7 DAY) and
e.device_id = d.device_id
group by hostname, message
order by count desc
limit 15;";
?>
<h1>15 Most frequent eventlog messages this week </h1>
<table class="table table-hover table-striped table-bordered table-condensed table-rounded" style="margin-top: 10px;">
<thead>
<tr>
<th></th>
<th></th>
<th>Count</th>
<th>Hostname</th>
<th>Message</th>
</tr>
</thead>
<tbody>
<?php
foreach (dbFetchRows($query) as $device)
{
humanize_device($device);
echo('<tr class="'.$device['html_row_class'].'"><td style="width: 1px; background-color: '.$device['html_tab_colour'].'; margin: 0px; padding: 0px"></td><td>'.getImage($device).'</td><td>'.$device["count"].'</td><td>'.$device["hostname"].'</td><td>'.$device["message"].'</td></tr>');
}
?>
</tbody>
</table>
<?php
// MOST FREQUENT SYSLOG MESSAGES THIS WEEK
$query = "select count(*) as count, d.*, s.msg as message
from syslog as s, devices as d
where timestamp >= DATE(NOW() - INTERVAL 7 DAY) and
s.device_id = d.device_id
group by hostname, message
order by count desc
limit 15;";
?>
<h1>15 Most frequent eventlog messages this week </h1>
<table class="table table-hover table-striped table-bordered table-condensed table-rounded" style="margin-top: 10px;">
<thead>
<tr>
<th></th>
<th></th>
<th>Count</th>
<th>Hostname</th>
<th>Message</th>
</tr>
</thead>
<tbody>
<?php
foreach (dbFetchRows($query) as $device)
{
humanize_device($device);
echo('<tr class="'.$device['html_row_class'].'"><td style="width: 1px; background-color: '.$device['html_tab_colour'].'; margin: 0px; padding: 0px"></td><td>'.getImage($device).'</td><td>'.$device["count"].'</td><td>'.$device["hostname"].'</td><td>'.$device["message"].'</td></tr>');
}
?>
</tbody>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.