mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Send validator telemetry to the private overlay (#1325)
* Send validator telemetry to the private overlay * Improve rotating neighbours in overlays
This commit is contained in:
parent
52b010ff34
commit
061c82f89c
30 changed files with 426 additions and 13 deletions
|
@ -472,4 +472,45 @@ Result<TotalMemStat> get_total_mem_stat() {
|
|||
#endif
|
||||
}
|
||||
|
||||
Result<uint32> get_cpu_cores() {
|
||||
#if TD_LINUX
|
||||
uint32 result = 0;
|
||||
TRY_RESULT(fd, FileFd::open("/proc/cpuinfo", FileFd::Read));
|
||||
SCOPE_EXIT {
|
||||
fd.close();
|
||||
};
|
||||
std::string data;
|
||||
char buf[10000];
|
||||
while (true) {
|
||||
TRY_RESULT(size, fd.read(MutableSlice{buf, sizeof(buf) - 1}));
|
||||
if (size == 0) {
|
||||
break;
|
||||
}
|
||||
buf[size] = '\0';
|
||||
data += buf;
|
||||
}
|
||||
size_t i = 0;
|
||||
while (i < data.size()) {
|
||||
const char *line_begin = data.data() + i;
|
||||
while (i < data.size() && data[i] != '\n') {
|
||||
++i;
|
||||
}
|
||||
auto line_end = data.data() + i;
|
||||
++i;
|
||||
Slice line{line_begin, line_end};
|
||||
size_t j = 0;
|
||||
while (j < line.size() && line[j] != ' ' && line[j] != '\t' && line[j] != ':') {
|
||||
++j;
|
||||
}
|
||||
Slice name = line.substr(0, j);
|
||||
if (name == "processor") {
|
||||
++result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
#else
|
||||
return Status::Error("Not supported");
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue