diff --git a/doc/dashboards/Sysmon - Host Overview.json b/doc/dashboards/Sysmon - Host Overview.json index 0bd3d94..724ca78 100644 --- a/doc/dashboards/Sysmon - Host Overview.json +++ b/doc/dashboards/Sysmon - Host Overview.json @@ -35,6 +35,12 @@ "name": "Stat", "version": "" }, + { + "type": "panel", + "id": "table", + "name": "Table", + "version": "" + }, { "type": "panel", "id": "text", @@ -115,8 +121,10 @@ "description": "", "fieldConfig": { "defaults": { - "color": { - "mode": "palette-classic" + "custom": { + "align": "center", + "displayMode": "auto", + "inspect": false }, "mappings": [], "thresholds": { @@ -128,30 +136,26 @@ } ] }, - "unit": "text" + "unit": "string" }, "overrides": [] }, "gridPos": { - "h": 6, + "h": 3, "w": 24, "x": 0, "y": 3 }, "id": 35, "options": { - "colorMode": "none", - "graphMode": "none", - "justifyMode": "center", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" + "footer": { + "fields": "", + "reducer": [ + "sum" ], - "fields": "/.*/", - "values": false + "show": false }, - "textMode": "value_and_name" + "showHeader": true }, "pluginVersion": "9.1.6", "targets": [ @@ -184,7 +188,7 @@ "measurement": "base_info", "orderByTime": "DESC", "policy": "default", - "query": "SELECT last(\"os_manufacturer\") AS \"manufacturer\", last(\"os_family\") AS \"family\", last(\"os_version\") AS \"version\", last(\"os_codename\") AS \"codename\", last(\"os_build\") AS \"build\", last(\"boot_time\") * 1000 AS \"boottime\" FROM \"base_info\" WHERE (\"hostname\" =~ /^$hostname$/) AND $timeFilter GROUP BY time($__interval), \"hostname\" fill(null) ORDER BY time DESC LIMIT 1000", + "query": "SELECT last(\"os_manufacturer\") AS \"manufacturer\", last(\"os_family\") AS \"family\", last(\"os_version\") AS \"version\", last(\"os_codename\") AS \"codename\", last(\"os_build\") AS \"build\", last(\"boot_time\") * 1000 AS \"boottime\" FROM \"base_info\" WHERE (\"hostname\" =~ /^$hostname$/) AND $timeFilter GROUP BY \"hostname\" fill(previous) ORDER BY time DESC LIMIT 1", "rawQuery": true, "refId": "A", "resultFormat": "table", @@ -350,7 +354,8 @@ } } ], - "type": "stat" + "transparent": true, + "type": "table" }, { "datasource": { @@ -415,7 +420,7 @@ "h": 5, "w": 12, "x": 0, - "y": 9 + "y": 6 }, "id": 2, "options": { @@ -647,7 +652,7 @@ "h": 5, "w": 12, "x": 12, - "y": 9 + "y": 6 }, "id": 16, "options": { @@ -876,7 +881,7 @@ "h": 6, "w": 12, "x": 0, - "y": 14 + "y": 11 }, "id": 29, "options": { @@ -984,6 +989,12 @@ ], "type": "moving_average" }, + { + "params": [ + "*-1" + ], + "type": "math" + }, { "params": [ "steal" @@ -1137,7 +1148,7 @@ "h": 6, "w": 4, "x": 12, - "y": 14 + "y": 11 }, "id": 19, "options": { @@ -1313,7 +1324,7 @@ "h": 6, "w": 8, "x": 16, - "y": 14 + "y": 11 }, "id": 17, "options": { @@ -1488,7 +1499,7 @@ "h": 9, "w": 12, "x": 0, - "y": 20 + "y": 17 }, "id": 10, "options": { @@ -1648,7 +1659,7 @@ "h": 9, "w": 12, "x": 12, - "y": 20 + "y": 17 }, "id": 30, "options": { @@ -1809,7 +1820,7 @@ "h": 9, "w": 12, "x": 0, - "y": 29 + "y": 26 }, "id": 18, "options": { @@ -1964,7 +1975,7 @@ "h": 9, "w": 12, "x": 12, - "y": 29 + "y": 26 }, "id": 31, "options": { @@ -2074,8 +2085,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" } ] }, @@ -2184,7 +2194,7 @@ "h": 5, "w": 24, "x": 0, - "y": 38 + "y": 35 }, "id": 22, "options": { @@ -2479,8 +2489,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -2496,7 +2505,7 @@ "h": 10, "w": 12, "x": 0, - "y": 43 + "y": 40 }, "id": 24, "options": { @@ -2638,8 +2647,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" } ] }, @@ -2651,7 +2659,7 @@ "h": 10, "w": 12, "x": 12, - "y": 43 + "y": 40 }, "id": 25, "options": { @@ -2779,8 +2787,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -2796,7 +2803,7 @@ "h": 9, "w": 12, "x": 0, - "y": 53 + "y": 50 }, "id": 8, "options": { @@ -2973,8 +2980,7 @@ "mode": "absolute", "steps": [ { - "color": "transparent", - "value": null + "color": "transparent" }, { "color": "orange", @@ -2994,7 +3000,7 @@ "h": 9, "w": 12, "x": 12, - "y": 53 + "y": 50 }, "id": 26, "options": { @@ -3151,6 +3157,6 @@ "timezone": "", "title": "Sysmon - Host Overview", "uid": "QkVPjseMt", - "version": 18, + "version": 21, "weekStart": "" } \ No newline at end of file diff --git a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseProcessorExtension.java b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseProcessorExtension.java index 55c9e14..994d18b 100644 --- a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseProcessorExtension.java +++ b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseProcessorExtension.java @@ -8,6 +8,7 @@ import oshi.hardware.HardwareAbstractionLayer; import sysmon.shared.Measurement; import sysmon.shared.MetricExtension; import sysmon.shared.MetricResult; +import sysmon.shared.PluginHelper; import java.util.HashMap; import java.util.Map; @@ -105,15 +106,15 @@ public class BaseProcessorExtension implements MetricExtension { long nonBusy = idle + iowait; long total = busy + nonBusy; - fieldsMap.put("system", ((float) system / (float) total) * 100); - fieldsMap.put("user", ((float) user / (float) total) * 100); - fieldsMap.put("nice", ((float) nice / (float) total) * 100); - fieldsMap.put("iowait", ((float) iowait / (float) total) * 100); - fieldsMap.put("steal", ((float) steal / (float) total) * 100); - fieldsMap.put("irq", ((float) irq / (float) total) * 100); - fieldsMap.put("softirq", ((float) softirq / (float) total) * 100); - fieldsMap.put("idle", ((float) idle / (float) total) * 100); - fieldsMap.put("busy", ((float) busy / (float) total) * 100); + fieldsMap.put("system", PluginHelper.round(((double) system / (double) total) * 100, 2)); + fieldsMap.put("user", PluginHelper.round(((double) user / (double) total) * 100, 2)); + fieldsMap.put("nice", PluginHelper.round(((double) nice / (double) total) * 100, 2)); + fieldsMap.put("iowait", PluginHelper.round(((double) iowait / (double) total) * 100, 2)); + fieldsMap.put("steal", PluginHelper.round(((double) steal / (double) total) * 100, 2)); + fieldsMap.put("irq", PluginHelper.round(((double) irq / (double) total) * 100, 2)); + fieldsMap.put("softirq", PluginHelper.round(((double) softirq / (double) total) * 100, 2)); + fieldsMap.put("idle", PluginHelper.round(((double) idle / (double) total) * 100, 2)); + fieldsMap.put("busy", PluginHelper.round(((double) busy / (double) total) * 100, 2)); oldTicks = ticks; log.debug(fieldsMap.toString()); diff --git a/shared/src/main/java/sysmon/shared/PluginHelper.java b/shared/src/main/java/sysmon/shared/PluginHelper.java index 6c4abde..db7f790 100644 --- a/shared/src/main/java/sysmon/shared/PluginHelper.java +++ b/shared/src/main/java/sysmon/shared/PluginHelper.java @@ -69,4 +69,10 @@ public class PluginHelper { return allLines; } + + public static double round(double average, int scale) { + double pow = Math.pow(10, scale); + return Math.round(average * pow) / pow; + } + }