Skip to content

Commit bc049c9

Browse files
committed
EXPERIMENTAL Add top-like monitoring tool
Inspiration and code from qui-domains. Known issues: - R4.2: scrolling works fast - R4.3: scrolling is slow
1 parent 4e4fa79 commit bc049c9

5 files changed

Lines changed: 444 additions & 6 deletions

File tree

doc/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@
366366
u'Manage tags on a qube', _man_pages_author, 1),
367367
('manpages/qvm-template', 'qvm-template',
368368
u'Manage templates', _man_pages_author, 1),
369+
('manpages/qvm-top', 'qvm-top',
370+
u'Top-like monitoring tool', _man_pages_author, 1),
369371
('manpages/qvm-unpause', 'qvm-unpause',
370372
u'Pause a qube', _man_pages_author, 1),
371373
('manpages/qvm-volume', 'qvm-volume',

doc/manpages/qvm-top.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.. program:: qvm-top
2+
3+
:program:`qvm-top` -- top-like monitoring tool
4+
==============================================
5+
6+
Synopsis
7+
--------
8+
9+
:command:`qvm-top`
10+
11+
Notes
12+
-----
13+
14+
Quit by pressing `q`, `Q`, or `ESC`.
15+
16+
Authors
17+
-------
18+
19+
| Benjamin Grande <ben.grande.b at gmail dot com>
20+
| For complete author list see: https://github.com/QubesOS/qubes-core-admin-client.git
21+
22+
.. vim: ts=3 sw=3 et tw=80

doc/qubesadmin.tools.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@ qubesadmin\.tools\.qvm\_template\_postprocess module
196196
:undoc-members:
197197
:show-inheritance:
198198

199+
qubesadmin\.tools\.qvm\_top module
200+
----------------------------------------------------
201+
202+
.. automodule:: qubesadmin.tools.qvm_top
203+
:members:
204+
:undoc-members:
205+
:show-inheritance:
206+
199207
qubesadmin\.tools\.qvm\_unpause module
200208
--------------------------------------
201209

qubesadmin/tools/__init__.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,15 @@ def parse_qubes_app(self, parser, namespace):
157157
assert hasattr(namespace, 'app')
158158
setattr(namespace, 'domains', [])
159159
app = namespace.app
160-
if hasattr(namespace, 'all_domains') and namespace.all_domains:
160+
if (
161+
hasattr(namespace, 'all_domains')
162+
and namespace.all_domains
163+
and not getattr(namespace, 'VMNAME')
164+
):
161165
namespace.domains = [
162166
vm
163167
for vm in app.domains
164-
if not vm.klass == 'AdminVM' and
168+
if (namespace.all_domains == "global" or not vm.klass == 'AdminVM') and
165169
vm.name not in namespace.exclude
166170
]
167171
else:
@@ -361,7 +365,7 @@ class QubesArgumentParser(argparse.ArgumentParser):
361365
'''
362366

363367
def __init__(self, vmname_nargs=None, show_forceroot=False, version=None, \
364-
**kwargs):
368+
all_default=False, all_include_adminvm=False, **kwargs):
365369

366370
super().__init__(add_help=False, **kwargs)
367371

@@ -398,7 +402,7 @@ def __init__(self, vmname_nargs=None, show_forceroot=False, version=None, \
398402
self.add_argument('--version', action='version')
399403

400404
if self._vmname_nargs in [argparse.ZERO_OR_MORE, argparse.ONE_OR_MORE]:
401-
vm_name_group = VmNameGroup(self,
405+
vm_name_group = VmNameGroup(self, all_default=all_default,
402406
required=(self._vmname_nargs
403407
not in [argparse.ZERO_OR_MORE, argparse.OPTIONAL]))
404408
self._mutually_exclusive_groups.append(vm_name_group)
@@ -574,13 +578,16 @@ class VmNameGroup(argparse._MutuallyExclusiveGroup):
574578
:py:class:``argparse.ArgumentParser```.
575579
'''
576580

577-
def __init__(self, container, required, vm_action=VmNameAction, help=None):
581+
def __init__(self, container, required, vm_action=VmNameAction,\
582+
all_default=False, all_include_adminvm=False, help=None):
578583
# pylint: disable=redefined-builtin
579584
super().__init__(container, required=required)
580585
if not help:
581586
help = 'perform the action on all qubes'
587+
if all_default and all_include_adminvm:
588+
default = "global"
582589
self.add_argument('--all', action='store_true', dest='all_domains',
583-
help=help)
590+
default="global", help=help)
584591
container.add_argument('--exclude', action='append', default=[],
585592
help='exclude the qube from --all')
586593

0 commit comments

Comments
 (0)