Skip to content

Commit

Permalink
MySQL ODBC Database Monitor 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
epuzanov committed Dec 26, 2010
1 parent 3a85408 commit 2b98d56
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 26 deletions.
Expand Up @@ -86,15 +86,15 @@ def hostname(self):
inst = self.getDBSrvInst()
if inst: return inst.hostname
else: return self.device().manageIp

def port(self):
"""
Return the port attribute of DBSrvInst
"""
inst = self.getDBSrvInst()
if inst: return inst.port
else: return 3306

def zMySqlConnectionString(self):
"""
Return the ODBC connection string
Expand Down
Expand Up @@ -12,9 +12,9 @@
MySqlDatabaseMap maps the MySQL Databases table to Database objects
$Id: MySqlDatabaseMap.py,v 1.3 2010/10/06 09:59:28 egor Exp $"""
$Id: MySqlDatabaseMap.py,v 1.4 2010/12/15 21:04:28 egor Exp $"""

__version__ = "$Revision: 1.3 $"[11:-2]
__version__ = "$Revision: 1.4 $"[11:-2]

from Products.ZenModel.ZenPackPersistence import ZenPackPersistence
from Products.DataCollector.plugins.DataMaps import MultiArgs
Expand All @@ -38,19 +38,19 @@ class MySqlDatabaseMap(ZenPackPersistence, SQLPlugin):

def queries(self, device):
queries = {}
inst = 0
uid = getattr(device, 'zMySqlUsername', None)
pwd = getattr(device, 'zMySqlUsername', None)
inst = 0
uid = getattr(device, 'zMySqlUsername', None)
pwd = getattr(device, 'zMySqlPassword', None)
for cs in getattr(device, 'zMySqlConnectionString', ['DRIVER={MySQL}']):
options = dict([opt.split('=') for opt in cs.split(';')])
cs = ['MySQLdb']
cs.append("host='%s'"%options.get('SERVER', device.manageIp))
cs.append("port=%s"%options.get('PORT', '3306'))
cs.append("host='%s'"%options.get('SERVER', device.manageIp))
cs.append("port=%s"%options.get('PORT', '3306'))
cs.append("db='information_schema'")
if uid or 'UID' in options:
cs.append("user='%s'"%options.get('UID', uid))
cs.append("user='%s'"%options.get('UID', uid))
if pwd or 'PWD' in options:
cs.append("passwd='%s'"%options.get('PWD', pwd))
cs.append("passwd='%s'"%options.get('PWD', pwd))
queries['si_%s'%inst] = (
"SHOW VARIABLES",
None,
Expand All @@ -74,7 +74,7 @@ def queries(self, device):
engine,
MIN(create_time) as created,
version,
MIN(table_collation) as collation,
MIN(table_collation) as collation,
'%s' as instance
FROM TABLES
GROUP BY table_schema"""%inst,
Expand All @@ -90,7 +90,7 @@ def queries(self, device):
})
inst = inst + 1
return queries


def process(self, device, results, log):
log.info('processing %s for device %s', self.name(), device.id)
Expand Down
Expand Up @@ -2,9 +2,6 @@
<objects>
<!-- ('', 'zport', 'dmd', 'Devices', 'Server', 'rrdTemplates', 'MySqlDatabase') -->
<object id='/zport/dmd/Devices/Server/rrdTemplates/MySqlDatabase' module='Products.ZenModel.RRDTemplate' class='RRDTemplate'>
<property id='zendoc' type='string'>
MySQL Server Database Statistics
</property>
<property type="text" id="description" mode="w" >
MySQL Server Database Statistics
</property>
Expand Down Expand Up @@ -162,9 +159,6 @@ AVERAGE
</object>
<!-- ('', 'zport', 'dmd', 'Devices', 'Server', 'rrdTemplates', 'MySqlSrvInst') -->
<object id='/zport/dmd/Devices/Server/rrdTemplates/MySqlSrvInst' module='Products.ZenModel.RRDTemplate' class='RRDTemplate'>
<property id='zendoc' type='string'>
MySQL Server Instance Statistics
</property>
<property type="text" id="description" mode="w" >
MySQL Server Instance Statistics
</property>
Expand Down Expand Up @@ -1439,9 +1433,6 @@ MySQL Server 5.0.45 (x86_64)
<property type="boolean" id="isOS" mode="w" >
False
</property>
<tomany id='instances'>
<link objid='/zport/dmd/Devices/Server/Linux/devices/RS-MGM-07.bmg.local/os/softwaredbsrvinstances/0'/>
</tomany>
</object>
<object id='MySQL-client-standard-5.0.24a-0.rhel4' module='Products.ZenModel.SoftwareClass' class='SoftwareClass'>
<property type="string" id="name" mode="w" >
Expand Down Expand Up @@ -1562,9 +1553,6 @@ True
</property>
<tomanycont id='osProcessClasses'>
<object id='mysqld' module='Products.ZenModel.OSProcessClass' class='OSProcessClass'>
<property id='zendoc' type='string'>
MySQL Server Process
</property>
<property type="string" id="name" mode="w" >
mysqld
</property>
Expand Down
2 changes: 1 addition & 1 deletion ZenPacks.community.MySQLMon_ODBC/setup.py
Expand Up @@ -3,7 +3,7 @@
# or saved. Do not modify them directly here.
# NB: PACKAGES is deprecated
NAME = "ZenPacks.community.MySQLMon_ODBC"
VERSION = "3.0"
VERSION = "3.1"
AUTHOR = "Egor Puzanov"
LICENSE = ""
NAMESPACE_PACKAGES = ['ZenPacks', 'ZenPacks.community']
Expand Down

0 comments on commit 2b98d56

Please sign in to comment.