Files
librenms-librenms/includes/html/pages/device/graphs/availability.inc.php
Tony Murray c1258320f8 Availability module fixes (#15369)
* Refactor poller to allow modules to run even if the device is down
Include core in config (but not webui) to avoid silly shenanigans
Inject datastore into polling

* Needed to split datastore interface

* Cleanup some data_udpate() references

* Apply fixes from StyleCI

* Fix legacy poller :D

* Output to the correct stream

* Fix lint issues

* Apply fixes from StyleCI

* Fix discovery not including core and submodule handling

* Use whereRaw

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
2023-10-04 10:32:59 -05:00

28 lines
1013 B
PHP

<?php
$graph_type = 'availability';
$deviceModel = DeviceCache::getPrimary();
foreach ($deviceModel->availability as $index => $duration) {
if (is_integer($index / 2)) {
$row_colour = \LibreNMS\Config::get('list_colour.even');
} else {
$row_colour = \LibreNMS\Config::get('list_colour.odd');
}
$graph_array['device'] = $duration->device_id;
$graph_array['type'] = 'device_' . $graph_type;
$graph_array['duration'] = $duration->duration;
$human_duration = \LibreNMS\Util\Time::formatInterval($duration->duration, parts: 1);
$graph_title = $deviceModel->displayName() . ' - ' . $human_duration;
echo "<div class='panel panel-default'>
<div class='panel-heading'>
<h3 class='panel-title'>" . $human_duration . "<div class='pull-right'>" . round($duration->availability_perc, 3) . '%</div></h3>
</div>';
echo "<div class='panel-body'>";
include 'includes/html/print-graphrow.inc.php';
echo '</div></div>';
}