more DiskMonitor docs

This commit is contained in:
phryk 2018-10-04 23:12:22 +02:00
parent c52d8d51d1
commit 7a340bcd91
2 changed files with 92 additions and 12 deletions
doc/man
gulik

View File

@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "GULIK" "1" "Oct 03, 2018" "0.0.0.1" "gulik"
.TH "GULIK" "1" "Oct 04, 2018" "0.0.0.1" "gulik"
.SH NAME
gulik \- gulik Documentation
.
@ -449,7 +449,7 @@ done through the functions \fBMonitor.normalize()\fP and \fBMonitor.caption()\fP
.IP \(bu 2
\fI\%BatteryMonitor\fP
.IP \(bu 2
\fBDiskMonitor\fP
\fI\%DiskMonitor\fP
.IP \(bu 2
\fBNetdataMonitor\fP
.UNINDENT
@ -679,7 +679,7 @@ Memory for CPU usage.
.B caption(fmt)
.INDENT 7.0
.TP
.B Elements exposed:
.B Exposed keys:
.INDENT 7.0
.IP \(bu 2
\fBaggregate\fP: average cpu use, sum of all core loads divided by number of cores
@ -716,7 +716,7 @@ Monitor for memory usage
.B caption(fmt)
.INDENT 7.0
.TP
.B Elements exposed:
.B Exposed keys:
.INDENT 7.0
.IP \(bu 2
\fBtotal\fP: how much memory this machine has in total,
@ -839,6 +839,63 @@ the current fill of the battery.
.UNINDENT
.INDENT 0.0
.TP
.B class gulik.DiskMonitor(*args, **kwargs)
Monitors disk I/O and partitions.
.INDENT 7.0
.TP
.B normalize(element)
.INDENT 7.0
.TP
.B Elements exposed:
.INDENT 7.0
.IP \(bu 2
.INDENT 2.0
.TP
.B \fBio\fP
.INDENT 7.0
.IP \(bu 2
Valid subelements are disk device file names as found in
\fB/dev\fP\&. Examples: \fBada0\fP, \fBsda\fP\&.
.INDENT 2.0
.TP
.B Valid subsubelements are as follows:
.INDENT 7.0
.IP \(bu 2
\fBread_bytes\fP
.IP \(bu 2
\fBwrite_bytes\fP
.IP \(bu 2
\fBread_time\fP
.IP \(bu 2
\fBwrite_time\fP
.IP \(bu 2
\fBbusy_time\fP
.UNINDENT
.UNINDENT
.UNINDENT
.UNINDENT
.IP \(bu 2
.INDENT 2.0
.TP
.B \fBpartitions\fP
.INDENT 7.0
.IP \(bu 2
Valid subelements are partition device file names as
found in \fB/dev\fP, with dots (\fB\&.\fP) being replaced
with dashes (\fB\-\fP). Examples: \fBroot\-eli\fP, \fBsda1\fP\&.
.UNINDENT
.UNINDENT
.UNINDENT
.UNINDENT
.UNINDENT
.INDENT 7.0
.TP
.B caption(fmt)
Exposed keys are the same as for \fI\%DiskMonitor.normalize()\fP\&.
.UNINDENT
.UNINDENT
.INDENT 0.0
.TP
.B class gulik.Visualizer(app, monitor, x=0, y=0, width=None, height=None, margin=None, margin_left=None, margin_right=None, margin_top=None, margin_bottom=None, padding=None, padding_left=None, padding_right=None, padding_top=None, padding_bottom=None, elements=None, captions=None, caption_placement=None, legend=None, legend_order=None, legend_format=None, legend_size=None, legend_placement=None, legend_margin=None, legend_margin_left=None, legend_margin_right=None, legend_margin_top=None, legend_margin_bottom=None, legend_padding=None, legend_padding_left=None, legend_padding_right=None, legend_padding_top=None, legend_padding_bottom=None, foreground=None, background=None, pattern=None, palette=None, combination=None, operator=None)
The base class for all visualizers. Not called widget to avoid naming
confusion with gtk widgets (which aren\(aqt even used in gulik).

View File

@ -1102,6 +1102,7 @@ class Monitor(threading.Thread):
def register_elements(self, elements):
print(self, elements)
pass
@ -1178,7 +1179,7 @@ class CPUMonitor(Monitor):
def caption(self, fmt):
"""
Elements exposed:
Exposed keys:
* ``aggregate``: average cpu use, sum of all core loads divided by number of cores
* ``core_<n>``: load of core ``<n>``, with possible values of ``<n>`` being 0 to number of cores - 1
* ``count``: number of cores
@ -1226,7 +1227,7 @@ class MemoryMonitor(Monitor):
def caption(self, fmt):
"""
Elements exposed:
Exposed keys:
* ``total``: how much memory this machine has in total,
* ``percent``: total memory usage in percent.
* ``available``: how much memory can be malloc'd without going into swap (roughly).
@ -1558,15 +1559,22 @@ class DiskMonitor(Monitor):
"""
Elements exposed:
* ``io``
* Valid subelements are disk device file names as found in
``/dev``. Examples: ``ada0``, ``sda``.
Valid subsubelements are as follows:
* ``read_bytes``
* ``write_bytes``
* ``read_time``
* ``write_time``
* ``busy_time``
* ``partitions``
Subelements of io are disk names.
Subelements of partitions are cleaned up patition names (TODO: explain cleanup)
* Valid subelements are partition device file names as
found in ``/dev``, with dots (``.``) being replaced
with dashes (``-``). Examples: ``root-eli``, ``sda1``.
"""
print(self.data['partitions'])
parts = element.split('.')
if parts[0] == 'io':
@ -1591,9 +1599,23 @@ class DiskMonitor(Monitor):
def caption(self, fmt):
"""
Exposed keys are the same as for :func:`DiskMonitor.normalize`.
"""
data = DotDict()
if 'partitions' in self.data and 'io' in self.data:
data['io'] = DotDict()
for name, diskinfo in self.data['io'].items():
data['io'][name] = DotDict()
for key, value in diskinfo.items():
if key.endswith('_bytes'):
value = pretty_bytes(value)
data['io'][name][key] = value
data['partitions'] = DotDict()
for name, partition in self.data['partitions'].items():
@ -1604,6 +1626,7 @@ class DiskMonitor(Monitor):
part_data['usage'] = DotDict(partition['usage'])
data['partitions'][name] = part_data
return fmt.format(**data)
return fmt