2 Commits
Author SHA1 Message Date
Spine feaadb87ef add resource usage to grafana and report endpoints 2024-02-17 17:35:43 +01:00
Spine 0337402c36 Merge branch 'detab-source' into 'master'
detabbed source code, no code changes

See merge request tracker/ocelot!9
2024-02-15 19:22:51 +00:00
2 changed files with 42 additions and 1 deletions

No files matched your search

+8
View File
@@ -1,3 +1,11 @@
-- 2.1.2 (2024-02-17)
FEATURES
* show resource usage in Gazelle and Grafana report endpoints
-- 2.1.1 (2024-02-15)
BUILD
* Detabbed source code in first step towards having the code lint cleanly, no code changes
-- 2.1.0 (2024-02-11)
FEATURES
* announce jitter is now a uniform distribution and can be modified on the fly
+34 -1
View File
@@ -1,6 +1,9 @@
// Copyright [2017-2024] Orpheus
#include <sys/resource.h>
#include <iostream>
#include <iomanip> // for std::setfill() and std::setw()
#include <map>
#include <sstream>
@@ -47,6 +50,21 @@ std::string report(params_type &params, user_list &users_list, client_opts_t &cl
<< announce_interval << " announce interval\n"
<< announce_jitter << " announce jitter\n"
;
struct rusage r;
if (getrusage(RUSAGE_SELF, &r) == 0) {
output << r.ru_utime.tv_sec << '.' << std::setfill('0') << std::setw(6) << r.ru_utime.tv_usec << " user time\n"
<< r.ru_stime.tv_sec << '.' << std::setfill('0') << std::setw(6) << r.ru_stime.tv_usec << " system time\n"
<< r.ru_maxrss << " maximum resident set size\n"
<< r.ru_minflt << " minor page faults\n"
<< r.ru_majflt << " major page faults\n"
<< r.ru_inblock << " blocks in\n"
<< r.ru_oublock << " blocks out\n"
<< r.ru_nvcsw << " voluntary context switches\n"
<< r.ru_nivcsw << " involuntary context switches\n"
;
}
} else if (action == "prom_stats") {
time_t uptime = time(NULL) - stats.start_time;
output << "ocelot_uptime " << uptime << "\n"
@@ -65,7 +83,22 @@ std::string report(params_type &params, user_list &users_list, client_opts_t &cl
<< "ocelot_snatch_queue " << stats.snatch_queue_size << "\n"
<< "ocelot_token_queue " << stats.token_queue_size << "\n"
<< "ocelot_bytes_read " << stats.bytes_read << "\n"
<< "ocelot_bytes_written " << stats.bytes_written << "\n#";
<< "ocelot_bytes_written " << stats.bytes_written << "\n";
struct rusage r;
if (getrusage(RUSAGE_SELF, &r) == 0) {
output << "ocelot_time_user " << r.ru_utime.tv_sec << '.' << std::setfill('0') << std::setw(6) << r.ru_utime.tv_usec << "\n"
"ocelot_time_system " << r.ru_stime.tv_sec << '.' << std::setfill('0') << std::setw(6) << r.ru_stime.tv_usec << "\n"
"ocelot_max_rss " << r.ru_maxrss << "\n"
"ocelot_minor_fault " << r.ru_minflt << "\n"
"ocelot_major_fault " << r.ru_majflt << "\n"
"ocelot_blk_in " << r.ru_inblock << "\n"
"ocelot_blk_out " << r.ru_oublock << "\n"
"ocelot_nvcsw " << r.ru_nvcsw << "\n"
"ocelot_nivcsw " << r.ru_nivcsw << "\n"
;
}
output << '#';
} else if (action == "user") {
std::string key = params["key"];
if (key.empty()) {