From a1ec78bf0dc93d0e05e5f066f1949dc3baecea06 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:44:51 +0200 Subject: Adding upstream version 0.20.0. Signed-off-by: Daniel Baumann --- vendor/gipfl/linux-health/src/Cpu.php | 59 +++++++++++++++++++++++++++++++ vendor/gipfl/linux-health/src/Memory.php | 52 +++++++++++++++++++++++++++ vendor/gipfl/linux-health/src/Network.php | 36 +++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 vendor/gipfl/linux-health/src/Cpu.php create mode 100644 vendor/gipfl/linux-health/src/Memory.php create mode 100644 vendor/gipfl/linux-health/src/Network.php (limited to 'vendor/gipfl/linux-health/src') diff --git a/vendor/gipfl/linux-health/src/Cpu.php b/vendor/gipfl/linux-health/src/Cpu.php new file mode 100644 index 0000000..43f2e50 --- /dev/null +++ b/vendor/gipfl/linux-health/src/Cpu.php @@ -0,0 +1,59 @@ += 2.5.41) + 'irq', // Time servicing interrupts. (Linux >= 2.6.0-test4) + 'softirq', // Time servicing softirqs. (Linux >= 2.6.0-test4) + 'steal', // Stolen time, which is the time spent in other operating + // systems when running in a virtualized environment + // (Linux >= 2.6.11) + 'guest', // Time spent running a virtual CPU for guest operating systems + // under the control of the Linux kernel. (Linux >= 2.6.24) + 'guest_nice' // Time spent running a niced guest (virtual CPU for guest + // operating systems under the control of the Linux kernel). + // (Linux >= 2.6.33) + ]; + + // TODO: + // ctxt 891299797 -> The number of context switches that the system underwent + // btime 1540828526 -> boot time, in seconds since the Epoch + // processes 2079015 -> Number of forks since boot + // procs_running 6 -> Number of processes in runnable state + // procs_blocked 0 -> Number of processes blocked waiting for I/O to complete + + foreach (file($procFile, FILE_IGNORE_NEW_LINES) as $line) { + $parts = preg_split('/\s+/', $line); + $key = array_shift($parts); + if (substr($key, 0, 3) === 'cpu') { + // TODO: handle count mismatch + $cpus[$key] = array_combine( + array_slice($cpuKeys, 0, count($parts), true), + $parts + ); + + for ($i = count($cpus[$key]) - 1; $i < count($cpuKeys); $i++) { + $cpus[$key][$cpuKeys[$i]] = 0; + } + } else { + $info[$key] = $parts; + } + } + + return $cpus; + } +} diff --git a/vendor/gipfl/linux-health/src/Memory.php b/vendor/gipfl/linux-health/src/Memory.php new file mode 100644 index 0000000..0c6f197 --- /dev/null +++ b/vendor/gipfl/linux-health/src/Memory.php @@ -0,0 +1,52 @@ + $pageSize * (int) $parts[0], + 'rss' => $pageSize * (int) $parts[1], + 'shared' => $pageSize * (int) $parts[3], + ]; + } + + /** + * @return int + */ + public static function getPageSize() + { + if (self::$pageSize === null) { + $output = trim(`getconf PAGESIZE 2>&1`); + if (strlen($output)) { + self::$pageSize = (int) $output; + } + } + + return self::$pageSize; + } + + /** + * @param int $pageSize + */ + public static function setPageSize($pageSize) + { + self::$pageSize = (int) $pageSize; + } +} diff --git a/vendor/gipfl/linux-health/src/Network.php b/vendor/gipfl/linux-health/src/Network.php new file mode 100644 index 0000000..e0bad7d --- /dev/null +++ b/vendor/gipfl/linux-health/src/Network.php @@ -0,0 +1,36 @@ +