mirror of https://github.com/nicolargo/glances
Improve issue stdout
parent
38d0e706d7
commit
2633757929
|
@ -10,10 +10,13 @@ For an enhancement or new feature: Describe your needs.
|
|||
|
||||
#### Versions
|
||||
|
||||
* Glances & psutil (glances -V):
|
||||
* Operating System (lsb_release -a):
|
||||
* How do you install Glances (Pypi package, script, package manager, source):
|
||||
* Glances & psutil (glances -V): `To be completed`
|
||||
* Operating System (lsb_release -a): `To be completed`
|
||||
* How do you install Glances (Pypi package, script, package manager, source): `To be completed`
|
||||
|
||||
#### Logs
|
||||
#### Configuration and log file
|
||||
|
||||
You can also pastebin the Glances logs file (https://glances.readthedocs.io/en/latest/config.html#logging)
|
||||
You can also [pastebin](https://pastebin.com/):
|
||||
|
||||
* the Glances configuration file (https://glances.readthedocs.io/en/latest/config.html#location)
|
||||
* the Glances log file (https://glances.readthedocs.io/en/latest/config.html#logging)
|
||||
|
|
|
@ -22,11 +22,15 @@ A clear and concise description of what you expected to happen.
|
|||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
**Environement (please complete the following information):**
|
||||
- OS: [e.g. GNU/Linux Ubuntu 20.04]
|
||||
- Glances Version [output of glances -V]
|
||||
- Glances logs file [output of tail -10 <glances logs file>]
|
||||
- Glances test [output of glances --issue] (only available with Glances 3.1.7 or higher)
|
||||
|
||||
```
|
||||
Copy paste output of glances --issue here
|
||||
```
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
import os
|
||||
import sys
|
||||
import platform
|
||||
import shutil
|
||||
import time
|
||||
import pprint
|
||||
|
||||
from glances.timer import Counter
|
||||
from glances import __version__, psutil_version
|
||||
|
@ -21,10 +21,7 @@ from glances import __version__, psutil_version
|
|||
import psutil
|
||||
import glances
|
||||
|
||||
try:
|
||||
TERMINAL_WIDTH = shutil.get_terminal_size(fallback=(79, 24)).columns
|
||||
except Exception:
|
||||
TERMINAL_WIDTH = 79
|
||||
TERMINAL_WIDTH = 79
|
||||
|
||||
|
||||
class colors:
|
||||
|
@ -105,6 +102,10 @@ class GlancesStdoutIssue(object):
|
|||
stats._plugins[plugin].update()
|
||||
# Get the stats
|
||||
stat = stats.get_plugin(plugin).get_export()
|
||||
# Hide private information
|
||||
if plugin == 'ip':
|
||||
for key in stat.keys():
|
||||
stat[key] = '***'
|
||||
except Exception as e:
|
||||
stat_error = e
|
||||
if stat_error is None:
|
||||
|
@ -113,14 +114,17 @@ class GlancesStdoutIssue(object):
|
|||
)
|
||||
if isinstance(stat, list) and len(stat) > 0 and 'key' in stat[0]:
|
||||
key = 'key={} '.format(stat[0]['key'])
|
||||
message = colors.ORANGE + key + colors.NO + str(stat)[0 : TERMINAL_WIDTH - 41 - len(key)]
|
||||
stat_output = pprint.pformat([stat[0]], compact=True, width=120, depth=3)
|
||||
message = colors.ORANGE + key + colors.NO + '\n' + stat_output[0:-1] + ', ...' + stat_output[-1]
|
||||
else:
|
||||
message = colors.NO + str(stat)[0 : TERMINAL_WIDTH - 41]
|
||||
message = '\n' + colors.NO + pprint.pformat(stat, compact=True, width=120, depth=2)
|
||||
else:
|
||||
result = (colors.RED + '[ERROR]' + colors.BLUE + ' {:.5f}s '.format(counter.get())).rjust(
|
||||
41 - len(plugin)
|
||||
)
|
||||
message = colors.NO + str(stat_error)[0 : TERMINAL_WIDTH - 41]
|
||||
message = colors.NO + str(stat_error)[0: TERMINAL_WIDTH - 41]
|
||||
|
||||
# Display the result
|
||||
self.print_issue(plugin, result, message)
|
||||
|
||||
# Display total time need to update all plugins
|
||||
|
|
Loading…
Reference in New Issue