Skip to content

Commit 40b3ffb

Browse files
committed
Don't crash if db was never vacuumed
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
1 parent 06d9455 commit 40b3ffb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

postgresql/python_modules/postgres.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ def pg_metrics_queries():
146146
pg_stat_table_values = results[0]
147147
seqscan = int(pg_stat_table_values[0])
148148
idxfetch = int(pg_stat_table_values[1])
149-
hours_since_vacuum = int(pg_stat_table_values[2])
150-
hours_since_analyze = int(pg_stat_table_values[3])
149+
hours_since_vacuum = int(pg_stat_table_values[2]) if pg_stat_table_values[2] != None else None
150+
hours_since_analyze = int(pg_stat_table_values[3]) if pg_stat_table_values[3] != None else None
151151
pg_metrics.update(
152152
{'Pypg_tup_seqscan':seqscan,
153153
'Pypg_tup_idxfetch':idxfetch,

0 commit comments

Comments
 (0)