|
| 1 | +/* |
| 2 | + * Display Upstairs status for all matching processes |
| 3 | + */ |
| 4 | +#pragma D option quiet |
| 5 | +#pragma D option strsize=1k |
| 6 | + |
| 7 | +/* |
| 8 | + * Print the header right away |
| 9 | + */ |
| 10 | +dtrace:::BEGIN |
| 11 | +{ |
| 12 | + /* |
| 13 | + * We have to init something for last_id so we can use the |
| 14 | + * default values for all the session IDs that we don't yet have. |
| 15 | + */ |
| 16 | + last_id["string"] = (int64_t)1; |
| 17 | + printf("%5s %8s ", "PID", "SESSION"); |
| 18 | + printf("%3s %3s %3s", "DS0", "DS1", "DS2"); |
| 19 | + printf(" %10s %5s %4s", "NEXT_JOB", "DELTA", "CONN"); |
| 20 | + printf(" %5s %5s", "ELR", "ELC"); |
| 21 | + printf(" %5s %5s", "ERR", "ERN"); |
| 22 | + printf("\n"); |
| 23 | +} |
| 24 | + |
| 25 | +/* |
| 26 | + * After reporting for 10 seconds, exit |
| 27 | + */ |
| 28 | +tick-10s |
| 29 | +{ |
| 30 | + exit(0); |
| 31 | +} |
| 32 | + |
| 33 | +/* |
| 34 | + * All variables should be this-> |
| 35 | + * Otherwise, there is a chance another probe will fire and |
| 36 | + * clobber the contents. |
| 37 | + */ |
| 38 | +crucible_upstairs*:::up-status |
| 39 | +{ |
| 40 | + this->ds0state = json(copyinstr(arg1), "ok.ds_state[0]"); |
| 41 | + if (this->ds0state == "active") { |
| 42 | + this->d0 = "ACT"; |
| 43 | + } else if (this->ds0state == "new") { |
| 44 | + this->d0 = "NEW"; |
| 45 | + } else if (this->ds0state == "live_repair_ready") { |
| 46 | + this->d0 = "LRR"; |
| 47 | + } else if (this->ds0state == "live_repair") { |
| 48 | + this->d0 = " LR"; |
| 49 | + } else if (this->ds0state == "faulted") { |
| 50 | + this->d0 = "FLT"; |
| 51 | + } else if (this->ds0state == "offline") { |
| 52 | + this->d0 = "OFL"; |
| 53 | + } else { |
| 54 | + this->d0 = this->ds0state; |
| 55 | + } |
| 56 | + |
| 57 | + this->ds1state = json(copyinstr(arg1), "ok.ds_state[1]"); |
| 58 | + if (this->ds1state == "active") { |
| 59 | + this->d1 = "ACT"; |
| 60 | + } else if (this->ds1state == "new") { |
| 61 | + this->d1 = "NEW"; |
| 62 | + } else if (this->ds1state == "live_repair_ready") { |
| 63 | + this->d1 = "LRR"; |
| 64 | + } else if (this->ds1state == "live_repair") { |
| 65 | + this->d1 = " LR"; |
| 66 | + } else if (this->ds1state == "faulted") { |
| 67 | + this->d1 = "FLT"; |
| 68 | + } else if (this->ds1state == "offline") { |
| 69 | + this->d1 = "OFL"; |
| 70 | + } else { |
| 71 | + this->d1 = this->ds1state; |
| 72 | + } |
| 73 | + |
| 74 | + this->ds2state = json(copyinstr(arg1), "ok.ds_state[2]"); |
| 75 | + if (this->ds2state == "active") { |
| 76 | + this->d2 = "ACT"; |
| 77 | + } else if (this->ds2state == "new") { |
| 78 | + this->d2 = "NEW"; |
| 79 | + } else if (this->ds2state == "live_repair_ready") { |
| 80 | + this->d2 = "LRR"; |
| 81 | + } else if (this->ds2state == "live_repair") { |
| 82 | + this->d2 = " LR"; |
| 83 | + } else if (this->ds2state == "faulted") { |
| 84 | + this->d2 = "FLT"; |
| 85 | + } else if (this->ds2state == "offline") { |
| 86 | + this->d2 = "OFL"; |
| 87 | + } else { |
| 88 | + this->d2 = this->ds2state; |
| 89 | + } |
| 90 | + |
| 91 | + /* |
| 92 | + * All these local variables require the "this->" so the probe firing |
| 93 | + * from different sessions don't collide with each other. |
| 94 | + */ |
| 95 | + this->full_session_id = json(copyinstr(arg1), "ok.session_id"); |
| 96 | + this->session_id = substr(this->full_session_id, 0, 8); |
| 97 | + |
| 98 | + this->next_id_str = json(copyinstr(arg1), "ok.next_job_id"); |
| 99 | + this->next_id_value = strtoll(this->next_id_str); |
| 100 | + |
| 101 | + if (last_id[this->session_id] == 0) { |
| 102 | + this->delta = 0; |
| 103 | + last_id[this->session_id] = this->next_id_value; |
| 104 | + } else { |
| 105 | + this->delta = this->next_id_value - last_id[this->session_id]; |
| 106 | + } |
| 107 | + |
| 108 | + /* Total of extents live repaired */ |
| 109 | + this->elr = strtoll(json(copyinstr(arg1), "ok.ds_extents_repaired[0]")) + |
| 110 | + strtoll(json(copyinstr(arg1), "ok.ds_extents_repaired[1]")) + |
| 111 | + strtoll(json(copyinstr(arg1), "ok.ds_extents_repaired[2]")); |
| 112 | + /* Total of extents not needing repair during live repair */ |
| 113 | + this->elc = strtoll(json(copyinstr(arg1), "ok.ds_extents_confirmed[0]")) + |
| 114 | + strtoll(json(copyinstr(arg1), "ok.ds_extents_confirmed[1]")) + |
| 115 | + strtoll(json(copyinstr(arg1), "ok.ds_extents_confirmed[2]")); |
| 116 | + |
| 117 | + this->connections = strtoll(json(copyinstr(arg1), "ok.ds_connected[0]")) + |
| 118 | + strtoll(json(copyinstr(arg1), "ok.ds_connected[1]")) + |
| 119 | + strtoll(json(copyinstr(arg1), "ok.ds_connected[2]")); |
| 120 | + |
| 121 | + printf("%5d %8s %3s %3s %3s %10s %5d %4d %5d %5d %5s %5s\n", |
| 122 | + pid, |
| 123 | + this->session_id, |
| 124 | + /* |
| 125 | + * State for the three downstairs |
| 126 | + */ |
| 127 | + this->d0, |
| 128 | + this->d1, |
| 129 | + this->d2, |
| 130 | + |
| 131 | + /* |
| 132 | + * Job ID, job delta and write bytes outstanding |
| 133 | + */ |
| 134 | + json(copyinstr(arg1), "ok.next_job_id"), |
| 135 | + this->delta, |
| 136 | + this->connections, |
| 137 | + this->elr, |
| 138 | + this->elc, |
| 139 | + json(copyinstr(arg1), "ok.ds_reconciled"), |
| 140 | + json(copyinstr(arg1), "ok.ds_reconcile_needed")); |
| 141 | +} |
0 commit comments