def get_data(self): cmd = 'mysql -u%s -p%s -h %s -P %s -e "show global status"|/usr/bin/awk \'BEGIN {OFS=","} {print $1,$2}\'' % ( self.kwargs['user'], self.kwargs['passwd'], self.kwargs['host'], self.kwargs['port']) output = subprocess.check_output(cmd, shell=True) regex = '(.*?),(.*)\n' pattern = re.compile(regex, re.IGNORECASE) matched = pattern.findall(output) status = dict() for m in matched: status[m[0].lower()] = parse_str(m[1]) return self.mktimestamp(status)
def get_data(self): cmd = 'mysql -u%s -p%s -h %s -P %s -e "show slave status\G"' % ( self.kwargs['user'], self.kwargs['passwd'], self.kwargs['host'], self.kwargs['port']) output = subprocess.check_output(cmd, shell=True) regex = '(.*?):(.*)\n' pattern = re.compile(regex, re.IGNORECASE) matched = pattern.findall(output) status = dict() for m in matched: status[m[0].lower()] = parse_str(m[1]) return self.mktimestamp(status)