forked from samuel/python-munin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmysql_dbrows_
More file actions
executable file
·33 lines (27 loc) · 809 Bytes
/
mysql_dbrows_
File metadata and controls
executable file
·33 lines (27 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from 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()