IEEE-VIT / termiboard

A smart CLI Dashboard to fetch cpu, memory and network stats!
MIT License
35 stars 16 forks source link

[BUG] GetTopProcesses does not work on Windows #42

Closed S-Maciejewski closed 3 years ago

S-Maciejewski commented 3 years ago

Describe the bug An error occurs when running termiboard on Windows, process finishes with exit code 2. The error:

Could not retrieve memory usage details.
panic: The parameter is incorrect.

goroutine 1 [running]:
main.GetTopProcesses.func1(0x0, 0x24, 0xc0000926c0)
    memory.go:57 +0x1c5
sort.medianOfThree_func(0xc00010fe48, 0xc0000926c0, 0x0, 0x24, 0x48)
    go/current/src/sort/zfuncversion.go:53 +0x45
sort.doPivot_func(0xc00010fe48, 0xc0000926c0, 0x0, 0x121, 0x18, 0xc0000926a0)
    go/current/src/sort/zfuncversion.go:76 +0x4fc
sort.quickSort_func(0xc00010fe48, 0xc0000926c0, 0x0, 0x121, 0x12)
    go/current/src/sort/zfuncversion.go:143 +0xa6
sort.Slice(0x118dd60, 0xc0000926a0, 0xc00010fe48)
    go/current/src/sort/slice.go:17 +0xfa
main.GetTopProcesses()
    memory.go:53 +0xe7
main.main()
    main.go:59 +0x4e3

To Reproduce Steps to reproduce the behavior:

  1. Run termiboard on Windows

Expected behavior Program should finish with exit code 0 and top processes should be displayed

sjchoure commented 3 years ago

Hey @S-Maciejewski , It was raised previously at #30. It is because you need to give it administrative permissions in Windows to get it running.

sjchoure commented 3 years ago

You even might consider inspecting code in memory.go file line number 67 to 73

S-Maciejewski commented 3 years ago

@saviourcode Unfortunately I still cannot make it work, even with elevated privileges. Shouldn't the condition in lines 69 to 73 eliminate the need for running this as admin btw?

Anyways, the error seems to occur in processes sorting. I wonder if there are any other processes running on my machine that should be excluded from the list. I will investigate this issue further, because for now it makes the whole program just crash on Windows

sjchoure commented 3 years ago

@S-Maciejewski The Error is because somehow, the sort.Slice block got included twice in the source code, remove the lines from 53 through 65 and then do go build and runas admin. It will work.

sjchoure commented 3 years ago

@S-Maciejewski Can you please raise the PR after doing those changes, thanks in advance 👍

sjchoure commented 3 years ago

For brevity, I used the --top5-ram flag but here's how it will produce ouptut. I am using Windows Terminal with Admin Access. Solu

DarthBenro008 commented 3 years ago

@saviourcode yes you are right, I found this issue few hours ago and am fixing this along the new refactor of code in a dev branch which will go public soon. This will be fixed there. Kudos for @S-Maciejewski to realise this and @saviourcode effectively figuring a solution!

sjchoure commented 3 years ago

@S-Maciejewski Thanks for making us aware of our silly mistake. If you can provide a better way to List those Top5 Processes with Memory Usage without elevated privileges, please raise a PR for it. We will highly appreciate it.