# Path: collectors/etc/pxcconf.py
# def getUserPassword():
# def getKeyMap():
# def getGaleraFile():
# def getInterval():
# def getPrefix():
# 
# Path: collectors/lib/utils.py
# PY3 = sys.version_info[0] > 2
# USER = "nobody"
# def drop_privileges(user=USER):
# def is_sockfile(path):
# def err(msg):
#     def is_numeric(value):
#     def is_numeric(value):


import MySQLdb as mysql # pylint: disable=import-error
import time
import sys
import os.path
from collectors.etc import pxcconf
from collectors.lib import utils
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.  This program is distributed in the hope that it
# will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
# General Public License for more details.  You should have received a copy
# of the GNU Lesser General Public License along with this program.  If not,
# see <http://www.gnu.org/licenses/>.

"""
TCollector for Percona XtraDB Clusters

It's possible to query every single 'wsrep'-Variable.
If you want to add more variables simply edit the pxcconf.py

ATTENTION: Only tested on Debian/Ubuntu systems.
"""


__author__     = "Kai Laufer"
__version__    = "1.0.1"
__email__      = "mail@kai-laufer.de"

""" You can find these functions and additional information in etc/pxcconf.py """
prefix      = pxcconf.getPrefix() or "pxc" # Prefix for the collector, e.g. pxc -> pxc.wsrep_replicated_bytes
interval    = pxcconf.getInterval() or 1 # Interval for checking MySQL statistics
galeraFile  = pxcconf.getGaleraFile() or "/usr/lib/libgalera_smm.so" # Path to a galera specific file for ensuring that check won't run with a usual MySQL server. Default: "/usr/lib/libgalera_smm.so"
login       = pxcconf.getUserPassword() # MySQL-User, MySQL-Password and MySQL-Host (localhost)

# Path: collectors/etc/pxcconf.py
# def getUserPassword():
# def getKeyMap():
# def getGaleraFile():
# def getInterval():
# def getPrefix():
# 
# Path: collectors/lib/utils.py
# PY3 = sys.version_info[0] > 2
# USER = "nobody"
# def drop_privileges(user=USER):
# def is_sockfile(path):
# def err(msg):
#     def is_numeric(value):
#     def is_numeric(value):


# Path: collectors/0/pxc-collector.py
import MySQLdb as mysql # pylint: disable=import-error
import time
import sys
import os.path
from collectors.etc import pxcconf
from collectors.lib import utils

#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.  This program is distributed in the hope that it
# will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
# General Public License for more details.  You should have received a copy
# of the GNU Lesser General Public License along with this program.  If not,
# see <http://www.gnu.org/licenses/>.

"""
TCollector for Percona XtraDB Clusters

It's possible to query every single 'wsrep'-Variable.
If you want to add more variables simply edit the pxcconf.py

ATTENTION: Only tested on Debian/Ubuntu systems.
"""


__author__     = "Kai Laufer"
__version__    = "1.0.1"
__email__      = "mail@kai-laufer.de"

""" You can find these functions and additional information in etc/pxcconf.py """
prefix      = pxcconf.getPrefix() or "pxc" # Prefix for the collector, e.g. pxc -> pxc.wsrep_replicated_bytes
interval    = pxcconf.getInterval() or 1 # Interval for checking MySQL statistics
galeraFile  = pxcconf.getGaleraFile() or "/usr/lib/libgalera_smm.so" # Path to a galera specific file for ensuring that check won't run with a usual MySQL server. Default: "/usr/lib/libgalera_smm.so"
login       = pxcconf.getUserPassword() # MySQL-User, MySQL-Password and MySQL-Host (localhost)

myMap       = pxcconf.getKeyMap() or ( "wsrep_last_committed", "wsrep_replicated", "wsrep_repl_keys", "wsrep_local_commits" ) # Status variables which should be read