From 40b3ffbf37ee95daa05d47be1bd86b7acb2c88a7 Mon Sep 17 00:00:00 2001 From: Luis Bosque Date: Thu, 23 Oct 2014 04:33:44 +0200 Subject: [PATCH] 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 --- postgresql/python_modules/postgres.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/postgresql/python_modules/postgres.py b/postgresql/python_modules/postgres.py index c35b27af..c38da0ef 100644 --- a/postgresql/python_modules/postgres.py +++ b/postgresql/python_modules/postgres.py @@ -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,