From 829f387427973ff5b0f68d3bdc30d9d8c36ef2a8 Mon Sep 17 00:00:00 2001 From: David Hain Date: Thu, 21 Jun 2018 14:18:38 -0400 Subject: [PATCH] Add scrape duration gauge --- storcli.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/storcli.py b/storcli.py index 153c1d7..59f1e70 100644 --- a/storcli.py +++ b/storcli.py @@ -21,6 +21,7 @@ import json import os import subprocess import re +import time from decimal import Decimal DESCRIPTION = """Parses StorCLI's JSON output and exposes MegaRAID health as @@ -46,7 +47,10 @@ def main(args): controllers = [] vds = [] pds = [] + + start = time.time() data = json.loads(get_storcli_json(args.storcli_path)) + end = time.time() for ctrl in data['Controllers']: dg_vd_map = {'-': None} @@ -87,6 +91,10 @@ def main(args): 'size': parse_size(pd['Size']), }) + print('# HELP megaraid_scrape_duration_seconds Scrape duration') + print('# TYPE megaraid_scrape_duration_seconds gauge') + print('megaraid_scrape_duration_seconds {:f}'.format(end - start)) + print('# HELP megaraid_controllers MegaRAID controllers') print('# TYPE megaraid_controllers gauge') for ctrl in controllers: