mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Final version for storage page
This commit is contained in:
@@ -1,6 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$sql = " FROM `storage` AS `S`, `devices` AS `D` WHERE `S`.`device_id` = `D`.`device_id`";
|
$graph_type = "storage_usage";
|
||||||
|
|
||||||
|
$where = 1;
|
||||||
|
|
||||||
|
$sql = " FROM `storage` AS `S` LEFT JOIN `devices` AS `D` ON `S`.`device_id` = `D`.`device_id`";
|
||||||
|
|
||||||
|
if (is_admin() === FALSE && is_read() === FALSE) {
|
||||||
|
$sql .= " LEFT JOIN `devices_perms` AS `DP` ON `S`.`device_id` = `DP`.`device_id`";
|
||||||
|
$where .= " AND `DP`.`user_id`=?";
|
||||||
|
$param[] = $_SESSION['user_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= " WHERE $where";
|
||||||
|
|
||||||
|
if (isset($searchPhrase) && !empty($searchPhrase)) {
|
||||||
|
$sql .= " AND (`hostname` LIKE '%$searchPhrase%' OR `storage_descr` LIKE '%$searchPhrase%')";
|
||||||
|
}
|
||||||
|
|
||||||
$count_sql = "SELECT COUNT(`storage_id`) $sql";
|
$count_sql = "SELECT COUNT(`storage_id`) $sql";
|
||||||
|
|
||||||
@@ -26,9 +42,7 @@ if ($rowCount != -1) {
|
|||||||
|
|
||||||
$sql = "SELECT * $sql";
|
$sql = "SELECT * $sql";
|
||||||
|
|
||||||
system("echo '$sql' >> /tmp/testing");
|
|
||||||
foreach (dbFetchRows($sql,$param) as $drive) {
|
foreach (dbFetchRows($sql,$param) as $drive) {
|
||||||
if (device_permitted($drive['device_id'])) {
|
|
||||||
$skipdrive = 0;
|
$skipdrive = 0;
|
||||||
|
|
||||||
if ($drive["os"] == "junos") {
|
if ($drive["os"] == "junos") {
|
||||||
@@ -72,13 +86,12 @@ foreach (dbFetchRows($sql,$param) as $drive) {
|
|||||||
|
|
||||||
$background = get_percentage_colours($perc);
|
$background = get_percentage_colours($perc);
|
||||||
|
|
||||||
$response[] = array('device_id' => generate_device_link($drive),
|
$response[] = array('hostname' => generate_device_link($drive),
|
||||||
'storage_descr' => $drive['storage_descr'],
|
'storage_descr' => $drive['storage_descr'],
|
||||||
'graph' => $mini_graph,
|
'graph' => $mini_graph,
|
||||||
'usage' => $bar_link,
|
'storage_size' => $bar_link,
|
||||||
'storage_used' => $perc . "%");
|
'storage_used' => $perc . "%");
|
||||||
if ($_POST['view'] == "graphs") {
|
if ($_POST['view'] == "graphs") {
|
||||||
system("echo 'test' >> /tmp/testing");
|
|
||||||
$graph_array['height'] = "100";
|
$graph_array['height'] = "100";
|
||||||
$graph_array['width'] = "216";
|
$graph_array['width'] = "216";
|
||||||
$graph_array['to'] = $config['time']['now'];
|
$graph_array['to'] = $config['time']['now'];
|
||||||
@@ -88,14 +101,13 @@ foreach (dbFetchRows($sql,$param) as $drive) {
|
|||||||
$return_data = true;
|
$return_data = true;
|
||||||
include("includes/print-graphrow.inc.php");
|
include("includes/print-graphrow.inc.php");
|
||||||
unset($return_data);
|
unset($return_data);
|
||||||
$response[] = array('device_id' => $graph_data[0],
|
$response[] = array('hostname' => $graph_data[0],
|
||||||
'storage_descr' => $graph_data[1],
|
'storage_descr' => $graph_data[1],
|
||||||
'graph' => $graph_data[2],
|
'graph' => $graph_data[2],
|
||||||
'usage' => $graph_data[3],
|
'storage_size' => $graph_data[3],
|
||||||
'storage_used' => '');
|
'storage_used' => '');
|
||||||
|
|
||||||
} # endif graphs
|
} # endif graphs
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total);
|
$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total);
|
||||||
|
@@ -1,20 +1,12 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$graph_type = "storage_usage";
|
|
||||||
|
|
||||||
echo $vars['view'];
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table id="storage" class="table table-hover table-condensed storage">
|
<table id="storage" class="table table-hover table-condensed storage">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th data-column-id="device_id">Device</th>
|
<th data-column-id="hostname">Device</th>
|
||||||
<th data-column-id="storage_descr">Storage</th>
|
<th data-column-id="storage_descr">Storage</th>
|
||||||
<th data-column-id="graph" data-sortable="false"></th>
|
<th data-column-id="graph" data-sortable="false" data-searchable="false"></th>
|
||||||
<th data-column-id="usage">Usage</th>
|
<th data-column-id="storage_size" data-searchable="false">Usage</th>
|
||||||
<th data-column-id="storage_used">Used</th>
|
<th data-column-id="storage_used" data-searchable="false">Used</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>
|
||||||
@@ -23,6 +15,7 @@ echo $vars['view'];
|
|||||||
<script>
|
<script>
|
||||||
var grid = $("#storage").bootgrid({
|
var grid = $("#storage").bootgrid({
|
||||||
ajax: true,
|
ajax: true,
|
||||||
|
rowCount: [25,50,100,250,-1],
|
||||||
post: function ()
|
post: function ()
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
|
Reference in New Issue
Block a user