From 13cc0bbcfc7c5ef289ff7009c7ae1ee27667c519 Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Fri, 11 Jun 2021 02:21:32 +0200 Subject: [PATCH] Disable netstat extension. Update example dashboard. --- README.md | 15 +- ...9.json => Sysmon Agent-1623356330000.json} | 769 ++++++------------ gradle.properties | 2 +- .../plugins/os_aix/AixNetstatExtension.java | 3 +- .../plugins/os_base/BaseDiskExtension.java | 13 +- .../plugins/os_base/BaseMemoryExtension.java | 13 +- .../plugins/os_base/BaseNetworkExtension.java | 13 +- .../sysmon/plugins/os_base/BasePlugin.java | 22 + .../os_base/BaseProcessorExtension.java | 13 +- .../os_linux/LinuxNetstatExtension.java | 3 +- 10 files changed, 280 insertions(+), 586 deletions(-) rename doc/{Sysmon-Example-1623307971559.json => Sysmon Agent-1623356330000.json} (80%) diff --git a/README.md b/README.md index e59346f..783b480 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,20 @@ Java based system monitoring solution with support for plugins. +- Example Grafana [dashboard](https://bitbucket.org/mnellemann/sysmon/downloads/sysmon-example-dashboard.png) showing metrics from a host running *sysmon*. -## Client +## Components -Runs on your hosts and collects metrics. Metrics are aggregated and sent to the central *server*. +### Client + +Runs on your hosts and collects metrics, which are sent to the central *server*. -## Server +### Server -Receives aggregated measurements from clients and saves metrics into InfluxDB. +Receives aggregated metrics from clients and saves these into InfluxDB. -## Plugins +### Plugins -Loaded by the client and provides extensions for doing the actual metric monitoring. \ No newline at end of file +Loaded by the client and provides extensions for doing the actual collecting of metrics. \ No newline at end of file diff --git a/doc/Sysmon-Example-1623307971559.json b/doc/Sysmon Agent-1623356330000.json similarity index 80% rename from doc/Sysmon-Example-1623307971559.json rename to doc/Sysmon Agent-1623356330000.json index 0875d93..8424464 100644 --- a/doc/Sysmon-Example-1623307971559.json +++ b/doc/Sysmon Agent-1623356330000.json @@ -1,4 +1,46 @@ { + "__inputs": [ + { + "name": "DS_INFLUXDB-SYSMON", + "label": "InfluxDB-sysmon", + "description": "", + "type": "datasource", + "pluginId": "influxdb", + "pluginName": "InfluxDB" + } + ], + "__requires": [ + { + "type": "panel", + "id": "gauge", + "name": "Gauge", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "8.0.0" + }, + { + "type": "panel", + "id": "graph", + "name": "Graph (old)", + "version": "" + }, + { + "type": "datasource", + "id": "influxdb", + "name": "InfluxDB", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + } + ], "annotations": { "list": [ { @@ -12,11 +54,12 @@ } ] }, + "description": "Metrics from within host / guest / partition.", "editable": true, "gnetId": null, "graphTooltip": 0, - "id": 43, - "iteration": 1623307961363, + "id": null, + "iteration": 1623356323404, "links": [], "panels": [ { @@ -31,13 +74,6 @@ "id": 4, "panels": [], "repeat": "hostname", - "scopedVars": { - "hostname": { - "selected": true, - "text": "S824Rhel71le", - "value": "S824Rhel71le" - } - }, "title": "${hostname}", "type": "row" }, @@ -46,16 +82,12 @@ "bars": false, "dashLength": 10, "dashes": false, - "datasource": "InfluxDB-sysmon", + "datasource": "${DS_INFLUXDB-SYSMON}", "description": "", - "fieldConfig": { - "defaults": {}, - "overrides": [] - }, "fill": 1, "fillGradient": 0, "gridPos": { - "h": 7, + "h": 10, "w": 10, "x": 0, "y": 1 @@ -78,17 +110,10 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.5.2", + "pluginVersion": "8.0.0", "pointradius": 2, "points": false, "renderer": "flot", - "scopedVars": { - "hostname": { - "selected": true, - "text": "S824Rhel71le", - "value": "S824Rhel71le" - } - }, "seriesOverrides": [], "spaceLength": 10, "stack": true, @@ -275,7 +300,7 @@ } }, { - "datasource": "InfluxDB-sysmon", + "datasource": "${DS_INFLUXDB-SYSMON}", "description": "", "fieldConfig": { "defaults": { @@ -349,7 +374,7 @@ ] }, "gridPos": { - "h": 7, + "h": 3, "w": 4, "x": 10, "y": 1 @@ -370,14 +395,7 @@ "text": {}, "textMode": "value_and_name" }, - "pluginVersion": "7.5.2", - "scopedVars": { - "hostname": { - "selected": true, - "text": "S824Rhel71le", - "value": "S824Rhel71le" - } - }, + "pluginVersion": "8.0.0", "targets": [ { "groupBy": [ @@ -484,11 +502,11 @@ ], "timeFrom": null, "timeShift": null, - "title": "LPAR Processor Details", + "title": "Power LPAR Details", "type": "stat" }, { - "datasource": "InfluxDB-sysmon", + "datasource": "${DS_INFLUXDB-SYSMON}", "description": "", "fieldConfig": { "defaults": { @@ -547,7 +565,7 @@ ] }, "gridPos": { - "h": 7, + "h": 10, "w": 10, "x": 14, "y": 1 @@ -568,14 +586,7 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "7.5.2", - "scopedVars": { - "hostname": { - "selected": true, - "text": "S824Rhel71le", - "value": "S824Rhel71le" - } - }, + "pluginVersion": "8.0.0", "targets": [ { "groupBy": [ @@ -664,15 +675,168 @@ ], "timeFrom": null, "timeShift": null, - "title": "LPAR Processor Usage", + "title": "Power LPAR Processor Usage", "type": "stat" }, + { + "datasource": "${DS_INFLUXDB-SYSMON}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "disk.iotime" + }, + "properties": [ + { + "id": "displayName", + "value": "I/O Time" + }, + { + "id": "unit", + "value": "ms" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "disk.queue" + }, + "properties": [ + { + "id": "displayName", + "value": "Queue" + }, + { + "id": "unit", + "value": "none" + } + ] + } + ] + }, + "gridPos": { + "h": 7, + "w": 4, + "x": 10, + "y": 4 + }, + "id": 19, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "8.0.0", + "targets": [ + { + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "linear" + ], + "type": "fill" + } + ], + "measurement": "disk", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "iotime" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + }, + { + "params": [ + "1s" + ], + "type": "non_negative_derivative" + }, + { + "params": [ + "iotime" + ], + "type": "alias" + } + ], + [ + { + "params": [ + "queue" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + }, + { + "params": [ + "queue" + ], + "type": "alias" + } + ] + ], + "tags": [ + { + "key": "hostname", + "operator": "=~", + "value": "/^$hostname$/" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Disk Metrics", + "type": "gauge" + }, { "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, - "datasource": "InfluxDB-sysmon", + "datasource": "${DS_INFLUXDB-SYSMON}", "fieldConfig": { "defaults": { "unit": "bytes" @@ -682,10 +846,10 @@ "fill": 1, "fillGradient": 0, "gridPos": { - "h": 7, + "h": 10, "w": 10, "x": 0, - "y": 8 + "y": 11 }, "hiddenSeries": false, "id": 8, @@ -705,17 +869,10 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.5.2", + "pluginVersion": "8.0.0", "pointradius": 2, "points": false, "renderer": "flot", - "scopedVars": { - "hostname": { - "selected": true, - "text": "S824Rhel71le", - "value": "S824Rhel71le" - } - }, "seriesOverrides": [], "spaceLength": 10, "stack": false, @@ -865,172 +1022,12 @@ "alignLevel": null } }, - { - "datasource": "InfluxDB-sysmon", - "fieldConfig": { - "defaults": { - "color": { - "mode": "continuous-GrYlRd" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - }, - "unit": "none" - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "disk.iotime" - }, - "properties": [ - { - "id": "displayName", - "value": "I/O Time" - }, - { - "id": "unit", - "value": "ms" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "disk.queue" - }, - "properties": [ - { - "id": "displayName", - "value": "Queue" - }, - { - "id": "unit", - "value": "none" - } - ] - } - ] - }, - "gridPos": { - "h": 7, - "w": 4, - "x": 10, - "y": 8 - }, - "id": 19, - "options": { - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "showThresholdLabels": false, - "showThresholdMarkers": true, - "text": {} - }, - "pluginVersion": "7.5.2", - "scopedVars": { - "hostname": { - "selected": true, - "text": "S824Rhel71le", - "value": "S824Rhel71le" - } - }, - "targets": [ - { - "groupBy": [ - { - "params": [ - "$__interval" - ], - "type": "time" - }, - { - "params": [ - "linear" - ], - "type": "fill" - } - ], - "measurement": "disk", - "orderByTime": "ASC", - "policy": "default", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "iotime" - ], - "type": "field" - }, - { - "params": [], - "type": "last" - }, - { - "params": [ - "1s" - ], - "type": "non_negative_derivative" - }, - { - "params": [ - "iotime" - ], - "type": "alias" - } - ], - [ - { - "params": [ - "queue" - ], - "type": "field" - }, - { - "params": [], - "type": "last" - }, - { - "params": [ - "queue" - ], - "type": "alias" - } - ] - ], - "tags": [ - { - "key": "hostname", - "operator": "=~", - "value": "/^$hostname$/" - } - ] - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Disk Metrics", - "type": "gauge" - }, { "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, - "datasource": "InfluxDB-sysmon", + "datasource": "${DS_INFLUXDB-SYSMON}", "fieldConfig": { "defaults": { "unit": "binBps" @@ -1040,10 +1037,10 @@ "fill": 1, "fillGradient": 0, "gridPos": { - "h": 7, - "w": 10, - "x": 14, - "y": 8 + "h": 10, + "w": 14, + "x": 10, + "y": 11 }, "hiddenSeries": false, "id": 10, @@ -1063,17 +1060,10 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.5.2", + "pluginVersion": "8.0.0", "pointradius": 2, "points": false, "renderer": "flot", - "scopedVars": { - "hostname": { - "selected": true, - "text": "S824Rhel71le", - "value": "S824Rhel71le" - } - }, "seriesOverrides": [], "spaceLength": 10, "stack": false, @@ -1204,7 +1194,7 @@ "bars": false, "dashLength": 10, "dashes": false, - "datasource": "InfluxDB-sysmon", + "datasource": "${DS_INFLUXDB-SYSMON}", "fieldConfig": { "defaults": { "unit": "binBps" @@ -1214,10 +1204,10 @@ "fill": 1, "fillGradient": 0, "gridPos": { - "h": 7, + "h": 11, "w": 10, "x": 0, - "y": 15 + "y": 21 }, "hiddenSeries": false, "id": 18, @@ -1237,17 +1227,10 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.5.2", + "pluginVersion": "8.0.0", "pointradius": 2, "points": false, "renderer": "flot", - "scopedVars": { - "hostname": { - "selected": true, - "text": "S824Rhel71le", - "value": "S824Rhel71le" - } - }, "seriesOverrides": [], "spaceLength": 10, "stack": false, @@ -1374,271 +1357,8 @@ } }, { - "datasource": "InfluxDB-sysmon", - "fieldConfig": { - "defaults": { - "color": { - "mode": "continuous-GrYlRd" - }, - "decimals": 2, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - }, - "unit": "none" - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "network_netstat.tcp_connections" - }, - "properties": [ - { - "id": "displayName", - "value": "TCP Connections" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "network_netstat.tcp_pkts_recv" - }, - "properties": [ - { - "id": "displayName", - "value": "TCP Segments Recv." - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "network_netstat.tcp_pkts_sent" - }, - "properties": [ - { - "id": "displayName", - "value": "TCP Segments Sent" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "network_netstat.udp_pkts_recv" - }, - "properties": [ - { - "id": "displayName", - "value": "UDP Datagrams Recv." - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "network_netstat.udp_pkts_sent" - }, - "properties": [ - { - "id": "displayName", - "value": "UDP Datagrams Sent" - } - ] - } - ] - }, - "gridPos": { - "h": 7, - "w": 7, - "x": 10, - "y": 15 - }, - "id": 21, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "text": {}, - "textMode": "auto" - }, - "pluginVersion": "7.5.2", - "scopedVars": { - "hostname": { - "selected": true, - "text": "S824Rhel71le", - "value": "S824Rhel71le" - } - }, - "targets": [ - { - "groupBy": [ - { - "params": [ - "$__interval" - ], - "type": "time" - }, - { - "params": [ - "linear" - ], - "type": "fill" - } - ], - "measurement": "network_netstat", - "orderByTime": "ASC", - "policy": "default", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "tcp_connections" - ], - "type": "field" - }, - { - "params": [], - "type": "last" - }, - { - "params": [ - "tcp_connections" - ], - "type": "alias" - } - ], - [ - { - "params": [ - "tcp_pkts_recv" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [ - "1s" - ], - "type": "non_negative_derivative" - }, - { - "params": [ - "tcp_pkts_recv" - ], - "type": "alias" - } - ], - [ - { - "params": [ - "tcp_pkts_sent" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [ - "1s" - ], - "type": "non_negative_derivative" - }, - { - "params": [ - "tcp_pkts_sent" - ], - "type": "alias" - } - ], - [ - { - "params": [ - "udp_pkts_recv" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [ - "1s" - ], - "type": "non_negative_derivative" - }, - { - "params": [ - "udp_pkts_recv" - ], - "type": "alias" - } - ], - [ - { - "params": [ - "udp_pkts_sent" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [ - "1s" - ], - "type": "non_negative_derivative" - }, - { - "params": [ - "udp_pkts_sent" - ], - "type": "alias" - } - ] - ], - "tags": [ - { - "key": "hostname", - "operator": "=~", - "value": "/^$hostname$/" - } - ] - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Network Statistics", - "type": "stat" - }, - { - "datasource": "InfluxDB-sysmon", + "datasource": "${DS_INFLUXDB-SYSMON}", + "description": "", "fieldConfig": { "defaults": { "color": { @@ -1756,10 +1476,10 @@ ] }, "gridPos": { - "h": 7, - "w": 7, - "x": 17, - "y": 15 + "h": 11, + "w": 14, + "x": 10, + "y": 21 }, "id": 22, "options": { @@ -1777,14 +1497,7 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "7.5.2", - "scopedVars": { - "hostname": { - "selected": true, - "text": "S824Rhel71le", - "value": "S824Rhel71le" - } - }, + "pluginVersion": "8.0.0", "targets": [ { "groupBy": [ @@ -1963,29 +1676,20 @@ ], "timeFrom": null, "timeShift": null, - "title": "Network Sockets", + "title": "Network Sockets (Linux)", "type": "stat" } ], "refresh": "30s", - "schemaVersion": 27, + "schemaVersion": 30, "style": "dark", "tags": [], "templating": { "list": [ { "allValue": null, - "current": { - "selected": true, - "tags": [], - "text": [ - "S824Rhel71le" - ], - "value": [ - "S824Rhel71le" - ] - }, - "datasource": "InfluxDB-sysmon", + "current": {}, + "datasource": "${DS_INFLUXDB-SYSMON}", "definition": "SHOW TAG VALUES FROM \"processor\" WITH KEY = \"hostname\" WHERE time > now() - 24h", "description": null, "error": null, @@ -2001,7 +1705,6 @@ "skipUrlSync": false, "sort": 0, "tagValuesQuery": "", - "tags": [], "tagsQuery": "", "type": "query", "useTags": false @@ -2027,7 +1730,7 @@ ] }, "timezone": "", - "title": "Sysmon-Example", + "title": "Sysmon Agent", "uid": "QkVPjseMk", - "version": 25 + "version": 30 } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index df1734b..970fc1b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=0.0.2 +version=0.0.3 pf4jVersion=3.6.0 slf4jVersion=1.7.30 camelVersion=3.7.4 diff --git a/plugins/os-aix/src/main/java/sysmon/plugins/os_aix/AixNetstatExtension.java b/plugins/os-aix/src/main/java/sysmon/plugins/os_aix/AixNetstatExtension.java index 83b0a1a..007410a 100644 --- a/plugins/os-aix/src/main/java/sysmon/plugins/os_aix/AixNetstatExtension.java +++ b/plugins/os-aix/src/main/java/sysmon/plugins/os_aix/AixNetstatExtension.java @@ -12,7 +12,8 @@ import java.io.IOException; import java.io.InputStream; import java.util.Map; -@Extension +// Disabled +//@Extension public class AixNetstatExtension implements MetricExtension { private static final Logger log = LoggerFactory.getLogger(AixNetstatExtension.class); diff --git a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseDiskExtension.java b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseDiskExtension.java index 2f8c433..8fe5353 100644 --- a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseDiskExtension.java +++ b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseDiskExtension.java @@ -19,22 +19,13 @@ public class BaseDiskExtension implements MetricExtension { private static final Logger log = LoggerFactory.getLogger(BaseDiskExtension.class); - private SystemInfo systemInfo; private HardwareAbstractionLayer hardwareAbstractionLayer; @Override public boolean isSupported() { - - try { - systemInfo = new SystemInfo(); - hardwareAbstractionLayer = systemInfo.getHardware(); - return true; - } catch (UnsupportedOperationException e) { - log.warn(e.getMessage()); - } - - return false; + hardwareAbstractionLayer = BasePlugin.getHardwareAbstractionLayer(); + return hardwareAbstractionLayer != null; } @Override diff --git a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseMemoryExtension.java b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseMemoryExtension.java index b73ad48..024c46a 100644 --- a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseMemoryExtension.java +++ b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseMemoryExtension.java @@ -17,21 +17,12 @@ public class BaseMemoryExtension implements MetricExtension { private static final Logger log = LoggerFactory.getLogger(BaseMemoryExtension.class); - private SystemInfo systemInfo; private HardwareAbstractionLayer hardwareAbstractionLayer; @Override public boolean isSupported() { - - try { - systemInfo = new SystemInfo(); - hardwareAbstractionLayer = systemInfo.getHardware(); - return true; - } catch (UnsupportedOperationException e) { - log.warn(e.getMessage()); - } - - return false; + hardwareAbstractionLayer = BasePlugin.getHardwareAbstractionLayer(); + return hardwareAbstractionLayer != null; } @Override diff --git a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseNetworkExtension.java b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseNetworkExtension.java index 8b5a7c0..a16efba 100644 --- a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseNetworkExtension.java +++ b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseNetworkExtension.java @@ -19,21 +19,12 @@ public class BaseNetworkExtension implements MetricExtension { private static final Logger log = LoggerFactory.getLogger(BaseNetworkExtension.class); - private SystemInfo systemInfo; private HardwareAbstractionLayer hardwareAbstractionLayer; @Override public boolean isSupported() { - - try { - systemInfo = new SystemInfo(); - hardwareAbstractionLayer = systemInfo.getHardware(); - return true; - } catch (UnsupportedOperationException e) { - log.warn(e.getMessage()); - } - - return false; + hardwareAbstractionLayer = BasePlugin.getHardwareAbstractionLayer(); + return hardwareAbstractionLayer != null; } @Override diff --git a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BasePlugin.java b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BasePlugin.java index 203cceb..87f193e 100644 --- a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BasePlugin.java +++ b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BasePlugin.java @@ -4,14 +4,36 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.pf4j.Plugin; import org.pf4j.PluginWrapper; +import oshi.SystemInfo; +import oshi.hardware.HardwareAbstractionLayer; public class BasePlugin extends Plugin { private static final Logger log = LoggerFactory.getLogger(BasePlugin.class); + private static SystemInfo systemInfo; + private static HardwareAbstractionLayer hardwareAbstractionLayer; + public BasePlugin(PluginWrapper wrapper) { super(wrapper); } + public static HardwareAbstractionLayer getHardwareAbstractionLayer() { + + try { + if(systemInfo == null) { + systemInfo = new SystemInfo(); + } + if(hardwareAbstractionLayer == null) { + hardwareAbstractionLayer = systemInfo.getHardware(); + } + + } catch (UnsupportedOperationException e) { + log.warn(e.getMessage()); + } + + return hardwareAbstractionLayer; + } + } 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 9b39018..c444fc6 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 @@ -24,22 +24,13 @@ public class BaseProcessorExtension implements MetricExtension { private static final Logger log = LoggerFactory.getLogger(BaseProcessorExtension.class); - private SystemInfo systemInfo; private HardwareAbstractionLayer hardwareAbstractionLayer; private long[] oldTicks; @Override public boolean isSupported() { - - try { - systemInfo = new SystemInfo(); - hardwareAbstractionLayer = systemInfo.getHardware(); - return true; - } catch (UnsupportedOperationException e) { - log.warn(e.getMessage()); - } - - return false; + hardwareAbstractionLayer = BasePlugin.getHardwareAbstractionLayer(); + return hardwareAbstractionLayer != null; } @Override diff --git a/plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxNetstatExtension.java b/plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxNetstatExtension.java index d4a96d3..0a1d80b 100644 --- a/plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxNetstatExtension.java +++ b/plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxNetstatExtension.java @@ -12,7 +12,8 @@ import java.io.IOException; import java.io.InputStream; import java.util.Map; -@Extension +// Disabled +//@Extension public class LinuxNetstatExtension implements MetricExtension { private static final Logger log = LoggerFactory.getLogger(LinuxNetstatExtension.class);