0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-27 19:28:52 +02:00

modules/console: Add cmds to count peers and DNS cache entries.

This commit is contained in:
Jason Volk 2018-09-02 19:24:20 -07:00
parent a5d014d10a
commit b30a637dfa

View file

@ -2196,6 +2196,22 @@ console_cmd__peer(opt &out, const string_view &line)
return true;
}
bool
console_cmd__peer__count(opt &out, const string_view &line)
{
size_t i{0};
for(const auto &pair : ircd::server::peers)
{
assert(bool(pair.second));
const auto &peer{*pair.second};
if(!peer.err_has())
++i;
}
out << i << std::endl;
return true;
}
bool
console_cmd__peer__error(opt &out, const string_view &line)
{
@ -2232,6 +2248,22 @@ console_cmd__peer__error(opt &out, const string_view &line)
return true;
}
bool
console_cmd__peer__error__count(opt &out, const string_view &line)
{
size_t i{0};
for(const auto &pair : ircd::server::peers)
{
assert(bool(pair.second));
const auto &peer{*pair.second};
if(peer.err_has())
++i;
}
out << i << std::endl;
return true;
}
bool
console_cmd__peer__error__clear__all(opt &out, const string_view &line)
{
@ -2483,6 +2515,22 @@ console_cmd__net__host__cache__A(opt &out, const string_view &line)
return true;
}
bool
console_cmd__net__host__cache__A__count(opt &out, const string_view &line)
{
size_t count[2] {0};
for(const auto &pair : net::dns::cache.A)
{
const auto &host{pair.first};
const auto &record{pair.second};
++count[bool(record.ip4)];
}
out << "resolved: " << count[1] << std::endl;
out << "error: " << count[0] << std::endl;
return true;
}
bool
console_cmd__net__host__cache__SRV(opt &out, const string_view &line)
{
@ -2505,6 +2553,22 @@ console_cmd__net__host__cache__SRV(opt &out, const string_view &line)
return true;
}
bool
console_cmd__net__host__cache__SRV__count(opt &out, const string_view &line)
{
size_t count[2] {0};
for(const auto &pair : net::dns::cache.SRV)
{
const auto &host{pair.first};
const auto &record{pair.second};
++count[bool(record.tgt)];
}
out << "resolved: " << count[1] << std::endl;
out << "error: " << count[0] << std::endl;
return true;
}
bool
console_cmd__net__host__prefetch(opt &out, const string_view &line)
{