13 #ifndef __PROCESS_SYSTEM_HPP__ 14 #define __PROCESS_SYSTEM_HPP__ 51 self().
id +
"/mem_total_bytes",
54 self().
id +
"/mem_free_bytes",
70 route(
"/stats.json", statsHelp(), &System::stats);
84 static std::string statsHelp()
88 "Shows local system metrics."),
90 "> cpus_total Total number of available CPUs",
91 "> load_1min Average system load for last" 92 " minute in uptime(1) style",
93 "> load_5min Average system load for last" 94 " 5 minutes in uptime(1) style",
95 "> load_15min Average system load for last" 96 " 15 minutes in uptime(1) style",
97 "> memory_total_bytes Total system memory in bytes",
98 "> memory_free_bytes Free system memory in bytes"));
108 return Failure(
"Failed to get loadavg: " + load.
error());
118 return Failure(
"Failed to get loadavg: " + load.
error());
128 return Failure(
"Failed to get loadavg: " + load.
error());
146 return static_cast<double>(memory->
total.
bytes());
148 return Failure(
"Failed to get memory: " + memory.
error());
156 return static_cast<double>(memory->
free.
bytes());
158 return Failure(
"Failed to get memory: " + memory.
error());
167 object.values[
"avg_load_1min"] = load->
one;
168 object.values[
"avg_load_5min"] = load->
five;
169 object.values[
"avg_load_15min"] = load->
fifteen;
174 object.values[
"cpus_total"] = cpus.
get();
179 object.values[
"mem_total_bytes"] = memory->
total.
bytes();
180 object.values[
"mem_free_bytes"] = memory->
free.
bytes();
198 #endif // __PROCESS_SYSTEM_HPP__ Definition: system.hpp:33
Future< Response > request(const Request &request, bool streamedResponse=false)
Asynchronously sends an HTTP request to the process and returns the HTTP response once the entire res...
T & get()&
Definition: try.hpp:80
URL url
Definition: http.hpp:544
Future< Nothing > remove(const Metric &metric)
Definition: metrics.hpp:109
Definition: future.hpp:668
void initialize() override
Invoked when a process gets spawned.
Definition: system.hpp:60
~System() override
Definition: system.hpp:57
Definition: process.hpp:72
void route(const std::string &name, const Option< std::string > &help, const HttpRequestHandler &handler, const RouteOptions &options=RouteOptions())
Sets up a handler for HTTP requests with the specified name.
Future< Nothing > add(const T &metric)
Definition: metrics.hpp:95
hashmap< std::string, std::string > query
Definition: http.hpp:189
Try< Load > loadavg()
Definition: os.hpp:280
Definition: pull_gauge.hpp:46
std::string TLDR(const std::string &tldr)
Definition: help.hpp:69
Try< long > cpus()
Definition: os.hpp:265
bool isSome() const
Definition: try.hpp:77
static Try error(const E &e)
Definition: try.hpp:43
void finalize() override
Invoked when a process is terminated.
Definition: system.hpp:73
std::string HELP(const std::string &tldr, const Option< std::string > &description=None(), const Option< std::string > &authentication=None(), const Option< std::string > &authorization=None(), const Option< std::string > &references=None())
Bytes total
Definition: os.hpp:36
System()
Definition: system.hpp:36
Definition: executor.hpp:48
uint64_t bytes() const
Definition: bytes.hpp:79
PID< System > self() const
Returns the PID of the process.
Definition: process.hpp:514
double fifteen
Definition: os.hpp:28
Try< Memory > memory()
Definition: freebsd.hpp:78
Definition: process.hpp:505
Deferred< void()> defer(const PID< T > &pid, void(T::*method)())
Definition: defer.hpp:35
Bytes free
Definition: os.hpp:37
double five
Definition: os.hpp:27
Option< Value > get(const Key &key) const
Definition: hashmap.hpp:121
double one
Definition: os.hpp:26
std::string DESCRIPTION(T &&...args)
Definition: help.hpp:76
Definition: future.hpp:58