Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
astibal committed Jun 13, 2024
2 parents ed46561 + 8352b89 commit 5b21815
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/proxy/nbrhood.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ struct Neighbor {

class NbrHood {
public:
static size_t inline MAX_CACHE_SZ = 8000;

using nbr_t = std::shared_ptr<Neighbor>;
using nbr_cache_t = LRUCache<std::string, nbr_t>;

Expand Down Expand Up @@ -376,7 +378,7 @@ class NbrHood {
}

static NbrHood& instance() {
static NbrHood r(8000);
static NbrHood r(NbrHood::MAX_CACHE_SZ);
return r;
}
private:
Expand Down
16 changes: 16 additions & 0 deletions src/service/cmd/diag/diag_cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2331,6 +2331,21 @@ int cli_diag_neighbor_list(struct cli_def *cli, const char *command, char *argv[
return CLI_OK;
}

int cli_diag_neighbor_stats(struct cli_def *cli, const char *command, char *argv[], int argc) {
std::stringstream ss;
{
auto& nb = NbrHood::instance();
auto _lc = std::scoped_lock(nb.cache().lock());

ss << "Neighbors stats:\n";
ss << " cache size: " << nb.cache().get_map_ul().size() << "\r\n";
ss << " cache max entries: " << NbrHood::MAX_CACHE_SZ << "\r\n";
}

cli_print(cli, "%s", ss.str().c_str());
return CLI_OK;
}

int cli_diag_neighbor_clear(struct cli_def *cli, const char *command, char *argv[], int argc) {

size_t sz = 0;
Expand Down Expand Up @@ -2539,6 +2554,7 @@ bool register_diags(cli_def* cli, cli_command* diag) {

auto diag_neighbor = cli_register_command(cli,diag,"neighbor",nullptr,PRIVILEGE_PRIVILEGED, MODE_EXEC,"proxy neighbors diag");
cli_register_command(cli,diag_neighbor,"list",cli_diag_neighbor_list,PRIVILEGE_PRIVILEGED, MODE_EXEC,"list active neighbors");
cli_register_command(cli,diag_neighbor,"stats",cli_diag_neighbor_stats,PRIVILEGE_PRIVILEGED, MODE_EXEC,"neighbors database stats");
cli_register_command(cli,diag_neighbor,"clear",cli_diag_neighbor_clear,PRIVILEGE_PRIVILEGED, MODE_EXEC,"clear neighbors database");
cli_register_command(cli,diag_neighbor,"tag",cli_diag_neighbor_tag,PRIVILEGE_PRIVILEGED, MODE_EXEC,"update a neighbor entry with a tag-string");
cli_register_command(cli,diag_neighbor,"webhook-update",cli_diag_neighbor_webhook_update,PRIVILEGE_PRIVILEGED, MODE_EXEC,"send single neighbor entry webhook update");
Expand Down

0 comments on commit 5b21815

Please sign in to comment.