pyre-cli 10.3.0 → 10.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -0
- package/dist/{alertChannels-TPSQIJ7S.js → alertChannels-MNX4XH6J.js} +1 -0
- package/dist/{anomaliesCmd-25OFKYPK.js → anomaliesCmd-HHTY5LYL.js} +2 -0
- package/dist/benchGitCmd-HIXUC5EK.js +87 -0
- package/dist/{benchmarkCmd-A3ETK6VY.js → benchmarkCmd-B7DLP2VC.js} +2 -0
- package/dist/{blender-FGH3ASEQ.js → blender-6ZX5SPYC.js} +3 -1
- package/dist/{brewHealth-P2GW5Y5C.js → brewHealth-VFW33QB3.js} +1 -0
- package/dist/budgetCmd-TGO3RYLN.js +11 -0
- package/dist/{buildCmd-CDPZ2ZFA.js → buildCmd-E7KUCFYG.js} +3 -1
- package/dist/{checkCmd-WQAHAUWO.js → checkCmd-QLYTP77Y.js} +5 -3
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/{chunk-VIACN2RU.js → chunk-FYCBGUTW.js} +41 -19
- package/dist/chunk-JH7P6KLN.js +143 -0
- package/dist/{chunk-QM5L43EK.js → chunk-LDJB5V4N.js} +5 -1
- package/dist/chunk-NMGQVRCA.js +111 -0
- package/dist/chunk-OCL7P7N7.js +936 -0
- package/dist/{chunk-23YWCI3O.js → chunk-QEH4LR6P.js} +28 -686
- package/dist/{chunk-KVUMOA6C.js → chunk-RKPGPVTO.js} +77 -4
- package/dist/chunk-UF3XQ3R3.js +3800 -0
- package/dist/{collectors-JDN5Y7EV.js → collectors-V7SCIIDH.js} +5 -3
- package/dist/{completions-ZVTNE52B.js → completions-FTPXDSR2.js} +44 -3
- package/dist/{config-J4YMADEF.js → config-5WW5M63G.js} +2 -1
- package/dist/containersCmd-FSMYOBG2.js +84 -0
- package/dist/{doctor-LHFW4UJP.js → doctor-O4DIAMHK.js} +3 -2
- package/dist/{explainCmd-MF6PIMLW.js → explainCmd-7PBPA7O5.js} +1 -0
- package/dist/{extensions-XJGHG7X3.js → extensions-QQEV7U3D.js} +1 -0
- package/dist/{firebaseSync-ON3RZ6KX.js → firebaseSync-LRN67UTV.js} +2 -0
- package/dist/flightRecorder-GJIAQOXC.js +162 -0
- package/dist/index.js +736 -4125
- package/dist/inspectCmd-5FXJBJTK.js +137 -0
- package/dist/menu-AJFGDLBP.js +1233 -0
- package/dist/monitors/platform/windows-ui.ps1 +31 -29
- package/dist/{netUsageCmd-67IBZZYN.js → netUsageCmd-JP6YKBPF.js} +7 -5
- package/dist/optimizeCmd-WZKLFYZU.js +1110 -0
- package/dist/{pipeCmd-2N4JPKYE.js → pipeCmd-CPK6FVKB.js} +5 -3
- package/dist/playbookCmd-FRROIEXR.js +145 -0
- package/dist/{profileProcCmd-N4H6MCBT.js → profileProcCmd-5Y3733E7.js} +64 -13
- package/dist/{prometheus-5BL5PVLC.js → prometheus-CYNUR3QT.js} +1 -0
- package/dist/{prometheusCmd-LEUM5WCZ.js → prometheusCmd-G2CSEZRQ.js} +5 -3
- package/dist/{replayCmd-Z3PYXY7V.js → replayCmd-ODB5SPOQ.js} +25 -6
- package/dist/{run-HOGQDDTA.js → run-UJQYT2TO.js} +1 -0
- package/dist/{serveCmd-L7LVJOZN.js → serveCmd-KDPWLVQI.js} +5 -3
- package/dist/{service-7GIX3YNC.js → service-LIYYR3UI.js} +1 -0
- package/dist/{smartCmd-ODWKSFNG.js → smartCmd-2BJJ37GV.js} +130 -5
- package/dist/statuslineCmd-EUKYRR2G.js +75 -0
- package/dist/{stressCmd-MFXMFXYX.js → stressCmd-GKHGY26X.js} +2 -0
- package/dist/{syncCmd-42IRF633.js → syncCmd-MIBFKX24.js} +16 -5
- package/dist/topoCmd-RTXQJ6XA.js +189 -0
- package/dist/{updateCheck-52X6LJG5.js → updateCheck-LJHEMG3G.js} +2 -0
- package/dist/{watchdogCmd-6GR4UN6B.js → watchdogCmd-XM6OPTKM.js} +41 -6
- package/dist/{wizard-JQMQWFAW.js → wizard-PRDOJROQ.js} +2 -1
- package/package.json +2 -2
- package/src/benchGitCmd.ts +110 -0
- package/src/budgetCmd.ts +199 -0
- package/src/completions.ts +42 -3
- package/src/containersCmd.ts +106 -0
- package/src/doctor.ts +86 -6
- package/src/easy_features.test.ts +83 -0
- package/src/flightRecorder.ts +214 -0
- package/src/index.ts +181 -8
- package/src/inspectCmd.ts +165 -0
- package/src/live/input.ts +70 -3
- package/src/live/render.ts +1 -1
- package/src/live/state.ts +2 -1
- package/src/menu/commands.ts +754 -0
- package/src/menu/index.ts +358 -0
- package/src/menu/render.ts +272 -0
- package/src/menu/types.ts +63 -0
- package/src/menu.test.ts +110 -0
- package/src/monitors/blender.ts +49 -19
- package/src/monitors/buildTracker.ts +72 -54
- package/src/monitors/platform/windows-ui.ps1 +31 -29
- package/src/monitors/platform/windows.ts +613 -280
- package/src/optimizeCmd.ts +1248 -0
- package/src/platform.test.ts +135 -0
- package/src/playbookCmd.ts +156 -0
- package/src/power_features.test.ts +251 -0
- package/src/profileProcCmd.ts +68 -21
- package/src/replayCmd.ts +15 -6
- package/src/smartCmd.ts +149 -10
- package/src/state/config.ts +13 -0
- package/src/statuslineCmd.ts +87 -0
- package/src/syncCmd.ts +12 -0
- package/src/topoCmd.ts +83 -50
- package/src/watchdogCmd.ts +40 -3
- package/src/xbar.ts +195 -17
- package/dist/chunk-M73HCQD2.js +0 -95
- package/dist/topoCmd-DZ3YS5IL.js +0 -148
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
2
|
collectBuilds
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NMGQVRCA.js";
|
|
4
4
|
import {
|
|
5
5
|
collectBlenderRenders
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-FYCBGUTW.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
collectWindowsBattery,
|
|
9
|
+
collectWindowsCpu,
|
|
10
|
+
collectWindowsDisk,
|
|
11
|
+
collectWindowsGpu,
|
|
12
|
+
collectWindowsMemory,
|
|
13
|
+
collectWindowsNetwork,
|
|
14
|
+
collectWindowsPackets,
|
|
15
|
+
collectWindowsPower,
|
|
16
|
+
collectWindowsProcesses,
|
|
17
|
+
collectWindowsSystem,
|
|
18
|
+
collectWindowsTasks,
|
|
19
|
+
collectWindowsThermal,
|
|
20
|
+
getWindowsDisplayInfo
|
|
21
|
+
} from "./chunk-OCL7P7N7.js";
|
|
22
|
+
import {
|
|
23
|
+
run
|
|
10
24
|
} from "./chunk-MZO5QKUR.js";
|
|
11
25
|
|
|
12
26
|
// src/monitors/collectors.ts
|
|
13
27
|
import chalk from "chalk";
|
|
14
|
-
import
|
|
28
|
+
import os2 from "os";
|
|
15
29
|
import path3 from "path";
|
|
16
30
|
import { fileURLToPath } from "url";
|
|
17
31
|
import fs3 from "fs";
|
|
@@ -816,678 +830,6 @@ async function getLinuxDisplayInfo() {
|
|
|
816
830
|
return displays;
|
|
817
831
|
}
|
|
818
832
|
|
|
819
|
-
// src/monitors/platform/windows.ts
|
|
820
|
-
import os2 from "os";
|
|
821
|
-
var prevNetSample2 = null;
|
|
822
|
-
function safeParseInt(s, def = 0) {
|
|
823
|
-
if (!s) return def;
|
|
824
|
-
const n = parseInt(s, 10);
|
|
825
|
-
return Number.isFinite(n) ? n : def;
|
|
826
|
-
}
|
|
827
|
-
async function getCimRow(className) {
|
|
828
|
-
const raw = await runPowerShell(
|
|
829
|
-
`Get-CimInstance -ClassName ${className} -ErrorAction SilentlyContinue | Select-Object -Property * -ExcludeProperty CIM* | ConvertTo-Csv -NoTypeInformation`,
|
|
830
|
-
""
|
|
831
|
-
);
|
|
832
|
-
const lines = raw.split("\n").filter((l) => l.trim().length > 0);
|
|
833
|
-
if (lines.length < 2) return {};
|
|
834
|
-
const headers = lines[0].split(",").map((h) => h.trim().replace(/^"|"$/g, ""));
|
|
835
|
-
const values = lines[1].split(",").map((v) => v.trim().replace(/^"|"$/g, ""));
|
|
836
|
-
const row = {};
|
|
837
|
-
headers.forEach((h, i) => {
|
|
838
|
-
row[h] = values[i] || "";
|
|
839
|
-
});
|
|
840
|
-
return row;
|
|
841
|
-
}
|
|
842
|
-
async function collectWindowsSystem() {
|
|
843
|
-
const hostname = os2.hostname();
|
|
844
|
-
const rel = os2.release();
|
|
845
|
-
const build = parseInt(rel.split(".")[2] || "0", 10);
|
|
846
|
-
let osName = "Windows";
|
|
847
|
-
if (build >= 22e3) {
|
|
848
|
-
osName = `Windows 11 (${rel})`;
|
|
849
|
-
} else if (rel.startsWith("10.0")) {
|
|
850
|
-
osName = `Windows 10 (${rel})`;
|
|
851
|
-
} else {
|
|
852
|
-
osName = `Windows (${rel})`;
|
|
853
|
-
}
|
|
854
|
-
const uptimeSec = Math.floor(os2.uptime());
|
|
855
|
-
const days = Math.floor(uptimeSec / 86400);
|
|
856
|
-
const hours = Math.floor(uptimeSec % 86400 / 3600);
|
|
857
|
-
const minutes = Math.floor(uptimeSec % 3600 / 60);
|
|
858
|
-
let uptime = "";
|
|
859
|
-
if (days > 0) uptime += `${days} ${days === 1 ? "day" : "days"}, `;
|
|
860
|
-
uptime += `${hours.toString().padStart(2, "0")}:${minutes.toString().padStart(2, "0")}`;
|
|
861
|
-
return { hostname, os: osName, uptime };
|
|
862
|
-
}
|
|
863
|
-
async function collectWindowsCpu(prevCpuTimesRef) {
|
|
864
|
-
const cpus = os2.cpus();
|
|
865
|
-
const cores = cpus.length || 1;
|
|
866
|
-
let brand = cpus[0]?.model || "Windows CPU";
|
|
867
|
-
let physicalCores = cores;
|
|
868
|
-
let frequency = cpus[0]?.speed || 0;
|
|
869
|
-
try {
|
|
870
|
-
const cpuRow = await getCimRow("Win32_Processor");
|
|
871
|
-
if (cpuRow.Name) brand = cpuRow.Name.trim();
|
|
872
|
-
if (cpuRow.NumberOfCores) physicalCores = safeParseInt(cpuRow.NumberOfCores, cores);
|
|
873
|
-
if (cpuRow.MaxClockSpeed) frequency = safeParseInt(cpuRow.MaxClockSpeed, frequency);
|
|
874
|
-
} catch {
|
|
875
|
-
}
|
|
876
|
-
const current = cpus.map((cpu) => ({
|
|
877
|
-
total: cpu.times.user + cpu.times.nice + cpu.times.sys + cpu.times.idle + cpu.times.irq,
|
|
878
|
-
idle: cpu.times.idle
|
|
879
|
-
}));
|
|
880
|
-
let coreUsage = [];
|
|
881
|
-
let usage = 0;
|
|
882
|
-
const prevCpuTimes2 = prevCpuTimesRef.current;
|
|
883
|
-
if (prevCpuTimes2 && prevCpuTimes2.length === current.length) {
|
|
884
|
-
coreUsage = current.map((c, i) => {
|
|
885
|
-
const prev = prevCpuTimes2[i];
|
|
886
|
-
const totalDelta = c.total - prev.total;
|
|
887
|
-
const idleDelta = c.idle - prev.idle;
|
|
888
|
-
if (totalDelta <= 0) return 0;
|
|
889
|
-
return Math.min(100, Math.max(0, Math.round((totalDelta - idleDelta) / totalDelta * 100)));
|
|
890
|
-
});
|
|
891
|
-
if (coreUsage.length > 0) {
|
|
892
|
-
usage = Math.round(coreUsage.reduce((a, b) => a + b, 0) / coreUsage.length);
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
prevCpuTimesRef.current = current;
|
|
896
|
-
const activeLoad = Math.round(usage / 100 * cores * 100) / 100;
|
|
897
|
-
const loadAvg = [activeLoad, activeLoad, activeLoad];
|
|
898
|
-
let temperature;
|
|
899
|
-
try {
|
|
900
|
-
const raw = await runPowerShell(
|
|
901
|
-
`(Get-Counter 'Thermal Zone Information(*)*' -ErrorAction SilentlyContinue).CounterSamples | Where-Object { $_.CookedValue -gt 200 -and $_.CookedValue -lt 400 } | Select-Object -First 1 -ExpandProperty CookedValue`,
|
|
902
|
-
""
|
|
903
|
-
).catch(() => "");
|
|
904
|
-
const tempK = parseFloat(raw);
|
|
905
|
-
if (tempK > 200 && tempK < 400) {
|
|
906
|
-
temperature = Math.round((tempK - 273.15) * 10) / 10;
|
|
907
|
-
}
|
|
908
|
-
} catch {
|
|
909
|
-
}
|
|
910
|
-
if (temperature === void 0) {
|
|
911
|
-
try {
|
|
912
|
-
const rawWmi = await run("wmic /namespace:\\\\root\\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature 2>nul", "", 1500);
|
|
913
|
-
const match = rawWmi.match(/(\d{3,4})/);
|
|
914
|
-
if (match) {
|
|
915
|
-
const kelvinTenths = parseInt(match[1], 10);
|
|
916
|
-
const c = Math.round((kelvinTenths - 2732) / 10 * 10) / 10;
|
|
917
|
-
if (c >= 15 && c <= 115) temperature = c;
|
|
918
|
-
}
|
|
919
|
-
} catch {
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
return {
|
|
923
|
-
brand,
|
|
924
|
-
cores,
|
|
925
|
-
physicalCores,
|
|
926
|
-
frequency,
|
|
927
|
-
usage,
|
|
928
|
-
loadAvg,
|
|
929
|
-
temperature,
|
|
930
|
-
coreUsage
|
|
931
|
-
};
|
|
932
|
-
}
|
|
933
|
-
async function collectWindowsMemory() {
|
|
934
|
-
const total = os2.totalmem();
|
|
935
|
-
const free = os2.freemem();
|
|
936
|
-
const used = Math.max(0, total - free);
|
|
937
|
-
const usagePercent = total > 0 ? Math.round(used / total * 100) : 0;
|
|
938
|
-
let swapTotal = 0;
|
|
939
|
-
let swapUsed = 0;
|
|
940
|
-
let swapFree = 0;
|
|
941
|
-
try {
|
|
942
|
-
const rawPage = await runPowerShell(
|
|
943
|
-
`Get-CimInstance Win32_PageFileUsage | ForEach-Object { "$($_.AllocatedBaseSize)|$($_.CurrentUsage)" }`,
|
|
944
|
-
""
|
|
945
|
-
);
|
|
946
|
-
const lines = rawPage.split("\n").filter((l) => l.trim().length > 0);
|
|
947
|
-
for (const line of lines) {
|
|
948
|
-
const [allocStr, usedStr] = line.split("|");
|
|
949
|
-
const allocMb = safeParseInt(allocStr);
|
|
950
|
-
const usedMb = safeParseInt(usedStr);
|
|
951
|
-
swapTotal += allocMb * 1024 * 1024;
|
|
952
|
-
swapUsed += usedMb * 1024 * 1024;
|
|
953
|
-
}
|
|
954
|
-
swapFree = Math.max(0, swapTotal - swapUsed);
|
|
955
|
-
} catch {
|
|
956
|
-
}
|
|
957
|
-
let pressureLevel = "Normal";
|
|
958
|
-
if (usagePercent > 92) pressureLevel = "Critical";
|
|
959
|
-
else if (usagePercent > 82) pressureLevel = "Warning";
|
|
960
|
-
return {
|
|
961
|
-
total,
|
|
962
|
-
used,
|
|
963
|
-
free,
|
|
964
|
-
swapTotal,
|
|
965
|
-
swapUsed,
|
|
966
|
-
swapFree,
|
|
967
|
-
pageSize: 4096,
|
|
968
|
-
usagePercent,
|
|
969
|
-
pressureLevel
|
|
970
|
-
};
|
|
971
|
-
}
|
|
972
|
-
async function collectWindowsDisk() {
|
|
973
|
-
try {
|
|
974
|
-
const raw = await runPowerShell(
|
|
975
|
-
`Get-CimInstance Win32_LogicalDisk -Filter "DriveType=3" | ForEach-Object { "$($_.DeviceID)|$($_.FileSystem)|$($_.Size)|$($_.FreeSpace)" }`,
|
|
976
|
-
""
|
|
977
|
-
);
|
|
978
|
-
const disks = [];
|
|
979
|
-
for (const line of raw.split("\n")) {
|
|
980
|
-
const parts = line.trim().split("|");
|
|
981
|
-
if (parts.length >= 4) {
|
|
982
|
-
const drive = parts[0];
|
|
983
|
-
const totalBytes = safeParseInt(parts[2]);
|
|
984
|
-
const freeBytes = safeParseInt(parts[3]);
|
|
985
|
-
if (totalBytes > 0) {
|
|
986
|
-
const usedBytes = Math.max(0, totalBytes - freeBytes);
|
|
987
|
-
const capPct = Math.round(usedBytes / totalBytes * 100);
|
|
988
|
-
disks.push({
|
|
989
|
-
filesystem: drive,
|
|
990
|
-
size: formatBytesStr(totalBytes),
|
|
991
|
-
used: formatBytesStr(usedBytes),
|
|
992
|
-
available: formatBytesStr(freeBytes),
|
|
993
|
-
capacity: `${capPct}%`,
|
|
994
|
-
mountpoint: drive,
|
|
995
|
-
readBytesSec: 0,
|
|
996
|
-
writeBytesSec: 0
|
|
997
|
-
});
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
if (disks.length > 0) return disks;
|
|
1002
|
-
} catch {
|
|
1003
|
-
}
|
|
1004
|
-
return [
|
|
1005
|
-
{
|
|
1006
|
-
filesystem: "C:",
|
|
1007
|
-
size: "500G",
|
|
1008
|
-
used: "150G",
|
|
1009
|
-
available: "350G",
|
|
1010
|
-
capacity: "30%",
|
|
1011
|
-
mountpoint: "C:",
|
|
1012
|
-
readBytesSec: 0,
|
|
1013
|
-
writeBytesSec: 0
|
|
1014
|
-
}
|
|
1015
|
-
];
|
|
1016
|
-
}
|
|
1017
|
-
function formatBytesStr(bytes) {
|
|
1018
|
-
if (bytes >= 1024 * 1024 * 1024 * 1024) return (bytes / (1024 * 1024 * 1024 * 1024)).toFixed(1) + "T";
|
|
1019
|
-
if (bytes >= 1024 * 1024 * 1024) return (bytes / (1024 * 1024 * 1024)).toFixed(1) + "G";
|
|
1020
|
-
if (bytes >= 1024 * 1024) return (bytes / (1024 * 1024)).toFixed(1) + "M";
|
|
1021
|
-
return (bytes / 1024).toFixed(0) + "K";
|
|
1022
|
-
}
|
|
1023
|
-
async function collectWindowsBattery() {
|
|
1024
|
-
try {
|
|
1025
|
-
const raw = await runPowerShell(
|
|
1026
|
-
`$bat = Get-CimInstance Win32_Battery -ErrorAction SilentlyContinue; if ($bat) { "$($bat.EstimatedChargeRemaining)|$($bat.BatteryStatus)|$($bat.EstimatedRunTime)|$($bat.DischargeRate)" } else { '' }`,
|
|
1027
|
-
""
|
|
1028
|
-
);
|
|
1029
|
-
if (!raw) return null;
|
|
1030
|
-
const parts = raw.split("|");
|
|
1031
|
-
const level = safeParseInt(parts[0], 0);
|
|
1032
|
-
const statusCode = safeParseInt(parts[1], 1);
|
|
1033
|
-
const runTimeMinutes = safeParseInt(parts[2], 0);
|
|
1034
|
-
const dischargeRate = safeParseInt(parts[3], 0);
|
|
1035
|
-
const powerSource = statusCode === 2 || statusCode === 3 || statusCode === 6 ? "AC" : "Battery";
|
|
1036
|
-
const state = statusCode === 3 ? "charged" : statusCode === 6 || statusCode === 2 ? "charging" : "discharging";
|
|
1037
|
-
let timeRemaining = "calculating";
|
|
1038
|
-
if (state === "charged") timeRemaining = "\u221E";
|
|
1039
|
-
else if (runTimeMinutes && runTimeMinutes > 0 && runTimeMinutes < 7e4) {
|
|
1040
|
-
const h = Math.floor(runTimeMinutes / 60);
|
|
1041
|
-
const m = runTimeMinutes % 60;
|
|
1042
|
-
timeRemaining = `${h}:${m.toString().padStart(2, "0")}`;
|
|
1043
|
-
}
|
|
1044
|
-
const powerWatts = dischargeRate > 0 ? Math.round(dischargeRate / 1e3 * 100) / 100 : void 0;
|
|
1045
|
-
return {
|
|
1046
|
-
level,
|
|
1047
|
-
state,
|
|
1048
|
-
timeRemaining,
|
|
1049
|
-
health: "Good",
|
|
1050
|
-
powerSource,
|
|
1051
|
-
powerWatts
|
|
1052
|
-
};
|
|
1053
|
-
} catch {
|
|
1054
|
-
return null;
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
async function collectWindowsThermal() {
|
|
1058
|
-
const temperatures = {};
|
|
1059
|
-
let tempC;
|
|
1060
|
-
try {
|
|
1061
|
-
const raw = await runPowerShell(
|
|
1062
|
-
`(Get-Counter 'Thermal Zone Information(*)*' -ErrorAction SilentlyContinue).CounterSamples | Where-Object { $_.CookedValue -gt 200 -and $_.CookedValue -lt 400 } | Select-Object -First 1 -ExpandProperty CookedValue`,
|
|
1063
|
-
""
|
|
1064
|
-
).catch(() => "");
|
|
1065
|
-
const tempK = parseFloat(raw);
|
|
1066
|
-
if (tempK > 200 && tempK < 400) {
|
|
1067
|
-
tempC = Math.round((tempK - 273.15) * 10) / 10;
|
|
1068
|
-
temperatures["cpu"] = tempC;
|
|
1069
|
-
}
|
|
1070
|
-
} catch {
|
|
1071
|
-
}
|
|
1072
|
-
if (tempC === void 0) {
|
|
1073
|
-
try {
|
|
1074
|
-
const rawWmi = await run("wmic /namespace:\\\\root\\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature 2>nul", "", 1500);
|
|
1075
|
-
const match = rawWmi.match(/(\d{3,4})/);
|
|
1076
|
-
if (match) {
|
|
1077
|
-
const kelvinTenths = parseInt(match[1], 10);
|
|
1078
|
-
const c = Math.round((kelvinTenths - 2732) / 10 * 10) / 10;
|
|
1079
|
-
if (c >= 15 && c <= 115) {
|
|
1080
|
-
tempC = c;
|
|
1081
|
-
temperatures["cpu"] = c;
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
} catch {
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
let gpuTemp;
|
|
1088
|
-
try {
|
|
1089
|
-
const gpuRaw = await runPowerShell(
|
|
1090
|
-
`(Get-Counter 'GPU(*)*' -ErrorAction SilentlyContinue).CounterSamples | Where-Object { $_.CounterName -match 'Temperature' -and $_.CookedValue -gt 0 } | Select-Object -First 1 -ExpandProperty CookedValue`,
|
|
1091
|
-
""
|
|
1092
|
-
).catch(() => "");
|
|
1093
|
-
gpuTemp = parseFloat(gpuRaw);
|
|
1094
|
-
if (gpuTemp > 0 && gpuTemp < 150) {
|
|
1095
|
-
temperatures["gpu"] = Math.round(gpuTemp * 10) / 10;
|
|
1096
|
-
}
|
|
1097
|
-
} catch {
|
|
1098
|
-
}
|
|
1099
|
-
const cpuTemp = tempC ?? gpuTemp;
|
|
1100
|
-
let state = "Nominal";
|
|
1101
|
-
let pressureLevel = 0;
|
|
1102
|
-
if (cpuTemp !== void 0) {
|
|
1103
|
-
if (cpuTemp >= 100) {
|
|
1104
|
-
state = "Critical";
|
|
1105
|
-
pressureLevel = 3;
|
|
1106
|
-
} else if (cpuTemp >= 90) {
|
|
1107
|
-
state = "Serious";
|
|
1108
|
-
pressureLevel = 2;
|
|
1109
|
-
} else if (cpuTemp >= 80) {
|
|
1110
|
-
state = "Fair";
|
|
1111
|
-
pressureLevel = 1;
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
return {
|
|
1115
|
-
state,
|
|
1116
|
-
detail: cpuTemp !== void 0 ? `${state} (${cpuTemp}\xB0C)` : state,
|
|
1117
|
-
pressureLevel,
|
|
1118
|
-
temperatures: Object.keys(temperatures).length ? temperatures : void 0
|
|
1119
|
-
};
|
|
1120
|
-
}
|
|
1121
|
-
async function collectWindowsPower() {
|
|
1122
|
-
const power = {};
|
|
1123
|
-
try {
|
|
1124
|
-
const batRaw = await runPowerShell(
|
|
1125
|
-
`$bat = Get-CimInstance Win32_Battery -ErrorAction SilentlyContinue; if ($bat) { "$($bat.DischargeRate)|$($bat.BatteryStatus)" } else { '|0' }`,
|
|
1126
|
-
""
|
|
1127
|
-
);
|
|
1128
|
-
const [dischargeStr, statusStr] = batRaw.split("|");
|
|
1129
|
-
const dischargeRate = safeParseInt(dischargeStr);
|
|
1130
|
-
const statusCode = safeParseInt(statusStr, 1);
|
|
1131
|
-
if (dischargeRate > 0 && (statusCode === 1 || statusCode === 2)) {
|
|
1132
|
-
power.combinedWatts = Math.round(dischargeRate / 1e3 * 100) / 100;
|
|
1133
|
-
}
|
|
1134
|
-
} catch {
|
|
1135
|
-
}
|
|
1136
|
-
try {
|
|
1137
|
-
const cpu = os2.cpus();
|
|
1138
|
-
const usage = cpu.length > 0 ? Math.round(cpu.reduce((a, c) => a + (c.times.user + c.times.nice + c.times.sys + c.times.irq - c.times.idle) / (c.times.user + c.times.nice + c.times.sys + c.times.idle + c.times.irq), 0) / cpu.length * 100) : 0;
|
|
1139
|
-
const tdpWatts = 65;
|
|
1140
|
-
if (usage > 0) {
|
|
1141
|
-
power.cpuWatts = Math.round(usage / 100 * tdpWatts * 100) / 100;
|
|
1142
|
-
}
|
|
1143
|
-
} catch {
|
|
1144
|
-
}
|
|
1145
|
-
try {
|
|
1146
|
-
const nvRaw = await run("nvidia-smi --query-gpu=power.draw,utilization.gpu --format=csv,noheader,nounits 2>nul", "").catch(() => "");
|
|
1147
|
-
const nvLines = nvRaw.split("\n").filter((l) => l.trim());
|
|
1148
|
-
for (const line of nvLines) {
|
|
1149
|
-
const parts = line.trim().split(",").map((s) => s.trim());
|
|
1150
|
-
const pwr = parseFloat(parts[0]);
|
|
1151
|
-
if (pwr > 0) {
|
|
1152
|
-
power.gpuWatts = Math.round(pwr * 100) / 100;
|
|
1153
|
-
if (!power.combinedWatts) power.combinedWatts = power.gpuWatts;
|
|
1154
|
-
else power.combinedWatts = Math.round((power.combinedWatts + power.gpuWatts) * 100) / 100;
|
|
1155
|
-
break;
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
} catch {
|
|
1159
|
-
}
|
|
1160
|
-
if (power.combinedWatts || power.cpuWatts || power.gpuWatts) {
|
|
1161
|
-
if (!power.combinedWatts) {
|
|
1162
|
-
power.combinedWatts = Math.round(((power.cpuWatts || 0) + (power.gpuWatts || 0)) * 100) / 100;
|
|
1163
|
-
}
|
|
1164
|
-
return power;
|
|
1165
|
-
}
|
|
1166
|
-
return null;
|
|
1167
|
-
}
|
|
1168
|
-
async function getNvidiaGpu() {
|
|
1169
|
-
try {
|
|
1170
|
-
const nvRaw = await run("nvidia-smi --query-gpu=gpu_name,memory.total,utilization.gpu,temperature.gpu,power.draw --format=csv,noheader,nounits 2>nul", "");
|
|
1171
|
-
const nvLines = nvRaw.split("\n").filter((l) => l.trim());
|
|
1172
|
-
if (nvLines.length > 0) {
|
|
1173
|
-
const parts = nvLines[0].trim().split(",").map((s) => s.trim());
|
|
1174
|
-
if (parts.length >= 3) {
|
|
1175
|
-
const model = parts[0];
|
|
1176
|
-
const memory = (parseFloat(parts[1]) || 0) * 1024 * 1024;
|
|
1177
|
-
const utilization = Math.min(100, Math.max(0, Math.round(parseFloat(parts[2]) || 0)));
|
|
1178
|
-
const temperature = parts[3] ? parseFloat(parts[3]) : void 0;
|
|
1179
|
-
const powerDraw = parts[4] ? parseFloat(parts[4]) : void 0;
|
|
1180
|
-
return {
|
|
1181
|
-
model,
|
|
1182
|
-
memory,
|
|
1183
|
-
utilization,
|
|
1184
|
-
temperature: Number.isFinite(temperature) ? temperature : void 0,
|
|
1185
|
-
processes: 0,
|
|
1186
|
-
powerDraw: Number.isFinite(powerDraw) ? powerDraw : void 0
|
|
1187
|
-
};
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
} catch {
|
|
1191
|
-
}
|
|
1192
|
-
return null;
|
|
1193
|
-
}
|
|
1194
|
-
async function getWmiGpu() {
|
|
1195
|
-
try {
|
|
1196
|
-
const raw = await runPowerShell(
|
|
1197
|
-
`Get-CimInstance Win32_VideoController | Select-Object Name, AdapterRAM, DriverVersion, VideoProcessor | ConvertTo-Csv -NoTypeInformation`,
|
|
1198
|
-
""
|
|
1199
|
-
);
|
|
1200
|
-
const lines = raw.split("\n").filter((l) => l.trim().length > 0);
|
|
1201
|
-
if (lines.length >= 2) {
|
|
1202
|
-
const headers = lines[0].split(",").map((h) => h.trim().replace(/^"|"$/g, ""));
|
|
1203
|
-
const values = lines[1].split(",").map((v) => v.trim().replace(/^"|"$/g, ""));
|
|
1204
|
-
const row = {};
|
|
1205
|
-
headers.forEach((h, i) => {
|
|
1206
|
-
row[h] = values[i] || "";
|
|
1207
|
-
});
|
|
1208
|
-
const name = row.Name || row.VideoProcessor || "Windows Display Adapter";
|
|
1209
|
-
const ram = safeParseInt(row.AdapterRAM);
|
|
1210
|
-
return {
|
|
1211
|
-
model: name,
|
|
1212
|
-
memory: ram,
|
|
1213
|
-
utilization: 0,
|
|
1214
|
-
processes: 0
|
|
1215
|
-
};
|
|
1216
|
-
}
|
|
1217
|
-
} catch {
|
|
1218
|
-
}
|
|
1219
|
-
return null;
|
|
1220
|
-
}
|
|
1221
|
-
async function getPerfCounterGpu() {
|
|
1222
|
-
try {
|
|
1223
|
-
const raw = await runPowerShell(
|
|
1224
|
-
`$engines = Get-Counter 'GPU Engine(*)*' -ErrorAction SilentlyContinue; if ($engines) { $engines.CounterSamples | Where-Object { $_.CounterName -match 'Utilization Percentage|GPU Time' -and $_.CookedValue -gt 0 } | ForEach-Object { "$($_.InstanceName)|$($_.CounterName)|$($_.CookedValue)" } }`,
|
|
1225
|
-
""
|
|
1226
|
-
).catch(() => "");
|
|
1227
|
-
if (!raw) return null;
|
|
1228
|
-
const lines = raw.split("\n").filter((l) => l.trim());
|
|
1229
|
-
if (lines.length === 0) return null;
|
|
1230
|
-
const gpuGroups = /* @__PURE__ */ new Map();
|
|
1231
|
-
for (const line of lines) {
|
|
1232
|
-
const [instanceName, counterName, valueStr] = line.split("|");
|
|
1233
|
-
const baseName = instanceName.replace(/\s*\(\d+\)\s*$/, "").trim();
|
|
1234
|
-
if (!gpuGroups.has(baseName)) {
|
|
1235
|
-
gpuGroups.set(baseName, { name: baseName, values: [] });
|
|
1236
|
-
}
|
|
1237
|
-
gpuGroups.get(baseName).values.push(parseFloat(valueStr) || 0);
|
|
1238
|
-
}
|
|
1239
|
-
let bestGpu = null;
|
|
1240
|
-
for (const group of gpuGroups.values()) {
|
|
1241
|
-
const total = group.values.reduce((a, b) => a + b, 0);
|
|
1242
|
-
const util = Math.min(100, Math.round(total));
|
|
1243
|
-
if (!bestGpu || util > bestGpu.util) {
|
|
1244
|
-
bestGpu = { name: group.name, util };
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
if (bestGpu) {
|
|
1248
|
-
return {
|
|
1249
|
-
model: bestGpu.name,
|
|
1250
|
-
memory: 0,
|
|
1251
|
-
utilization: bestGpu.util,
|
|
1252
|
-
processes: 0
|
|
1253
|
-
};
|
|
1254
|
-
}
|
|
1255
|
-
} catch {
|
|
1256
|
-
}
|
|
1257
|
-
return null;
|
|
1258
|
-
}
|
|
1259
|
-
async function collectWindowsGpu() {
|
|
1260
|
-
const nv = await getNvidiaGpu();
|
|
1261
|
-
if (nv) return nv;
|
|
1262
|
-
const perf = await getPerfCounterGpu();
|
|
1263
|
-
if (perf) return perf;
|
|
1264
|
-
const wmi = await getWmiGpu();
|
|
1265
|
-
if (wmi) return wmi;
|
|
1266
|
-
return null;
|
|
1267
|
-
}
|
|
1268
|
-
async function collectWindowsNetwork() {
|
|
1269
|
-
let iface = "Ethernet";
|
|
1270
|
-
let ip = "127.0.0.1";
|
|
1271
|
-
const interfaces = os2.networkInterfaces();
|
|
1272
|
-
for (const [name, addrs] of Object.entries(interfaces)) {
|
|
1273
|
-
const addr = addrs?.find((a) => a.family === "IPv4" && !a.internal);
|
|
1274
|
-
if (addr) {
|
|
1275
|
-
iface = name;
|
|
1276
|
-
ip = addr.address;
|
|
1277
|
-
break;
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
let rxBytes = 0;
|
|
1281
|
-
let txBytes = 0;
|
|
1282
|
-
let rxPackets = 0;
|
|
1283
|
-
let txPackets = 0;
|
|
1284
|
-
try {
|
|
1285
|
-
const raw = await runPowerShell(
|
|
1286
|
-
`Get-NetIPConfiguration -AddressFamily IPv4 -ErrorAction SilentlyContinue | Where-Object { $_.NetAdapter.Status -eq 'Up' } | Select-Object -First 1 -ExpandProperty NetAdapter.Name`,
|
|
1287
|
-
""
|
|
1288
|
-
);
|
|
1289
|
-
if (raw) iface = raw;
|
|
1290
|
-
} catch {
|
|
1291
|
-
}
|
|
1292
|
-
try {
|
|
1293
|
-
const netstatE = await run("netstat -e 2>nul", "", 1500);
|
|
1294
|
-
const lines = netstatE.split("\n");
|
|
1295
|
-
for (const line of lines) {
|
|
1296
|
-
const parts = line.trim().split(/\s+/);
|
|
1297
|
-
if (parts[0] && parts[0].toLowerCase() === "bytes" && parts.length >= 3) {
|
|
1298
|
-
rxBytes = parseInt(parts[1], 10) || 0;
|
|
1299
|
-
txBytes = parseInt(parts[2], 10) || 0;
|
|
1300
|
-
} else if (parts[0] && parts[0].toLowerCase().includes("unicast") && parts.length >= 3) {
|
|
1301
|
-
rxPackets += parseInt(parts[1], 10) || 0;
|
|
1302
|
-
txPackets += parseInt(parts[2], 10) || 0;
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
} catch {
|
|
1306
|
-
}
|
|
1307
|
-
const now = Date.now();
|
|
1308
|
-
let rxRate = 0;
|
|
1309
|
-
let txRate = 0;
|
|
1310
|
-
if (prevNetSample2 && prevNetSample2.ts > 0) {
|
|
1311
|
-
const dt = Math.max((now - prevNetSample2.ts) / 1e3, 1e-3);
|
|
1312
|
-
rxRate = Math.max(0, (rxBytes - prevNetSample2.rxBytes) / dt);
|
|
1313
|
-
txRate = Math.max(0, (txBytes - prevNetSample2.txBytes) / dt);
|
|
1314
|
-
}
|
|
1315
|
-
prevNetSample2 = { rxBytes, txBytes, ts: now };
|
|
1316
|
-
const connectionStates = await getWindowsConnectionStates();
|
|
1317
|
-
return {
|
|
1318
|
-
interface: iface,
|
|
1319
|
-
ip,
|
|
1320
|
-
rxBytes,
|
|
1321
|
-
txBytes,
|
|
1322
|
-
rxPackets,
|
|
1323
|
-
txPackets,
|
|
1324
|
-
rxRate,
|
|
1325
|
-
txRate,
|
|
1326
|
-
connections: connectionStates.established,
|
|
1327
|
-
protocols: {
|
|
1328
|
-
tcp: { connections: connectionStates.established, rxBytes: 0, txBytes: 0 },
|
|
1329
|
-
udp: { connections: 0, rxBytes: 0, txBytes: 0 }
|
|
1330
|
-
},
|
|
1331
|
-
connectionStates,
|
|
1332
|
-
listeningPorts: [],
|
|
1333
|
-
establishedConnections: connectionStates.established,
|
|
1334
|
-
topRemoteHosts: []
|
|
1335
|
-
};
|
|
1336
|
-
}
|
|
1337
|
-
async function getWindowsConnectionStates() {
|
|
1338
|
-
const stats = { established: 0, listening: 0, timeWait: 0, closeWait: 0, other: 0 };
|
|
1339
|
-
try {
|
|
1340
|
-
const raw = await runPowerShell(
|
|
1341
|
-
`Get-NetTCPConnection -State Established -ErrorAction SilentlyContinue | Measure-Object | Select-Object -ExpandProperty Count`,
|
|
1342
|
-
"0"
|
|
1343
|
-
);
|
|
1344
|
-
stats.established = safeParseInt(raw, 0);
|
|
1345
|
-
const listenRaw = await runPowerShell(
|
|
1346
|
-
`Get-NetTCPConnection -State Listen -ErrorAction SilentlyContinue | Measure-Object | Select-Object -ExpandProperty Count`,
|
|
1347
|
-
"0"
|
|
1348
|
-
);
|
|
1349
|
-
stats.listening = safeParseInt(listenRaw, 0);
|
|
1350
|
-
const twRaw = await runPowerShell(
|
|
1351
|
-
`Get-NetTCPConnection -State TimeWait -ErrorAction SilentlyContinue | Measure-Object | Select-Object -ExpandProperty Count`,
|
|
1352
|
-
"0"
|
|
1353
|
-
);
|
|
1354
|
-
stats.timeWait = safeParseInt(twRaw, 0);
|
|
1355
|
-
const cwRaw = await runPowerShell(
|
|
1356
|
-
`Get-NetTCPConnection -State CloseWait -ErrorAction SilentlyContinue | Measure-Object | Select-Object -ExpandProperty Count`,
|
|
1357
|
-
"0"
|
|
1358
|
-
);
|
|
1359
|
-
stats.closeWait = safeParseInt(cwRaw, 0);
|
|
1360
|
-
} catch {
|
|
1361
|
-
}
|
|
1362
|
-
return stats;
|
|
1363
|
-
}
|
|
1364
|
-
async function collectWindowsPackets() {
|
|
1365
|
-
let rxBytes = 0;
|
|
1366
|
-
let txBytes = 0;
|
|
1367
|
-
let rxPackets = 0;
|
|
1368
|
-
let txPackets = 0;
|
|
1369
|
-
try {
|
|
1370
|
-
const netstatE = await run("netstat -e 2>nul", "", 1500);
|
|
1371
|
-
const lines = netstatE.split("\n");
|
|
1372
|
-
for (const line of lines) {
|
|
1373
|
-
const parts = line.trim().split(/\s+/);
|
|
1374
|
-
if (parts[0] && parts[0].toLowerCase() === "bytes" && parts.length >= 3) {
|
|
1375
|
-
rxBytes = parseInt(parts[1], 10) || 0;
|
|
1376
|
-
txBytes = parseInt(parts[2], 10) || 0;
|
|
1377
|
-
} else if (parts[0] && parts[0].toLowerCase().includes("unicast") && parts.length >= 3) {
|
|
1378
|
-
rxPackets += parseInt(parts[1], 10) || 0;
|
|
1379
|
-
txPackets += parseInt(parts[2], 10) || 0;
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
} catch {
|
|
1383
|
-
}
|
|
1384
|
-
const connectionStates = await getWindowsConnectionStates();
|
|
1385
|
-
return {
|
|
1386
|
-
totalPackets: rxPackets + txPackets,
|
|
1387
|
-
rxPackets,
|
|
1388
|
-
txPackets,
|
|
1389
|
-
rxRate: 0,
|
|
1390
|
-
txRate: 0,
|
|
1391
|
-
connections: connectionStates.established,
|
|
1392
|
-
topProcesses: [],
|
|
1393
|
-
interfaces: [{ iface: "Primary", rxPackets, txPackets, rxBytes, txBytes }],
|
|
1394
|
-
allProcesses: [],
|
|
1395
|
-
connectionStates,
|
|
1396
|
-
listeningPorts: []
|
|
1397
|
-
};
|
|
1398
|
-
}
|
|
1399
|
-
var winProcCache = /* @__PURE__ */ new Map();
|
|
1400
|
-
async function collectWindowsProcesses(limit) {
|
|
1401
|
-
try {
|
|
1402
|
-
const raw = await runPowerShell(
|
|
1403
|
-
`Get-CimInstance Win32_Process | Select-Object Name, ProcessId, ThreadCount, WorkingSetSize, UserModeTime, KernelModeTime | ConvertTo-Csv -NoTypeInformation`,
|
|
1404
|
-
""
|
|
1405
|
-
);
|
|
1406
|
-
const lines = raw.split("\n").filter((l) => l.trim().length > 0 && !l.startsWith('"Name"'));
|
|
1407
|
-
const now = Date.now();
|
|
1408
|
-
const procs = [];
|
|
1409
|
-
const totalMem = os2.totalmem();
|
|
1410
|
-
for (const line of lines) {
|
|
1411
|
-
const parts = line.split(",").map((s) => s.trim().replace(/^"|"$/g, ""));
|
|
1412
|
-
if (parts.length < 6) continue;
|
|
1413
|
-
const name = parts[0];
|
|
1414
|
-
const pid = safeParseInt(parts[1], 0);
|
|
1415
|
-
const threads = safeParseInt(parts[2], 0);
|
|
1416
|
-
const memBytes = safeParseInt(parts[3], 0);
|
|
1417
|
-
const userTime = safeParseInt(parts[4], 0);
|
|
1418
|
-
const kernelTime = safeParseInt(parts[5], 0);
|
|
1419
|
-
if (!pid || pid <= 0) continue;
|
|
1420
|
-
const totalTime = userTime + kernelTime;
|
|
1421
|
-
let cpu = 0;
|
|
1422
|
-
const prev = winProcCache.get(pid);
|
|
1423
|
-
if (prev) {
|
|
1424
|
-
const dt = now - prev.ts;
|
|
1425
|
-
if (dt > 0) {
|
|
1426
|
-
const timeDelta = totalTime - (prev.user + prev.kernel);
|
|
1427
|
-
if (timeDelta > 0) {
|
|
1428
|
-
const cpuSeconds = timeDelta / 1e7;
|
|
1429
|
-
cpu = Math.min(100, Math.round(cpuSeconds / dt * 1e4) / 100);
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
}
|
|
1433
|
-
winProcCache.set(pid, { user: userTime, kernel: kernelTime, ts: now });
|
|
1434
|
-
const memPct = totalMem > 0 ? Math.round(memBytes / totalMem * 1e3) / 10 : 0;
|
|
1435
|
-
const isGpuOrMl = /gpu|vulkan|cuda|ollama|llama|torch|python|nvidia|amd|radeon|intel.*graphics/i.test(name);
|
|
1436
|
-
procs.push({
|
|
1437
|
-
pid,
|
|
1438
|
-
ppid: 0,
|
|
1439
|
-
user: "SYSTEM",
|
|
1440
|
-
cpu,
|
|
1441
|
-
mem: memPct,
|
|
1442
|
-
state: "R",
|
|
1443
|
-
threads,
|
|
1444
|
-
runtime: 0,
|
|
1445
|
-
command: name,
|
|
1446
|
-
isGpuOrMlAttributed: isGpuOrMl
|
|
1447
|
-
});
|
|
1448
|
-
}
|
|
1449
|
-
procs.sort((a, b) => b.cpu - a.cpu || b.mem - a.mem);
|
|
1450
|
-
if (limit && limit > 0) return procs.slice(0, limit);
|
|
1451
|
-
return procs;
|
|
1452
|
-
} catch {
|
|
1453
|
-
return [];
|
|
1454
|
-
}
|
|
1455
|
-
}
|
|
1456
|
-
async function collectWindowsTasks(limit = 12) {
|
|
1457
|
-
const procs = await collectWindowsProcesses(limit);
|
|
1458
|
-
return procs.map((p) => ({
|
|
1459
|
-
pid: p.pid,
|
|
1460
|
-
user: p.user,
|
|
1461
|
-
cpu: p.cpu,
|
|
1462
|
-
mem: p.mem,
|
|
1463
|
-
state: p.state,
|
|
1464
|
-
runtime: p.runtime,
|
|
1465
|
-
command: p.command
|
|
1466
|
-
}));
|
|
1467
|
-
}
|
|
1468
|
-
async function getWindowsDisplayInfo() {
|
|
1469
|
-
try {
|
|
1470
|
-
const raw = await runPowerShell(
|
|
1471
|
-
`Get-CimInstance Win32_VideoController | ForEach-Object { "$($_.Name)|$($_.VideoModeDescription)|$($_.VideoProcessor)" }`,
|
|
1472
|
-
""
|
|
1473
|
-
);
|
|
1474
|
-
const displays = [];
|
|
1475
|
-
for (const line of raw.split("\n")) {
|
|
1476
|
-
const parts = line.trim().split("|");
|
|
1477
|
-
if (parts[0]) {
|
|
1478
|
-
displays.push({
|
|
1479
|
-
name: parts[0],
|
|
1480
|
-
resolution: parts[1] || "Unknown",
|
|
1481
|
-
isMain: displays.length === 0
|
|
1482
|
-
});
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
return displays.length > 0 ? displays : [{ name: "Default Display", resolution: "1920x1080", isMain: true }];
|
|
1486
|
-
} catch {
|
|
1487
|
-
return [{ name: "Default Display", resolution: "1920x1080", isMain: true }];
|
|
1488
|
-
}
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
833
|
// src/monitors/batteryPredictor.ts
|
|
1492
834
|
import fs2 from "fs";
|
|
1493
835
|
import path2 from "path";
|
|
@@ -1586,7 +928,7 @@ var spBatteryCache = null;
|
|
|
1586
928
|
var netstatIbCache = null;
|
|
1587
929
|
var routeCache = null;
|
|
1588
930
|
var sysctlCache = /* @__PURE__ */ new Map();
|
|
1589
|
-
var
|
|
931
|
+
var prevNetSample2 = null;
|
|
1590
932
|
var cachedIoReportPath = void 0;
|
|
1591
933
|
function resolveIoReportScript() {
|
|
1592
934
|
if (cachedIoReportPath !== void 0) return cachedIoReportPath;
|
|
@@ -1945,7 +1287,7 @@ async function collectCpu() {
|
|
|
1945
1287
|
}
|
|
1946
1288
|
if (frequency === 0) {
|
|
1947
1289
|
try {
|
|
1948
|
-
const cpus =
|
|
1290
|
+
const cpus = os2.cpus();
|
|
1949
1291
|
if (cpus && cpus.length > 0 && cpus[0].speed) {
|
|
1950
1292
|
frequency = cpus[0].speed;
|
|
1951
1293
|
}
|
|
@@ -1954,7 +1296,7 @@ async function collectCpu() {
|
|
|
1954
1296
|
}
|
|
1955
1297
|
let usage = 0;
|
|
1956
1298
|
try {
|
|
1957
|
-
const cpus =
|
|
1299
|
+
const cpus = os2.cpus();
|
|
1958
1300
|
let totalNow = 0;
|
|
1959
1301
|
let idleNow = 0;
|
|
1960
1302
|
for (const cpu of cpus) {
|
|
@@ -1981,7 +1323,7 @@ async function collectCpu() {
|
|
|
1981
1323
|
}
|
|
1982
1324
|
let coreUsage = [];
|
|
1983
1325
|
try {
|
|
1984
|
-
const cpus =
|
|
1326
|
+
const cpus = os2.cpus();
|
|
1985
1327
|
const current = cpus.map((cpu) => ({
|
|
1986
1328
|
total: cpu.times.user + cpu.times.nice + cpu.times.sys + cpu.times.idle + cpu.times.irq,
|
|
1987
1329
|
idle: cpu.times.idle
|
|
@@ -2348,12 +1690,12 @@ async function collectNetwork() {
|
|
|
2348
1690
|
const now = Date.now();
|
|
2349
1691
|
let rxRate = 0;
|
|
2350
1692
|
let txRate = 0;
|
|
2351
|
-
if (
|
|
2352
|
-
const dt = Math.max((now -
|
|
2353
|
-
rxRate = Math.max(0, (rxBytes -
|
|
2354
|
-
txRate = Math.max(0, (txBytes -
|
|
1693
|
+
if (prevNetSample2 && prevNetSample2.ts > 0) {
|
|
1694
|
+
const dt = Math.max((now - prevNetSample2.ts) / 1e3, 1e-3);
|
|
1695
|
+
rxRate = Math.max(0, (rxBytes - prevNetSample2.rxBytes) / dt);
|
|
1696
|
+
txRate = Math.max(0, (txBytes - prevNetSample2.txBytes) / dt);
|
|
2355
1697
|
}
|
|
2356
|
-
|
|
1698
|
+
prevNetSample2 = { rxBytes, txBytes, rxPackets, txPackets, ts: now };
|
|
2357
1699
|
const protocolStats = await getProtocolStats();
|
|
2358
1700
|
const connectionStates = await getConnectionStates();
|
|
2359
1701
|
const listeningPorts = await getListeningPorts();
|