You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for the awesome library!
In my test, sudo can read stats just fine, but I'm getting null from LinuxTaskStatsReader.GetByThread when running without elevated permissions.
Code:
var tid = LinuxTaskStatsReader.GetTid();
Console.WriteLine("Tid = " + tid);
Console.WriteLine("IsGetTaskStatByThreadSupported = " + LinuxTaskStatsReader.IsGetTaskStatByThreadSupported);
Console.WriteLine("Stats = " + LinuxTaskStatsReader.GetByThread(tid));
Output:
~/dev/sandbox/Sandbox$ dotnet run
Tid = 726
IsGetTaskStatByThreadSupported = True
Stats = null
All I need is to get CPU time by thread, similar to what you other package CpuUsage does via libc getrusage. But I had to switch to NativeLinux.Interop because I want to read thead's CPU from another thread, so I need a function which accepts thread id/handle, not the one which only runs on the current thread.
Is there a more simple solution for my case maybe, which doesn't require elevated permissions? I'm not good at linux api unfortunately...
PS: I tested it on Ubuntu 22.04.1 LTS on WSL, but it doesn't seem to be version-specific.
Thanks!
The text was updated successfully, but these errors were encountered:
You can access CPU usage of the current thread and sub-task tree threads only. Additional permissions are required if we need access to a process created by another user.
Regarding WSL CpuUsage is fully supported on WSL v1 and v2.
But I didn't test taskstats on WSL.
Hi Mike,
Thank you for the awesome library!
In my test, sudo can read stats just fine, but I'm getting null from
LinuxTaskStatsReader.GetByThread
when running without elevated permissions.Code:
Output:
All I need is to get CPU time by thread, similar to what you other package
CpuUsage
does vialibc getrusage
. But I had to switch toNativeLinux.Interop
because I want to read thead's CPU from another thread, so I need a function which accepts thread id/handle, not the one which only runs on the current thread.Is there a more simple solution for my case maybe, which doesn't require elevated permissions? I'm not good at linux api unfortunately...
PS: I tested it on Ubuntu 22.04.1 LTS on WSL, but it doesn't seem to be version-specific.
Thanks!
The text was updated successfully, but these errors were encountered: