Skip to content

Commit fd3c00a

Browse files
authored
V2.1.1 (#175)
1 parent ae0f3bc commit fd3c00a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1212
-417
lines changed

_cmd.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def __init__(self):
422422
class TelemetryPostCommand(HiddenObdCommand):
423423

424424
def __init__(self):
425-
super(TelemetryPostCommand, self).__init__("post", "Post telemetry data to OceanBase.By default, OBD telemetry is enabled. To disable OBD telemetry, run the `obd env set TELEMETRY_MODE 0` command. To enable OBD telemetry data printing, run `obd env set TELEMETRY_LOG_MODE 1`.")
425+
super(TelemetryPostCommand, self).__init__('post', "Post telemetry data to OceanBase.By default, OBD telemetry is enabled. To disable OBD telemetry, run the `obd env set TELEMETRY_MODE 0` command. To enable OBD telemetry data printing, run `obd env set TELEMETRY_LOG_MODE 1`.")
426426
self.parser.add_option('-d', '--data', type='string', help="post obd data")
427427

428428
@property
@@ -431,9 +431,7 @@ def lock_mode(self):
431431

432432
@property
433433
def enable_log(self):
434-
if COMMAND_ENV.get(ENV.TELEMETRY_LOG_MODE, default='1') == '0':
435-
return False
436-
return True
434+
return COMMAND_ENV.get(ENV.TELEMETRY_LOG_MODE, default='0') == '1'
437435

438436
def init(self, cmd, args):
439437
super(TelemetryPostCommand, self).init(cmd, args)
@@ -447,7 +445,7 @@ def _do_command(self, obd):
447445
class TelemetryMajorCommand(HiddenMajorCommand):
448446

449447
def __init__(self):
450-
super(TelemetryMajorCommand, self).__init__("telemetry", "Telemetry for OB-Deploy.By default, OBD telemetry is enabled. To disable OBD telemetry, run the `obd env set TELEMETRY_MODE 0` command. To enable OBD telemetry data printing, run `obd env set TELEMETRY_LOG_MODE 1`.")
448+
super(TelemetryMajorCommand, self).__init__('telemetry', "Telemetry for OB-Deploy.By default, OBD telemetry is enabled. To disable OBD telemetry, run the `obd env set TELEMETRY_MODE 0` command. To enable OBD telemetry data printing, run `obd env set TELEMETRY_LOG_MODE 1`.")
451449
self.register_command(TelemetryPostCommand())
452450

453451
def do_command(self):
@@ -654,9 +652,11 @@ def get_obd_namespaces_data(self, obd):
654652
data[component] = _.get_variable('run_result')
655653
return data
656654

657-
def background_telemetry_task(self, obd):
655+
def background_telemetry_task(self, obd, demploy_name=None):
656+
if demploy_name is None:
657+
demploy_name = self.cmds[0]
658658
data = json.dumps(self.get_obd_namespaces_data(obd))
659-
LocalClient.execute_command_background(f"nohup obd telemetry post {self.cmds[0]} --data='{data}' >/dev/null 2>&1 &")
659+
LocalClient.execute_command_background(f"nohup obd telemetry post {demploy_name} --data='{data}' >/dev/null 2>&1 &")
660660

661661

662662
class ClusterConfigStyleChange(ClusterMirrorCommand):
@@ -704,7 +704,10 @@ def _do_command(self, obd):
704704
setattr(self.opts, 'force', True)
705705
setattr(self.opts, 'force_delete', True)
706706
obd.set_options(self.opts)
707-
return obd.demo()
707+
708+
res = obd.demo()
709+
self.background_telemetry_task(obd, 'demo')
710+
return res
708711

709712

710713
class WebCommand(ObdCommand):
@@ -1479,7 +1482,7 @@ def __init__(self):
14791482
self.parser.add_option('--scope', type='string', help="log type constrains, choices=[observer, election, rootservice, all]",default='all')
14801483
self.parser.add_option('--grep', type='string', help="specify keywords constrain")
14811484
self.parser.add_option('--encrypt', type='string', help="Whether the returned results need to be encrypted, choices=[true, false]", default="false")
1482-
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default=os.getcwd())
1485+
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default='./')
14831486
self.parser.add_option('--obdiag_dir', type='string', help="obdiag install dir",default=OBDIAG_HOME_PATH)
14841487

14851488
class ObdiagGatherLogCommand(ObdiagGatherMirrorCommand):
@@ -1500,7 +1503,7 @@ def __init__(self):
15001503
self.parser.add_option('--scope', type='string', help="log type constrains, choices=[observer, election, rootservice, all]",default='all')
15011504
self.parser.add_option('--grep', type='string', help="specify keywords constrain")
15021505
self.parser.add_option('--encrypt', type='string', help="Whether the returned results need to be encrypted, choices=[true, false]", default="false")
1503-
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default=os.getcwd())
1506+
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default='./')
15041507
self.parser.add_option('--obdiag_dir', type='string', help="obdiag install dir",default=OBDIAG_HOME_PATH)
15051508

15061509

@@ -1516,7 +1519,7 @@ def lock_mode(self):
15161519

15171520
def __init__(self):
15181521
super(ObdiagGatherSysStatCommand, self).__init__('sysstat', 'Gather Host information')
1519-
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default=os.getcwd())
1522+
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default='./')
15201523
self.parser.add_option('--obdiag_dir', type='string', help="obdiag install dir",default=OBDIAG_HOME_PATH)
15211524

15221525

@@ -1532,7 +1535,7 @@ def lock_mode(self):
15321535

15331536
def __init__(self):
15341537
super(ObdiagGatherStackCommand, self).__init__('stack', 'Gather stack')
1535-
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default=os.getcwd())
1538+
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default='./')
15361539
self.parser.add_option('--obdiag_dir', type='string', help="obdiag install dir",default=OBDIAG_HOME_PATH)
15371540

15381541

@@ -1548,7 +1551,7 @@ def lock_mode(self):
15481551

15491552
def __init__(self):
15501553
super(ObdiagGatherPerfCommand, self).__init__('perf', 'Gather perf')
1551-
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default=os.getcwd())
1554+
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default='./')
15521555
self.parser.add_option('--scope', type='string', help="perf type constrains, choices=[sample, flame, pstack, all]",default='all')
15531556
self.parser.add_option('--obdiag_dir', type='string', help="obdiag install dir",default=OBDIAG_HOME_PATH)
15541557

@@ -1569,7 +1572,7 @@ def __init__(self):
15691572
self.parser.add_option('--to', type='string', help="specify the end of the time range. format: yyyy-mm-dd hh:mm:ss")
15701573
self.parser.add_option('--since', type='string', help="Specify time range that from 'n' [d]ays, 'n' [h]ours or 'n' [m]inutes. before to now. format: <n> <m|h|d>. example: 1h.",default='30m')
15711574
self.parser.add_option('--encrypt', type='string', help="Whether the returned results need to be encrypted, choices=[true, false]", default="false")
1572-
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default=os.getcwd())
1575+
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default='./')
15731576
self.parser.add_option('--obdiag_dir', type='string', help="obdiag install dir",default=OBDIAG_HOME_PATH)
15741577

15751578

@@ -1589,7 +1592,7 @@ def __init__(self):
15891592
self.parser.add_option('--to', type='string', help="specify the end of the time range. format: yyyy-mm-dd hh:mm:ss")
15901593
self.parser.add_option('--since', type='string', help="Specify time range that from 'n' [d]ays, 'n' [h]ours or 'n' [m]inutes. before to now. format: <n> <m|h|d>. example: 1h.",default='30m')
15911594
self.parser.add_option('--encrypt', type='string', help="Whether the returned results need to be encrypted, choices=[true, false]", default="false")
1592-
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default=os.getcwd())
1595+
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default='./')
15931596
self.parser.add_option('--obdiag_dir', type='string', help="obdiag install dir",default=OBDIAG_HOME_PATH)
15941597

15951598

@@ -1607,7 +1610,7 @@ def __init__(self):
16071610
super(ObdiagGatherPlanMonitorCommand, self).__init__('plan_monitor', 'Gather ParalleSQL information')
16081611
self.parser.add_option('-c', '--component', type='string', help="Component name to connect.", default='oceanbase-ce')
16091612
self.parser.add_option('--trace_id', type='string', help='sql trace id')
1610-
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default=os.getcwd())
1613+
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default='./')
16111614
self.parser.add_option('-u', '--user', type='string', help='The username used by database connection. [root]',default='root')
16121615
self.parser.add_option('-p', '--password', type='string', help='The password used by database connection.',default='')
16131616
self.parser.add_option('--obdiag_dir', type='string', help="obdiag install dir",default=OBDIAG_HOME_PATH)
@@ -1631,7 +1634,7 @@ def __init__(self):
16311634
self.parser.add_option('--scope', type='string', help="log type constrains, choices=[observer, election, rootservice, all]",default='all')
16321635
self.parser.add_option('--grep', type='string', help="specify keywords constrain")
16331636
self.parser.add_option('--encrypt', type='string', help="Whether the returned results need to be encrypted, choices=[true, false]", default="false")
1634-
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default=os.getcwd())
1637+
self.parser.add_option('--store_dir', type='string', help='the dir to store gather result, current dir by default.', default='./')
16351638
self.parser.add_option('--obdiag_dir', type='string', help="obdiag install dir",default=OBDIAG_HOME_PATH)
16361639

16371640

@@ -1673,7 +1676,7 @@ def __init__(self):
16731676
sys.setdefaultencoding(defaultencoding)
16741677
sys.path.append(os.path.join(ObdCommand.OBD_INSTALL_PATH, 'lib/site-packages'))
16751678
ROOT_IO.track_limit += 2
1676-
if MainCommand().init('obd', sys.argv[1:]).do_command():
1679+
if MainCommand().init(sys.argv[0], sys.argv[1:]).do_command():
16771680
ROOT_IO.exit(0)
16781681
ROOT_IO.exit(1)
16791682

_mirror.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from _rpm import Package, PackageInfo
4545
from tool import ConfigUtil, FileUtil, var_replace
4646
from _manager import Manager
47+
from tool import timeout
4748

4849

4950
_ARCH = getArchList()
@@ -276,10 +277,13 @@ def __init__(self, mirror_path, meta_data, stdio=None):
276277

277278
@property
278279
def available(self):
280+
if not self.enabled:
281+
return False
279282
if self._available is None:
280283
try:
281-
req = requests.request('get', self.baseurl)
282-
self._available = req.status_code < 400
284+
with timeout(5):
285+
req = requests.request('get', self.baseurl)
286+
self._available = req.status_code < 400
283287
except Exception:
284288
self.stdio and getattr(self.stdio, 'exception', print)('')
285289
self._available = False

const.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
OB_OFFICIAL_WEBSITE = 'https://www.oceanbase.com/'
2222

2323
# post telemetry data to OceanBase official
24-
TELEMETRY_URL = 'http://openwebapi.dev.alipay.net/api/web/oceanbase/report'
24+
TELEMETRY_WEBSITE = '<TELEMETRY_WEBSITE>'
25+
TELEMETRY_URL = '{}/api/web/oceanbase/report'.format(TELEMETRY_WEBSITE if TELEMETRY_WEBSITE else 'https://openwebapi.oceanbase.com')
2526

2627
# obdeploy version
2728
VERSION = '<VERSION>'

core.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3963,21 +3963,14 @@ def telemetry_post(self, name):
39633963
if repositories == []:
39643964
return
39653965
self.set_repositories(repositories)
3966-
target_repository = None
3967-
for repository in repositories:
3968-
if repository.name in ['oceanbase', 'oceanbase-ce']:
3969-
target_repository = repository
3970-
break
3971-
else:
3972-
target_repository = repository
3973-
telemetry_info_collect_plugin = self.plugin_manager.get_best_py_script_plugin('telemetry_info_collect', 'general', '0.1')
3974-
ret = self.call_plugin(telemetry_info_collect_plugin, target_repository, target_repository=target_repository)
3975-
if ret:
3976-
post_data = ret.get_return('post_data')
3977-
self._call_stdio('verbose', 'telemetry_data: %s' % post_data)
39783966

3979-
telemetry_post_plugin = self.plugin_manager.get_best_py_script_plugin('telemetry_post', 'general', '0.1')
3980-
return self.call_plugin(telemetry_post_plugin, target_repository, data=post_data)
3967+
telemetry_info_collect_plugin = self.plugin_manager.get_best_py_script_plugin('telemetry_info_collect', 'general', '0.1')
3968+
for repository in repositories:
3969+
if not self.call_plugin(telemetry_info_collect_plugin, repository, spacename='telemetry'):
3970+
return False
3971+
3972+
telemetry_post_plugin = self.plugin_manager.get_best_py_script_plugin('telemetry_post', 'general', '0.1')
3973+
return self.call_plugin(telemetry_post_plugin, repository, spacename='telemetry')
39813974

39823975

39833976
def obdiag_gather(self, name, gather_type, opts):

example/all-components-min.yaml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,129 @@ obagent:
107107
ip: 172.19.33.4
108108
global:
109109
home_path: /root/obagent
110+
prometheus:
111+
servers:
112+
- 192.168.1.5
113+
depends:
114+
- obagent
115+
global:
116+
# The working directory for prometheus. prometheus is started under this directory. This is a required field.
117+
home_path: /root/prometheus
118+
# address: 0.0.0.0 # The ip address to bind to. Along with port, corresponds to the `web.listen-address` parameter.
119+
# port: 9090 # The http port to use. Along with address, corresponds to the `web.listen-address` parameter.
120+
# enable_lifecycle: true # Enable shutdown and reload via HTTP request. Corresponds to the `web.enable-lifecycle` parameter.
121+
# data_dir: /root/prometheus/data # Base path for metrics storage. Corresponds to the `storage.tsdb.path` parameter.
122+
# basic_auth_users: # Usernames and passwords that have full access to the web server via basic authentication. Corresponds to the `basic_auth_users` parameter.
123+
# <username>: <password> # The format of `basic_auth_users` : the key is the user name and the value is the password.
124+
# web_config: # Content of Prometheus web service config file. The format is consistent with the file. However, `basic_auth_users` cannot be set in it. Please set `basic_auth_users` above if needed. Corresponds to the `web.config.file` parameter.
125+
# tls_server_config:
126+
# # Certificate and key files for server to use to authenticate to client.
127+
# cert_file: <filename>
128+
# key_file: <filename>
129+
# config: # Configuration of the Prometheus service. The format is consistent with the Prometheus config file. Corresponds to the `config.file` parameter.
130+
# rule_files:
131+
# - rules/*rules.yaml
132+
# scrape_configs:
133+
# - job_name: prometheus
134+
# metrics_path: /metrics
135+
# scheme: http
136+
# static_configs:
137+
# - targets:
138+
# - localhost:9090
139+
# - job_name: node
140+
# basic_auth:
141+
# username: admin
142+
# password: root
143+
# metrics_path: /metrics/node/host
144+
# scheme: http
145+
# file_sd_configs: # Set the targets to be collected by reading local files. The example is to collect targets corresponding to all yaml files in the 'targets' directory under $home_path.
146+
# - files:
147+
# - 'targets/*.yaml'
148+
# - job_name: ob_basic
149+
# basic_auth:
150+
# username: admin
151+
# password: root
152+
# metrics_path: /metrics/ob/basic
153+
# scheme: http
154+
# file_sd_configs:
155+
# - files:
156+
# - 'targets/*.yaml'
157+
# - job_name: ob_extra
158+
# basic_auth:
159+
# username: admin
160+
# password: root
161+
# metrics_path: /metrics/ob/extra
162+
# scheme: http
163+
# file_sd_configs:
164+
# - files:
165+
# - 'targets/*.yaml'
166+
# - job_name: agent
167+
# basic_auth:
168+
# username: admin
169+
# password: root
170+
# metrics_path: /metrics/stat
171+
# scheme: http
172+
# file_sd_configs:
173+
# - files:
174+
# - 'targets/*.yaml'
175+
# additional_parameters: # Additional parameters for Prometheus service, among which `web.listen-address`, `web.enable-lifecycle`, `storage.tsdb.path`, `config.file` and `web.config.file` cannot be set. Please set them in the corresponding configuration above if needed.
176+
# - log.level: debug
177+
grafana:
178+
servers:
179+
- 192.168.1.5
180+
depends:
181+
- prometheus
182+
global:
183+
home_path: /root/grafana
184+
login_password: oceanbase # Grafana login password. The default value is 'oceanbase'.
185+
# data_dir: # Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used).$data_dir can be empty. The default value is $home_path/data.
186+
# logs_dir: # Directory where grafana can store logs, can be empty. The default value is $data_dir/log.
187+
# plugins_dir: # Directory where grafana will automatically scan and look for plugins, can be empty. The default value is $data_dir/plugins.
188+
# provisioning_dir: # folder that contains provisioning config files that grafana will apply on startup and while running, can be empty. The default value is $home_path/conf/provisioning.
189+
# temp_data_lifetime: # How long temporary images in data directory should be kept. Supported modifiers h (hours), m (minutes), Use 0 to never clean up temporary files, can be empty. The default value is 24h.
190+
# log_max_days: # Expired days of log file(delete after max days), can be empty. The default value is 7.
191+
# domian: # The public facing domain name used to access grafana from a browser, can be empty. The default value is $server.ip.
192+
# port: # The http port to use, can be empty. The default value is 3000.
193+
194+
# # list of datasources to insert/update depending on what's available in the database, can be empty.
195+
# # For more parameter settings, please refer to https://grafana.com/docs/grafana/latest/administration/provisioning/#datasources
196+
# datasources:
197+
# name: # name of the datasource. Required and should not be 'OB-Prometheus'
198+
# type: # datasource type. Required
199+
# access: # access mode. direct or proxy. Required
200+
# url: # the url of datasource
201+
202+
# list of dashboards providers that load dashboards into Grafana from the local filesystem, can be empty.
203+
# For more information, please refer to https://grafana.com/docs/grafana/latest/administration/provisioning/#dashboards
204+
# providers:
205+
# name: # an unique provider name. Required and should not be 'OceanBase Metrics'
206+
# type: # provider type. Default to 'file'
207+
# options:
208+
# path: # path to dashboard files on disk. Required when using the 'file' type
209+
210+
# # customize your Grafana instance by adding/modifying the custom configuration as follows
211+
# # for more information, please refer to https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#configure-grafana
212+
# # Here, setting parameters is required for format conversion.
213+
# # For example, if the original grafana configuration format is
214+
# #
215+
# # [section1.section2]
216+
# # key1 = value1
217+
# # key2 = value2
218+
# #
219+
# # Then when writing the configuration below, you need to write it as
220+
# #
221+
# # section1:
222+
# # section2:
223+
# # key1: value1
224+
# # key2: value2
225+
# #
226+
# # Here we only list one item, because there are more than 500 items. Please add them according to your own needs.
227+
# customize_config:
228+
# # original grafana configuration format is
229+
# # [server]
230+
# # protocol = http
231+
# server:
232+
# protocol: http
110233
ocp-express:
111234
depends:
112235
- oceanbase-ce

0 commit comments

Comments
 (0)