Skip to content

Commit

Permalink
Don't crash if db was never vacuumed
Browse files Browse the repository at this point in the history
If the connected DB was never vacuumed or analyzed the entire plugin crashed trying to cast to integer a None from the last_vacuum and last_analyze columns
  • Loading branch information
luisbosque committed Oct 23, 2014
1 parent 06d9455 commit 40b3ffb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions postgresql/python_modules/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def pg_metrics_queries():
pg_stat_table_values = results[0]
seqscan = int(pg_stat_table_values[0])
idxfetch = int(pg_stat_table_values[1])
hours_since_vacuum = int(pg_stat_table_values[2])
hours_since_analyze = int(pg_stat_table_values[3])
hours_since_vacuum = int(pg_stat_table_values[2]) if pg_stat_table_values[2] != None else None
hours_since_analyze = int(pg_stat_table_values[3]) if pg_stat_table_values[3] != None else None
pg_metrics.update(
{'Pypg_tup_seqscan':seqscan,
'Pypg_tup_idxfetch':idxfetch,
Expand Down

0 comments on commit 40b3ffb

Please sign in to comment.