NewsBlur/config/munin/mysql_dbsize_

42 lines
1.1 KiB
Text
Raw Permalink Normal View History

2016-11-11 11:09:13 -08:00
#!/srv/newsblur/venv/newsblur/bin/python
2011-12-02 16:22:38 -08:00
# -*- coding: utf-8 -*-
2016-11-11 11:06:33 -08:00
from vendor.munin.mysql import MuninMySQLPlugin
2011-12-02 16:22:38 -08:00
class MuninMySQLDBSizePlugin(MuninMySQLPlugin):
dbname_in_args = True
args = "-l 0 --base 1024"
vlabel = "bytes"
info = "Size of database"
fields = (
('datasize', dict(
label = "Data size (bytes)",
info = "Data size",
type = "GAUGE",
draw = "AREA",
)),
('indexsize', dict(
label = "Index size (bytes)",
info = "Index size",
type = "GAUGE",
draw = "AREA",
)),
)
@property
def title(self):
return "MySQL size of database %s" % self.dbname
def execute(self):
c = self.cursor()
c.execute("SELECT sum(data_length), sum(index_length) FROM information_schema.TABLES WHERE table_schema = %s", (self.dbname,))
row = c.fetchone()
return dict(
datasize = row[0],
indexsize = row[1],
)
if __name__ == "__main__":
MuninMySQLDBSizePlugin().run()