Created
November 25, 2017 19:09
-
-
Save reikoNeko/6a0600b3769d21a55cf2321f2a76651a to your computer and use it in GitHub Desktop.
Flexible icinga DB performace data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def build_dict(seq, key): | |
return dict((d[key], dict(d)) for (_, d) in enumerate(seq)) | |
i2stat = build_dict(raw["results"], 'name') | |
rate = {'IdoMysqlConnection': "idomysqlconnection_ido-mysql_queries_1min", | |
'IdoPgsqlConnection': "idomysqlconnection_ido-pgsql_queries_1min"} | |
print( set(i2stat.keys()) ) | |
activedb = list( set(rate.keys()).intersection(set(i2stat.keys())) )[0] | |
print(activedb) | |
db_performance = build_dict(i2stat[activedb]['perfdata'], 'label') | |
print(db_performance[rate[activedb]]['value']) | |
''' | |
This also works but it's less friendly. | |
[ x['value'] for x in i2stat[activedb]['perfdata'] if x['label'].endswith("1min")][0] | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment