mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-04-13 09:42:01 +00:00
26 lines
725 B
Python
Executable file
26 lines
725 B
Python
Executable file
#!/srv/newsblur/venv/newsblur/bin/python
|
|
|
|
""" Monitors the total table size (data + indexes)
|
|
for all tables in the specified database."""
|
|
|
|
from vendor.munin.postgres import MuninPostgresPlugin
|
|
|
|
class PostgresTableSizes(MuninPostgresPlugin):
|
|
vlabel = "Table Size"
|
|
title = "Table Sizes"
|
|
|
|
@property
|
|
def fields(self):
|
|
return [(table, {"label": table}) for table in self.tables()]
|
|
|
|
def execute(self):
|
|
tables = {}
|
|
for table in self.tables():
|
|
cursor = self.cursor()
|
|
cursor.execute("SELECT pg_total_relation_size(%s);", (table,))
|
|
tables[table] = cursor.fetchone()[0]
|
|
return tables
|
|
|
|
if __name__ == "__main__":
|
|
PostgresTableSizes().run()
|
|
|