Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

90 lines
3.4 KiB
PHP
Raw Permalink Normal View History

2010-02-24 14:34:24 +00:00
<?php
2021-03-28 17:25:30 -05:00
use LibreNMS\Util\Number;
$graph_type = 'storage_usage';
2011-05-16 12:48:50 +00:00
$drives = dbFetchRows('SELECT * FROM `storage` WHERE device_id = ? ORDER BY `storage_descr` ASC', [$device['device_id']]);
if (count($drives)) {
2018-11-29 19:23:40 -06:00
echo '
2014-02-26 22:33:45 +00:00
<div class="row">
<div class="col-md-12">
<div class="panel panel-default panel-condensed">
<div class="panel-heading">';
echo '<a href="device/device=' . $device['device_id'] . '/tab=health/metric=storage/">';
echo '<i class="fa fa-database fa-lg icon-theme" aria-hidden="true"></i> <strong>Storage</strong></a>';
2014-02-26 22:33:45 +00:00
echo ' </div>
<table class="table table-hover table-condensed table-striped">';
2015-07-13 20:10:26 +02:00
2011-05-16 12:48:50 +00:00
foreach ($drives as $drive) {
2010-02-24 14:34:24 +00:00
$skipdrive = 0;
2015-07-13 20:10:26 +02:00
2011-03-16 23:10:10 +00:00
if ($device['os'] == 'junos') {
2022-08-25 10:03:06 +02:00
foreach (\LibreNMS\Config::get('ignore_junos_os_drives', []) as $jdrive) {
2011-03-16 23:10:10 +00:00
if (preg_match($jdrive, $drive['storage_descr'])) {
$skipdrive = 1;
2015-07-13 20:10:26 +02:00
}
}
2011-03-16 23:10:10 +00:00
$drive['storage_descr'] = preg_replace('/.*mounted on: (.*)/', '\\1', $drive['storage_descr']);
2010-02-24 14:34:24 +00:00
}
2015-07-13 20:10:26 +02:00
2011-03-16 23:10:10 +00:00
if ($device['os'] == 'freebsd') {
2022-08-25 10:03:06 +02:00
foreach (\LibreNMS\Config::get('ignore_bsd_os_drives', []) as $jdrive) {
2011-03-16 23:10:10 +00:00
if (preg_match($jdrive, $drive['storage_descr'])) {
$skipdrive = 1;
2015-07-13 20:10:26 +02:00
}
}
}
2010-02-24 14:34:24 +00:00
if ($skipdrive) {
continue;
2010-02-26 13:07:30 +00:00
}
2015-07-13 20:10:26 +02:00
2021-03-28 17:25:30 -05:00
$percent = round($drive['storage_perc']);
$total = Number::formatBi($drive['storage_size']);
$free = Number::formatBi($drive['storage_free']);
$used = Number::formatBi($drive['storage_used']);
$background = \LibreNMS\Util\Color::percentage($percent, $drive['storage_perc_warn']);
2015-07-13 20:10:26 +02:00
2011-09-17 19:14:44 +00:00
$graph_array = [];
$graph_array['height'] = '100';
$graph_array['width'] = '210';
2019-06-23 00:29:12 -05:00
$graph_array['to'] = \LibreNMS\Config::get('time.now');
2011-09-17 19:14:44 +00:00
$graph_array['id'] = $drive['storage_id'];
$graph_array['type'] = $graph_type;
2019-06-23 00:29:12 -05:00
$graph_array['from'] = \LibreNMS\Config::get('time.day');
2011-09-17 19:14:44 +00:00
$graph_array['legend'] = 'no';
2015-07-13 20:10:26 +02:00
2011-09-17 19:14:44 +00:00
$link_array = $graph_array;
$link_array['page'] = 'graphs';
unset($link_array['height'], $link_array['width'], $link_array['legend']);
2021-03-28 17:25:30 -05:00
$link = \LibreNMS\Util\Url::generate($link_array);
2015-07-13 20:10:26 +02:00
2021-03-28 17:25:30 -05:00
$drive['storage_descr'] = \LibreNMS\Util\StringHelpers::shortenText($drive['storage_descr'], 50);
2011-09-30 11:40:23 +00:00
$overlib_content = generate_overlib_content($graph_array, $device['hostname'] . ' - ' . $drive['storage_descr']);
2015-07-13 20:10:26 +02:00
$graph_array['width'] = 80;
$graph_array['height'] = 20;
$graph_array['bg'] = 'ffffff00';
// the 00 at the end makes the area transparent.
2021-03-28 17:25:30 -05:00
$minigraph = \LibreNMS\Util\Url::lazyGraphTag($graph_array);
2015-07-13 20:10:26 +02:00
2014-02-26 22:33:45 +00:00
echo '<tr>
2021-03-28 17:25:30 -05:00
<td class="col-md-4">' . \LibreNMS\Util\Url::overlibLink($link, $drive['storage_descr'], $overlib_content) . '</td>
<td class="col-md-4">' . \LibreNMS\Util\Url::overlibLink($link, $minigraph, $overlib_content) . '</td>
<td class="col-md-4">' . \LibreNMS\Util\Url::overlibLink($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent . '%', 'ffffff', $background['right']), $overlib_content) . '
2011-09-17 19:14:44 +00:00
</a></td>
</tr>';
2010-02-24 14:34:24 +00:00
}//end foreach
2014-02-26 22:33:45 +00:00
echo '</table>
</div>
</div>
</div>';
2010-02-24 14:34:24 +00:00
}//end if
unset($drive_rows);