@cryptotaxi247 / netdata-1 / commits / dcf124207

Add Buffer Cache

Facetoe committed Oct 3, 2016 at 19:14 UTC dcf1242076e38a00998d002a2ec0fb444131f1ff
1 file changed +19 -2
python.d/postgres.chart.py
+19 -2
@@ -18,7 +18,7 @@ retries = 60
18 # 'port': 5432
19 # }
20
21 -ORDER = ["Tuples", "Scans", "BGWriter"]
21 +ORDER = ["Tuples", "Scans", "BGWriter", "BufferCache"]
22 CHARTS = {
23 "Tuples": {
24 'options': ["tuples", "PostgreSQL tuple access", "Tuples / sec", "tuples", "postgres.tuples", "line"],
@@ -43,6 +43,12 @@ CHARTS = {
43 ["buffers_clean", "buffers_clean", "incremental", 1, 1],
44 ["buffers_checkpoint", "buffers_checkpoint", "incremental", 1, 1],
45 ["buffers_backend", "buffers_backend", "incremental", 1, 1],
46 + ]},
47 + "BufferCache": {
48 + 'options': ["buffer_cache", "Buffer Cache", "Buffers / sec", "buffer_cache", "postgres.buffer_cache", "line"],
49 + 'lines': [
50 + ["blks_read", "blks_read", "incremental", 1, 1],
51 + ["blks_hit", "blks_hit", "incremental", 1, 1],
52 ]}
53 }
54
@@ -52,7 +58,6 @@ class Service(SimpleService):
58 super(self.__class__, self).__init__(configuration=configuration, name=name)
59 self.order = ORDER
60 self.definitions = CHARTS
55 - self.error(str(configuration))
61 self.configuration = configuration
62 self.connection = None
63
@@ -93,6 +98,7 @@ class Service(SimpleService):
98 """)
99 graph_data = {k: float(v) for k, v in cursor.fetchone().items()}
100
101 + # Pull in BGWriter info
102 cursor.execute("""
103 SELECT
104 buffers_checkpoint,
@@ -104,6 +110,17 @@ class Service(SimpleService):
110 """)
111 graph_data.update(dict(cursor.fetchone()))
112
113 + cursor.execute("""
114 + SELECT
115 + sum(blks_read) AS blks_read,
116 + sum(blks_hit) AS blks_hit
117 + FROM
118 + pg_stat_database
119 + WHERE
120 + datname = %(database)s
121 + """, self.configuration)
122 + graph_data.update({k: float(v) for k, v in cursor.fetchone().items()})
123 +
124 self.connection.commit()
125 cursor.close()
126 return graph_data