NewsBlur/config/munin/mysql_dbrows_
2016-11-11 11:09:13 -08:00

33 lines
835 B
Python
Executable file

#!/srv/newsblur/venv/newsblur/bin/python
# -*- coding: utf-8 -*-
from vendor.munin.mysql import MuninMySQLPlugin
class MuninMySQLDBRowsPlugin(MuninMySQLPlugin):
dbname_in_args = True
args = "-l 0 --base 1000"
vlabel = "rows"
info = "Rows in database"
fields = (
('rows', dict(
label = "Row count",
info = "Row count",
type = "GAUGE",
)),
)
@property
def title(self):
return "MySQL number of rows in database %s" % self.dbname
def execute(self):
c = self.cursor()
c.execute("SELECT sum(table_rows) FROM information_schema.TABLES WHERE table_schema = %s", (self.dbname,))
row = c.fetchone()
return dict(
rows = row[0],
)
if __name__ == "__main__":
MuninMySQLDBRowsPlugin().run()