diff options
author | Facetoe <facetoe@facetoe.com.au> | 2016-10-03 19:14:22 +0800 |
---|---|---|
committer | Facetoe <facetoe@facetoe.com.au> | 2016-10-03 19:19:15 +0800 |
commit | dcf1242076e38a00998d002a2ec0fb444131f1ff (patch) | |
tree | c3a6f03cf9c4a9d5a7db27ce11016413144b4ebc /python.d | |
parent | 9ed56f71f505703e130f474b4e725dd25a1f9ad2 (diff) |
Add Buffer Cache
Diffstat (limited to 'python.d')
-rw-r--r-- | python.d/postgres.chart.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/python.d/postgres.chart.py b/python.d/postgres.chart.py index d3b14395ea..2946195364 100644 --- a/python.d/postgres.chart.py +++ b/python.d/postgres.chart.py @@ -18,7 +18,7 @@ retries = 60 # 'port': 5432 # } -ORDER = ["Tuples", "Scans", "BGWriter"] +ORDER = ["Tuples", "Scans", "BGWriter", "BufferCache"] CHARTS = { "Tuples": { 'options': ["tuples", "PostgreSQL tuple access", "Tuples / sec", "tuples", "postgres.tuples", "line"], @@ -43,6 +43,12 @@ CHARTS = { ["buffers_clean", "buffers_clean", "incremental", 1, 1], ["buffers_checkpoint", "buffers_checkpoint", "incremental", 1, 1], ["buffers_backend", "buffers_backend", "incremental", 1, 1], + ]}, + "BufferCache": { + 'options': ["buffer_cache", "Buffer Cache", "Buffers / sec", "buffer_cache", "postgres.buffer_cache", "line"], + 'lines': [ + ["blks_read", "blks_read", "incremental", 1, 1], + ["blks_hit", "blks_hit", "incremental", 1, 1], ]} } @@ -52,7 +58,6 @@ class Service(SimpleService): super(self.__class__, self).__init__(configuration=configuration, name=name) self.order = ORDER self.definitions = CHARTS - self.error(str(configuration)) self.configuration = configuration self.connection = None @@ -93,6 +98,7 @@ class Service(SimpleService): """) graph_data = {k: float(v) for k, v in cursor.fetchone().items()} + # Pull in BGWriter info cursor.execute(""" SELECT buffers_checkpoint, @@ -104,6 +110,17 @@ class Service(SimpleService): """) graph_data.update(dict(cursor.fetchone())) + cursor.execute(""" + SELECT + sum(blks_read) AS blks_read, + sum(blks_hit) AS blks_hit + FROM + pg_stat_database + WHERE + datname = %(database)s + """, self.configuration) + graph_data.update({k: float(v) for k, v in cursor.fetchone().items()}) + self.connection.commit() cursor.close() return graph_data |