diff --git a/Kernel/GlobalProcessExposed.cpp b/Kernel/GlobalProcessExposed.cpp index c3f15c7d08..e1cd1c1029 100644 --- a/Kernel/GlobalProcessExposed.cpp +++ b/Kernel/GlobalProcessExposed.cpp @@ -411,6 +411,29 @@ private: } }; +class ProcFSSystemStatistics final : public ProcFSGlobalInformation { +public: + static NonnullRefPtr must_create(); + +private: + ProcFSSystemStatistics(); + virtual KResult try_generate(KBufferBuilder& builder) override + { + JsonObjectSerializer json { builder }; + auto total_time_scheduled = Scheduler::get_total_time_scheduled(); + json.add("total_time", total_time_scheduled.total); + json.add("kernel_time", total_time_scheduled.total_kernel); + json.add("user_time", total_time_scheduled.total - total_time_scheduled.total_kernel); + u64 idle_time = 0; + Processor::for_each([&](Processor& processor) { + idle_time += processor.time_spent_idle(); + }); + json.add("idle_time", idle_time); + json.finish(); + return KSuccess; + } +}; + class ProcFSOverallProcesses final : public ProcFSGlobalInformation { public: static NonnullRefPtr must_create(); @@ -730,6 +753,10 @@ UNMAP_AFTER_INIT NonnullRefPtr ProcFSMemoryStatus::must_crea { return adopt_ref_if_nonnull(new (nothrow) ProcFSMemoryStatus).release_nonnull(); } +UNMAP_AFTER_INIT NonnullRefPtr ProcFSSystemStatistics::must_create() +{ + return adopt_ref_if_nonnull(new (nothrow) ProcFSSystemStatistics).release_nonnull(); +} UNMAP_AFTER_INIT NonnullRefPtr ProcFSOverallProcesses::must_create() { return adopt_ref_if_nonnull(new (nothrow) ProcFSOverallProcesses).release_nonnull(); @@ -788,6 +815,10 @@ UNMAP_AFTER_INIT ProcFSMemoryStatus::ProcFSMemoryStatus() : ProcFSGlobalInformation("memstat"sv) { } +UNMAP_AFTER_INIT ProcFSSystemStatistics::ProcFSSystemStatistics() + : ProcFSGlobalInformation("stat"sv) +{ +} UNMAP_AFTER_INIT ProcFSOverallProcesses::ProcFSOverallProcesses() : ProcFSGlobalInformation("all"sv) { @@ -854,6 +885,7 @@ UNMAP_AFTER_INIT NonnullRefPtr ProcFSRootDirectory::must_cr directory->m_components.append(ProcFSSelfProcessDirectory::must_create()); directory->m_components.append(ProcFSDiskUsage::must_create()); directory->m_components.append(ProcFSMemoryStatus::must_create()); + directory->m_components.append(ProcFSSystemStatistics::must_create()); directory->m_components.append(ProcFSOverallProcesses::must_create()); directory->m_components.append(ProcFSCPUInformation::must_create()); directory->m_components.append(ProcFSDmesg::must_create());