Skip to content

Commit e01e11e

Browse files
committed
Implement I/O mirror graph mode for Disk and Network I/O meters
1 parent 2150b2d commit e01e11e

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

DiskIOMeter.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ static void DiskIOMeter_updateValues(Meter* this) {
7272
} else {
7373
diff = 0;
7474
}
75+
this->values[1] = diff;
7576
Meter_humanUnit(cached_read_diff_str, diff, sizeof(cached_read_diff_str));
7677

7778
if (data.totalBytesWritten > cached_write_total) {
@@ -81,6 +82,7 @@ static void DiskIOMeter_updateValues(Meter* this) {
8182
} else {
8283
diff = 0;
8384
}
85+
this->values[2] = diff;
8486
Meter_humanUnit(cached_write_diff_str, diff, sizeof(cached_write_diff_str));
8587

8688
cached_utilisation_diff = 0.0;
@@ -156,8 +158,13 @@ const MeterClass DiskIOMeter_class = {
156158
},
157159
.updateValues = DiskIOMeter_updateValues,
158160
.defaultMode = TEXT_METERMODE,
159-
.supportedModes = METERMODE_DEFAULT_SUPPORTED,
160-
.maxItems = 1,
161+
.supportedModes =
162+
(1 << BAR_METERMODE) |
163+
(1 << TEXT_METERMODE) |
164+
(1 << GRAPH_METERMODE) |
165+
(1 << LED_METERMODE) |
166+
(1 << IO_METERMODE),
167+
.maxItems = 3,
161168
.total = 1.0,
162169
.attributes = DiskIOMeter_attributes,
163170
.name = "DiskIO",

NetworkIOMeter.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ static void NetworkIOMeter_updateValues(Meter* this) {
109109
cached_txp_total = data.packetsTransmitted;
110110
}
111111

112-
this->values[0] = cached_rxb_diff;
113-
this->values[1] = cached_txb_diff;
112+
this->values[0] = cached_rxb_diff + cached_txb_diff;
113+
this->values[1] = cached_rxb_diff;
114+
this->values[2] = cached_txb_diff;
114115
if (cached_rxb_diff + cached_txb_diff > this->total) {
115116
this->total = cached_rxb_diff + cached_txb_diff;
116117
}
@@ -169,8 +170,13 @@ const MeterClass NetworkIOMeter_class = {
169170
},
170171
.updateValues = NetworkIOMeter_updateValues,
171172
.defaultMode = TEXT_METERMODE,
172-
.supportedModes = METERMODE_DEFAULT_SUPPORTED,
173-
.maxItems = 2,
173+
.supportedModes =
174+
(1 << BAR_METERMODE) |
175+
(1 << TEXT_METERMODE) |
176+
(1 << GRAPH_METERMODE) |
177+
(1 << LED_METERMODE) |
178+
(1 << IO_METERMODE),
179+
.maxItems = 3,
174180
.total = 100.0,
175181
.attributes = NetworkIOMeter_attributes,
176182
.name = "NetworkIO",

0 commit comments

Comments
 (0)