def query(self, sql_query): """ Execute a SQL query and fetch all data. :param sql_query: SQL query. :type sql_query: str, unicode :return: Results of the SQL query :rtype: list """ logger.debug('Executing SQL query:') debug_multiline(sql_query) try: results = self.mssql.execute(sql_query) return results.fetchall() except PluginError as e: self.unknown(e)
import jit from jit.sysdb_data import SysDbDataCheck logger = logging.getLogger('plugin.sysdb_data') logger.debug("Starting...") # Init plugin plugin = SysDbDataCheck(version=jit.VERSION, description='Check status of all MSSQL databases.') plugin.shortoutput = "SYSDB_DATA: {databases_status}" # Query the database size logger.debug("Querying the database...") db_status = plugin.get_all_db_status() debug_multiline(pformat(db_status)) # Final status exit for the plugin status = None # Keys used to substitute values in Nagios output output_vars = { 'databases_status': [], } for db in db_status: name, state = db # Check thresholds logger.debug("Checking thresholds for \"{0}\"...".format(name)) logger.debug("\t{0}: {1}".format(name, state))
from jit.bbdd import BBDDCheck logger = logging.getLogger('plugin.bbdd') logger.debug("Starting...") # Init plugin plugin = BBDDCheck(version=jit.VERSION, description='Check the size of a JIT database file. ' 'Either database or log files can be checked.') plugin.shortoutput = "BBDD: {files_usage} {threshold}" # Query the database size logger.debug("Querying the database...") db_size = plugin.get_db_size() debug_multiline(pformat(db_size)) # Final status exit for the plugin status = None # Keys used to substitute values in Nagios output output_vars = { 'files_usage': [], 'threshold': "", } # Filter out unwanted file types filename = "" for key, stats in db_size.viewitems(): if stats['type'] == plugin.options.dbfile: filename = key
import jit from jit.bbdd import BBDDCheck logger = logging.getLogger('plugin.bbdd') logger.debug("Starting...") # Init plugin plugin = BBDDCheck(version=jit.VERSION, description='Check the size of a JIT database file. ' 'Either database or log files can be checked.') plugin.shortoutput = "BBDD: {files_usage} {threshold}" # Query the database size logger.debug("Querying the database...") db_size = plugin.get_db_size() debug_multiline(pformat(db_size)) # Final status exit for the plugin status = None # Keys used to substitute values in Nagios output output_vars = { 'files_usage': [], 'threshold': "", } # Filter out unwanted file types filename = "" for key, stats in db_size.viewitems(): if stats['type'] == plugin.options.dbfile: filename = key