-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(backend): 监控采集模板刷新,补充machine_types,支持一个插件多个采集 close #1583
- Loading branch information
1 parent
11652b8
commit 2f1f12a
Showing
29 changed files
with
506,231 additions
and
44,823 deletions.
There are no files selected for viewing
12,586 changes: 6,318 additions & 6,268 deletions
12,586
dbm-ui/backend/bk_dataview/dashboards/json/es.json
Large diffs are not rendered by default.
Oops, something went wrong.
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
52 changes: 52 additions & 0 deletions
52
dbm-ui/backend/db_monitor/management/commands/fix_collect_template.py
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,52 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. | ||
Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved. | ||
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at https://opensource.org/licenses/MIT | ||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations under the License. | ||
""" | ||
import glob | ||
import json | ||
import logging | ||
import os | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
from backend.db_monitor.constants import TPLS_ALARM_DIR, TPLS_COLLECT_DIR, TargetPriority | ||
|
||
logger = logging.getLogger("root") | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "采集模板文件修复" | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
"-d", | ||
"--dbtype", | ||
choices=["mysql", "redis", "es", "hdfs", "kafka", "pulsar", "influxdb", "all"], | ||
default="all", | ||
type=str, | ||
help="db类型", | ||
) | ||
|
||
def update_json_file(self, f, template_dict): | ||
f.seek(0) | ||
f.write(json.dumps(template_dict, indent=2)) | ||
f.truncate() | ||
|
||
def handle(self, *args, **options): | ||
db_type = options["dbtype"] | ||
json_files = glob.glob(os.path.join(TPLS_COLLECT_DIR, "*.json")) | ||
for json_file in json_files: | ||
with open(json_file, "r+") as f: | ||
template_dict = json.loads(f.read()) | ||
# 补充 machine_types 参数 | ||
if not template_dict.get("machine_types"): | ||
template_dict["machine_types"] = [] | ||
|
||
template_dict.pop("short_name", None) | ||
self.update_json_file(f, template_dict) |
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
Oops, something went wrong.