Skip to content
Snippets Groups Projects
Commit d878caf0 authored by Tim Fechner's avatar Tim Fechner Committed by Tim Fechner
Browse files

Close #15, list of mounted devices

parent ac734358
Branches
No related tags found
No related merge requests found
from django.core.management.base import BaseCommand
from salt_observer.models import Minion
from . import ApiCommand
import json
class Command(ApiCommand, BaseCommand):
help = 'Fetch and save mount points data'
def save_packages(self, api):
mount_point_devices = api.get_server_module_data('ps.disk_partition_usage')
for minion_fqdn, devices in mount_point_devices.items():
minion = Minion.objects.filter(fqdn=minion_fqdn).first()
minion_data = json.loads(minion.data)
mounted_devices = devices
minion_data['mounted_devices'] = mounted_devices
minion.data = json.dumps(minion_data)
minion.save()
def handle(self, *args, **kwargs):
api = super().handle(*args, **kwargs)
self.save_packages(api)
api.logout()
......@@ -20,7 +20,7 @@
iconSortAsc: 'fa fa-sort-asc',
iconSortDesc: 'fa fa-sort-desc',
};
$('#usertable').tablesorter({
$('#usertable, #partitiontable').tablesorter({
theme: 'bootstrap',
headerTemplate: '{content} {icon}',
sortList: [[0,0]],
......@@ -54,6 +54,7 @@
<li role="presentation"><a href="#networks" aria-controls="networks" role="tab" data-toggle="tab">Networks</a></li>
<li role="presentation"><a href="#packages" aria-controls="packages" role="tab" data-toggle="tab">Packages</a></li>
<li role="presentation"><a href="#users" aria-controls="users" role="tab" data-toggle="tab">Users</a></li>
<li role="presentation"><a href="#partitions" aria-controls="partitions" role="tab" data-toggle="tab">Partitions</a></li>
</ul>
<!-- tab panes -->
......@@ -211,6 +212,30 @@
</tbody>
</table>
</div>
<div role="tabpanel" class="tab-pane fade" id="partitions">
<table id="partitiontable" class="table table-hover">
<thead>
<tr>
<th>Device</th>
<th>Mountpoint</th>
<th>FsType</th>
<th>Size</th>
<th>Used</th>
</tr>
</thead>
<tbody>
{% for device in minion.get_data.mounted_devices %}
<tr class="{% if device.percent > 90 %}danger{% elif device.percent > 65 %}warning{% endif %}">
<td><samp>{{ device.device }}</samp></td>
<td><samp>{{ device.mountpoint }}</samp></td>
<td>{{ device.fstype }}</td>
<td>{{ device.total|filesizeformat }}</td>
<td>{{ device.percent }} %</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<!-- tab panes end -->
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment