From 08c0235925f5091fe96748668508f3b59514b071 Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Thu, 1 Dec 2022 16:16:00 +0100 Subject: [PATCH] Remove excess logging when energy metrics are not available. --- CHANGELOG.md | 9 +- .../HMCi - Power System Utilization.json | 719 ++++++++++++++++++ .../biz/nellemann/hmci/ManagedSystem.java | 15 +- .../java/biz/nellemann/hmci/SystemEnergy.java | 19 +- 4 files changed, 729 insertions(+), 33 deletions(-) create mode 100644 doc/dashboards/HMCi - Power System Utilization.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 2feeb7c..d787e0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,29 +2,26 @@ All notable changes to this project will be documented in this file. -## [1.4.0] - 2011-12-xx -- Major rewrite of toml+xml+json de-serialization +## [1.4.0] - 2011-12-01 +- Rewrite of toml+xml+json de-serialization code (uses jackson now). - Changes to configuration file format - please look at [doc/hmci.toml](doc/hmci.toml) as example. +- Logging (write to file) JSON output from HMC is currently not possible. ## [1.3.3] - 2022-09-20 -### Added - Default configuration location on Windows platform. - Process LPAR SR-IOV logical network ports data - Update default dashboards - Update documentation ## [1.3.0] - 2022-02-04 -### Changed - Correct use of InfluxDB batch writing. ## [1.2.8] - 2022-02-28 -### Changed - Sort measurement tags before writing to InfluxDB. - Update 3rd party dependencies. ## [1.2.7] - 2022-02-24 -### Added - Options to include/exclude Managed Systems and/or Logical Partitions. [1.4.0]: https://bitbucket.org/mnellemann/hmci/branches/compare/v1.4.0%0Dv1.3.3 diff --git a/doc/dashboards/HMCi - Power System Utilization.json b/doc/dashboards/HMCi - Power System Utilization.json new file mode 100644 index 0000000..fa32e31 --- /dev/null +++ b/doc/dashboards/HMCi - Power System Utilization.json @@ -0,0 +1,719 @@ +{ + "__inputs": [ + { + "name": "DS_INFLUXDB", + "label": "InfluxDB", + "description": "", + "type": "datasource", + "pluginId": "influxdb", + "pluginName": "InfluxDB" + } + ], + "__elements": [], + "__requires": [ + { + "type": "panel", + "id": "bargauge", + "name": "Bar gauge", + "version": "" + }, + { + "type": "panel", + "id": "gauge", + "name": "Gauge", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "8.3.5" + }, + { + "type": "panel", + "id": "heatmap", + "name": "Heatmap", + "version": "" + }, + { + "type": "datasource", + "id": "influxdb", + "name": "InfluxDB", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + }, + { + "type": "panel", + "id": "text", + "name": "Text", + "version": "" + } + ], + "annotations": { + "enable": false, + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "description": "https://bitbucket.org/mnellemann/hmci/", + "editable": true, + "fiscalYearStartMonth": 0, + "gnetId": 1465, + "graphTooltip": 0, + "id": null, + "iteration": 1669798059148, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": { + "type": "influxdb", + "uid": "${DS_INFLUXDB}" + }, + "gridPos": { + "h": 3, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 33, + "options": { + "content": "## Metrics collected from IBM Power HMC\n \nFor more information: [bitbucket.org/mnellemann/hmci](https://bitbucket.org/mnellemann/hmci)\n ", + "mode": "markdown" + }, + "pluginVersion": "8.3.5", + "targets": [ + { + "datasource": { + "type": "influxdb", + "uid": "${DS_INFLUXDB}" + }, + "refId": "A" + } + ], + "transparent": true, + "type": "text" + }, + { + "cards": {}, + "color": { + "cardColor": "#b4ff00", + "colorScale": "sqrt", + "colorScheme": "interpolateOranges", + "exponent": 0.5, + "mode": "opacity" + }, + "dataFormat": "timeseries", + "description": "", + "gridPos": { + "h": 11, + "w": 24, + "x": 0, + "y": 3 + }, + "heatmap": {}, + "hideZeroBuckets": true, + "highlightCards": true, + "id": 30, + "legend": { + "show": false + }, + "pluginVersion": "8.3.5", + "reverseYBuckets": false, + "targets": [ + { + "alias": "$tag_servername", + "datasource": { + "type": "influxdb", + "uid": "${DS_INFLUXDB}" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "poolname" + ], + "type": "tag" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "server_sharedProcessorPool", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"utilizedProcUnits\") / mean(\"configurableProcUnits\") AS \"Utilization\" FROM \"server_processor\" WHERE $timeFilter GROUP BY time($__interval), \"servername\" fill(none)", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "utilizedProcUnits" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "servername", + "operator": "=~", + "value": "/^$ServerName$/" + } + ] + } + ], + "title": "Processors - Utilized / Configurable", + "tooltip": { + "show": true, + "showHistogram": false + }, + "transparent": true, + "type": "heatmap", + "xAxis": { + "show": true + }, + "yAxis": { + "decimals": 1, + "format": "percentunit", + "logBase": 1, + "max": "1", + "min": "0", + "show": true + }, + "yBucketBound": "auto" + }, + { + "description": "", + "fieldConfig": { + "defaults": { + "decimals": 2, + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 70 + }, + { + "color": "red", + "value": 85 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 12, + "x": 0, + "y": 14 + }, + "id": 36, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "8.3.5", + "targets": [ + { + "alias": "$tag_servername", + "datasource": { + "type": "influxdb", + "uid": "${DS_INFLUXDB}" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "poolname" + ], + "type": "tag" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "server_sharedProcessorPool", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"utilizedProcUnits\") / mean(\"configurableProcUnits\") AS \"Utilization\" FROM \"server_processor\" WHERE $timeFilter GROUP BY time($__interval), \"servername\" fill(none)", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "utilizedProcUnits" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "servername", + "operator": "=~", + "value": "/^$ServerName$/" + } + ] + } + ], + "title": "Processors - Utilized / Configurable", + "type": "gauge" + }, + { + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-BlYlRd" + }, + "decimals": 1, + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 12, + "x": 12, + "y": 14 + }, + "id": 37, + "options": { + "displayMode": "lcd", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showUnfilled": true + }, + "pluginVersion": "8.3.5", + "targets": [ + { + "alias": "$tag_servername", + "datasource": { + "type": "influxdb", + "uid": "${DS_INFLUXDB}" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "poolname" + ], + "type": "tag" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "server_sharedProcessorPool", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"utilizedProcUnits\") / mean(\"configurableProcUnits\") AS \"Utilization\" FROM \"server_processor\" WHERE $timeFilter GROUP BY time($__interval), \"servername\" fill(none)", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "utilizedProcUnits" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "servername", + "operator": "=~", + "value": "/^$ServerName$/" + } + ] + } + ], + "title": "Processors - Utilized / Configurable", + "type": "bargauge" + }, + { + "description": "Configurable processors are activated and available for use and assignment. The difference up to the total is \"dark cores\" which can be activated by code or used with PEP-2.0.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-BlPu" + }, + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 12, + "x": 0, + "y": 25 + }, + "id": 35, + "options": { + "displayMode": "lcd", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [], + "fields": "", + "values": false + }, + "showUnfilled": true + }, + "pluginVersion": "8.3.5", + "targets": [ + { + "alias": "$tag_servername", + "datasource": { + "type": "influxdb", + "uid": "${DS_INFLUXDB}" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "poolname" + ], + "type": "tag" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "server_sharedProcessorPool", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"configurableProcUnits\") / mean(\"totalProcUnits\") AS \"Utilization\" FROM \"server_processor\" WHERE $timeFilter GROUP BY time($__interval), \"servername\" fill(none)", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "utilizedProcUnits" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "servername", + "operator": "=~", + "value": "/^$ServerName$/" + } + ] + } + ], + "title": "Processors - Configurable / Total", + "type": "bargauge" + }, + { + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 85 + }, + { + "color": "red", + "value": 95 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 12, + "x": 12, + "y": 25 + }, + "id": 2, + "links": [], + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "center", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "text": { + "titleSize": 16 + }, + "textMode": "value_and_name" + }, + "pluginVersion": "8.3.5", + "targets": [ + { + "alias": "$tag_servername", + "datasource": { + "type": "influxdb", + "uid": "${DS_INFLUXDB}" + }, + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "servername" + ], + "type": "tag" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "server_memory", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"assignedMemToLpars\") / mean(\"totalMem\") AS \"Utilization\" FROM \"server_memory\" WHERE $timeFilter GROUP BY time($__interval), \"servername\" fill(none)", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "assignedMemToLpars" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "assigned" + ], + "type": "alias" + } + ], + [ + { + "params": [ + "availableMem" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "available" + ], + "type": "alias" + } + ] + ], + "tags": [] + } + ], + "title": "Memory Utilization - Assigned / Total", + "type": "stat" + } + ], + "refresh": "30s", + "schemaVersion": 34, + "style": "dark", + "tags": [ + "Power" + ], + "templating": { + "list": [] + }, + "time": { + "from": "now-7d", + "now": false, + "to": "now-30s" + }, + "timepicker": { + "nowDelay": "30s", + "refresh_intervals": [ + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "HMCi - Power System Utilization", + "uid": "MZ7Q-4K4k", + "version": 3, + "weekStart": "" +} diff --git a/src/main/java/biz/nellemann/hmci/ManagedSystem.java b/src/main/java/biz/nellemann/hmci/ManagedSystem.java index 94d96fb..4c2758f 100644 --- a/src/main/java/biz/nellemann/hmci/ManagedSystem.java +++ b/src/main/java/biz/nellemann/hmci/ManagedSystem.java @@ -79,20 +79,16 @@ class ManagedSystem extends Resource { this.includePartitions = includePartitions; } - public void setDoEnergy(Boolean doEnergy) { + public void setDoEnergy(Boolean enableEnergyMonitoring) { - if(pcmPreference == null) { + if(pcmPreference == null || !enableEnergyMonitoring) { return; } - if(doEnergy && pcmPreference.energyMonitoringCapable && !pcmPreference.energyMonitorEnabled) { + if(pcmPreference.energyMonitoringCapable && !pcmPreference.energyMonitorEnabled) { setPcmPreference(); } - if(pcmPreference.energyMonitorEnabled) { - systemEnergy = new SystemEnergy(restClient, this); - } - } @@ -195,14 +191,14 @@ class ManagedSystem extends Resource { } public void setPcmPreference() { - log.info("getPcmPreferences()"); + log.info("setPcmPreference()"); try { String urlPath = String.format("/rest/api/pcm/ManagedSystem/%s/preferences", id); XmlMapper xmlMapper = new XmlMapper(); if(pcmPreference.energyMonitoringCapable && !pcmPreference.energyMonitorEnabled) { - //log.warn("getPcmPreferences() - TODO: Enabling energyMonitor"); + log.warn("getPcmPreferences() - Enabling energyMonitor"); pcmPreference.metadata.atom = null; pcmPreference.energyMonitorEnabled = true; //xmlMapper.enable(SerializationFeature.INDENT_OUTPUT); @@ -211,6 +207,7 @@ class ManagedSystem extends Resource { restClient.postRequest(urlPath, updateXml); } } catch (IOException e) { + pcmPreference.energyMonitorEnabled = false; log.warn("setPcmPreferences() - Error: {}", e.getMessage()); } } diff --git a/src/main/java/biz/nellemann/hmci/SystemEnergy.java b/src/main/java/biz/nellemann/hmci/SystemEnergy.java index e4cf1bf..8e7c0b5 100644 --- a/src/main/java/biz/nellemann/hmci/SystemEnergy.java +++ b/src/main/java/biz/nellemann/hmci/SystemEnergy.java @@ -36,7 +36,7 @@ class SystemEnergy extends Resource { // Do not try to parse empty response if(xml == null || xml.length() <= 1) { - log.warn("refresh() - no data."); + log.debug("refresh() - no data."); // We do not log as 'warn' as many systems do not have this enabled. return; } @@ -62,23 +62,6 @@ class SystemEnergy extends Resource { log.error("refresh() - error: {} {}", e.getClass(), e.getMessage()); } - - /* - try { - Document doc = Jsoup.parse(responseBody); - Element entry = doc.select("feed > entry").first(); - Element link = Objects.requireNonNull(entry).select("link[href]").first(); - - if(Objects.requireNonNull(link).attr("type").equals("application/json")) { - String href = link.attr("href"); - log.trace("getPcmDataForEnergy() - URL: {}", href); - jsonBody = sendGetRequest(new URL(href)); - } - - } catch(Exception e) { - log.warn("getPcmDataForEnergy() - XML parse error: {}", systemEnergy, e); - } - */ }