Skip to content

Commit

Permalink
DTrace cleanup. (#1602)
Browse files Browse the repository at this point in the history
Update all the places where we print downstairs status able to handle
the new format.
Standardize the three letter name printed.

Use 10 for column width for next job ID
Use 6 for column width for job ID delta

For places where we print a header, print that header right away.

Updated `cmon` to use the same three letter strings as all the DTrace
scripts.

Co-authored-by: Alan Hanson <alan@oxide.computer>
  • Loading branch information
leftwo and Alan Hanson authored Jan 14, 2025
1 parent 4dd1b2c commit 2352a21
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 38 deletions.
8 changes: 4 additions & 4 deletions cmon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ fn short_state(dss: DsState) -> String {
DsState::Connecting {
state: NegotiationState::WaitActive,
..
} => "WAC".to_string(),
} => "WA".to_string(),

DsState::Connecting {
state: NegotiationState::WaitQuorum,
..
} => "WAQ".to_string(),
} => "WQ".to_string(),
DsState::Connecting {
state: NegotiationState::Reconcile,
..
Expand All @@ -121,14 +121,14 @@ fn short_state(dss: DsState) -> String {
DsState::Connecting {
mode: ConnectionMode::Offline,
..
} => "OFF".to_string(),
} => "OFL".to_string(),
DsState::Stopping(ClientStopReason::Deactivated) => "DAV".to_string(),
DsState::Stopping(ClientStopReason::Disabled) => "DIS".to_string(),
DsState::Stopping(ClientStopReason::Replacing)
| DsState::Connecting {
mode: ConnectionMode::Replaced,
..
} => "RPD".to_string(),
} => "RPL".to_string(),
}
}

Expand Down
8 changes: 5 additions & 3 deletions tools/dtrace/get-ds-state.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@ inline string short_state[string ss] =
ss == "offline" ? "OFL" :
ss == "reconcile" ? "REC" :
ss == "wait_quorum" ? "WQ" :
ss == "wait_active" ? "WA" :
ss == "replaced" ? "RPL" :
ss;

crucible_upstairs*:::up-status
{
my_sesh = json(copyinstr(arg1), "ok.session_id");

this->ds0state = json(copyinstr(arg1), "ok.ds_state[0]");
this->ds0state = json(copyinstr(arg1), "ok.ds_state[0].type");
this->d0 = short_state[this->ds0state];

this->ds1state = json(copyinstr(arg1), "ok.ds_state[1]");
this->ds1state = json(copyinstr(arg1), "ok.ds_state[1].type");
this->d1 = short_state[this->ds1state];

this->ds2state = json(copyinstr(arg1), "ok.ds_state[2]");
this->ds2state = json(copyinstr(arg1), "ok.ds_state[2].type");
this->d2 = short_state[this->ds2state];

printf("%6d %8s %3s %3s %3s\n",
Expand Down
8 changes: 5 additions & 3 deletions tools/dtrace/get-up-state.d
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ inline string short_state[string ss] =
ss == "offline" ? "OFL" :
ss == "reconcile" ? "REC" :
ss == "wait_quorum" ? "WQ" :
ss == "wait_active" ? "WA" :
ss == "replaced" ? "RPL" :
ss;

/*
Expand All @@ -52,13 +54,13 @@ inline string short_state[string ss] =
*/
crucible_upstairs*:::up-status
{
this->ds0state = json(copyinstr(arg1), "ok.ds_state[0]");
this->ds0state = json(copyinstr(arg1), "ok.ds_state[0].type");
this->d0 = short_state[this->ds0state];

this->ds1state = json(copyinstr(arg1), "ok.ds_state[1]");
this->ds1state = json(copyinstr(arg1), "ok.ds_state[1].type");
this->d1 = short_state[this->ds1state];

this->ds2state = json(copyinstr(arg1), "ok.ds_state[2]");
this->ds2state = json(copyinstr(arg1), "ok.ds_state[2].type");
this->d2 = short_state[this->ds2state];

this->full_session_id = json(copyinstr(arg1), "ok.session_id");
Expand Down
11 changes: 7 additions & 4 deletions tools/dtrace/simple.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dtrace:::BEGIN
/*
* Print our header at some interval
*/
tick-2s
dtrace:::BEGIN, tick-20s
{
printf("%5s %8s ", "PID", "SESSION");
printf("%3s %3s %3s", "DS0", "DS1", "DS2");
Expand All @@ -35,6 +35,9 @@ inline string short_state[string ss] =
ss == "faulted" ? "FLT" :
ss == "offline" ? "OFL" :
ss == "reconcile" ? "REC" :
ss == "wait_quorum" ? "WQ" :
ss == "wait_active" ? "WA" :
ss == "replaced" ? "RPL" :
ss;

/*
Expand All @@ -44,13 +47,13 @@ inline string short_state[string ss] =
*/
crucible_upstairs*:::up-status
{
this->ds0state = json(copyinstr(arg1), "ok.ds_state[0]");
this->ds0state = json(copyinstr(arg1), "ok.ds_state[0].type");
this->d0 = short_state[this->ds0state];

this->ds1state = json(copyinstr(arg1), "ok.ds_state[1]");
this->ds1state = json(copyinstr(arg1), "ok.ds_state[1].type");
this->d1 = short_state[this->ds1state];

this->ds2state = json(copyinstr(arg1), "ok.ds_state[2]");
this->ds2state = json(copyinstr(arg1), "ok.ds_state[2].type");
this->d2 = short_state[this->ds2state];

this->full_session_id = json(copyinstr(arg1), "ok.session_id");
Expand Down
37 changes: 30 additions & 7 deletions tools/dtrace/single_up_info.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ dtrace:::BEGIN
* Every second, check and see if we have printed enough that it is
* time to print the header again
*/
tick-1s
dtrace:::BEGIN, tick-1s
/show > 20/
{
printf("%8s ", "SESSION");
printf("%17s %17s %17s", "DS STATE 0", "DS STATE 1", "DS STATE 2");
printf(" %5s %5s %8s %5s", "UPW", "DSW", "NEXT_JOB", "DELTA");
printf("%3s %3s %3s", "DS0", "DS1", "DS2");
printf(" %5s %5s %10s %6s", "UPW", "DSW", "NEXT_JOB", "DELTA");
printf(" %10s", "WRITE_BO");
printf(" %5s %5s %5s", "IP0", "IP1", "IP2");
printf(" %5s %5s %5s", "D0", "D1", "D2");
Expand All @@ -36,6 +36,22 @@ tick-1s
show = 0;
}

/*
* Translate the longer state string into a shorter version
*/
inline string short_state[string ss] =
ss == "active" ? "ACT" :
ss == "new" ? "NEW" :
ss == "live_repair_ready" ? "LRR" :
ss == "live_repair" ? "LR" :
ss == "faulted" ? "FLT" :
ss == "offline" ? "OFL" :
ss == "reconcile" ? "REC" :
ss == "wait_quorum" ? "WQ" :
ss == "wait_active" ? "WA" :
ss == "replaced" ? "RPL" :
ss;

crucible_upstairs*:::up-status
/pid==$1/
{
Expand All @@ -44,6 +60,15 @@ crucible_upstairs*:::up-status
* All these local variables require the "this->" so the probe firing
* from different sessions don't collide with each other.
*/
this->ds0state = json(copyinstr(arg1), "ok.ds_state[0].type");
this->d0 = short_state[this->ds0state];

this->ds1state = json(copyinstr(arg1), "ok.ds_state[1].type");
this->d1 = short_state[this->ds1state];

this->ds2state = json(copyinstr(arg1), "ok.ds_state[2].type");
this->d2 = short_state[this->ds2state];

this->full_session_id = json(copyinstr(arg1), "ok.session_id");
this->session_id = substr(this->full_session_id, 0, 8);

Expand All @@ -58,15 +83,13 @@ crucible_upstairs*:::up-status
* I'm not very happy about this, but if we don't print it all on one
* line, then multiple sessions will clobber each others output.
*/
printf("%8s %17s %17s %17s %5s %5s %8s %5d %10s %5s %5s %5s %5s %5s %5s %5s %5s %5s %5s %5s %5s %5s %5s %5s\n",
printf("%8s %3s %3s %3s %5s %5s %10s %6d %10s %5s %5s %5s %5s %5s %5s %5s %5s %5s %5s %5s %5s %5s %5s %5s\n",

this->session_id,
/*
* State for the three downstairs
*/
json(copyinstr(arg1), "ok.ds_state[0]"),
json(copyinstr(arg1), "ok.ds_state[1]"),
json(copyinstr(arg1), "ok.ds_state[2]"),
this->d0, this->d1, this->d2,

/*
* Work queue counts for Upstairs and Downstairs
Expand Down
8 changes: 5 additions & 3 deletions tools/dtrace/up-info.d
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ inline string short_state[string ss] =
ss == "offline" ? "OFL" :
ss == "reconcile" ? "REC" :
ss == "wait_quorum" ? "WQ" :
ss == "wait_active" ? "WA" :
ss == "replaced" ? "RPL" :
ss;

/*
Expand All @@ -63,13 +65,13 @@ crucible_upstairs*:::up-status
/$target == 0 | $target == pid/
{
show = show + 1;
this->ds0state = json(copyinstr(arg1), "ok.ds_state[0]");
this->ds0state = json(copyinstr(arg1), "ok.ds_state[0].type");
this->d0 = short_state[this->ds0state];

this->ds1state = json(copyinstr(arg1), "ok.ds_state[1]");
this->ds1state = json(copyinstr(arg1), "ok.ds_state[1].type");
this->d1 = short_state[this->ds1state];

this->ds2state = json(copyinstr(arg1), "ok.ds_state[2]");
this->ds2state = json(copyinstr(arg1), "ok.ds_state[2].type");
this->d2 = short_state[this->ds2state];

this->full_session_id = json(copyinstr(arg1), "ok.session_id");
Expand Down
42 changes: 33 additions & 9 deletions tools/dtrace/upstairs_info.d
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ dtrace:::BEGIN
* Every second, check and see if we have printed enough that it is
* time to print the header again
*/
tick-1s
dtrace:::BEGIN, tick-1s
/show > 20/
{
printf("%6s ", "PID");
printf("%17s %17s %17s", "DS STATE 0", "DS STATE 1", "DS STATE 2");
printf(" %5s %5s %9s", "UPW", "DSW", "JOBID");
printf("%3s %3s %3s", "DS0", "DS1", "DS2");
printf(" %5s %5s %10s", "UPW", "DSW", "JOBID");
printf(" %10s", "WRITE_BO");
printf(" %5s %5s %5s", "IP0", "IP1", "IP2");
printf(" %5s %5s %5s", "D0", "D1", "D2");
Expand All @@ -29,28 +29,52 @@ tick-1s
show = 0;
}

/*
* Translate the longer state string into a shorter version
*/
inline string short_state[string ss] =
ss == "active" ? "ACT" :
ss == "new" ? "NEW" :
ss == "live_repair_ready" ? "LRR" :
ss == "live_repair" ? "LR" :
ss == "faulted" ? "FLT" :
ss == "offline" ? "OFL" :
ss == "reconcile" ? "REC" :
ss == "wait_quorum" ? "WQ" :
ss == "wait_active" ? "WA" :
ss == "replaced" ? "RPL" :
ss;

crucible_upstairs*:::up-status
{
show = show + 1;
printf("%6d ", pid);
this->ds0state = json(copyinstr(arg1), "ok.ds_state[0].type");
this->d0 = short_state[this->ds0state];

this->ds1state = json(copyinstr(arg1), "ok.ds_state[1].type");
this->d1 = short_state[this->ds1state];

this->ds2state = json(copyinstr(arg1), "ok.ds_state[2].type");
this->d2 = short_state[this->ds2state];

printf("%6d", pid);
/*
* State for the three downstairs
*/
printf("%17s", json(copyinstr(arg1), "ok.ds_state[0]"));
printf(" %17s", json(copyinstr(arg1), "ok.ds_state[1]"));
printf(" %17s", json(copyinstr(arg1), "ok.ds_state[2]"));
printf(" %3s", this->d0);
printf(" %3s", this->d1);
printf(" %3s", this->d2);

/*
* Work queue counts for Upstairs and Downstairs
*/
printf(" ");
printf(" %5s", json(copyinstr(arg1), "ok.up_count"));
printf(" %5s", json(copyinstr(arg1), "ok.ds_count"));

/*
* Job ID and outstanding bytes
*/
printf(" %9s", json(copyinstr(arg1), "ok.next_job_id"));
printf(" %10s", json(copyinstr(arg1), "ok.next_job_id"));
printf(" %10s", json(copyinstr(arg1), "ok.write_bytes_out"));

/*
Expand Down
36 changes: 31 additions & 5 deletions tools/dtrace/upstairs_repair.d
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ dtrace:::BEGIN
* Every second, check and see if we have printed enough that it is
* time to print the header again
*/
tick-1s
dtrace:::BEGIN, tick-1s
/show > 20/
{
printf("%17s %17s %17s", "DS STATE 0", "DS STATE 1", "DS STATE 2");
printf("%3s %3s %3s", "DS0", "DS1", "DS2");
printf(" ");

/* Header width, three downstairs, space between: 5+1+5+1+5 = 17 */
Expand All @@ -32,15 +32,41 @@ tick-1s
show = 0;
}

/*
* Translate the longer state string into a shorter version
*/
inline string short_state[string ss] =
ss == "active" ? "ACT" :
ss == "new" ? "NEW" :
ss == "live_repair_ready" ? "LRR" :
ss == "live_repair" ? "LR" :
ss == "faulted" ? "FLT" :
ss == "offline" ? "OFL" :
ss == "reconcile" ? "REC" :
ss == "wait_quorum" ? "WQ" :
ss == "wait_active" ? "WA" :
ss == "replaced" ? "RPL" :
ss;

crucible_upstairs*:::up-status
{
show = show + 1;
/*
* State for the three downstairs
*/
printf("%17s", json(copyinstr(arg1), "ok.ds_state[0]"));
printf(" %17s", json(copyinstr(arg1), "ok.ds_state[1]"));
printf(" %17s", json(copyinstr(arg1), "ok.ds_state[2]"));

this->ds0state = json(copyinstr(arg1), "ok.ds_state[0].type");
this->d0 = short_state[this->ds0state];

this->ds1state = json(copyinstr(arg1), "ok.ds_state[1].type");
this->d1 = short_state[this->ds1state];

this->ds2state = json(copyinstr(arg1), "ok.ds_state[2].type");
this->d2 = short_state[this->ds2state];

printf("%3s", this->d0);
printf(" %3s", this->d1);
printf(" %3s", this->d2);

printf(" ");
printf(" %5s", json(copyinstr(arg1), "ok.ds_live_repair_completed[0]"));
Expand Down

0 comments on commit 2352a21

Please sign in to comment.