diff --git a/macro/run/grafana_models/HowTo_TimeSeriesMonitoring.md b/macro/run/grafana_models/HowTo_TimeSeriesMonitoring.md new file mode 100644 index 0000000000000000000000000000000000000000..6ca4915d41adc33e395f7a65b93087ec94f22333 --- /dev/null +++ b/macro/run/grafana_models/HowTo_TimeSeriesMonitoring.md @@ -0,0 +1,102 @@ +HowTo for tests on Monitoring with Timeseries database + + +# Installation + +## InfluxDb + +1. Follow the instructions at https://docs.influxdata.com/influxdb/ \ + In my case I used the `legacy` version `v1.8` for which the instructions are at + https://docs.influxdata.com/influxdb/v1.8/introduction/install/ +1. Tune the options in `/etc/influxdb/influxdb.conf` \ + For example in my case I disabled the reporting of usage data to the developper and set the host address to + `127.0.0.1:8086` in order to restrict connections to the test server to local ones. + ``` + reporting-disabled = true + [...] + [http] + bind-address = "127.0.0.1:8086" + ``` +1. Enable the InfluxDb service in the OS + ``` + sudo -k systemctl enable --now influxdb + systemctl status influxdb + ``` + +## Grafana + +1. Follow the instructions at https://grafana.com/docs/grafana/latest/setup-grafana/installation/ +1. Tune the options in `/etc/grafana/grafana.ini` \ + For example in my case I set the host address to `127.0.0.1:3000` in order to restrict connections to the test server + to local ones. +1. Enable the Grafana service in the OS + ``` + sudo -k systemctl enable --now grafana-server.service + systemctl status grafana-server.service + ``` + +## Cbmroot + +Nothing special to do, just normal compilation (and installation). + +# Initialization + +1. Create the target database in InfluxDb + ``` + influx + > create database monitoring_tests + > quit + ``` +1. Enable the publishing of the monitoring data in the unpacking macro + ``` + edit macro/run/run_unpack_tsa.C + > Uncomment line 486 + ``` +1. Setup connection to InfluxDb in Grafana + 1. Connect to `https://localhost:3000` in your favorite web browser (tested with Firefox >= 102) + 1. Connect as `admin:admin` and set the new admin password when requested (only first connection) + 1. Click on the three horizontal bars in the top left and then on `Connections > Connect Data` + 1. In the search bar enter `InfluxDb` and select `InfluxDB` (not `Influx Admin`!) + 1. Click on the new right button `create a InfluxDB data source` (blue if in Dark mode) + 1. In URL, enter `http://127.0.0.1:8086` + 1. Down in the page, in database enter `monitoring_tests` + 1. Click on `Save and Test` at the bottom of the page +1. Add the unpacker dashboard in Grafana + 1. Click on the three horizontal bars in the top left and then on `Dashboards` + 1. Click on the `New` button in the right (blue in Dark mode) + 1. Click on `Import` in the new menu which rolled down + 1. Select the file `macro/run/grafana_models/UnpackerPerfs.json` + 1. Click on `Import` at the bottom of the page + +# Running and checking + +1. In a first console, just run the unpacker macro with the typical command, everything will happen in the background + ``` + root -l -b -q 'run_unpack_tsa.C(<TSA file>, <RUN ID>, <"" or setup name if not standard>, <-1 or NB TS>)' + example > root -l -b -q 'run_unpack_tsa.C("/opt/cbm/beamtime-test-data/mcbm2022/2391_firstSpill.tsa",2391,"",-1)' + ``` +1. In a second console, check if the data arrive in the InfluxDB (this may take some time as entries are queued only + every `1 s` in data time and published only every `10 s` in processing time) + ``` + influx + > use monitoring_tests + > select * from unpack_perf + > select * from unpack_perf where "det" = "Bmon" + ``` +1. In you prefered web browser, connect to the grafana server and load the dashboard "Unpacker Performances" + 1. Click on the three horizontal bars in the top left and select `Dashboards` + 1. Click on the `General` folder in the center if it is not already expanded + 1. Click on `Unpacker Performances` + 1. Refresh the page to see more and more points appearing (for the 1st spill of mCBM run 2391, the unpacking time is + around `600-700 s`) + +# Exporting a Dashboard + +To create/modify a dashboard, please refer to the graphana Documentation and the WebGUI itself.\ +Once a new dashboard has be generated and tested locally, you can export it to JSON and share it through this cbmroot +git repository with the following steps: +1. Click on "Dashboard settings": the dented wheel close to the data picking GUI in the top bar +1. Click on `JSON model` at the bottom of the left menu +1. Click in the "online editor" +1. Select all, copy and paste in your favorite editor +1. Save as `<DashboardName>.json` in the folder `<cbmroot_source>/macro/run/graphana_models` diff --git a/macro/run/grafana_models/UnpackerPerfs.json b/macro/run/grafana_models/UnpackerPerfs.json new file mode 100644 index 0000000000000000000000000000000000000000..4b9eca57ca6c309330d1eb5a61e48ff992437946 --- /dev/null +++ b/macro/run/grafana_models/UnpackerPerfs.json @@ -0,0 +1,2213 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 2, + "id": 1, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "always", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "decmbytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 0 + }, + "id": 1, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "alias": "Bmon", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "dataIn" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "Bmon" + } + ] + }, + { + "alias": "Sts", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "dataIn" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "STS" + } + ] + }, + { + "alias": "Much", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "dataIn" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "MUCH" + } + ] + }, + { + "alias": "Trd2D", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "D", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "dataIn" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "TRD2D" + } + ] + }, + { + "alias": "Trd1D", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "E", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "dataIn" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "TRD1D" + } + ] + }, + { + "alias": "Tof", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "F", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "dataIn" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "TOF" + } + ] + }, + { + "alias": "Rich", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "G", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "dataIn" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "RICH" + } + ] + }, + { + "alias": "All Sys", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "H", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "dataIn" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [] + } + ], + "title": "Data Size IN", + "type": "timeseries" + }, + { + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "always", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 0 + }, + "id": 3, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "alias": "Bmon", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "query": "SELECT DetVal/AllVal FROM (SELECT sum(\"dataIn\") AS DetVal FROM \"autogen\".\"unpack_perf\" WHERE (\"det\"::tag = 'Bmon') AND $timeFilter GROUP BY time($__interval) fill(null); SELECT sum(\"dataIn\") AS AllVal FROM \"autogen\".\"unpack_perf\" WHERE $timeFilter GROUP BY time($__interval) fill(null))", + "rawQuery": false, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "shareIn" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "Bmon" + } + ] + }, + { + "alias": "Sts", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "shareIn" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "STS" + } + ] + }, + { + "alias": "Much", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "shareIn" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "MUCH" + } + ] + }, + { + "alias": "Trd2D", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "D", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "shareIn" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "TRD2D" + } + ] + }, + { + "alias": "Trd1D", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "E", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "shareIn" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "TRD1D" + } + ] + }, + { + "alias": "Tof", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "F", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "shareIn" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "TOF" + } + ] + }, + { + "alias": "Rich", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "G", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "shareIn" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "RICH" + } + ] + } + ], + "title": "Data Share IN", + "type": "timeseries" + }, + { + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "always", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "decmbytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 8 + }, + "id": 2, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "alias": "Bmon", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "dataOut" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "Bmon" + } + ] + }, + { + "alias": "Sts", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "dataOut" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "STS" + } + ] + }, + { + "alias": "Much", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "dataOut" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "MUCH" + } + ] + }, + { + "alias": "Trd2D", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "D", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "dataOut" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "TRD2D" + } + ] + }, + { + "alias": "Trd1D", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "E", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "dataOut" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "TRD1D" + } + ] + }, + { + "alias": "Tof", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "F", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "dataOut" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "TOF" + } + ] + }, + { + "alias": "Rich", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "G", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "dataOut" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "RICH" + } + ] + }, + { + "alias": "All Sys", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "H", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "dataOut" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ] + } + ], + "title": "Data Size OUT", + "type": "timeseries" + }, + { + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 30, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "always", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 8 + }, + "id": 4, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "alias": "Bmon", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "shareOut" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "Bmon" + } + ] + }, + { + "alias": "Sts", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "shareOut" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "STS" + } + ] + }, + { + "alias": "Much", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "shareOut" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "MUCH" + } + ] + }, + { + "alias": "Trd2D", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "D", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "shareOut" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "TRD2D" + } + ] + }, + { + "alias": "Trd1D", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "E", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "shareOut" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "TRD1D" + } + ] + }, + { + "alias": "Tof", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "F", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "shareOut" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "TOF" + } + ] + }, + { + "alias": "Rich", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "G", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "shareOut" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "RICH" + } + ] + } + ], + "title": "Data Share OUT", + "type": "timeseries" + }, + { + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "always", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 24, + "x": 0, + "y": 16 + }, + "id": 5, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "alias": "Bmon", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "unpRatio" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "Bmon" + } + ] + }, + { + "alias": "Sts", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "unpRatio" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "STS" + } + ] + }, + { + "alias": "Much", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "unpRatio" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "MUCH" + } + ] + }, + { + "alias": "Trd2D", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "D", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "unpRatio" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "TRD2D" + } + ] + }, + { + "alias": "Trd1D", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "E", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "unpRatio" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "TRD1D" + } + ] + }, + { + "alias": "Tof", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "F", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "unpRatio" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "TOF" + } + ] + }, + { + "alias": "Rich", + "datasource": { + "type": "influxdb", + "uid": "d09daad8-6103-4391-a625-ad4047f4fd02" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "unpack_perf", + "orderByTime": "ASC", + "policy": "autogen", + "refId": "G", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "unpRatio" + ], + "type": "field" + }, + { + "params": [], + "type": "sum" + } + ] + ], + "tags": [ + { + "key": "det::tag", + "operator": "=", + "value": "RICH" + } + ] + } + ], + "title": "Unpacking I/O Ratio", + "type": "timeseries" + } + ], + "refresh": false, + "schemaVersion": 38, + "style": "dark", + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "2022-05-26T01:18:30.000Z", + "to": "2022-05-26T01:19:44.000Z" + }, + "timepicker": {}, + "timezone": "", + "title": "Unpacker Performances", + "uid": "e55baa37-9184-4848-881b-1ead07adb3b9", + "version": 7, + "weekStart": "" +} diff --git a/macro/run/run_unpack_tsa.C b/macro/run/run_unpack_tsa.C index 0b4f9e225cceba18aa5b8aa059a129489435b997..879ec84c6a5f63d7ba1be8738132fb70626f9485 100644 --- a/macro/run/run_unpack_tsa.C +++ b/macro/run/run_unpack_tsa.C @@ -480,6 +480,10 @@ void run_unpack_tsa(std::vector<std::string> infile = {"test.tsa"}, UInt_t runid auto source = new CbmSourceTsArchive(infile); auto unpack = source->GetRecoUnpack(); unpack->SetDoPerfProfiling(doPerfProfiling); + /// Uncomment following line to enable extra hists about unpacker and detectors performances (I/O, I/O shares, expan.) + // unpack->SetDoPerfProfilingPerTs(doPerfProfiling); + /// Uncomment following two line to enable the InfluxDb+Grafana based publication of unpacker performances + // unpack->SetPublishProfMoni(); unpack->SetOutputFilename(perfProfFileName); // Enable full time sorting instead sorting per FLIM link unpack->SetTimeSorting(true); diff --git a/reco/steer/CMakeLists.txt b/reco/steer/CMakeLists.txt index 5e7f056bb67838b431cef1ab4a557a5b52989713..b8f3b7bd122c0f59cdc24989a059913ecdb357b2 100644 --- a/reco/steer/CMakeLists.txt +++ b/reco/steer/CMakeLists.txt @@ -30,6 +30,7 @@ set(PRIVATE_DEPENDENCIES CbmRecoSts CbmTrdReco CbmBmonReco + external::fles_monitoring ) set(INTERFACE_DEPENDENCIES diff --git a/reco/steer/CbmRecoUnpack.cxx b/reco/steer/CbmRecoUnpack.cxx index deee4f22fb740edc742a5db1067fd2cb0843c80c..f82013ad34630761fcfc72e6b9b4d52cabf401d7 100644 --- a/reco/steer/CbmRecoUnpack.cxx +++ b/reco/steer/CbmRecoUnpack.cxx @@ -15,6 +15,9 @@ #include "CbmTrdDigi.h" #include "CbmTsEventHeader.h" +#include <Monitor.hpp> +#include <System.hpp> + #include <FairRootManager.h> #include <Logger.h> @@ -37,6 +40,14 @@ using std::unique_ptr; CbmRecoUnpack::CbmRecoUnpack() {} // ---------------------------------------------------------------------------- +// ----- Destructor ------------------------------------------------------ +CbmRecoUnpack::~CbmRecoUnpack() +{ + /// Need to stay in the cxx file due to destruction of Monitor unique pointer + LOG(debug) << "CbmRecoUnpack::~CbmRecoUnpack!"; +}; +// ---------------------------------------------------------------------------- + // ----- Finish ----------------------------------------------------------- void CbmRecoUnpack::Finish() @@ -54,6 +65,28 @@ void CbmRecoUnpack::Finish() // Create some default performance profiling histograms and write them to a file if (fDoPerfProf) performanceProfiling(); + if (fPublishProfMoni) { + double dTotalDataSizeIn = 0.0; + double dTotalDataSizeOut = 0.0; + for (auto datait : fDataSizeMapCurrSec) { + dTotalDataSizeIn += datait.second.first; + dTotalDataSizeOut += datait.second.second; + } + for (auto datait : fDataSizeMapCurrSec) { + double dUnpRatio = 0 < datait.second.first ? datait.second.second / datait.second.first : 0.0; + double dShareIn = 0 < dTotalDataSizeIn ? datait.second.first / dTotalDataSizeIn : 0.0; + double dShareOut = 0 < dTotalDataSizeOut ? datait.second.second / dTotalDataSizeOut : 0.0; + fMonitor->QueueMetric( + "unpack_perf", + {{"host", fMoniCurrrentHostname}, {"jobid", fMoniJobId}, {"det", fNameMapPerTs[datait.first].first}}, + {{"dataIn", datait.second.first}, + {"dataOut", datait.second.second}, + {"unpRatio", dUnpRatio}, + {"shareIn", dShareIn}, + {"shareOut", dShareOut}}, + fPubMoniProcTime ? std::chrono::system_clock::time_point() : fMonitorSecCurrentTs); + } + } } // ---------------------------------------------------------------------------- @@ -183,6 +216,13 @@ Bool_t CbmRecoUnpack::Init() 6000, 0, 6000); } + if (fPublishProfMoni) { // + fMonitor = std::make_unique<cbm::Monitor>(fUriPublishProfMoni); + fMoniCurrrentHostname = fles::system::current_hostname(); + LOG(info) << "Unpack: Publishing monitoring metrics to time-series DB at " << fUriPublishProfMoni << " as " + << fMoniCurrrentHostname << " with job ID " << fMoniJobId; + } + return kTRUE; } // ---------------------------------------------------------------------------- @@ -200,6 +240,9 @@ void CbmRecoUnpack::initPerformanceMaps(std::uint16_t subsysid, std::string name fNameMapPerTs.emplace(std::make_pair(subsysid, std::make_pair(name, 0))); fTimeMapPerTs.emplace(std::make_pair(subsysid, std::make_pair(0, 0))); fDataSizeMapPerTs.emplace(std::make_pair(subsysid, std::make_pair(0, 0))); + if (fPublishProfMoni) { // + fDataSizeMapCurrSec.emplace(std::make_pair(subsysid, std::make_pair(0, 0))); + } fvhInpRatioPerTs.emplace(std::make_pair( subsysid, @@ -241,8 +284,8 @@ void CbmRecoUnpack::performanceProfiling() // Speed performance auto timeit = fTimeMap.find(namepair.first); - double cpu = timeit->second.first / namepair.second.second; - double wall = timeit->second.second / namepair.second.second; + double cpu = 0 < namepair.second.second ? timeit->second.first / namepair.second.second : 0.0; + double wall = 0 < namepair.second.second ? timeit->second.second / namepair.second.second : 0.0; // Data performance auto datait = fDataSizeMap.find(namepair.first); @@ -331,15 +374,55 @@ void CbmRecoUnpack::performanceProfilingPerTs() double dTotalDataSizeIn = 0.0; double dTotalDataSizeOut = 0.0; + using sctp = std::chrono::system_clock::time_point; + sctp tsStart = sctp(std::chrono::seconds(static_cast<uint64_t>(fCbmTsEventHeader->GetTsStartTime() * 1e-9))); + if (fMonitorSecCurrentTs == sctp()) { // + fMonitorSecCurrentTs = tsStart; + } + else if (fPubMoniProcTime || fMonitorSecCurrentTs < tsStart) { + for (auto datait : fDataSizeMapCurrSec) { + dTotalDataSizeIn += datait.second.first; + dTotalDataSizeOut += datait.second.second; + } + for (auto datait : fDataSizeMapCurrSec) { + double dUnpRatio = 0 < datait.second.first ? datait.second.second / datait.second.first : 0.0; + double dShareIn = 0 < dTotalDataSizeIn ? datait.second.first / dTotalDataSizeIn : 0.0; + double dShareOut = 0 < dTotalDataSizeOut ? datait.second.second / dTotalDataSizeOut : 0.0; + fMonitor->QueueMetric( + "unpack_perf", + {{"host", fMoniCurrrentHostname}, {"jobid", fMoniJobId}, {"det", fNameMapPerTs[datait.first].first}}, + {{"dataIn", datait.second.first}, + {"dataOut", datait.second.second}, + {"unpRatio", dUnpRatio}, + {"shareIn", dShareIn}, + {"shareOut", dShareOut}}, + fPubMoniProcTime ? sctp() : fMonitorSecCurrentTs); + } + fMonitorSecCurrentTs = tsStart; + for (auto datait = fDataSizeMapCurrSec.begin(); datait != fDataSizeMapCurrSec.end(); ++datait) { + datait->second.first = 0.0; + datait->second.second = 0.0; + } + dTotalDataSizeIn = 0.0; + dTotalDataSizeOut = 0.0; + } + /// Data performance for (auto datait : fDataSizeMapPerTs) { dTotalDataSizeIn += datait.second.first; dTotalDataSizeOut += datait.second.second; + + if (fPublishProfMoni) { + fDataSizeMapCurrSec[datait.first].first += datait.second.first; + fDataSizeMapCurrSec[datait.first].second += datait.second.second; + } } for (auto datait : fDataSizeMapPerTs) { fvhInpRatioPerTs[datait.first]->Fill(fCbmTsEventHeader->GetTsIndex(), datait.second.first / dTotalDataSizeIn); fvhOutRatioPerTs[datait.first]->Fill(fCbmTsEventHeader->GetTsIndex(), datait.second.second / dTotalDataSizeOut); - fvhUnpRatioPerTs[datait.first]->Fill(fCbmTsEventHeader->GetTsIndex(), datait.second.second / datait.second.first); + if (datait.second.first) { // + fvhUnpRatioPerTs[datait.first]->Fill(fCbmTsEventHeader->GetTsIndex(), datait.second.second / datait.second.first); + } } fhUnpackingRatioPerTs->Fill(fCbmTsEventHeader->GetTsIndex(), dTotalDataSizeOut / dTotalDataSizeIn); fhCpuTimePerTs->Fill(fCbmTsEventHeader->GetTsIndex(), dTotalCpuTime); diff --git a/reco/steer/CbmRecoUnpack.h b/reco/steer/CbmRecoUnpack.h index 36880bde06186da7e6519c26418477a18d4940db..89e0c6303a37cf7b5600bf6e90dfa074affdd004 100644 --- a/reco/steer/CbmRecoUnpack.h +++ b/reco/steer/CbmRecoUnpack.h @@ -44,6 +44,10 @@ class CbmTimeSlice; class TH1; class TStopwatch; +namespace cbm +{ + class Monitor; +} /** @class CbmRecoUnpack ** @brief Main steering class for unpacking in cbmroot @@ -55,14 +59,12 @@ class TStopwatch; class CbmRecoUnpack : public TObject { public: - /** @brief Constructor - ** - */ + /** @brief Constructor **/ CbmRecoUnpack(); /** @brief Destructor **/ - ~CbmRecoUnpack() { LOG(debug) << "CbmRecoUnpack::~CbmRecoUnpack!"; }; + ~CbmRecoUnpack(); /** @brief Copy constructor - not implemented **/ CbmRecoUnpack(const CbmRecoUnpack&) = delete; @@ -104,6 +106,26 @@ public: fDoPerfProfPerTs = value; } + /** + * @brief (De)Activate the publication of performance profiling data to monitoring DB + * + * @param value + */ + void SetPublishProfMoni(bool value = true, std::string sUriMonitor = "", bool useProcTime = false, + std::string sJobId = "local") + { + if (value) { + fDoPerfProf = value; + fDoPerfProfPerTs = value; + } + fPublishProfMoni = value; + if ("" != sUriMonitor) { // + fUriPublishProfMoni = sUriMonitor; + } + fPubMoniProcTime = useProcTime; + fMoniJobId = sJobId; + } + /** * @brief Set the performance profiling Output Filename * @@ -175,6 +197,15 @@ private: /** @brief Flag if performance profiling per TS should be activated or not.*/ bool fDoPerfProfPerTs = false; //! + /** @brief Flag if performance profiling data should be published to monitoring DB.*/ + bool fPublishProfMoni = false; //! + + /** @brief URI (type:hostname:port:db_name) for optional connection to monitoring DB.*/ + std::string fUriPublishProfMoni = "influx1:localhost:8086:monitoring_tests"; //! + + /** @brief Flag if perf data should be published to moni DB using data time (false) or processing time (true).*/ + bool fPubMoniProcTime = true; + /** @brief Map to store a name for the unpackers and the processed amount of digis, key = fkFlesId*/ std::map<std::uint16_t, std::pair<std::string, size_t>> fNameMap = {}; //! @@ -194,14 +225,20 @@ private: std::map<std::uint16_t, std::pair<double, double>> fDataSizeMapPerTs = {}; //! TStopwatch* fTimerTs = nullptr; - TH1* fhCpuTimePerTs = nullptr; /// Processing time per TS - TH1* fhRealTimePerTs = nullptr; /// Processing time per TS - TH1* fhCpuTimePerTsHist = nullptr; /// Plotting time per TS - TH1* fhRealTimePerTsHist = nullptr; /// Plotting time per TS - std::map<std::uint16_t, TH1*> fvhInpRatioPerTs = {}; /// ratio of system data in total input size vs TS in run - std::map<std::uint16_t, TH1*> fvhOutRatioPerTs = {}; /// ratio of system digi size in total output size vs TS in run - std::map<std::uint16_t, TH1*> fvhUnpRatioPerTs = {}; /// ratio of selected digi vs TS in run - TH1* fhUnpackingRatioPerTs = nullptr; /// ratio of total unpacked size to input size vs TS in run + TH1* fhCpuTimePerTs = nullptr; //! Processing time per TS + TH1* fhRealTimePerTs = nullptr; //! Processing time per TS + TH1* fhCpuTimePerTsHist = nullptr; //! Plotting time per TS + TH1* fhRealTimePerTsHist = nullptr; //! Plotting time per TS + std::map<std::uint16_t, TH1*> fvhInpRatioPerTs = {}; //! ratio of system data in total input size vs TS in run + std::map<std::uint16_t, TH1*> fvhOutRatioPerTs = {}; //! ratio of system digi size in total output size vs TS in run + std::map<std::uint16_t, TH1*> fvhUnpRatioPerTs = {}; //! ratio of selected digi vs TS in run + TH1* fhUnpackingRatioPerTs = nullptr; //! ratio of total unpacked size to input size vs TS in run + + std::unique_ptr<cbm::Monitor> fMonitor; //! The application's monitoring object + std::string fMoniCurrrentHostname = ""; + std::string fMoniJobId = ""; + std::chrono::system_clock::time_point fMonitorSecCurrentTs = std::chrono::system_clock::time_point(); //! + std::map<std::uint16_t, std::pair<double, double>> fDataSizeMapCurrSec = {}; //! /** @brief Run the performance profiling based on the fTimeMap and fDataSizeMap members. */ void performanceProfiling();