diff options
author | Andreas Wirooks <4233401+nudgegoonies@users.noreply.github.com> | 2018-11-23 16:29:56 +0100 |
---|---|---|
committer | Ben Kochie <superq@gmail.com> | 2018-11-23 16:29:56 +0100 |
commit | 9c9e17aba7d1995dd8a1abdcece42c04f4af4095 (patch) | |
tree | c39f1a35608d47a42770235be4825193e1ac5852 /text_collector_examples | |
parent | ea8e1373f7d179885772f3065c4b7b21e0382ae7 (diff) | |
download | prometheus_node_collector-9c9e17aba7d1995dd8a1abdcece42c04f4af4095.tar.bz2 prometheus_node_collector-9c9e17aba7d1995dd8a1abdcece42c04f4af4095.tar.xz prometheus_node_collector-9c9e17aba7d1995dd8a1abdcece42c04f4af4095.zip |
Handle 'Unknown' as measurement value. (#1113)
We use the output-compatible perccli and storcli.py does not handle 'Unknown' as a result:
```
sg="Error parsing \"/var/lib/node_exporter/perccli.prom\": text format parsing error in line 222: expected float as value, got \"Unknown\"" source="textfile.go:212"
```
I know, the perccli should not return 'Unknown' but this error breaks all other useful measurements because the prom file is not parsable. My if condition fixes this.
Signed-off-by: Andreas Wirooks <andreas.wirooks@1und1.de>
Diffstat (limited to 'text_collector_examples')
-rwxr-xr-x | text_collector_examples/storcli.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/text_collector_examples/storcli.py b/text_collector_examples/storcli.py index 65fc00f..9935e88 100755 --- a/text_collector_examples/storcli.py +++ b/text_collector_examples/storcli.py | |||
@@ -198,8 +198,9 @@ def print_all_metrics(metrics): | |||
198 | print('# HELP {}{} MegaRAID {}'.format(metric_prefix, metric, metric.replace('_', ' '))) | 198 | print('# HELP {}{} MegaRAID {}'.format(metric_prefix, metric, metric.replace('_', ' '))) |
199 | print('# TYPE {}{} gauge'.format(metric_prefix, metric)) | 199 | print('# TYPE {}{} gauge'.format(metric_prefix, metric)) |
200 | for measurement in measurements: | 200 | for measurement in measurements: |
201 | print('{}{}{} {}'.format(metric_prefix, metric, '{' + measurement['labels'] + '}', | 201 | if measurement['value'] != 'Unknown': |
202 | measurement['value'])) | 202 | print('{}{}{} {}'.format(metric_prefix, metric, '{' + measurement['labels'] + '}', |
203 | measurement['value'])) | ||
203 | 204 | ||
204 | 205 | ||
205 | def get_storcli_json(storcli_args): | 206 | def get_storcli_json(storcli_args): |