pulsatrix
Loading...
Searching...
No Matches
system_monitor_detail.hpp File Reference

SystemMonitor internals exposed for unit tests: the platform-source interface, the filesystem-rooted Linux parsers, and the log record encoders. More...

#include <chrono>
#include <cstddef>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include "pulsatrix/system_monitor.hpp"
Include dependency graph for system_monitor_detail.hpp:

Go to the source code of this file.

Classes

struct  pulsatrix::detail::CpuTimes
 Aggregate CPU time counters (any consistent unit). busy = total - idle - iowait. More...
 
struct  pulsatrix::detail::RawReading
 Raw counters/levels from one platform read; rates are derived by SystemMonitor. More...
 
class  pulsatrix::detail::PlatformSources
 Where SystemMonitor reads from. Implementations must make read() thread-safe. More...
 
struct  pulsatrix::detail::AmdGpuDevice
 One AMD GPU found under <sys_root>/class/drm. More...
 
class  pulsatrix::detail::LinuxSources
 Linux /proc + /sys parsers rooted at configurable directories so tests can point them at a fake tree. Pure file parsing: compiles (and is unit-testable) everywhere. More...
 

Namespaces

namespace  pulsatrix
 
namespace  pulsatrix::detail
 

Functions

std::unique_ptr< PlatformSources > pulsatrix::detail::make_host_sources ()
 The sources for the host this binary runs on (Linux/Windows + NVML, or a stub).
 
std::optional< double > pulsatrix::detail::cpu_percent_from_deltas (const CpuTimes &previous, const CpuTimes &current)
 Utilization in percent from two counter readings; nullopt if no time elapsed.
 
std::string pulsatrix::detail::json_escape (const std::string &text)
 JSON string-literal body escaping (quotes, backslash, control characters).
 
std::string pulsatrix::detail::format_number (double value)
 Number as a JSON/CSV token: integral values without decimals, else 3 decimals; non-finite -> "".
 
std::string pulsatrix::detail::mark_to_json (std::chrono::system_clock::time_point timestamp, double elapsed_seconds, const std::string &label)
 The "event":"mark" JSON Lines record.
 
std::string pulsatrix::detail::csv_header (std::size_t gpu_count)
 CSV header for gpu_count GPUs (columns gpu_util, gpu_mem_used, ...).
 
std::string pulsatrix::detail::sample_to_csv (const SystemSample &sample, std::size_t gpu_count)
 One CSV data row for sample; GPU columns beyond those present are empty.
 
std::string pulsatrix::detail::mark_to_csv (std::chrono::system_clock::time_point timestamp, double elapsed_seconds, const std::string &label, std::size_t gpu_count)
 One CSV mark row (only event, timestamp, elapsed_seconds and label filled).
 

Detailed Description

SystemMonitor internals exposed for unit tests: the platform-source interface, the filesystem-rooted Linux parsers, and the log record encoders.

Note
Not part of the stable API. Kept out of system_monitor.hpp so the user-facing header stays small; the tests include this header to drive the parsers against fake /proc and /sys trees built in a temporary directory.