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

WebUI doesn't display valid time for process list #2902

Open
HoodedDeath opened this issue Jul 29, 2024 · 1 comment
Open

WebUI doesn't display valid time for process list #2902

HoodedDeath opened this issue Jul 29, 2024 · 1 comment

Comments

@HoodedDeath
Copy link

Check the bug
Before filling this bug report, please search if a similar issue already exists.
In this case, just add a comment on this existing issue.

Describe the bug
WebUI shows "8736h 00:00" in time column for every entry in the process list. Only happens in the web UI

To Reproduce
Steps to reproduce the behavior:

  1. Start Glances with the following options '-w'
  2. Open web UI and look at process list

Expected behavior
Show the process time as the curses UI does

Screenshots
Screenshot of web UI showing wrong time for all processes
Screenshot_20240728_214457

Environement (please complete the following information)

  • Operating System (lsb_release -a or OS name/version): Arch Linux
  • Glances & psutil versions: Glances v4.1.2, Glances API version 4, PsUtil v6.0.0
  • How do you install Glances (Pypi package, script, package manager, source): Official Arch package, AUR package glances-git, and source from develop branch
  • Glances test:
===============================================================================
Glances 4.1.2 (/usr/lib/python3.12/site-packages/glances/__init__.py)
Python 3.12.4 (/usr/bin/python)
PsUtil 6.0.0 (/usr/lib/python3.12/site-packages/psutil/__init__.py)
===============================================================================
alert         [OK]    0.00001s 
[]
amps          [OK]    0.00011s key=name 
[{'count': 0,
  'countmax': None,
  'countmin': 1.0,
  'key': 'name',
  'name': 'Dropbox',
  'refresh': 3.0,
  'regex': True,
  'result': None,
  'timer': 2.195830821990967}, ...]
cloud         [NA]
connections   [NA]
containers    [OK]    0.00002s 
{}
core          [OK]    0.00044s 
{'log': 16, 'phys': 8}
cpu           [OK]    0.00028s 
{'cpucore': 16,
 'ctx_switches': 0,
 'ctx_switches_gauge': 637639312,
 'guest': 0.0,
 'idle': 93.9,
 'interrupts': 0,
 'interrupts_gauge': 400242261,
 'iowait': 0.1,
 'irq': 0.2,
 'nice': 0.0,
 'soft_interrupts': 0,
 'soft_interrupts_gauge': 109188431,
 'steal': 0.0,
 'syscalls': 0,
 'syscalls_gauge': 0,
 'system': 1.2,
 'time_since_update': 2.123958110809326,
 'total': 6.0,
 'user': 4.6}
diskio        [OK]    0.00065s key=disk_name 
[{'disk_name': 'sda',
  'key': 'disk_name',
  'read_bytes': 0,
  'read_bytes_gauge': 727466496,
  'read_count': 0,
  'read_count_gauge': 1842,
  'time_since_update': 2.1239771842956543,
  'write_bytes': 0,
  'write_bytes_gauge': 36321280,
  'write_count': 0,
  'write_count_gauge': 1098}, ...]
folders       [OK]    0.00002s 
[]
fs            [OK]    0.00038s key=mnt_point 
[{'device_name': '/dev/mapper/overlord-root',
  'free': 2008001536000,
  'fs_type': 'btrfs',
  'key': 'mnt_point',
  'mnt_point': '/',
  'percent': 48.9,
  'size': 3930973011968,
  'used': 1922516590592}, ...]
gpu           [OK]    0.00398s key=gpu_id 
[{'fan_speed': None, 'gpu_id': 'amd0', 'key': 'gpu_id', 'mem': 20, 'name': 'AMD GPU', 'proc': 9, 'temperature': 48}, ...]
help          [OK]    0.00000s 
None
ip            [OK]    0.00002s 
{}
irq           [NA]
load          [OK]    0.00003s 
{'cpucore': 16, 'min1': 1.3876953125, 'min15': 1.02099609375, 'min5': 1.0478515625}
mem           [OK]    0.00011s 
{'active': 12242362368,
 'available': 24236838912,
 'buffers': 4296704,
 'cached': 23220871168,
 'free': 24236838912,
 'inactive': 17461157888,
 'percent': 27.8,
 'shared': 508440576,
 'total': 33555267584,
 'used': 9318428672}
memswap       [OK]    0.00013s 
{'free': 68719472640,
 'percent': 0.0,
 'sin': 0,
 'sout': 0,
 'time_since_update': 2.123225212097168,
 'total': 68719472640,
 'used': 0}
network       [OK]    0.00049s key=interface_name 
[{'alias': None,
  'bytes_all': 28528,
  'bytes_all_gauge': 2993216385,
  'bytes_all_rate_per_sec': 14208.0,
  'bytes_recv': 25950,
  'bytes_recv_gauge': 2300767278,
  'bytes_recv_rate_per_sec': 12924.0,
  'bytes_sent': 2578,
  'bytes_sent_gauge': 692449107,
  'bytes_sent_rate_per_sec': 1283.0,
  'interface_name': 'enp7s0',
  'key': 'interface_name',
  'speed': 1048576000,
  'time_since_update': 2.007822036743164}, ...]
now           [OK]    0.00003s 
{'custom': '2024-07-29 01:43:26 MDT', 'iso': '2024-07-29T01:43:26-06:00'}
percpu        [OK]    0.00045s key=cpu_number 
[{'cpu_number': 0,
  'dpc': None,
  'guest': 0.0,
  'guest_nice': 0.0,
  'idle': 98.1,
  'interrupt': None,
  'iowait': 0.0,
  'irq': 0.0,
  'key': 'cpu_number',
  'nice': 0.0,
  'softirq': 0.0,
  'steal': 0.0,
  'system': 0.5,
  'total': 1.9,
  'user': 1.4}, ...]
ports         [OK]    0.00001s 
[]
processcount  [OK]    0.06553s 
{'pid_max': 0, 'running': 1, 'sleeping': 262, 'thread': 2351, 'total': 467}
processlist   [OK]    0.00038s 
[]
psutilversion [OK]    0.00002s 
'6.0.0'
quicklook     [OK]    0.00025s 
{'cpu': 6.0,
 'cpu_hz': 3600000000.0,
 'cpu_hz_current': 2979209062.5,
 'cpu_log_core': 16,
 'cpu_name': 'AMD Ryzen 7 3700X 8-Core Processor',
 'cpu_phys_core': 8,
 'load': 6.4,
 'mem': 27.8,
 'percpu': [{...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...},
            {...}],
 'swap': 0.0}
raid          [NA]
sensors       [OK]    0.00000s key=label 
[{'critical': 84,
  'key': 'label',
  'label': 'Composite',
  'type': <SensorType.CPU_TEMP: 'temperature_core'>,
  'unit': 'C',
  'value': 46,
  'warning': 81}, ...]
smart         [NA]
system        [OK]    0.00000s 
{'hostname': 'Scarlet',
 'hr_name': 'Arch Linux 64bit / Linux 6.9.10-arch1-1',
 'linux_distro': 'Arch Linux',
 'os_name': 'Linux',
 'os_version': '6.9.10-arch1-1',
 'platform': '64bit'}
uptime        [OK]    0.00009s 
{'seconds': 32650}
version       [OK]    0.00001s 
'4.1.2'
vms           [OK]    0.00002s 
{}
wifi          [OK]    0.00006s 
[]
===============================================================================
Total time to update all stats: 0.07538s
===============================================================================

Additional context
I did a bit of trying to track down the problem in hopes of doing a PR instead of this, but I couldn't fix it myself. Here's what I found in my testing tonight though.

The file glances/outputs/static/js/filters.js was giving me a couple problems. The timemillis function seemed to be problematic. I don't have a great understanding currently of how the web side of Glances interacts with itself, but I did some testing with what I believe are the values that were being given to it, coming from the API at /api/4/processlist. Specifically, I grabbed one process' cpu_times values, which was:

{
  "user": 4229.49,
  "system": 1055.1,
  "children_user": 962.61,
  "children_system": 70.49,
  "iowait": 0
}

Running Node and passing that object to timemillis returned 0. It seemed to me that the for loop was failing to iterate over the object. Changing timemillis to iterate over the keys (for (var key in array)) got me an actual number out of it.

Looking then at timedelta:

  • d ends up representing 1970-01-01T00:00:00.000Z when sum is 0
  • doy results in 365
  • Return value ends up as:
{
  "hours": 8736,
  "minutes": 0,
  "seconds": 0,
  "milliseconds": 0
}

My guess is that the math around Date is not acting as expected, but that's all I've got with my current understanding of the code.

I don't currently know where else those two functions are used, if anywhere, but I'm planning to give more of a look later. Assuming I don't find anything else relying on these, I'll try gutting and remaking those functions, and opening a PR after some testing if it turns out well.

Copy link

This issue is stale because it has been open for 3 months with no activity.

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

No branches or pull requests

2 participants