diff --git a/src/Raven.Server/Utils/ThreadHelper.cs b/src/Raven.Server/Utils/ThreadHelper.cs index 250ef684c73c..9e2b3a5df6ff 100644 --- a/src/Raven.Server/Utils/ThreadHelper.cs +++ b/src/Raven.Server/Utils/ThreadHelper.cs @@ -1,6 +1,8 @@ using System; +using System.IO; using System.Threading; using Sparrow.Logging; +using Sparrow.Platform; namespace Raven.Server.Utils; @@ -34,4 +36,19 @@ public static ThreadPriority GetThreadPriority() return ThreadPriority.Normal; } } + + public static string GetThreadName(int processId, int threadId) + { + if (PlatformDetails.RunningOnLinux == false) + return null; + + try + { + return File.ReadAllText($"/proc/{processId}/task/{threadId}/comm"); + } + catch + { + return null; + } + } } diff --git a/src/Raven.Server/Utils/ThreadsUsage.cs b/src/Raven.Server/Utils/ThreadsUsage.cs index ba649ae7f21f..db33fea58c52 100644 --- a/src/Raven.Server/Utils/ThreadsUsage.cs +++ b/src/Raven.Server/Utils/ThreadsUsage.cs @@ -111,12 +111,14 @@ public ThreadsInfo Calculate(int? take = null, HashSet threadIds = null) } else { - threadName = threadStats.Name ?? "Thread Pool Thread"; + threadName = threadStats.Name ?? ThreadHelper.GetThreadName(process.Id, thread.Id) ?? "Thread Pool Thread"; } unmanagedAllocations = threadStats.TotalAllocated; } + threadName ??= ThreadHelper.GetThreadName(process.Id, thread.Id); + var threadState = GetThreadInfoOrDefault(() => thread.ThreadState); threadsInfo.List.Add(new ThreadInfo {