Files

88 lines
3.3 KiB
PHP
Raw Permalink Normal View History

2010-02-24 14:34:24 +00:00
<?php
2015-07-13 20:10:26 +02:00
$graph_type = 'storage_usage';
2015-07-13 20:10:26 +02:00
$drives = dbFetchRows('SELECT * FROM `storage` WHERE device_id = ? ORDER BY `storage_descr` ASC', array($device['device_id']));
2011-05-16 12:48:50 +00:00
2015-07-13 20:10:26 +02:00
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">
2015-07-13 20:10:26 +02:00
<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>';
2015-07-13 20:10:26 +02:00
echo ' </div>
<table class="table table-hover table-condensed table-striped">';
foreach ($drives as $drive) {
$skipdrive = 0;
if ($device['os'] == 'junos') {
2019-06-23 00:29:12 -05:00
foreach (\LibreNMS\Config::get('ignore_junos_os_drives') as $jdrive) {
2015-07-13 20:10:26 +02:00
if (preg_match($jdrive, $drive['storage_descr'])) {
$skipdrive = 1;
}
}
$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
if ($device['os'] == 'freebsd') {
2019-06-23 00:29:12 -05:00
foreach (\LibreNMS\Config::get('ignore_bsd_os_drives') as $jdrive) {
2015-07-13 20:10:26 +02:00
if (preg_match($jdrive, $drive['storage_descr'])) {
$skipdrive = 1;
}
}
}
if ($skipdrive) {
continue;
2010-02-26 13:07:30 +00:00
}
2015-07-13 20:10:26 +02:00
$percent = round($drive['storage_perc'], 0);
$total = formatStorage($drive['storage_size']);
$free = formatStorage($drive['storage_free']);
$used = formatStorage($drive['storage_used']);
$background = get_percentage_colours($percent, $drive['storage_perc_warn']);
2015-07-13 20:10:26 +02:00
$graph_array = 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');
2015-07-13 20:10:26 +02: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');
2015-07-13 20:10:26 +02:00
$graph_array['legend'] = 'no';
$link_array = $graph_array;
$link_array['page'] = 'graphs';
unset($link_array['height'], $link_array['width'], $link_array['legend']);
$link = generate_url($link_array);
$drive['storage_descr'] = shorten_text($drive['storage_descr'], 50);
2015-07-13 20:10:26 +02:00
$overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$drive['storage_descr']);
$graph_array['width'] = 80;
$graph_array['height'] = 20;
$graph_array['bg'] = 'ffffff00';
// the 00 at the end makes the area transparent.
2015-07-16 12:42:58 -04:00
$minigraph = generate_lazy_graph_tag($graph_array);
2015-07-13 20:10:26 +02:00
echo '<tr>
2016-02-28 02:29:51 +01:00
<td class="col-md-4">'.overlib_link($link, $drive['storage_descr'], $overlib_content).'</td>
<td class="col-md-4">'.overlib_link($link, $minigraph, $overlib_content).'</td>
<td class="col-md-4">'.overlib_link($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>
2015-07-13 20:10:26 +02:00
</tr>';
}//end foreach
2015-07-13 20:10:26 +02:00
echo '</table>
2014-02-26 22:33:45 +00:00
</div>
</div>
2015-07-13 20:10:26 +02:00
</div>';
}//end if
2010-02-24 14:34:24 +00:00
2015-07-13 20:10:26 +02:00
unset($drive_rows);