Skip to content
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
65 changes: 22 additions & 43 deletions cmon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ use strum::IntoEnumIterator;
use strum_macros::EnumIter;
use tokio::time::{sleep, Duration};

use crucible::{
ClientStopReason, ConnectionMode, DsState, DtraceInfo, NegotiationState,
};
use crucible::DtraceInfo;

/// Connect to crucible control server
#[derive(Parser, Debug)]
Expand Down Expand Up @@ -86,44 +84,25 @@ enum Action {
Repair,
}

/// Translate a [`DsState`] into a three letter string for printing.
fn short_state(dss: DsState) -> String {
/// Translate what the default DsState string is (that we are getting from DTrace)
/// into a three letter string for printing.
fn short_state(dss: &str) -> String {
match dss {
DsState::Connecting {
state: NegotiationState::WaitQuorum,
..
} => "WQ".to_string(),
DsState::Connecting {
state: NegotiationState::Reconcile,
..
} => "REC".to_string(),
DsState::Active => "ACT".to_string(),
DsState::Connecting {
state: NegotiationState::LiveRepairReady,
..
} => "LRR".to_string(),
DsState::Stopping(ClientStopReason::NegotiationFailed(..))
| DsState::Connecting {
mode: ConnectionMode::New,
..
} => "NEW".to_string(),
DsState::Connecting {
mode: ConnectionMode::Faulted,
..
}
| DsState::Stopping(ClientStopReason::Fault(..)) => "FLT".to_string(),
DsState::LiveRepair => "LR".to_string(),
DsState::Connecting {
mode: ConnectionMode::Offline,
..
} => "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,
..
} => "RPL".to_string(),
"Active" => "ACT".to_string(),
"WaitQuorum" => "WQ".to_string(),
"Reconcile" => "REC".to_string(),
"LiveRepairReady" => "LRR".to_string(),
"New" => "NEW".to_string(),
"Faulted" => "FLT".to_string(),
"Offline" => "OFL".to_string(),
"Replaced" => "RPL".to_string(),
"LiveRepair" => "LR".to_string(),
"Replacing" => "RPC".to_string(),
"Disabled" => "DIS".to_string(),
"Deactivated" => "DAV".to_string(),
"NegotiationFailed" => "NF".to_string(),
"Fault" => "FLT".to_string(),
x => x.to_string(),
}
}

Expand Down Expand Up @@ -277,9 +256,9 @@ fn print_dtrace_row(
DtraceDisplay::State => {
print!(
" {:>3} {:>3} {:>3}",
short_state(d_out.ds_state[0]),
short_state(d_out.ds_state[1]),
short_state(d_out.ds_state[2]),
short_state(&d_out.ds_state[0]),
short_state(&d_out.ds_state[1]),
short_state(&d_out.ds_state[2]),
);
}
DtraceDisplay::UpCount => {
Expand Down
4 changes: 2 additions & 2 deletions tools/dtrace/all_downstairs.d
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ crucible_downstairs*:::work-done

tick-4s
{
printf("%5s %4s %4s %4s %4s %5s %5s %5s %5s %5s\n",
printf("%5s %5s %5s %5s %5s %5s %5s %5s %5s %5s\n",
"PID", "F>", "F<", "W>", "W<", "R>", "R<", "WS", "WIP", "WD");
printa("%05d %@4u %@4u %@4u %@4u %@5u %@5u %@5u %@5u %@5u\n",
printa("%05d %@5u %@5u %@5u %@5u %@5u %@5u %@5u %@5u %@5u\n",
@sf_start, @sf_done, @sw_start, @sw_done, @sr_start, @sr_done,
@work_start, @work_process, @work_done
);
Expand Down
33 changes: 18 additions & 15 deletions tools/dtrace/get-ds-state.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,40 @@
* Exit after 5 seconds.
*/
#pragma D option quiet
#pragma D option strsize=1k
#pragma D option strsize=2k

/*
* Translate the longer state string into a shorter version
*/
inline string short_state[string ss] =
ss == "active" ? "ACT" :
ss == "new" ? "NEW" :
ss == "replaced" ? "RPL" :
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 == "connecting" ? "CON" :
ss == "Active" ? "ACT" :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to share this function with all the other scripts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe... Let me see if I can find an easy way.
I think it's "possible", but I don't want the callers of the scripts have to do too much, or remember too much.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me see if I can find an easier way.. in a follow up commit :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want these changes so I can triage what is going on when multiple downstairs come and go while doing LR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could look at what OPTE does, which has a few shared type and function definitions for these kinds of things.

ss == "WaitQuorum" ? "WQ" :
ss == "Reconcile" ? "REC" :
ss == "LiveRepairReady" ? "LRR" :
ss == "New" ? "NEW" :
ss == "Faulted" ? "FLT" :
ss == "Offline" ? "OFL" :
ss == "LiveRepair" ? "LR" :
ss == "Replacing" ? "RPC" :
ss == "Replaced" ? "RPL" :
ss == "Disabled" ? "DIS" :
ss == "Deactivated" ? "DAV" :
ss == "NegotiationFailed" ? "NF" :
ss == "Fault" ? "FLT" :
ss;

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

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

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

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

printf("%6d %8s %8s %3s %3s %3s\n",
Expand Down
33 changes: 18 additions & 15 deletions tools/dtrace/get-up-state.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Display Upstairs status for all matching processes
*/
#pragma D option quiet
#pragma D option strsize=1k
#pragma D option strsize=2k

/*
* Print the header right away
Expand Down Expand Up @@ -34,17 +34,20 @@ tick-10s
* Translate the longer state string into a shorter version
*/
inline string short_state[string ss] =
ss == "active" ? "ACT" :
ss == "new" ? "NEW" :
ss == "replaced" ? "RPL" :
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 == "connecting" ? "CON" :
ss == "Active" ? "ACT" :
ss == "WaitQuorum" ? "WQ" :
ss == "Reconcile" ? "REC" :
ss == "LiveRepairReady" ? "LRR" :
ss == "New" ? "NEW" :
ss == "Faulted" ? "FLT" :
ss == "Offline" ? "OFL" :
ss == "LiveRepair" ? "LR" :
ss == "Replacing" ? "RPC" :
ss == "Replaced" ? "RPL" :
ss == "Disabled" ? "DIS" :
ss == "Deactivated" ? "DAV" :
ss == "NegotiationFailed" ? "NF" :
ss == "Fault" ? "FLT" :
ss;

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

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

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

this->full_session_id = json(copyinstr(arg1), "ok.session_id");
Expand Down
33 changes: 18 additions & 15 deletions tools/dtrace/simple.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma D option quiet
#pragma D option strsize=1k
#pragma D option strsize=2k

dtrace:::BEGIN
{
Expand Down Expand Up @@ -28,17 +28,20 @@ dtrace:::BEGIN, tick-20s
* 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 == "connecting" ? "CON" :
ss == "Active" ? "ACT" :
ss == "WaitQuorum" ? "WQ" :
ss == "Reconcile" ? "REC" :
ss == "LiveRepairReady" ? "LRR" :
ss == "New" ? "NEW" :
ss == "Faulted" ? "FLT" :
ss == "Offline" ? "OFL" :
ss == "LiveRepair" ? "LR" :
ss == "Replacing" ? "RPC" :
ss == "Replaced" ? "RPL" :
ss == "Disabled" ? "DIS" :
ss == "Deactivated" ? "DAV" :
ss == "NegotiationFailed" ? "NF" :
ss == "Fault" ? "FLT" :
ss;

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

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

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

this->full_upstairs_id = json(copyinstr(arg1), "ok.upstairs_id");
Expand Down
33 changes: 18 additions & 15 deletions tools/dtrace/single_up_info.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Display internal Upstairs status for the PID provided as $1
*/
#pragma D option quiet
#pragma D option strsize=1k
#pragma D option strsize=2k
/*
* Print the header right away
*/
Expand Down Expand Up @@ -40,17 +40,20 @@ dtrace:::BEGIN, tick-1s
* 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 == "connecting" ? "CON" :
ss == "Active" ? "ACT" :
ss == "WaitQuorum" ? "WQ" :
ss == "Reconcile" ? "REC" :
ss == "LiveRepairReady" ? "LRR" :
ss == "New" ? "NEW" :
ss == "Faulted" ? "FLT" :
ss == "Offline" ? "OFL" :
ss == "LiveRepair" ? "LR" :
ss == "Replacing" ? "RPC" :
ss == "Replaced" ? "RPL" :
ss == "Disabled" ? "DIS" :
ss == "Deactivated" ? "DAV" :
ss == "NegotiationFailed" ? "NF" :
ss == "Fault" ? "FLT" :
ss;

crucible_upstairs*:::up-status
Expand All @@ -61,13 +64,13 @@ 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->ds0state = json(copyinstr(arg1), "ok.ds_state[0]");
this->d0 = short_state[this->ds0state];

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

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

this->full_upstairs_id = json(copyinstr(arg1), "ok.upstairs_id");
Expand Down
33 changes: 18 additions & 15 deletions tools/dtrace/sled_upstairs_info.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* will share the PID, but have unique SESSIONs.
*/
#pragma D option quiet
#pragma D option strsize=1k
#pragma D option strsize=2k
/*
* Print the header right away
*/
Expand Down Expand Up @@ -40,17 +40,20 @@ tick-1s
* 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 == "connecting" ? "CON" :
ss == "Active" ? "ACT" :
ss == "WaitQuorum" ? "WQ" :
ss == "Reconcile" ? "REC" :
ss == "LiveRepairReady" ? "LRR" :
ss == "New" ? "NEW" :
ss == "Faulted" ? "FLT" :
ss == "Offline" ? "OFL" :
ss == "LiveRepair" ? "LR" :
ss == "Replacing" ? "RPC" :
ss == "Replaced" ? "RPL" :
ss == "Disabled" ? "DIS" :
ss == "Deactivated" ? "DAV" :
ss == "NegotiationFailed" ? "NF" :
ss == "Fault" ? "FLT" :
ss;

crucible_upstairs*:::up-status
Expand All @@ -59,13 +62,13 @@ crucible_upstairs*:::up-status
this->upstairs_id = json(copyinstr(arg1), "ok.upstairs_id");
this->session_id = json(copyinstr(arg1), "ok.session_id");

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

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

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


Expand Down
Loading