def get_stats(self, params):
        metrics = {'status': {}}

        if not self.connect(params):
            return metrics

        rows = self.get_db_global_status()
        for row in rows:
            try:
                metrics['status'][row['Variable_name']] = float(row['Value'])
            except:
                pass

        if self.config['master']:
            metrics['master'] = {}
            try:
                rows = self.get_db_master_status()
                for row_master in rows:
                    for key, value in row_master.items():
                        if key in self._IGNORE_KEYS:
                            continue
                        try:
                            metrics['master'][key] = float(row_master[key])
                        except:
                            pass
            except:
                self.log.error('MySQLCollector: Couldnt get master status')
                pass

        if self.config['slave']:
            metrics['slave'] = {}
            try:
                rows = self.get_db_slave_status()
                for row_slave in rows:
                    for key, value in row_slave.items():
                        if key in self._IGNORE_KEYS:
                            continue
                        try:
                            metrics['slave'][key] = float(row_slave[key])
                        except:
                            pass
            except:
                self.log.error('MySQLCollector: Couldnt get slave status')
                pass

        if self.config['innodb_rseg']:
            metrics['innodb_rseg'] = {}
            try:
                rows = self.get_db_innodb_rollback_segment()
                for row_rseg in rows:
                    metrics['innodb_rseg']['Innodb_rseg_curr_size'] = float(row_rseg['curr_size'])
                    metrics['innodb_rseg']['Innodb_rseg_max_size'] = float(row_rseg['max_size'])
            except:
                self.log.error('MySQLCollector: Couldnt get InnoDB rollback segment stats')
                pass

        if self.config['processlist']:
            metrics['processlist'] = {}
            try:
                rows = self.get_db_processlist()
                for idx, row_processlist in enumerate(rows):
                    cmd = str(row_processlist['Command'])
                    if cmd in self._IGNORE_KEYS:
                        continue

                    query = str(row_processlist['Info'])
                    user = str(row_processlist['User'])
                    running_time = 0
                    if row_processlist['Time'] is not None:
                        running_time = float(row_processlist['Time'])

                    if cmd == "Sleep":
                        if running_time > self.config['idle_threshold']:
                            metrics['processlist'][idx] = {
                                'metric_name': 'MySQL_idle_threads',
                                'metric_value': running_time,
                                'dimensions': {
                                    'user': str(user),
                                }
                            }
                    elif user not in self.config['ignore_users'] and running_time > self.config['query_threshold']:
                        metrics['processlist'][idx] = {
                            'metric_name': 'MySQL_long_queries',
                            'metric_value': running_time,
                            'dimensions': {
                                'user': str(user),
                                'query': str(query),
                            }
                        }
            except:
                self.log.error('MySQLCollector: Couldnt get processlist')
                pass

        if self.config['temp_tables']:
            file_match = re.compile(self.config['temp_tables'])
            metrics['temp_tables'] = {}
            try:
                tmpdir = self.config.get('tmpdir', False)
                if tmpdir:
                    for idx, tmp_file in enumerate(os.listdir(tmpdir)):
                        if file_match.match(tmp_file):
                            metrics['temp_tables'][idx] = {
                                'metric_name': 'MySQL_temptable_size',
                                'metric_value': float(os.stat(os.path.join(tmpdir, tmp_file)).st_size),
                            }
                else:
                    self.log.error("MySQLCollector: tempdir not defined in config")
            except:
                self.log.error('MySQLCollector: Couldnt get temp_table sizes')
                pass

        if self.config['innodb']:
            metrics['innodb'] = {}
            innodb_status_timer = time.time()
            try:
                rows = self.get_db_innodb_status()

                innodb_status_output = rows[0]

                todo = self.innodb_status_keys.keys()
                for line in innodb_status_output['Status'].split('\n'):
                    for key in todo:
                        match = self.innodb_status_keys[key].match(line)
                        if match is not None:
                            todo.remove(key)
                            match_index = 1
                            for key_index in key.split(','):
                                try:
                                    value = float(match.group(match_index))
                                    # store value
                                    if key_index in metrics:
                                        self.log.debug("MySQLCollector: %s"
                                                       + " already defined, "
                                                       + " ignoring new value",
                                                       key_index)
                                    else:
                                        metrics['innodb'][key_index] = value
                                    match_index += 1
                                except __HOLE__:
                                    self.log.debug("MySQLCollector: Cannot find"
                                                   + " value in innodb status "
                                                   + "for %s", key_index)
                for key in todo:
                    self.log.debug("MySQLCollector: %s regexp not matched in"
                                   + " innodb status", key)
            except Exception, innodb_status_error:
                self.log.error('MySQLCollector: Couldnt get engine innodb'
                               + ' status, check user permissions: %s',
                               innodb_status_error)
            Innodb_status_process_time = time.time() - innodb_status_timer
            self.log.debug("MySQLCollector: innodb status process time: %f",
                           Innodb_status_process_time)
            subkey = "Innodb_status_process_time"
            metrics['innodb'][subkey] = Innodb_status_process_time

        self.disconnect()

        return metrics
dataset/ETHPy150Open Yelp/fullerite/src/diamond/collectors/mysqlstat/mysqlstat.py/MySQLCollector.get_stats