Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newline in container command corrupts display / hides container #2733

Closed
Trayshar opened this issue Apr 21, 2024 · 1 comment
Closed

Newline in container command corrupts display / hides container #2733

Trayshar opened this issue Apr 21, 2024 · 1 comment
Labels
Milestone

Comments

@Trayshar
Copy link

Describe the bug
If a container's command contains newlines, they are interpreted and spill over to the other sections of the display. I noticed this when running a VSCode devcontainer and checking glances.

Further testing showed that a Windows newline (\r\n) clears the container's line, effectivly hiding it.

To Reproduce
Steps to reproduce the behavior:

  1. Start Glances with the default settings
  2. Start a VSCode devcontainer or the sample I provided below
  3. See error

Sample Dockerfile

FROM python:latest
# Test UNIX newline. Substitute \r\n to demonstrate hiding behaiviour
CMD ["/bin/sh", "-c", "echo Running\nwhile true; do sleep 1; done"]

Expected behavior
The newline should be converted to a whitespace. It should not spill over and should not hide the container's existance,

Screenshots
Running the devcontainer (has command echo Container started\ntrap "exit 0" 15\n\nexec "$@"\nwhile sleep 1 & wait $!; do :; done', '-):
Screenshot_20240421_193110

Running the sample docker container with windows newline:
Screenshot_20240421_194410

Environement (please complete the following information)

  • Operating System (lsb_release -a or OS name/version): Manjaro Linux 23.1.4
  • Glances & psutil versions: Glances v3.4.0.3 with PsUtil v5.9.8
  • How do you install Glances (Pypi package, script, package manager, source): AUR
Glances test (only available with Glances 3.1.7 or higher):
===============================================================================
Glances 3.4.0.3 (/usr/lib/python3.11/site-packages/glances/__init__.py)
Python 3.11.8 (/usr/bin/python)
PsUtil 5.9.8 (/usr/lib/python3.11/site-packages/psutil/__init__.py)
===============================================================================
alert         [OK]    0.00001s 
[]
amps          [OK]    0.00010s key=name 
[{'count': 0,
  'countmax': None,
  'countmin': 1.0,
  'key': 'name',
  'name': 'Dropbox',
  'refresh': 3.0,
  'regex': True,
  'result': None,
  'timer': 2.2797250747680664}, ...]
cloud         [NA]
connections   [NA]
containers    [OK]    0.00295s key=name 
[{'Command': ['/bin/sh', '-c',
              'echo Container started\ntrap "exit 0" 15\n\nexec "$@"\nwhile sleep 1 & wait $!; do :; done', '-'],
  'Created': '2024-04-20T07:54:35.171978671Z',
  'Id': '249c1ee0236567240f07154b6bd926effcf86af8996a0f98fa1a7bc8a4d54e68',
  'Image': ['vsc-redacted-b2cd5bc98658407c2e7c95e85c3a5c028eb65a503cb36cbea6c40bab96d3cf04-uid:latest'],
  'Status': 'running',
  'Uptime': '2 hours',
  'cpu_percent': 2.2989526184538653,
  'engine': 'docker',
  'io_r': None,
  'io_w': None,
  'key': 'name',
  'memory_usage': 1233633280,
  'name': 'peaceful_jepsen',
  'network_rx': None,
  'network_tx': None}, ...]
core          [OK]    0.00035s 
{'log': 16, 'phys': 8}
cpu           [OK]    0.00015s 
{'cpucore': 16,
 'ctx_switches': 19789,
 'guest': 0.0,
 'guest_nice': 0.0,
 'idle': 97.0,
 'interrupts': 14363,
 'iowait': 0.5,
 'irq': 0.1,
 'nice': 0.0,
 'soft_interrupts': 4768,
 'softirq': 0.0,
 'steal': 0.0,
 'syscalls': 0,
 'system': 1.0,
 'time_since_update': 2.154247999191284,
 'total': 6.7,
 'user': 1.2}
diskio        [OK]    0.00018s key=disk_name 
[{'disk_name': 'nvme1n1',
  'key': 'disk_name',
  'read_bytes': 0,
  'read_count': 0,
  'time_since_update': 2.154282331466675,
  'write_bytes': 0,
  'write_count': 0}, ...]
folders       [OK]    0.00001s 
[]
fs            [OK]    0.00058s key=mnt_point 
[{'device_name': '/dev/nvme1n1p2',
  'free': 1352133763072,
  'fs_type': 'btrfs',
  'key': 'mnt_point',
  'mnt_point': '/',
  'percent': 33.9,
  'size': 2047554355200,
  'used': 693927616512}, ...]
gpu           [OK]    0.00001s 
[]
help          [OK]    0.00000s 
None
ip            [OK]    0.00001s 
{}
irq           [NA]
load          [OK]    0.00001s 
{'cpucore': 16, 'min1': 1.23974609375, 'min15': 1.61083984375, 'min5': 1.4189453125}
mem           [OK]    0.00005s 
{'active': 12190928896,
 'available': 22673707008,
 'buffers': 5316608,
 'cached': 17202130944,
 'free': 22673707008,
 'inactive': 11445317632,
 'percent': 31.9,
 'shared': 793235456,
 'total': 33318920192,
 'used': 10645213184}
memswap       [OK]    0.00008s 
{'free': 68699987968,
 'percent': 0.0,
 'sin': 0,
 'sout': 0,
 'time_since_update': 2.1540277004241943,
 'total': 68719472640,
 'used': 19484672}
network       [OK]    0.00032s key=interface_name 
[{'alias': None,
  'cumulative_cx': 7665477790,
  'cumulative_rx': 3832738895,
  'cumulative_tx': 3832738895,
  'cx': 200,
  'interface_name': 'lo',
  'is_up': True,
  'key': 'interface_name',
  'rx': 100,
  'speed': 0,
  'time_since_update': 2.0055296421051025,
  'tx': 100}, ...]
now           [OK]    0.00001s 
'2024-04-21 19:24:10 CEST'
percpu        [OK]    0.00003s key=cpu_number 
[{'cpu_number': 0,
  'guest': 0.0,
  'guest_nice': 0.0,
  'idle': 16.0,
  'iowait': 0.0,
  'irq': 0.0,
  'key': 'cpu_number',
  'nice': 0.0,
  'softirq': 0.0,
  'steal': 0.0,
  'system': 0.0,
  'total': 84.0,
  'user': 0.0}, ...]
ports         [OK]    0.00000s 
[]
processcount  [OK]    0.03613s 
{'pid_max': 0, 'running': 2, 'sleeping': 284, 'thread': 1985, 'total': 455}
processlist   [OK]    0.00018s key=pid 
[{'cmdline': ['echo redacted'],
  'cpu_percent': 13.1,
  'cpu_times': pcputimes(user=478.48, system=132.41, children_user=0.0, children_system=0.0, iowait=0.0),
  'gids': pgids(real=1000, effective=1000, saved=1000),
  'io_counters': [2633728, 507904, 2633728, 507904, 1],
  'key': 'pid',
  'memory_info': pmem(rss=330006528, vms=35563229184, shared=218345472, text=189702144, lib=0, data=433606656, dirty=0),
  'memory_percent': 0.9904478479444716,
  'name': 'Vivaldi-Gpu',
  'nice': 0,
  'num_threads': 26,
  'pid': 54032,
  'status': 'S',
  'time_since_update': 2.1536948680877686,
  'username': 'valle'}, ...]
psutilversion [OK]    0.00001s 
(5, 9, 8)
quicklook     [OK]    0.00015s 
{'cpu': 6.7,
 'cpu_hz': 5573000000.0,
 'cpu_hz_current': 2722056687.5,
 'cpu_name': 'AMD Ryzen 7 7700X 8-Core Processor',
 'mem': 32.0,
 'percpu': [{...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...},
            {...}],
 'swap': 0.0}
raid          [NA]
sensors       [OK]    0.00000s key=label 
[{'critical': 94,
  'key': 'label',
  'label': 'Composite',
  'type': 'temperature_core',
  'unit': 'C',
  'value': 38,
  'warning': 89}, ...]
smart         [NA]
system        [OK]    0.00000s 
{'hostname': 'atlas',
 'hr_name': 'Manjaro Linux 64bit',
 'linux_distro': 'Manjaro Linux',
 'os_name': 'Linux',
 'os_version': '6.6.26-1-MANJARO',
 'platform': '64bit'}
uptime        [OK]    0.00007s 
{'seconds': 20209}
wifi          [NA]
===============================================================================
Total time to update all stats: 0.04256s
===============================================================================

Additional Information
Same issue in process table: #2337

Tab (\t) is interpreted as well. Just adds a bit of space.

@nicolargo
Copy link
Owner

Corrected in the develop branch:

image

Will be release in Glances v4.0

Thanks for the issue report @Trayshar !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants