-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add info collected from TiDB's server API (#33)
* tidb: add info collected from TiDB's server API * See pingcap/tidb#7082 for details of the API * tidb: minor cleanup of pdctl code * tidb: check wheather tidb server api is supported * tidb: fix runtime error when collecting pdctl
- Loading branch information
1 parent
cc36955
commit f1ee159
Showing
5 changed files
with
76 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- coding: utf-8 -*- | ||
# Collect infomation with TiDB API | ||
|
||
import logging | ||
import os | ||
|
||
from utils import util | ||
from utils import fileopt | ||
from utils.measurement import MeasurementBase | ||
|
||
|
||
class TiDBInfo(MeasurementBase): | ||
# default to localhost | ||
host = "localhost" | ||
port = 10080 | ||
|
||
# The API's URI | ||
uri = "/info/all" | ||
|
||
def __init__(self, args, basedir=None, subdir=None): | ||
# init self.options and prepare self.outdir | ||
super(TiDBInfo, self).__init__(args, basedir, subdir) | ||
if args.host: | ||
self.host = args.host | ||
if args.port: | ||
self.port = args.port | ||
self.url = "http://%s:%s%s" % ( | ||
self.host, self.port, self.uri) | ||
|
||
def read_api(self): | ||
result, code = util.read_url(self.url) | ||
if code == 404: | ||
logging.info( | ||
"TiDB server API is not supported by this running instance.") | ||
return None | ||
return result | ||
|
||
def run_collecting(self): | ||
info = self.read_api() | ||
if info: | ||
fileopt.write_file(os.path.join( | ||
self.outdir, "%s_%s-tidb-info.json" % (self.host, self.port)), info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters