feat: Live-update IO stats (#225)

This commit is contained in:
Maciej Hirsz
2020-01-30 15:39:46 +01:00
committed by GitHub
parent 19f57d71be
commit 0a6cd08747
3 changed files with 24 additions and 3 deletions
+2 -1
View File
@@ -187,7 +187,8 @@ export type Message =
| Variants.AfgReceivedPrecommit
| Variants.AfgAuthoritySet
| Variants.StaleNodeMessage
| Variants.PongMessage;
| Variants.PongMessage
| Variants.NodeIOMessage;
/**
* Data type to be sent to the feed. Passing through strings means we can only serialize once,
+19 -1
View File
@@ -237,7 +237,25 @@ export class Connection {
nodes.mutAndMaybeSort(
id,
(node) => node.updateHardware(nodeHardware),
sortByColumn === Column.CPU || sortByColumn === Column.MEM || sortByColumn === Column.UPLOAD || sortByColumn === Column.DOWNLOAD,
sortByColumn === Column.CPU
|| sortByColumn === Column.MEM
|| sortByColumn === Column.UPLOAD
|| sortByColumn === Column.DOWNLOAD,
);
break;
}
case Actions.NodeIO: {
const [id, nodeIO] = message.payload;
nodes.mutAndMaybeSort(
id,
(node) => node.updateIO(nodeIO),
sortByColumn === Column.STATE_CACHE
|| sortByColumn === Column.DB_CACHE
|| sortByColumn === Column.DISK_READ
|| sortByColumn === Column.DISK_WRITE,
);
break;
@@ -405,7 +405,9 @@ function formatMemory(kbs: number, stamp: Maybe<Types.Timestamp>): string {
function formatBytes(bytes: number, stamp: Maybe<Types.Timestamp>): string {
const ago = stamp ? ` (${formatStamp(stamp)})` : '';
if (bytes >= 1024 * 1024) {
if (bytes >= 1024 * 1024 * 1024) {
return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB${ago}`;
} else if (bytes >= 1024 * 1024) {
return `${(bytes / (1024 * 1024)).toFixed(1)} MB${ago}`;
} else if (bytes >= 1000) {
return `${(bytes / 1024).toFixed(1)} kB${ago}`;