diff --git a/Modules/Disk/readers.swift b/Modules/Disk/readers.swift index 9d83b4bb..d1d91487 100644 --- a/Modules/Disk/readers.swift +++ b/Modules/Disk/readers.swift @@ -74,7 +74,7 @@ internal class CapacityReader: Reader { } // https://opensource.apple.com/source/bless/bless-152/libbless/APFS/BLAPFSUtilities.c.auto.html - public func getDeviceIOParent(_ obj: io_registry_entry_t, fileSystem: String = "") -> io_registry_entry_t? { + public func getDeviceIOParent(_ obj: io_registry_entry_t) -> io_registry_entry_t? { var parent: io_registry_entry_t = 0 if IORegistryEntryGetParentEntry(obj, kIOServicePlane, &parent) != KERN_SUCCESS { @@ -160,7 +160,7 @@ internal class CapacityReader: Reader { d.free = freeDiskSpaceInBytes(d.path!.absoluteString) } - if let parent = self.getDeviceIOParent(DADiskCopyIOMedia(disk), fileSystem: d.fileSystem) { + if let parent = self.getDeviceIOParent(DADiskCopyIOMedia(disk)) { d.parent = parent self.driveStats(parent, &d.stats) } diff --git a/Modules/GPU/reader.swift b/Modules/GPU/reader.swift index 68055a70..0fbe7ce8 100644 --- a/Modules/GPU/reader.swift +++ b/Modules/GPU/reader.swift @@ -32,8 +32,6 @@ internal class InfoReader: Reader { } let devices = PCIdevices.filter{ $0.object(forKey: "IOName") as? String == "display" } - print("Found \(devices.count) devices", to: &Log.log) - devices.forEach { (dict: NSDictionary) in guard let deviceID = dict["device-id"] as? Data, let vendorID = dict["vendor-id"] as? Data else { print("device-id or vendor-id not found", to: &Log.log) @@ -60,15 +58,11 @@ internal class InfoReader: Reader { self.devices[i].used = false } - print("------------", "read()", "------------", to: &Log.log) - print("Found \(accelerators.count) accelerators", to: &Log.log) - accelerators.forEach { (accelerator: NSDictionary) in guard let IOClass = accelerator.object(forKey: "IOClass") as? String else { print("IOClass not found", to: &Log.log) return } - print("Processing \(IOClass) accelerator", to: &Log.log) guard let stats = accelerator["PerformanceStatistics"] as? [String:Any] else { print("PerformanceStatistics not found", to: &Log.log) @@ -127,12 +121,8 @@ internal class InfoReader: Reader { self.gpus.list[idx].utilization = utilization == 0 ? 0 : Double(utilization)/100 self.gpus.list[idx].temperature = temperature - - print("\(model): utilization=\(utilization), temperature=\(temperature)", to: &Log.log) } - print("Callback \(self.gpus.list.count) GPUs", to: &Log.log) - self.gpus.list.sort{ !$0.state && $1.state } self.callback(self.gpus) } diff --git a/Modules/Memory/readers.swift b/Modules/Memory/readers.swift index 89b0746d..72a997c4 100644 --- a/Modules/Memory/readers.swift +++ b/Modules/Memory/readers.swift @@ -128,20 +128,20 @@ public class ProcessReader: Reader<[TopProcess]> { var processes: [TopProcess] = [] output.enumerateLines { (line, _) -> () in - if line.matches("^\\d+ + .+ +\\d+.\\d[M\\+\\-]+ *$") { - var str = line.trimmingCharacters(in: .whitespaces) - let pidString = str.findAndCrop(pattern: "^\\d+") - let usageString = str.findAndCrop(pattern: " [0-9]+M(\\+|\\-)*$") - var command = str.trimmingCharacters(in: .whitespaces) + if line.matches("^\\d+ +.* +\\d+[A-Z]* *$") { + let str = line.trimmingCharacters(in: .whitespaces) + let pidString = str.prefix(6) + let startIndex = str.index(str.startIndex, offsetBy: 6) + let endIndex = str.index(str.startIndex, offsetBy: 22) + var command = String(str[startIndex...endIndex]) + let usageString = str.suffix(5) if let regex = try? NSRegularExpression(pattern: " (\\+|\\-)*$", options: .caseInsensitive) { command = regex.stringByReplacingMatches(in: command, options: [], range: NSRange(location: 0, length: command.count), withTemplate: "") } - let pid = Int(pidString) ?? 0 - guard let usage = Double(usageString.filter("01234567890.".contains)) else { - return - } + let pid = Int(pidString.filter("01234567890.".contains)) ?? 0 + let usage = Double(usageString.filter("01234567890.".contains)) ?? 0 var name: String? = nil var icon: NSImage? = nil diff --git a/Stats/Supporting Files/Info.plist b/Stats/Supporting Files/Info.plist index d2529fe3..17835876 100755 --- a/Stats/Supporting Files/Info.plist +++ b/Stats/Supporting Files/Info.plist @@ -17,7 +17,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 164 + 171 Description Simple macOS system monitor in your menu bar LSApplicationCategoryType