From c96b4c5e79dc5a89916ce00b3507f54fb758186d Mon Sep 17 00:00:00 2001 From: Vernon R Schierding III Date: Tue, 23 Apr 2019 05:23:30 -0400 Subject: [PATCH] CPU metrics fix for when system memory percent is 0 (#218) --- AUTHORS.md | 1 + Sources/SwiftMetrics/SwiftMonitor.swift | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index f6b76f7..122d31d 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -12,3 +12,4 @@ Authors ordered by first contribution: - Kye Maloy (https://github.com/kyemaloy97) - Jonathan Spruce (https://github.com/jonathan-spruce) - Shihab Mehboob (https://github.com/ShihabMehboob) + - Vernon Schierding (https://github.com/schlingding) diff --git a/Sources/SwiftMetrics/SwiftMonitor.swift b/Sources/SwiftMetrics/SwiftMonitor.swift index 4f44c05..f416f0e 100644 --- a/Sources/SwiftMetrics/SwiftMonitor.swift +++ b/Sources/SwiftMetrics/SwiftMonitor.swift @@ -128,7 +128,7 @@ public class SwiftMonitor { //cpu: startCPU@#1412609879696@#0.00499877@#0.137468 var values:[Substring] = [] for value in message.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).split(separator: "#") { - values.append(value.dropLast()) + values.append(value.last == "@" ? value.dropLast() : value) } if let timeOfSample = Int(values[1]), let percentUsedByApplication = Float(values[2]), let percentUsedBySystem = Float(values[3]) {