mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-10-28 23:05:01 -04:00
add interface speed for networking (windows for now) #7354
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
parent
a051cb5548
commit
b50d07c183
@ -5908,6 +5908,23 @@ function sendNetworkUpdate(force) {
|
||||
try {
|
||||
// Update the network interfaces information data
|
||||
var netInfo = { netif2: require('os').networkInterfaces() };
|
||||
if (process.platform == 'win32') {
|
||||
try {
|
||||
var ret = require('win-wmi').query('ROOT\\CIMV2', 'SELECT InterfaceIndex,NetConnectionID,Speed FROM Win32_NetworkAdapter', ['InterfaceIndex','NetConnectionID','Speed']);
|
||||
if (ret[0]) {
|
||||
var speedMap = {};
|
||||
for (var i = 0; i < ret.length; i++) speedMap[ret[i].InterfaceIndex] = ret[i].Speed;
|
||||
var adapterNames = Object.keys(netInfo.netif2);
|
||||
for (var j = 0; j < adapterNames.length; j++) {
|
||||
var interfaces = netInfo.netif2[adapterNames[j]];
|
||||
for (var k = 0; k < interfaces.length; k++) {
|
||||
var iface = interfaces[k], speed = speedMap[iface.index] || 0;
|
||||
iface.speed = parseInt(speed); // bits per seconds
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(ex) { }
|
||||
}
|
||||
if (netInfo.netif2) {
|
||||
netInfo.action = 'netinfo';
|
||||
var netInfoStr = JSON.stringify(netInfo);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -2919,6 +2919,14 @@
|
||||
return format("{0}g left", Math.round(bytes / 1024 / 1024 / 1024));
|
||||
}
|
||||
|
||||
function getNetworkSpeed(bitsPerSecond) {
|
||||
if (bitsPerSecond <= 0) return "0 bps";
|
||||
if (bitsPerSecond < 1000) return format("{0} bps", bitsPerSecond);
|
||||
if (bitsPerSecond < 1000000) return format("{0} Kbps", Math.round(bitsPerSecond / 1000));
|
||||
if (bitsPerSecond < 1000000000) return format("{0} Mbps", Math.round(bitsPerSecond / 1000000));
|
||||
return format("{0} Gbps", (bitsPerSecond / 1000000000).toFixed(1));
|
||||
}
|
||||
|
||||
function p5getQuotabar(f) {
|
||||
while (f.t > 1 && f.t != 4) { f = f.parent; }
|
||||
if ((f.t != 1 && f.t != 4) || (f.maxbytes == null)) return '';
|
||||
@ -6436,6 +6444,9 @@
|
||||
x += addDetailItem("MAC Layer", format("MAC: {0}", EscapeHtml(m[0].mac)));
|
||||
}
|
||||
}
|
||||
if (typeof m[0].speed == 'number' && (m[0].speed != 9223372036854775807 && m[0].speed > 0)) {
|
||||
x += addDetailItem("Interface Speed", format("{0}", getNetworkSpeed(m[0].speed)));
|
||||
}
|
||||
for (var j = 0; j < m.length; j++) {
|
||||
var iplayer = m[j], items = [];
|
||||
if (iplayer.address) { items.push(format("IP: {0}", EscapeHtml(iplayer.address))); }
|
||||
|
||||
@ -12324,6 +12324,9 @@
|
||||
x += addDetailItem("MAC Layer", format("MAC: {0}", EscapeHtml(m[0].mac)));
|
||||
}
|
||||
}
|
||||
if (typeof m[0].speed == 'number' && (m[0].speed != 9223372036854775807 && m[0].speed > 0)) {
|
||||
x += addDetailItem("Interface Speed", format("{0}", getNetworkSpeed(m[0].speed)));
|
||||
}
|
||||
for (var j = 0; j < m.length; j++) {
|
||||
var iplayer = m[j], items = [];
|
||||
if (iplayer.address) { items.push(format("IP: {0}", EscapeHtml(iplayer.address))); }
|
||||
@ -15022,6 +15025,14 @@
|
||||
return format("{0} Gb", round(bytes / 1024 / 1024 / 1024, 1));
|
||||
}
|
||||
|
||||
function getNetworkSpeed(bitsPerSecond) {
|
||||
if (bitsPerSecond <= 0) return "0 bps";
|
||||
if (bitsPerSecond < 1000) return format("{0} bps", bitsPerSecond);
|
||||
if (bitsPerSecond < 1000000) return format("{0} Kbps", Math.round(bitsPerSecond / 1000));
|
||||
if (bitsPerSecond < 1000000000) return format("{0} Mbps", Math.round(bitsPerSecond / 1000000));
|
||||
return format("{0} Gbps", (bitsPerSecond / 1000000000).toFixed(1));
|
||||
}
|
||||
|
||||
function p5getQuotabar(f) {
|
||||
while (f.t > 1 && f.t != 4) { f = f.parent; }
|
||||
if ((f.t != 1 && f.t != 4) || (f.maxbytes == null)) return '';
|
||||
|
||||
@ -13339,6 +13339,9 @@
|
||||
x += addDetailItem("MAC Layer", format("MAC: {0}", EscapeHtml(m[0].mac)));
|
||||
}
|
||||
}
|
||||
if (typeof m[0].speed == 'number' && (m[0].speed != 9223372036854775807 && m[0].speed > 0)) {
|
||||
x += addDetailItem("Interface Speed", format("{0}", getNetworkSpeed(m[0].speed)));
|
||||
}
|
||||
for (var j = 0; j < m.length; j++) {
|
||||
var iplayer = m[j], items = [];
|
||||
if (iplayer.address) { items.push(format("IP: {0}", EscapeHtml(iplayer.address))); }
|
||||
@ -16328,6 +16331,14 @@
|
||||
return format("{0} Gb", round(bytes / 1024 / 1024 / 1024, 1));
|
||||
}
|
||||
|
||||
function getNetworkSpeed(bitsPerSecond) {
|
||||
if (bitsPerSecond <= 0) return "0 bps";
|
||||
if (bitsPerSecond < 1000) return format("{0} bps", bitsPerSecond);
|
||||
if (bitsPerSecond < 1000000) return format("{0} Kbps", Math.round(bitsPerSecond / 1000));
|
||||
if (bitsPerSecond < 1000000000) return format("{0} Mbps", Math.round(bitsPerSecond / 1000000));
|
||||
return format("{0} Gbps", (bitsPerSecond / 1000000000).toFixed(1));
|
||||
}
|
||||
|
||||
function p5getQuotabar(f) {
|
||||
while (f.t > 1 && f.t != 4) { f = f.parent; }
|
||||
if ((f.t != 1 && f.t != 4) || (f.maxbytes == null)) return '';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user