1 // Copyright (c) 2020 Tomasz Konojacki
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright notice,
7 // this list of conditions and the following disclaimer.
9 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
10 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
11 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
12 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
13 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
14 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
15 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
16 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
17 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
18 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
19 // POSSIBILITY OF SUCH DAMAGE.
21 // SPDX-License-Identifier: BSD-1-Clause
31 #if defined(__GNUC__) || defined(__clang__)
32 # define SM_LIKELY(x) __builtin_expect(!!(x),1)
33 # define SM_UNLIKELY(x) __builtin_expect(!!(x), 0)
35 # define SM_LIKELY(x) (x)
36 # define SM_UNLIKELY(x) (x)
47 uint64_t available = 0;
57 class system_metrics {
62 struct cpu_times cpu_times();
63 std::vector<struct cpu_times> per_cpu_times();
64 uint64_t number_of_cpus();
66 struct mem_info mem_info();
67 std::vector<struct process> process_list();
71 std::vector<double> per_cpu_usage();
74 struct cpu_times prev_cpu_times;
75 std::vector<struct cpu_times> prev_per_cpu_times;
76 std::unique_ptr<struct sm_private> _priv;