-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add info collected from TiDB's server API #33
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2d65c64
tidb: add info collected from TiDB's server API
AstroProfundis a235e5d
tidb: minor cleanup of pdctl code
AstroProfundis 2fba3ba
tidb: check wheather tidb server api is supported
AstroProfundis b6152be
tidb: fix runtime error when collecting pdctl
AstroProfundis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we handle when
util.read_url(url)[0]
equals toNone
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We didn't do that before the change, either. I'll do some more work on error handling later, there're more unhandled potential exceptions than this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And BTW, for this particular situation, the return won't be
None
unless Prom is not working on this node, when trowing the exception will not getting things worse.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, LGTM