Add scrape duration gauge

This commit is contained in:
David Hain 2018-06-21 14:18:38 -04:00
parent e02c99a19b
commit 829f387427
1 changed files with 8 additions and 0 deletions

View File

@ -21,6 +21,7 @@ import json
import os import os
import subprocess import subprocess
import re import re
import time
from decimal import Decimal from decimal import Decimal
DESCRIPTION = """Parses StorCLI's JSON output and exposes MegaRAID health as DESCRIPTION = """Parses StorCLI's JSON output and exposes MegaRAID health as
@ -46,7 +47,10 @@ def main(args):
controllers = [] controllers = []
vds = [] vds = []
pds = [] pds = []
start = time.time()
data = json.loads(get_storcli_json(args.storcli_path)) data = json.loads(get_storcli_json(args.storcli_path))
end = time.time()
for ctrl in data['Controllers']: for ctrl in data['Controllers']:
dg_vd_map = {'-': None} dg_vd_map = {'-': None}
@ -87,6 +91,10 @@ def main(args):
'size': parse_size(pd['Size']), '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('# HELP megaraid_controllers MegaRAID controllers')
print('# TYPE megaraid_controllers gauge') print('# TYPE megaraid_controllers gauge')
for ctrl in controllers: for ctrl in controllers: