Skip to content

Commit 25165fb

Browse files
authored
multicore-sys-monitor v3.4.1: Smoother reading of all system data, even those related to networks (#8291)
1 parent 35d26cd commit 25165fb

File tree

5 files changed

+147
-60
lines changed

5 files changed

+147
-60
lines changed

multicore-sys-monitor@ccadeptic23/files/multicore-sys-monitor@ccadeptic23/6.4/applet.js

Lines changed: 120 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ class MCSM extends Applet.IconApplet {
172172
this.settings.bind("Disk_devicesList", "Disk_devicesList");
173173
this.settings.bind("labelsOn", "labelsOn");
174174
this.settings.bind("borderOn", "borderOn");
175+
this.settings.bind("graphStep", "graphStep");
175176
this.settings.bind("graphSpacing", "graphSpacing");
176177
this.settings.bind("percentAtEndOfLine", "percentAtEndOfLine");
177178
this.settings.bind("CPU_labelOn", "CPU_labelOn");
@@ -188,7 +189,7 @@ class MCSM extends Applet.IconApplet {
188189
this.settings.bind("backgroundColor", "backgroundColor");
189190
this.settings.bind("CPU_enabled", "CPU_enabled");
190191
this.settings.bind("CPU_squared", "CPU_squared");
191-
this.settings.bind("CPU_width", "CPU_width");
192+
this.settings.bind("CPU_width", "CPU_width", () => { this.adjust_CPU_width() });
192193
this.settings.bind("CPU_mergeAll", "CPU_mergeAll");
193194
this.settings.bind("CPU_color0", "CPU_color0");
194195
this.settings.bind("CPU_color1", "CPU_color1");
@@ -201,7 +202,7 @@ class MCSM extends Applet.IconApplet {
201202
this.settings.bind("CPU_activity_80_100", "CPU_activity_80_100");
202203
this.settings.bind("Mem_enabled", "Mem_enabled");
203204
this.settings.bind("Mem_squared", "Mem_squared");
204-
this.settings.bind("Mem_width", "Mem_width");
205+
this.settings.bind("Mem_width", "Mem_width", () => { this.adjust_Mem_width() });
205206
this.settings.bind("Mem_startAt12Oclock", "Mem_startAt12Oclock");
206207
this.settings.bind("Mem_colorUsedup", "Mem_colorUsedup");
207208
this.settings.bind("Mem_colorCache", "Mem_colorCache");
@@ -211,20 +212,20 @@ class MCSM extends Applet.IconApplet {
211212
this.settings.bind("Mem_swapWidth", "Mem_swapWidth");
212213
this.settings.bind("Net_enabled", "Net_enabled");
213214
this.settings.bind("Net_squared", "Net_squared");
214-
this.settings.bind("Net_width", "Net_width");
215+
this.settings.bind("Net_width", "Net_width", () => { this.adjust_Net_width() });
215216
this.settings.bind("Net_mergeAll", "Net_mergeAll");
216217
this.settings.bind("Net_autoscale", "Net_autoscale");
217218
this.settings.bind("Net_logscale", "Net_logscale");
218219
this.settings.bind("Disk_enabled", "Disk_enabled");
219220
this.settings.bind("Disk_squared", "Disk_squared");
220-
this.settings.bind("Disk_width", "Disk_width");
221+
this.settings.bind("Disk_width", "Disk_width", () => { this.adjust_Disk_width() });
221222
this.settings.bind("Disk_mergeAll", "Disk_mergeAll");
222223
this.settings.bind("Disk_autoscale", "Disk_autoscale");
223224
this.settings.bind("Disk_logscale", "Disk_logscale");
224225
this.settings.bind("DiskUsage_enabled", "DiskUsage_enabled");
225226
this.settings.bind("DiskUsage_labelOn", "DiskUsage_labelOn");
226227
this.settings.bind("DiskUsage_squared", "DiskUsage_squared");
227-
this.settings.bind("DiskUsage_width", "DiskUsage_width");
228+
this.settings.bind("DiskUsage_width", "DiskUsage_width", () => { this.adjust_DiskUsage_width() });
228229
this.settings.bind("DiskUsage_mergeAll", "DiskUsage_mergeAll");
229230
//this.settings.bind("DiskUsage_chartType", "DiskUsage_chartType");
230231
this.DiskUsage_chartType = "bar";
@@ -291,6 +292,7 @@ class MCSM extends Applet.IconApplet {
291292
this.multiCpuProvider = new MultiCpuDataProvider(this);
292293
this.swapProvider = new SwapDataProvider(this);
293294
this.buffcachesharedProvider = new BufferCacheSharedDataProvider(this);
295+
this.lastDataNet = {};
294296
this.networkProvider = new NetDataProvider(this);
295297
this.diskProvider = new DiskDataProvider(this);
296298
this.diskUsageProvider = new DiskUsageDataProvider(this);
@@ -323,6 +325,51 @@ class MCSM extends Applet.IconApplet {
323325
this.actor.add_actor(this.graphArea);
324326
this.graphArea.connect('repaint', (area) => this.onGraphRepaint(area));
325327
}
328+
329+
adjust_CPU_width() {
330+
if (this.graphStep === 1) return;
331+
let CPU_width = Math.max(
332+
Math.min(this.graphStep, 16),
333+
Math.round(this.CPU_width / this.graphStep) * this.graphStep
334+
);
335+
this.CPU_width = CPU_width;
336+
}
337+
338+
adjust_Mem_width() {
339+
if (this.graphStep === 1) return;
340+
let Mem_width = Math.max(
341+
Math.min(this.graphStep, 16),
342+
Math.round(this.Mem_width / this.graphStep) * this.graphStep
343+
);
344+
this.Mem_width = Mem_width;
345+
}
346+
347+
adjust_Net_width() {
348+
if (this.graphStep === 1) return;
349+
let Net_width = Math.max(
350+
Math.min(this.graphStep, 16),
351+
Math.round(this.Net_width / this.graphStep) * this.graphStep
352+
);
353+
this.Net_width = Net_width;
354+
}
355+
356+
adjust_Disk_width() {
357+
if (this.graphStep === 1) return;
358+
let Disk_width = Math.max(
359+
Math.min(this.graphStep, 16),
360+
Math.round(this.Disk_width / this.graphStep) * this.graphStep
361+
);
362+
this.Disk_width = Disk_width;
363+
}
364+
365+
adjust_DiskUsage_width() {
366+
if (this.graphStep === 1) return;
367+
let DiskUsage_width = Math.max(
368+
Math.min(this.graphStep, 16),
369+
Math.round(this.DiskUsage_width / this.graphStep) * this.graphStep
370+
);
371+
this.DiskUsage_width = DiskUsage_width;
372+
}
326373

327374
set_panelHeight() {
328375
this.iconSize = this.getPanelIconSize(St.IconType.FULLCOLOR);
@@ -842,7 +889,8 @@ class MCSM extends Applet.IconApplet {
842889
idleValue = 1 * idleValue;
843890
let total = totalValue - this.oldCPU_Total_Values[0];
844891
let idle = idleValue - this.oldCPU_Idle_Values[0];
845-
data.push((total - idle) / total);
892+
if (total != 0)
893+
data.push((total - idle) / total);
846894
this.oldCPU_Total_Values[0] = totalValue;
847895
this.oldCPU_Idle_Values[0] = idleValue;
848896
for (let i=1, len=values.length; i < len; i++) {
@@ -864,7 +912,8 @@ class MCSM extends Applet.IconApplet {
864912
i++;
865913
continue;
866914
}
867-
data.push((total - idle) / total);
915+
if (total != 0)
916+
data.push((total - idle) / total);
868917
i++;
869918
}
870919
}
@@ -879,51 +928,16 @@ class MCSM extends Applet.IconApplet {
879928
}
880929
});
881930
}
882-
883-
get_net_info() {
884-
if (!this.isRunning) return;
885-
if (!this.Net_enabled) return;
886-
const net_dir_path = "/sys/class/net";
887-
let old, duration;
888-
if (DEBUG) old = Date.now();
889-
var ret = "";
890-
if (GLib.file_test(NETWORK_DEVICES_STATUS_PATH, GLib.FileTest.EXISTS)) {
891-
let [success, line] = GLib.file_get_contents(NETWORK_DEVICES_STATUS_PATH);
892-
let names_status = to_string(line).trim().split(" ");
893-
for (let name_status of names_status) {
894-
let [name, status] = name_status.split(":");
895-
if (status == "up") {
896-
let rx_bytes_path = `${net_dir_path}/${name}/statistics/rx_bytes`;
897-
let tx_bytes_path = `${net_dir_path}/${name}/statistics/tx_bytes`;
898-
let [rx_success, rx_bytes] = GLib.file_get_contents(rx_bytes_path);
899-
let [tx_success, tx_bytes] = GLib.file_get_contents(tx_bytes_path);
900-
rx_bytes = to_string(rx_bytes).trim();
901-
tx_bytes = to_string(tx_bytes).trim();
902-
ret = ret + `${name}:${rx_bytes}:${tx_bytes} `;
903-
}
904-
}
905-
} else {
906-
const net_dir = Gio.file_new_for_path(net_dir_path);
907-
const children = net_dir.enumerate_children("standard::name,standard::type", Gio.FileQueryInfoFlags.NONE, null);
908-
for (let child of children) {
909-
let name = child.get_name();
910-
let operstate_file_path = `${net_dir_path}/${name}/operstate`;
911-
let [net_success, net_status] = GLib.file_get_contents(operstate_file_path);
912-
net_status = to_string(net_status).trim();
913-
if (net_status == "up") {
914-
let rx_bytes_path = `${net_dir_path}/${name}/statistics/rx_bytes`;
915-
let tx_bytes_path = `${net_dir_path}/${name}/statistics/tx_bytes`;
916-
let [rx_success, rx_bytes] = GLib.file_get_contents(rx_bytes_path);
917-
let [tx_success, tx_bytes] = GLib.file_get_contents(tx_bytes_path);
918-
rx_bytes = to_string(rx_bytes).trim();
919-
tx_bytes = to_string(tx_bytes).trim();
920-
ret = ret + `${name}:${rx_bytes}:${tx_bytes} `;
921-
}
922-
}
923-
children.close(null);
931+
932+
set_net_devices_data() {
933+
let dataNet = JSON.parse(JSON.stringify(this.lastDataNet, null, 4));
934+
var datastring = "";
935+
for (let name of Object.keys(dataNet)) {
936+
let rx = dataNet[name]["rx"];
937+
let tx = dataNet[name]["tx"];
938+
datastring += name + ":" + rx + ":" + tx + " ";
924939
}
925-
926-
ret = ret.trim();
940+
datastring = datastring.trim();
927941
var allowedInterfaces = [];
928942
var names = {};
929943
for (let dev of this.Net_devicesList) {
@@ -934,7 +948,7 @@ class MCSM extends Applet.IconApplet {
934948
}
935949
var data = [];
936950
var disabledDevices = [];
937-
let netInfo = ret.split(" ");
951+
let netInfo = datastring.split(" ");
938952
var sum_rx = 0;
939953
var sum_tx = 0;
940954
for (let info of netInfo) {
@@ -965,6 +979,60 @@ class MCSM extends Applet.IconApplet {
965979
disabledDevices = [];
966980
}
967981
this.networkProvider.setData(data, disabledDevices);
982+
}
983+
984+
get_net_info() {
985+
if (!this.isRunning) return;
986+
if (!this.Net_enabled) return;
987+
const net_dir_path = "/sys/class/net";
988+
let old, duration;
989+
if (DEBUG) old = Date.now();
990+
if (GLib.file_test(NETWORK_DEVICES_STATUS_PATH, GLib.FileTest.EXISTS)) {
991+
readFileAsync(NETWORK_DEVICES_STATUS_PATH).then( (result) => {
992+
let names_status = result.trim().split(" ");
993+
for (let name_status of names_status) {
994+
let [name, status] = name_status.split(":");
995+
if (status == "up") {
996+
var rx_bytes = "", tx_bytes = "";
997+
let rx_bytes_path = `${net_dir_path}/${name}/statistics/rx_bytes`;
998+
let tx_bytes_path = `${net_dir_path}/${name}/statistics/tx_bytes`;
999+
readFileAsync(rx_bytes_path).then( (outputR) => {
1000+
rx_bytes = outputR.trim();
1001+
readFileAsync(tx_bytes_path).then( (outputT) => {
1002+
tx_bytes = outputT.trim();
1003+
this.lastDataNet[""+name] = {"rx": parseInt(rx_bytes), "tx": parseInt(tx_bytes)};
1004+
});
1005+
});
1006+
}
1007+
}
1008+
});
1009+
} else {
1010+
const net_dir = Gio.file_new_for_path(net_dir_path);
1011+
const children = net_dir.enumerate_children("standard::name,standard::type", Gio.FileQueryInfoFlags.NONE, null);
1012+
for (let child of children) {
1013+
let name = child.get_name();
1014+
let operstate_file_path = `${net_dir_path}/${name}/operstate`;
1015+
readFileAsync(operstate_file_path).then( (output) => {
1016+
let net_status = output.trim();
1017+
if (net_status == "up") {
1018+
let rx_bytes_path = `${net_dir_path}/${name}/statistics/rx_bytes`;
1019+
let tx_bytes_path = `${net_dir_path}/${name}/statistics/tx_bytes`;
1020+
1021+
readFileAsync(rx_bytes_path).then( (outputR) => {
1022+
let rx_bytes = outputR.trim();
1023+
readFileAsync(tx_bytes_path).then( (outputT) => {
1024+
let tx_bytes = outputT.trim();
1025+
this.lastDataNet[""+name] = {"rx": parseInt(rx_bytes), "tx": parseInt(tx_bytes)};
1026+
});
1027+
});
1028+
}
1029+
});
1030+
1031+
}
1032+
children.close(null);
1033+
}
1034+
this.set_net_devices_data();
1035+
9681036
if (DEBUG) {
9691037
duration = Date.now() - old;
9701038
global.log(UUID + " - get_net_info Duration: " + duration + " ms.");

multicore-sys-monitor@ccadeptic23/files/multicore-sys-monitor@ccadeptic23/6.4/settings-schema.json

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
"removeEnlightenment",
7878
"labelsOn",
7979
"borderOn",
80+
"graphStep",
8081
"graphSpacing",
8182
"thickness",
8283
"useIconSize",
@@ -297,6 +298,20 @@
297298
"default": false,
298299
"description": "Add a border to each graph"
299300
},
301+
"graphStep": {
302+
"type": "combobox",
303+
"default": 16,
304+
"options": {
305+
"1px": 1,
306+
"2px": 2,
307+
"4px": 4,
308+
"8px": 8,
309+
"16px": 16,
310+
"32px": 32,
311+
"64px": 64
312+
},
313+
"description": "Step for the width of a graph"
314+
},
300315
"graphSpacing": {
301316
"type": "scale",
302317
"default": 1,
@@ -392,7 +407,7 @@
392407
"description": "Width",
393408
"min": 16,
394409
"max": 320,
395-
"step": 16,
410+
"step": 1,
396411
"show-value": true,
397412
"dependency": "!CPU_squared"
398413
},
@@ -483,7 +498,7 @@
483498
"description": "Width",
484499
"min": 16,
485500
"max": 320,
486-
"step": 16,
501+
"step": 1,
487502
"show-value": true,
488503
"dependency": "!Mem_squared"
489504
},
@@ -550,7 +565,7 @@
550565
"description": "Width",
551566
"min": 16,
552567
"max": 320,
553-
"step": 16,
568+
"step": 1,
554569
"show-value": true,
555570
"dependency": "!Net_squared"
556571
},
@@ -713,7 +728,7 @@
713728
"description": "Width",
714729
"min": 16,
715730
"max": 320,
716-
"step": 16,
731+
"step": 1,
717732
"show-value": true,
718733
"dependency": "!Disk_squared"
719734
},
@@ -894,7 +909,7 @@
894909
"description": "Width",
895910
"min": 16,
896911
"max": 320,
897-
"step": 16,
912+
"step": 1,
898913
"show-value": true,
899914
"dependency": "!DiskUsage_squared"
900915
},

multicore-sys-monitor@ccadeptic23/files/multicore-sys-monitor@ccadeptic23/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### v3.4.1~20260208
2+
* Smoother reading of all system data, even those related to networks.
3+
* The box width can be adjusted in increments of 1, 2, 4, 8, 16, 32, and 64 pixels in the General tab of this applet's settings.
4+
15
### v3.4.0~20260203
26
* Smoother reading of most system data.
37
* Uses readFileAsync module.

multicore-sys-monitor@ccadeptic23/files/multicore-sys-monitor@ccadeptic23/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"uuid": "multicore-sys-monitor@ccadeptic23",
33
"name": "Multi-Core System Monitor",
4-
"version": "3.4.0",
4+
"version": "3.4.1",
55
"description": "Displays in realtime the cpu usage for each core/cpu and overall memory usage.",
66
"multiversion": true,
77
"cinnamon-version": [

multicore-sys-monitor@ccadeptic23/files/multicore-sys-monitor@ccadeptic23/po/fr.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ msgstr ""
99
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-applets/"
1010
"issues\n"
1111
"POT-Creation-Date: 2026-01-07 00:52+0100\n"
12-
"PO-Revision-Date: 2026-01-07 00:53+0100\n"
12+
"PO-Revision-Date: 2026-02-07 22:09+0100\n"
1313
"Last-Translator: claudiux\n"
1414
"Language-Team: \n"
1515
"Language: fr\n"
@@ -475,7 +475,7 @@ msgstr "Étiquettes"
475475

476476
#. 6.4->settings-schema.json->borderOn->description
477477
msgid "Add a border to each graph"
478-
msgstr "Ajouter une bordure à chaque grapique"
478+
msgstr "Ajouter une bordure à chaque graphique"
479479

480480
#. 6.4->settings-schema.json->graphSpacing->description
481481
msgid "Graph spacing"

0 commit comments

Comments
 (0)