Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shell: improve app_stat to add app_id and partition_count column #285

Merged
merged 3 commits into from
Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions scripts/pegasus_stat_available.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ fi

app_count=`cat $app_stat_result | wc -l`
app_count=$((app_count-2))
data_size=`cat $app_stat_result | tail -n 1 | awk '{print $(NF-3)}' | sed 's/\.00$//'`
data_size=$(((data_size+1024)/1024))
data_size_column=`cat $app_stat_result | awk '/file_mb/{ for(i = 1; i <= NF; i++) { if ($i == "file_mb") print i; } }'`
data_size=`cat $app_stat_result | tail -n 1 | awk '{print $'$data_size_column'}' | sed 's/\.00$//'`
data_size=$(((data_size+1023)/1024))

all_result="/tmp/$UID.$PID.pegasus.stat_available.all_result"
rm -f $all_result
Expand Down
4 changes: 4 additions & 0 deletions src/shell/command_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ inline bool parse_app_pegasus_perf_counter_name(const std::string &name,
struct row_data
{
std::string row_name;
int32_t app_id = 0;
int32_t partition_count = 0;
double get_qps = 0;
double multi_get_qps = 0;
double put_qps = 0;
Expand Down Expand Up @@ -603,6 +605,8 @@ get_app_stat(shell_context *sc, const std::string &app_name, std::vector<row_dat
std::map<int32_t, int> app_row_idx; // app_id --> row_idx
for (::dsn::app_info &app : apps) {
rows[idx].row_name = app.app_name;
rows[idx].app_id = app.app_id;
rows[idx].partition_count = app.partition_count;
app_row_idx[app.app_id] = idx;
idx++;
}
Expand Down
12 changes: 11 additions & 1 deletion src/shell/commands/table_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,10 @@ bool app_stat(command_executor *e, shell_context *sc, arguments args)

rows.resize(rows.size() + 1);
row_data &sum = rows.back();
sum.row_name = "(sum)";
for (int i = 0; i < rows.size() - 1; ++i) {
row_data &row = rows[i];
sum.partition_count += row.partition_count;
sum.get_qps += row.get_qps;
sum.multi_get_qps += row.multi_get_qps;
sum.put_qps += row.put_qps;
Expand Down Expand Up @@ -465,7 +467,11 @@ bool app_stat(command_executor *e, shell_context *sc, arguments args)
std::ostream out(buf);

::dsn::utils::table_printer tp;
tp.add_title(app_name.empty() ? "app" : "pidx");
tp.add_title(app_name.empty() ? "app_name" : "pidx");
if (app_name.empty()) {
tp.add_column("app_id", tp_alignment::kRight);
tp.add_column("pcount", tp_alignment::kRight);
}
tp.add_column("GET", tp_alignment::kRight);
tp.add_column("MGET", tp_alignment::kRight);
tp.add_column("PUT", tp_alignment::kRight);
Expand All @@ -491,6 +497,10 @@ bool app_stat(command_executor *e, shell_context *sc, arguments args)

for (row_data &row : rows) {
tp.add_row(row.row_name);
if (app_name.empty()) {
tp.append_data(row.app_id);
tp.append_data(row.partition_count);
}
tp.append_data(row.get_qps);
tp.append_data(row.multi_get_qps);
tp.append_data(row.put_qps);
Expand Down