Skip to content

Commit

Permalink
do not reset runtime statistics counters when munin asks for them and…
Browse files Browse the repository at this point in the history
… let it derive the current value
  • Loading branch information
janbuchar committed Nov 14, 2017
1 parent 8970018 commit b8dd643
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
6 changes: 6 additions & 0 deletions install/munin-broker
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ if __name__ == "__main__":
print("graph_vlabel jobs")
print("graph_category broker")
print("evaluated.label Jobs evaluated")
print("evaluated.type DERIVE")
print("evaluated.min 0")
print("failed.label Failed jobs")
print("failed.type DERIVE")
print("failed.min 0")
print("queued.label Jobs in queue")
print("queued.type DERIVE")
print("queued.min 0")
sys.exit(0)

broker_address = "tcp://127.0.0.1:9658"
Expand Down
26 changes: 11 additions & 15 deletions src/handlers/broker_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ broker_handler::broker_handler(std::shared_ptr<const broker_config> config,
logger_ = helpers::create_null_logger();
}

runtime_stats_.emplace(STATS_QUEUED_JOBS, 0);
runtime_stats_.emplace(STATS_EVALUATED_JOBS, 0);
runtime_stats_.emplace(STATS_FAILED_JOBS, 0);
runtime_stats_.emplace(STATS_WORKER_COUNT, 0);
runtime_stats_.emplace(STATS_IDLE_WORKER_COUNT, 0);

client_commands_.register_command(
"eval", [this](const std::string &identity, const std::vector<std::string> &message, response_cb respond) {
process_client_eval(identity, message, respond);
});

client_commands_.register_command("get-runtime-stats",
[this](const std::string &identity, const std::vector<std::string> &message, response_cb respond) {
client_commands_.register_command(
"get-runtime-stats", [this](const std::string &identity, const std::vector<std::string> &message, response_cb respond) {
process_client_get_runtime_stats(identity, message, respond);
});

Expand Down Expand Up @@ -51,8 +57,6 @@ broker_handler::broker_handler(std::shared_ptr<const broker_config> config,
"progress", [this](const std::string &identity, const std::vector<std::string> &message, response_cb respond) {
process_worker_progress(identity, message, respond);
});

clear_runtime_stats();
}

void broker_handler::on_request(const message_container &message, response_cb respond)
Expand Down Expand Up @@ -429,6 +433,9 @@ void broker_handler::process_timer(const message_container &message, handler_int
runtime_stats_[STATS_IDLE_WORKER_COUNT] += 1;
}
}

runtime_stats_[STATS_JOBS_IN_PROGRESS] =
runtime_stats_[STATS_WORKER_COUNT] - runtime_stats_[STATS_IDLE_WORKER_COUNT];
}

bool broker_handler::reassign_request(worker::request_ptr request, handler_interface::response_cb respond)
Expand Down Expand Up @@ -500,17 +507,6 @@ void broker_handler::process_client_get_runtime_stats(
}

respond(response);
clear_runtime_stats();
}

void broker_handler::clear_runtime_stats()
{
runtime_stats_.clear();
runtime_stats_.emplace(STATS_QUEUED_JOBS, 0);
runtime_stats_.emplace(STATS_EVALUATED_JOBS, 0);
runtime_stats_.emplace(STATS_FAILED_JOBS, 0);
runtime_stats_.emplace(STATS_WORKER_COUNT, 0);
runtime_stats_.emplace(STATS_IDLE_WORKER_COUNT, 0);
}

void broker_handler::process_client_freeze(
Expand Down
7 changes: 2 additions & 5 deletions src/handlers/broker_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class broker_handler : public handler_interface

const std::string STATS_EVALUATED_JOBS = "evaluated-jobs";

const std::string STATS_JOBS_IN_PROGRESS = "jobs-in-progress";

const std::string STATS_FAILED_JOBS = "failed-jobs";

const std::string STATS_WORKER_COUNT = "worker-count";
Expand Down Expand Up @@ -97,11 +99,6 @@ class broker_handler : public handler_interface
*/
void process_client_eval(const std::string &identity, const std::vector<std::string> &message, response_cb respond);

/**
* Initialize all runtime statistics to their initial values
*/
void clear_runtime_stats();

/**
* Process a request for data about system load.
*/
Expand Down

0 comments on commit b8dd643

Please sign in to comment.