├── .dockerignore ├── .gitignore ├── .workflow ├── branch-pipeline.yml ├── master-pipeline.yml └── pr-pipeline.yml ├── Dockerfile ├── License ├── Makefile ├── README.md ├── constant ├── dbmind ├── __init__.py ├── __main__.py ├── app │ ├── __init__.py │ ├── diagnosis │ │ ├── __init__.py │ │ ├── cluster │ │ │ ├── __init__.py │ │ │ └── entry.py │ │ ├── query │ │ │ ├── __init__.py │ │ │ ├── entry.py │ │ │ └── slow_sql │ │ │ │ ├── __init__.py │ │ │ │ ├── analyzer.py │ │ │ │ ├── featurelib │ │ │ │ ├── __init__.py │ │ │ │ ├── feature_mapping.py │ │ │ │ ├── feature_model.py │ │ │ │ └── features.py │ │ │ │ ├── query_feature.py │ │ │ │ ├── query_info_source.py │ │ │ │ ├── significance_detection │ │ │ │ ├── __init__.py │ │ │ │ ├── average_base.py │ │ │ │ ├── ks_base.py │ │ │ │ └── sum_base.py │ │ │ │ └── slow_query.py │ │ └── system │ │ │ └── __init__.py │ ├── healing │ │ ├── __init__.py │ │ ├── _om_repair_impl.py │ │ ├── _repair_toolkit.py │ │ └── types.py │ ├── monitoring │ │ ├── __init__.py │ │ ├── ad_pool_manager.py │ │ ├── generic_anomaly_detector.py │ │ ├── regular_inspection.py │ │ └── specific_detection.py │ ├── optimization │ │ ├── __init__.py │ │ ├── index_recommendation.py │ │ ├── index_recommendation_rpc_executor.py │ │ └── knob_recommendation.py │ └── timed_app.py ├── cmd │ ├── __init__.py │ ├── cli.py │ ├── configs │ │ ├── __init__.py │ │ ├── base_configurator.py │ │ ├── config_constants.py │ │ ├── config_utils.py │ │ └── configurators.py │ ├── edbmind.py │ └── setup.py ├── common │ ├── __init__.py │ ├── algorithm │ │ ├── __init__.py │ │ ├── anomaly_detection │ │ │ ├── __init__.py │ │ │ ├── _abstract_detector.py │ │ │ ├── _utils.py │ │ │ ├── agg.py │ │ │ ├── detector_params.py │ │ │ ├── esd_test_detector.py │ │ │ ├── gradient_detector.py │ │ │ ├── increase_detector.py │ │ │ ├── iqr_detector.py │ │ │ ├── level_shift_detector.py │ │ │ ├── mad_detector.py │ │ │ ├── quantile_detector.py │ │ │ ├── seasonal_detector.py │ │ │ ├── spike_detector.py │ │ │ ├── threshold_detector.py │ │ │ └── volatility_shift_detector.py │ │ ├── basic.py │ │ ├── correlation.py │ │ ├── data_statistic.py │ │ ├── forecasting │ │ │ ├── __init__.py │ │ │ ├── adf.py │ │ │ ├── adf_values.py │ │ │ ├── arima_model │ │ │ │ ├── __init__.py │ │ │ │ └── arima_alg.py │ │ │ ├── forecasting_algorithm.py │ │ │ ├── forecasting_utils.py │ │ │ ├── linear_models.py │ │ │ └── simple_forecasting.py │ │ ├── preprocessing.py │ │ ├── seasonal.py │ │ └── stat_utils.py │ ├── cmd_executor.py │ ├── daemon.py │ ├── dispatcher │ │ ├── __init__.py │ │ ├── task_scheduler.py │ │ └── task_worker.py │ ├── either.py │ ├── exceptions.py │ ├── http │ │ ├── __init__.py │ │ ├── _service_impl.py │ │ └── requests_utils.py │ ├── opengauss_driver.py │ ├── parser │ │ ├── __init__.py │ │ ├── others.py │ │ ├── plan_parsing.py │ │ ├── semantic_analysis.py │ │ └── sql_parsing.py │ ├── platform │ │ ├── __init__.py │ │ └── _win32.py │ ├── process.py │ ├── rpc │ │ ├── __init__.py │ │ ├── base.py │ │ ├── client.py │ │ ├── errors.py │ │ ├── register.py │ │ └── server.py │ ├── security.py │ ├── sequence_buffer.py │ ├── tsdb │ │ ├── __init__.py │ │ ├── influxdb_client.py │ │ ├── opentsdb_client.py │ │ ├── prometheus_client.py │ │ ├── tsdb_client.py │ │ └── tsdb_client_factory.py │ ├── types │ │ ├── __init__.py │ │ ├── _typing.py │ │ ├── alarm.py │ │ ├── enums.py │ │ ├── misc.py │ │ ├── root_cause.py │ │ ├── sequence.py │ │ └── ssl.py │ └── utils │ │ ├── __init__.py │ │ ├── base.py │ │ ├── checking.py │ │ ├── cli.py │ │ ├── component.py │ │ ├── debugging.py │ │ └── exporter.py ├── components │ ├── __init__.py │ ├── anomaly_analysis.py │ ├── anomaly_detection.py │ ├── cmd_exporter │ │ ├── __init__.py │ │ ├── __main__.py │ │ ├── core │ │ │ ├── __init__.py │ │ │ ├── controller.py │ │ │ ├── main.py │ │ │ └── service.py │ │ └── yamls │ │ │ └── default.yml │ ├── deployment │ │ ├── __init__.py │ │ ├── __main__.py │ │ ├── deploy.conf │ │ ├── prometheus_deploy.py │ │ └── utils.py │ ├── extract_log.py │ ├── fetch_statement │ │ ├── __init__.py │ │ ├── collect_workloads.py │ │ └── fetch_statement.py │ ├── forecast.py │ ├── index_advisor │ │ ├── __init__.py │ │ ├── __main__.py │ │ ├── api_index_advise.py │ │ ├── executors │ │ │ ├── __init__.py │ │ │ ├── common.py │ │ │ ├── driver_executor.py │ │ │ └── gsql_executor.py │ │ ├── index_advisor_workload.py │ │ ├── mcts.py │ │ ├── process_bar.py │ │ ├── sql_generator.py │ │ ├── sql_output_parser.py │ │ ├── table.py │ │ └── utils.py │ ├── memory_check.py │ ├── opengauss_exporter │ │ ├── __init__.py │ │ ├── __main__.py │ │ ├── core │ │ │ ├── __init__.py │ │ │ ├── agent.py │ │ │ ├── controller.py │ │ │ ├── main.py │ │ │ └── service.py │ │ └── yamls │ │ │ ├── coming_from_each_database.yml │ │ │ ├── default.yml │ │ │ ├── pg_settings.yml │ │ │ └── statements.yml │ ├── reprocessing_exporter │ │ ├── __init__.py │ │ ├── __main__.py │ │ ├── core │ │ │ ├── __init__.py │ │ │ ├── controller.py │ │ │ ├── dao.py │ │ │ ├── main.py │ │ │ └── service.py │ │ └── reprocessing_exporter.yml │ ├── slow_query_diagnosis.py │ ├── sql_rewriter │ │ ├── __init__.py │ │ ├── executor.py │ │ ├── rules.py │ │ ├── sql_rewriter.py │ │ └── utils.py │ ├── sqldiag │ │ ├── __init__.py │ │ ├── __main__.py │ │ ├── algorithm │ │ │ ├── diag.py │ │ │ ├── duration_time_model │ │ │ │ ├── __init__.py │ │ │ │ ├── dnn.py │ │ │ │ └── template.py │ │ │ ├── sql_similarity │ │ │ │ ├── __init__.py │ │ │ │ ├── cosine_distance.py │ │ │ │ ├── levenshtein.py │ │ │ │ ├── list_distance.py │ │ │ │ └── parse_tree.py │ │ │ └── word2vec.py │ │ ├── load_sql_from_wdr.py │ │ ├── main.py │ │ ├── preprocessing.py │ │ ├── sample_data │ │ │ ├── predict.csv │ │ │ └── train.csv │ │ ├── sqldiag.conf │ │ └── utils.py │ └── xtuner │ │ ├── README.md │ │ ├── __init__.py │ │ ├── __main__.py │ │ ├── share │ │ ├── knobs.json.template │ │ ├── server.json.template │ │ └── xtuner.conf.template │ │ └── tuner │ │ ├── __init__.py │ │ ├── algorithms │ │ ├── __init__.py │ │ ├── pso.py │ │ └── rl_agent.py │ │ ├── benchmark │ │ ├── README.md │ │ ├── __init__.py │ │ ├── period.py │ │ ├── sysbench.py │ │ ├── template.py │ │ ├── tpcc.py │ │ ├── tpcds.py │ │ └── tpch.py │ │ ├── character.py │ │ ├── db_agent.py │ │ ├── db_env.py │ │ ├── env.py │ │ ├── exceptions.py │ │ ├── knob.py │ │ ├── main.py │ │ ├── recommend.py │ │ ├── recorder.py │ │ ├── utils.py │ │ ├── xtuner.conf │ │ └── xtuner.py ├── constants.py ├── controllers │ ├── __init__.py │ ├── dbmind_core.py │ ├── om_transponding.py │ └── static_files.py ├── global_vars.py ├── metadatabase │ ├── __init__.py │ ├── base.py │ ├── dao │ │ ├── __init__.py │ │ ├── alarms.py │ │ ├── dynamic_config.py │ │ ├── healing_records.py │ │ ├── index_recommendation.py │ │ ├── knob_recommendation.py │ │ ├── regular_inspections.py │ │ └── slow_queries.py │ ├── ddl.py │ ├── dynamic_config_db_session.py │ ├── result_db_session.py │ ├── schema │ │ ├── __init__.py │ │ ├── config_dynamic_params.py │ │ ├── existing_index.py │ │ ├── future_alarms.py │ │ ├── healing_records.py │ │ ├── history_alarms.py │ │ ├── index_recomm.py │ │ ├── index_recomm_stats.py │ │ ├── index_recomm_stmt_details.py │ │ ├── index_recomm_stmt_templates.py │ │ ├── knob_recomm_details.py │ │ ├── knob_recomm_metric_snapshot.py │ │ ├── knob_recomm_warnings.py │ │ ├── regular_inspections.py │ │ ├── slow_queries.py │ │ ├── slow_queries_journal.py │ │ └── slow_queries_killed.py │ └── utils.py ├── misc │ ├── VERSION │ ├── dbmind.conf │ ├── filter_label.conf │ ├── metric_map.conf │ ├── metric_value_range.conf │ └── shares │ │ └── grafana │ │ ├── forecasting.json │ │ ├── index-advisor.json │ │ ├── recommendation.json │ │ ├── regular-checking.json │ │ └── slow-query-analysis.json └── service │ ├── __init__.py │ ├── dai.py │ ├── multicluster.py │ ├── utils.py │ └── web │ ├── __init__.py │ ├── context_manager.py │ ├── data_transformer.py │ └── jsonify_utils.py ├── decompress ├── docker_run.py ├── docs ├── dbmind.png └── glossary.md ├── flake8.conf ├── gs_dbmind ├── package.sh ├── requirements-aarch64.txt ├── requirements-optional.txt ├── requirements-x86.txt ├── tests ├── __init__.py ├── conftest.py ├── features ├── mock_slow_queries.py ├── test_arima.py ├── test_basic_algorithms.py ├── test_cmd_executor.py ├── test_correlation_analysis.py ├── test_daemon.py ├── test_dai.py ├── test_detection.py ├── test_detector.py ├── test_edbmind.py ├── test_exporters.py ├── test_index_advisor_workload.py ├── test_metadatabase.py ├── test_preprocessing.py ├── test_prometheus_deploy.py ├── test_query_source.py ├── test_rewrite_sql.py ├── test_rpc.py ├── test_security.py ├── test_sequence_buffer.py ├── test_slow_sql_analyzer.py ├── test_slow_sql_feature.py ├── test_stats_algorithms.py ├── test_task_scheduler.py ├── test_timed_app.py ├── test_types.py ├── test_utils.py ├── test_worker.py └── test_xtuner_pso.py ├── tox.ini └── ui ├── README.md ├── build └── index.html ├── package.json ├── public └── index.html └── src ├── App.js ├── Main.js ├── api ├── aiTool.js ├── autonomousManagement.js ├── clusterInformation.js ├── common.js ├── databaseOptimization.js ├── dbmindSettings.js ├── intelligentInspection.js ├── overview.js ├── request.js └── securityManagement.js ├── assets ├── css │ ├── common.css │ ├── logIn.css │ └── main │ │ ├── IntelligentInspection.css │ │ ├── aiToolkit.css │ │ ├── alarm.css │ │ ├── clusterInfo.css │ │ ├── databaseOptimization.css │ │ ├── dbmindSettings.css │ │ ├── header.css │ │ ├── index.css │ │ ├── indexTuning.css │ │ ├── nodeinformation.css │ │ ├── overview.css │ │ ├── regularInspections.css │ │ └── slowQueryAnaly.css └── imgs │ ├── Analyze.png │ ├── Available.png │ ├── Average Queue Length.png │ ├── Average request delay.png │ ├── Average request size.png │ ├── Bandwidth Utilization.png │ ├── Buffer.png │ ├── Cache.png │ ├── Create.png │ ├── Current Receive Rate.png │ ├── Current Sending Rate.png │ ├── Detail.png │ ├── Details.png │ ├── Empty.png │ ├── Error packet.png │ ├── ExecutionPlan.png │ ├── Export.png │ ├── Help.png │ ├── Initiate.png │ ├── IsDeveloping.png │ ├── Packet loss.png │ ├── Pause.png │ ├── Read rate.png │ ├── Receive_drop.png │ ├── Receive_error.png │ ├── Refresh.png │ ├── Setup.png │ ├── Single Read Time.png │ ├── Single Write Time.png │ ├── Svctm.png │ ├── System.png │ ├── Tps.png │ ├── Transmit_drop.png │ ├── Transmit_error.png │ ├── Used.png │ ├── User.png │ ├── Wait.png │ ├── Write rate.png │ ├── alarm1.png │ ├── alarm2.png │ ├── alarm3.png │ ├── alarm4.png │ ├── cn.png │ ├── dlogo.png │ ├── dn.png │ ├── end.png │ ├── failure.png │ ├── getback.png │ ├── icon1.png │ ├── icon10.png │ ├── icon2.png │ ├── icon3.png │ ├── icon4.png │ ├── icon5.png │ ├── icon6.png │ ├── icon7.png │ ├── icon8.png │ ├── icon9.png │ ├── iconok.png │ ├── iconokgreen.png │ ├── iconstop.png │ ├── instance.png │ ├── logo.png │ ├── logotip.png │ ├── main.png │ ├── master.png │ ├── nb.png │ ├── not.png │ ├── notstarted.png │ ├── over.png │ ├── particular.png │ ├── run.png │ ├── running.png │ ├── slave.png │ ├── stop.png │ ├── threshold.png │ └── update.png ├── components ├── AiToolkit │ ├── IndexAdvisor.jsx │ ├── IntelligentSqlAnalysis.jsx │ ├── QueryTuning.jsx │ └── RiskAnalysis.jsx ├── AutonomousManagement │ ├── Alarms.jsx │ ├── AlarmsModules │ │ ├── HistoryAlarms.jsx │ │ ├── MetricChart.jsx │ │ └── SelfhealingRecordsTable.jsx │ ├── IntelligentInspection.jsx │ ├── IntelligentInspectionModules │ │ ├── InspectionRecords.jsx │ │ ├── InspectionTask.jsx │ │ ├── IntelligentInspectionDetail.jsx │ │ ├── RealtimeDatabase.jsx │ │ ├── RealtimeInspectionModule │ │ │ ├── DBCacheInformation.jsx │ │ │ ├── DBCapability.jsx │ │ │ ├── DBCapacityMetric.jsx │ │ │ ├── DBMemory.jsx │ │ │ ├── DBPerformance.jsx │ │ │ ├── DBUsage.jsx │ │ │ ├── SystemCpu.jsx │ │ │ ├── SystemIO.jsx │ │ │ ├── SystemMemory.jsx │ │ │ └── SystemNetwork.jsx │ │ └── RealtimeSystem.jsx │ └── SecurityManagement.jsx ├── DatabaseOptimization │ ├── DatabaseTuning.jsx │ ├── DatabaseTuningModules │ │ ├── Knob.jsx │ │ ├── Metric.jsx │ │ └── Warning.jsx │ ├── DrawerInfo.jsx │ ├── DrawerStatistics.jsx │ ├── IndexTuning.jsx │ ├── IndexTuningModules │ │ ├── AdvisedIndexes.jsx │ │ ├── ExistingIndexes.jsx │ │ ├── ImprovementRateChart.jsx │ │ ├── InvalidIndexChart.jsx │ │ ├── InvalidIndexesChange.jsx │ │ ├── PositiveSql.jsx │ │ ├── RedundantIndexesChangeChart.jsx │ │ ├── SuggestionsChangeChart.jsx │ │ └── TopShowList.jsx │ ├── IntelligentSqlCondition.jsx │ ├── RegularInspections.jsx │ ├── RegularInspectionsDay.jsx │ ├── RegularInspectionsModules │ │ ├── ActiveConnections.jsx │ │ ├── ActiveConnectionsChart.jsx │ │ ├── DatabaseSize.jsx │ │ ├── DatabaseSizeChart.jsx │ │ ├── DistributionRootCause.jsx │ │ ├── DistributionSlowSql.jsx │ │ ├── Dml.jsx │ │ ├── DynamicMemory.jsx │ │ ├── DynamicMemoryChart.jsx │ │ ├── HistoryAlarm.jsx │ │ ├── HistoryAlarmChart.jsx │ │ ├── InstanceResource.jsx │ │ ├── InstanceSlowSqlChart.jsx │ │ ├── RcaSql.jsx │ │ ├── ResponseTime.jsx │ │ ├── ResponseTimeLineChart.jsx │ │ ├── RiskAnalysis.jsx │ │ ├── SystemResourceChart.jsx │ │ ├── TableSize.jsx │ │ ├── TableSizeChart.jsx │ │ ├── TopkSql.jsx │ │ ├── TotalConnections.jsx │ │ ├── TotalConnectionsChart.jsx │ │ ├── Tps.jsx │ │ └── TpsLineChart.jsx │ ├── RegularInspectionsWeek.jsx │ ├── SlowQueryAnalysis.jsx │ ├── SlowQueryAnalysisModules │ │ ├── DistributionChart.jsx │ │ ├── KilledSlowQuery.jsx │ │ ├── MeanBufferHitRateChart.jsx │ │ ├── MeanCpuTimeChart.jsx │ │ ├── MeanFetchTimeChart.jsx │ │ ├── MeanIoTimeChart.jsx │ │ ├── SlowQueryTable.jsx │ │ ├── SlowquerycountChart.jsx │ │ ├── StatisticsChart.jsx │ │ ├── StatisticsForDatabaseChart.jsx │ │ ├── StatisticsForSchemaChart.jsx │ │ ├── SystemtableRateChart.jsx │ │ └── TableofSlowQueryTable.jsx │ └── SlowSqlDiagnosis.jsx ├── Foot.jsx ├── Header.jsx ├── MenuLeft.jsx ├── NodeInformation │ ├── CacheInformation.jsx │ ├── CapacityMetric.jsx │ ├── DBLockingAndCaching.jsx │ ├── DBMemory.jsx │ ├── DBPerformanceIndicators.jsx │ ├── DBResourceUsage.jsx │ ├── DBServiceCapability.jsx │ ├── Host.jsx │ ├── LockInformation.jsx │ ├── Node.jsx │ ├── NodeCpu.jsx │ ├── NodeIO.jsx │ ├── NodeMemory.jsx │ ├── NodeModules │ │ └── NodeEchartFormWork.jsx │ ├── NodeNetwork.jsx │ ├── Session.jsx │ ├── SessionTopQuery.jsx │ ├── SqlPlan.jsx │ ├── Storage.jsx │ ├── TopQuery.jsx │ └── VisualDeadlock.jsx ├── Overview │ ├── CollectionTable.jsx │ ├── ConnectionCharts.jsx │ ├── DataDiskCharts.jsx │ ├── DatabaseSizeChart.jsx │ ├── Instance.jsx │ ├── NodeTable.jsx │ ├── Proxy.jsx │ ├── ResponseTimeCharts.jsx │ ├── ScheduledTaskTable.jsx │ ├── SqlDistributionChart.jsx │ ├── TpsCharts.jsx │ └── TransactionStateChart.jsx └── common │ └── ResizeableTitle.jsx ├── index.js ├── pages ├── DbmindSettings.jsx ├── LogIn.jsx ├── NodeInformation.jsx └── Overview.jsx ├── router └── menu.js ├── setupProxy.js └── utils ├── exportPdf.js ├── function.js ├── history.js └── storage.js /.dockerignore: -------------------------------------------------------------------------------- 1 | .git/ 2 | 3 | *.pyc 4 | *.swp 5 | 6 | .tox 7 | .coverage 8 | 9 | __pycache__ 10 | docs/ 11 | 3rd/ 12 | 13 | *.tar.gz 14 | dbmind-installer* 15 | 16 | **/node_modules 17 | **/package-lock.json 18 | 19 | -------------------------------------------------------------------------------- /.workflow/branch-pipeline.yml: -------------------------------------------------------------------------------- 1 | version: '1.0' 2 | name: branch-pipeline 3 | displayName: BranchPipeline 4 | stages: 5 | - stage: 6 | name: compile 7 | displayName: 编译 8 | steps: 9 | - step: build@python 10 | name: build_python 11 | displayName: Python 构建 12 | pythonVersion: '3.9' 13 | # 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,7天后自动清除 14 | artifacts: 15 | # 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址 16 | - name: BUILD_ARTIFACT 17 | # 构建产物获取路径,是指代码编译完毕之后构建物的所在路径 18 | path: 19 | - ./ 20 | commands: 21 | - python3 -m pip install --upgrade pip 22 | - pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple 23 | - pip3 install -r requirements.txt 24 | - python3 ./main.py 25 | - step: publish@general_artifacts 26 | name: publish_general_artifacts 27 | displayName: 上传制品 28 | # 上游构建任务定义的产物名,默认BUILD_ARTIFACT 29 | dependArtifact: BUILD_ARTIFACT 30 | # 上传到制品库时的制品命名,默认output 31 | artifactName: output 32 | dependsOn: build_python 33 | - stage: 34 | name: release 35 | displayName: 发布 36 | steps: 37 | - step: publish@release_artifacts 38 | name: publish_release_artifacts 39 | displayName: '发布' 40 | # 上游上传制品任务的产出 41 | dependArtifact: output 42 | # 发布制品版本号 43 | version: '1.0.0.0' 44 | # 是否开启版本号自增,默认开启 45 | autoIncrement: true 46 | triggers: 47 | push: 48 | branches: 49 | exclude: 50 | - master 51 | include: 52 | - .* 53 | -------------------------------------------------------------------------------- /.workflow/master-pipeline.yml: -------------------------------------------------------------------------------- 1 | version: '1.0' 2 | name: master-pipeline 3 | displayName: MasterPipeline 4 | triggers: 5 | trigger: manual 6 | push: 7 | branches: 8 | include: 9 | - master 10 | stages: 11 | - name: compile 12 | displayName: 编译 13 | strategy: naturally 14 | trigger: auto 15 | steps: 16 | - step: build@python 17 | name: build_python 18 | displayName: Python 构建 19 | pythonVersion: '3.9' 20 | commands: 21 | - python3 -m pip install --upgrade pip 22 | - pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple 23 | - pip3 install -r requirements-x86.txt 24 | - pip3 install tox 25 | artifacts: 26 | - name: BUILD_ARTIFACT 27 | path: 28 | - ./ 29 | strategy: {} 30 | - step: publish@general_artifacts 31 | name: publish_general_artifacts 32 | displayName: 上传制品 33 | dependArtifact: BUILD_ARTIFACT 34 | artifactName: output 35 | dependsOn: build_python 36 | - name: release 37 | displayName: 发布 38 | strategy: naturally 39 | trigger: auto 40 | steps: 41 | - step: publish@release_artifacts 42 | name: publish_release_artifacts 43 | displayName: 发布 44 | dependArtifact: output 45 | version: 1.0.0.0 46 | autoIncrement: true 47 | strategy: {} 48 | -------------------------------------------------------------------------------- /.workflow/pr-pipeline.yml: -------------------------------------------------------------------------------- 1 | version: '1.0' 2 | name: pr-pipeline 3 | displayName: PRPipeline 4 | triggers: 5 | trigger: auto 6 | pr: 7 | branches: 8 | include: 9 | - master 10 | stages: 11 | - name: compile 12 | displayName: build 13 | strategy: naturally 14 | trigger: auto 15 | steps: 16 | - step: build@python 17 | name: build_python 18 | displayName: Python build 19 | pythonVersion: '3.9' 20 | commands: 21 | - pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple 22 | - '' 23 | - 'ls -l ' 24 | - env 25 | - 'git --version ' 26 | - '' 27 | - python3 -m pip install -r requirements-x86.txt 28 | - python3 -m pip install pytest 29 | - '' 30 | - python3 -m pytest tests 31 | - '' 32 | artifacts: 33 | - name: BUILD_ARTIFACT 34 | path: 35 | - ./ 36 | strategy: {} 37 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM prom/prometheus as prom 2 | FROM grafana/grafana as grafana 3 | FROM prom/node-exporter as node-exporter 4 | 5 | # build UI 6 | FROM node:16-alpine3.15 as js-builder 7 | ENV NODE_OPTIONS="--max_old_space_size=8000" 8 | 9 | WORKDIR /ui 10 | 11 | COPY ./ui . 12 | 13 | ENV NODE_ENV production 14 | RUN npm set progress=false; \ 15 | npm install --omit=dev; \ 16 | npm run build 17 | 18 | 19 | # final stage 20 | FROM python:3.9-slim 21 | MAINTAINER openGauss AI-SIG 22 | 23 | WORKDIR /app 24 | 25 | COPY requirements-x86.txt requirements.txt 26 | COPY . . 27 | 28 | COPY --from=prom /bin/prometheus /bin/prometheus 29 | COPY --from=prom /etc/prometheus/prometheus.yml /etc/prometheus/prometheus.yml 30 | COPY --from=prom /usr/share/prometheus/console_libraries/ /usr/share/prometheus/console_libraries/ 31 | COPY --from=prom /usr/share/prometheus/consoles/ /usr/share/prometheus/consoles/ 32 | COPY --from=node-exporter /bin/node_exporter /tmp/node_exporter 33 | 34 | COPY --from=js-builder /ui/build /app/ui/build 35 | 36 | # Install 3rd dependencies and move python runtime. 37 | RUN pip install --no-cache-dir -r requirements.txt -t 3rd; \ 38 | mkdir python; \ 39 | mv /usr/local/bin python; \ 40 | mv /usr/local/include python; \ 41 | mv /usr/local/lib python 42 | 43 | # Set envrionment for python runtime. 44 | ENV PATH "$PATH:/app:/app/python/bin" 45 | ENV LD_LIBRARY_PATH "/app/python/lib" 46 | ENV PYTHONPATH "3rd" 47 | # Prevent startup process from exiting, causing 48 | # the entire Docker container process to exit. 49 | ENV DBMIND_USE_DAEMON "0" 50 | 51 | # DBMind service 52 | EXPOSE 8080 53 | # Prometheus 54 | EXPOSE 9090 55 | # Grafana 56 | EXPOSE 3000 57 | 58 | CMD ["/app/python/bin/python", "/app/docker_run.py"] 59 | 60 | -------------------------------------------------------------------------------- /constant: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 4 | # 5 | # openGauss is licensed under Mulan PSL v2. 6 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 7 | # You may obtain a copy of Mulan PSL v2 at: 8 | # 9 | # http://license.coscl.org.cn/MulanPSL2 10 | # 11 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 12 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 13 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 14 | # See the Mulan PSL v2 for more details. 15 | 16 | MIN_PYTHON_VERSION="(3,7)" 17 | MAX_PYTHON_VERSION="(3,12)" 18 | 19 | -------------------------------------------------------------------------------- /dbmind/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | -------------------------------------------------------------------------------- /dbmind/app/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | def register_timed_app(): 16 | """A dummy function. 17 | We guess this `timed_app` has already been imported.""" 18 | from . import timed_app 19 | -------------------------------------------------------------------------------- /dbmind/app/diagnosis/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | -------------------------------------------------------------------------------- /dbmind/app/diagnosis/cluster/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | from .entry import diagnose_cluster 16 | -------------------------------------------------------------------------------- /dbmind/app/diagnosis/cluster/entry.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | def diagnose_cluster(host, alarm_log): 16 | pass 17 | -------------------------------------------------------------------------------- /dbmind/app/diagnosis/query/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | -------------------------------------------------------------------------------- /dbmind/app/diagnosis/query/entry.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | import logging 14 | 15 | from dbmind.common.platform import LINUX 16 | from dbmind.common.types.root_cause import RootCause 17 | from .slow_sql.analyzer import SlowSQLAnalyzer 18 | 19 | if LINUX: 20 | from dbmind.common.dispatcher.task_worker import get_mp_sync_manager 21 | 22 | shared_sql_buffer = get_mp_sync_manager().list() 23 | else: 24 | shared_sql_buffer = None 25 | _analyzer = SlowSQLAnalyzer(buffer=shared_sql_buffer) 26 | 27 | 28 | def diagnose_query(query_context): 29 | try: 30 | _analyzer.run(query_context) 31 | except Exception as e: 32 | query_context.slow_sql_instance.add_cause(RootCause.get('LACK_INFORMATION')) 33 | logging.exception(e) 34 | return query_context.slow_sql_instance 35 | -------------------------------------------------------------------------------- /dbmind/app/diagnosis/query/slow_sql/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from .slow_query import SlowQuery 14 | 15 | -------------------------------------------------------------------------------- /dbmind/app/diagnosis/query/slow_sql/featurelib/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from . import feature_mapping 14 | from . import features 15 | 16 | 17 | def load_feature_lib(): 18 | return features.FEATURE_LIB 19 | 20 | 21 | def get_feature_mapper(): 22 | return { 23 | item: value 24 | for item, value in 25 | feature_mapping.__dict__.items() if item.startswith('C') 26 | } 27 | -------------------------------------------------------------------------------- /dbmind/app/diagnosis/query/slow_sql/featurelib/feature_mapping.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | C1 = 'LOCK_CONTENTION' 14 | C2 = 'MANY_DEAD_TUPLES' 15 | C3 = 'HEAVY_SCAN_OPERATOR' 16 | C4 = 'ABNORMAL_PLAN_TIME' 17 | C5 = 'UNUSED_AND_REDUNDANT_INDEX' 18 | C6 = 'UPDATE_LARGE_DATA' 19 | C7 = 'INSERT_LARGE_DATA' 20 | C8 = 'DELETE_LARGE_DATA' 21 | C9 = 'TOO_MANY_INDEX' 22 | C10 = 'DISK_SPILL' 23 | C11 = 'VACUUM_EVENT' 24 | C12 = 'ANALYZE_EVENT' 25 | C13 = 'WORKLOAD_CONTENTION' 26 | C14 = 'CPU_RESOURCE_CONTENTION' 27 | C15 = 'IO_RESOURCE_CONTENTION' 28 | C16 = 'MEMORY_RESOURCE_CONTENTION' 29 | C17 = 'ABNORMAL_NETWORK_STATUS' 30 | C18 = 'OS_RESOURCE_CONTENTION' 31 | C19 = 'WAIT_EVENT' 32 | C20 = 'LACK_STATISTIC_INFO' 33 | C21 = 'MISSING_INDEXES' 34 | C22 = 'POOR_JOIN_PERFORMANCE' 35 | C23 = 'COMPLEX_BOOLEAN_EXPRESSIONS' 36 | C24 = 'STRING_MATCHING' 37 | C25 = 'COMPLEX_EXECUTION_PLAN' 38 | C26 = 'CORRELATED_SUBQUERY' 39 | C27 = 'POOR_AGGREGATION_PERFORMANCE' 40 | C28 = 'ABNORMAL_SQL_STRUCTURE' 41 | C29 = 'TIMED_TASK_CONFLICT' 42 | C_UNKNOWN = 'UNKNOWN' 43 | C_VIEW = 'DATABASE_VIEW' 44 | C_SQL = 'ILLEGAL_SQL' 45 | C_INVALID_SQL = 'INVALID_SQL' 46 | C_UNSUPPORTED_TYPE = 'UNSUPPORTED_TYPE' 47 | -------------------------------------------------------------------------------- /dbmind/app/diagnosis/query/slow_sql/significance_detection/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | def detect(data1, data2, method='bool', threshold=0.01, p_value=0.5): 16 | if method == 'bool': 17 | from .sum_base import detect as sum_detect 18 | from .average_base import detect as avg_detect 19 | from .ks_base import detect as ks_detect 20 | vote_res = [sum_detect(data1, data2, threshold=threshold), 21 | avg_detect(data1, data2, threshold=threshold), 22 | ks_detect(data1, data2, p_value=p_value)] 23 | return vote_res.count(True) > vote_res.count(False) 24 | elif method == 'other': 25 | from .average_base import detect as avg_detect 26 | return avg_detect(data1, data2, threshold=threshold, method=method) 27 | else: 28 | raise 29 | -------------------------------------------------------------------------------- /dbmind/app/diagnosis/query/slow_sql/significance_detection/average_base.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | alpha = 1e-10 15 | 16 | 17 | def detect(data1, data2, threshold=0.5, method='bool'): 18 | """ 19 | Calculate whether the data has abrupt changes based on the average value 20 | :param data1: input data array 21 | :param data2: input data array 22 | :param threshold: Mutation rate 23 | :param method: The way to calculate the mutation 24 | :return: bool 25 | """ 26 | if not isinstance(data1, list) or not isinstance(data2, list): 27 | raise TypeError("The format of the input data is wrong.") 28 | avg1 = sum(data1) / len(data1) if data1 else 0 29 | avg2 = sum(data2) / len(data2) if data2 else 0 30 | 31 | if method == 'bool': 32 | return avg1 * (1 - threshold) > avg2 33 | elif method == 'other': 34 | if avg1 < avg2: 35 | return 0 36 | else: 37 | return (avg1 - avg2) / (avg1 + alpha) 38 | else: 39 | raise ValueError('Not supported method %s.' % method) 40 | -------------------------------------------------------------------------------- /dbmind/app/diagnosis/query/slow_sql/significance_detection/ks_base.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from scipy.stats import ks_2samp 14 | 15 | 16 | def detect(data1, data2, p_value=0.05): 17 | """ 18 | Calculate whether the data has abrupt changes based on the KS algorithm 19 | :param data1: input data array 20 | :param data2: input data array 21 | :param p_value: confidence value 22 | :return: bool 23 | """ 24 | if not data1 or not data2: 25 | return False 26 | beta, norm = ks_2samp(data1, data2) 27 | if norm < p_value: 28 | return False 29 | return True 30 | -------------------------------------------------------------------------------- /dbmind/app/diagnosis/query/slow_sql/significance_detection/sum_base.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | def detect(data1, data2, threshold=0.5, method='bool'): 16 | """ 17 | Calculate whether the data has abrupt changes based on the sum value 18 | :param data1: input data array 19 | :param data2: input data array 20 | :param threshold: Mutation rate 21 | :param method: The way to calculate the mutation 22 | :return: bool 23 | """ 24 | alpha = 1e-10 25 | if not isinstance(data1, list) or not isinstance(data2, list): 26 | raise TypeError("The format of the input data is wrong.") 27 | sum1 = sum(data1) 28 | sum2 = sum(data2) 29 | if method == 'bool': 30 | return sum1 * (1 - threshold) > sum2 31 | elif method == 'other': 32 | if sum1 < sum2: 33 | return 0 34 | else: 35 | return (sum1 - sum2) / (sum1 + alpha) 36 | else: 37 | raise ValueError('Not supported method %s.' % method) 38 | -------------------------------------------------------------------------------- /dbmind/app/diagnosis/system/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from dbmind.common.types.root_cause import RootCause 14 | from dbmind.common.utils import dbmind_assert 15 | 16 | 17 | def diagnose_system(*args): 18 | dbmind_assert(args) 19 | return [RootCause.get('SYSTEM_ANOMALY')] 20 | -------------------------------------------------------------------------------- /dbmind/app/healing/_om_repair_impl.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from ._repair_toolkit import RepairToolkit 14 | 15 | 16 | class OMRepairToolkitImpl(RepairToolkit): 17 | @staticmethod 18 | def expand_disk(): 19 | return False, 'Cannot expand the disk because your environment ' \ 20 | 'is not a container or virtualized platform.' 21 | 22 | @staticmethod 23 | def expand_cpu(): 24 | return False, 'Cannot expand the disk because your environment ' \ 25 | 'is not a container or virtualized platform.' 26 | 27 | @staticmethod 28 | def expand_mem(): 29 | return False, 'Cannot expand the disk because your environment ' \ 30 | 'is not a container or virtualized platform.' 31 | 32 | @staticmethod 33 | def expand_cluster_nodes(): 34 | pass 35 | 36 | @staticmethod 37 | def reduce_cluster_nodes(): 38 | pass 39 | 40 | @staticmethod 41 | def set_os_params(): 42 | pass 43 | 44 | @staticmethod 45 | def set_db_params(): 46 | pass 47 | 48 | @staticmethod 49 | def db_flow_limit(): 50 | pass 51 | 52 | @staticmethod 53 | def db_restart(): 54 | pass 55 | -------------------------------------------------------------------------------- /dbmind/app/optimization/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from .index_recommendation import do_index_recomm, need_recommend_index, TemplateArgs, get_database_schemas 14 | from .knob_recommendation import recommend_knobs 15 | -------------------------------------------------------------------------------- /dbmind/cmd/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | import sys 14 | 15 | from .cli import DBMindRun 16 | from dbmind.common.utils import ExceptionCatcher 17 | 18 | 19 | @ExceptionCatcher(strategy='exit') 20 | @ExceptionCatcher(strategy='sensitive') 21 | def main() -> None: 22 | try: 23 | DBMindRun(sys.argv[1:]) 24 | except InterruptedError: 25 | sys.exit(1) 26 | -------------------------------------------------------------------------------- /dbmind/cmd/configs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/dbmind/cmd/configs/__init__.py -------------------------------------------------------------------------------- /dbmind/cmd/configs/base_configurator.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | class BaseConfig: 16 | def get(self, section, option,): 17 | raise NotImplementedError() 18 | 19 | def set(self, section, option, value): 20 | raise NotImplementedError() 21 | -------------------------------------------------------------------------------- /dbmind/common/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | -------------------------------------------------------------------------------- /dbmind/common/algorithm/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | -------------------------------------------------------------------------------- /dbmind/common/algorithm/anomaly_detection/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | from ._utils import pick_out_anomalies 15 | from .detector_params import * 16 | from .gradient_detector import GradientDetector 17 | from .increase_detector import IncreaseDetector 18 | from .iqr_detector import InterQuartileRangeDetector 19 | from .level_shift_detector import LevelShiftDetector 20 | from .seasonal_detector import SeasonalDetector 21 | from .spike_detector import SpikeDetector 22 | from .threshold_detector import ThresholdDetector 23 | from .volatility_shift_detector import VolatilityShiftDetector 24 | from .quantile_detector import QuantileDetector 25 | from .esd_test_detector import EsdTestDetector 26 | from .spike_detector import remove_spike 27 | 28 | 29 | detectors = { 30 | "GradientDetector": GradientDetector, 31 | "IncreaseDetector": IncreaseDetector, 32 | "InterQuartileRangeDetector": InterQuartileRangeDetector, 33 | "LevelShiftDetector": LevelShiftDetector, 34 | "SeasonalDetector": SeasonalDetector, 35 | "SpikeDetector": SpikeDetector, 36 | "ThresholdDetector": ThresholdDetector, 37 | "VolatilityShiftDetector": VolatilityShiftDetector, 38 | "QuantileDetector": QuantileDetector, 39 | "EsdTestDetector": EsdTestDetector, 40 | } 41 | -------------------------------------------------------------------------------- /dbmind/common/algorithm/anomaly_detection/_abstract_detector.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from abc import abstractmethod 14 | 15 | from ._utils import pick_out_anomalies 16 | from ...types import Sequence 17 | 18 | 19 | class AbstractDetector(object): 20 | @abstractmethod 21 | def _fit(self, sequence: Sequence): 22 | pass 23 | 24 | @abstractmethod 25 | def _predict(self, sequence: Sequence) -> Sequence: 26 | pass 27 | 28 | def fit_predict(self, sequence: Sequence): 29 | self._fit(sequence) 30 | anomalies = self._predict(sequence) 31 | return anomalies 32 | 33 | def detect(self, sequence: Sequence): 34 | anomalies = self.fit_predict(sequence) 35 | return pick_out_anomalies(sequence, anomalies) 36 | -------------------------------------------------------------------------------- /dbmind/common/algorithm/anomaly_detection/agg.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | from functools import reduce 15 | 16 | import numpy as np 17 | 18 | from ...types import Sequence 19 | 20 | np.seterr(divide="ignore", invalid="ignore") 21 | 22 | 23 | def merge_with_and_operator(s_list): 24 | result_values = reduce( 25 | lambda x, y: np.logical_and(x, y.values), 26 | s_list[1:], np.array(s_list[0].values) 27 | ) 28 | return Sequence(timestamps=s_list[0].timestamps, values=result_values) 29 | 30 | 31 | def merge_with_or_operator(s_list): 32 | result_values = reduce( 33 | lambda x, y: np.logical_or(x, y.values), 34 | s_list[1:], np.array(s_list[0].values) 35 | ) 36 | return Sequence(timestamps=s_list[0].timestamps, values=result_values) 37 | -------------------------------------------------------------------------------- /dbmind/common/algorithm/anomaly_detection/detector_params.py: -------------------------------------------------------------------------------- 1 | # According to actual experience, the predicted result 2 | # will be more perfect after the amount of data 3 | # (length of the sequence) exceeds a certain level, 4 | # so we set a threshold here based on experience 5 | # to decide different detection behaviors. 6 | 7 | THRESHOLD = { 8 | "positive": (0.0, -float("inf")), 9 | "negative": (float("inf"), 0.0), 10 | "both": (-float("inf"), float("inf")), 11 | "neither": (float("inf"), -float("inf")) 12 | } 13 | 14 | WAIT_EVENT_GRAPH = { 15 | 'os_cpu_usage': { 16 | 'threshold': 0.6, 17 | 'correlation': 0.2, 18 | 'wait_events': [ 19 | 'analyze', 20 | 'BufFileRead', 21 | 'BufFileWrite', 22 | 'BufMappingLock', 23 | 'BufferIOLock', 24 | 'BufHashTableSearch', 25 | 'DataFileRead', 26 | 'HashJoin - build hash', 27 | 'Sort', 28 | 'Sort - fetch tuple', 29 | 'Sort - write file', 30 | 'StrategyGetBuffer', 31 | 'WALWriteLock' 32 | ], 33 | 'other_metrics': [ 34 | 'os_mem_usage', 35 | 'os_cpu_iowait', 36 | 'os_disk_usage', 37 | 'os_disk_iops', 38 | 'os_disk_ioutils', 39 | 'os_disk_iocapacity', 40 | 'io_read_total', 41 | 'io_read_bytes', 42 | 'io_write_total', 43 | 'io_write_bytes', 44 | 'io_queue_number', 45 | 'io_read_delay_time', 46 | 'io_write_delay_time', 47 | 'pg_database_all_size', 48 | 'gaussdb_cpu_time', 49 | 'gaussdb_state_memory', 50 | 'gaussdb_data_file_read_time', 51 | 'gaussdb_data_file_write_time', 52 | 'gaussdb_confl_temp_bytes_rate', 53 | 'gaussdb_confl_temp_files_rate', 54 | 'gaussdb_connections_used_ratio', 55 | ] 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /dbmind/common/algorithm/anomaly_detection/gradient_detector.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | import numpy as np 15 | 16 | from ._abstract_detector import AbstractDetector 17 | from ._utils import over_max_coef 18 | from .spike_detector import remove_spike 19 | from ...types import Sequence 20 | 21 | 22 | def linear_fitting(x, y): 23 | x = np.array(x) 24 | y = np.array(y, dtype='float') 25 | coef, intercept = np.polyfit(x, y, deg=1) 26 | return coef, intercept 27 | 28 | 29 | class GradientDetector(AbstractDetector): 30 | def __init__(self, side="positive", max_coef=1): 31 | self.side = side 32 | self.max_coef = abs(max_coef) 33 | 34 | def do_gradient_detect(self, s: Sequence): 35 | coef, _ = linear_fitting(s.timestamps, s.values) 36 | if over_max_coef(coef, self.side, self.max_coef): 37 | return (True,) * len(s) 38 | else: 39 | return (False,) * len(s) 40 | 41 | def _fit(self, sequence: Sequence): 42 | """Nothing to impl""" 43 | 44 | def _predict(self, s: Sequence) -> Sequence: 45 | normal_sequence = remove_spike(s) # remove spike points 46 | predicted = self.do_gradient_detect(normal_sequence) # do detect for rapid change 47 | return Sequence(timestamps=normal_sequence.timestamps, values=predicted) 48 | -------------------------------------------------------------------------------- /dbmind/common/algorithm/anomaly_detection/iqr_detector.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | import numpy as np 15 | 16 | from ._abstract_detector import AbstractDetector 17 | from ...types import Sequence 18 | 19 | 20 | class InterQuartileRangeDetector(AbstractDetector): 21 | def __init__(self, outliers=(3, 3)): 22 | self.outliers = outliers 23 | 24 | def _fit(self, s: Sequence) -> None: 25 | q1 = np.nanquantile(s.values, 0.25) 26 | q3 = np.nanquantile(s.values, 0.75) 27 | iqr = q3 - q1 28 | 29 | if isinstance(self.outliers[0], (int, float)): 30 | self.lower_bound = (q1 - iqr * self.outliers[0]) 31 | else: 32 | self.lower_bound = -float("inf") 33 | 34 | if isinstance(self.outliers[1], (int, float)): 35 | self.upper_bound = (q3 + iqr * self.outliers[1]) 36 | else: 37 | self.upper_bound = float("inf") 38 | 39 | def _predict(self, s: Sequence) -> Sequence: 40 | values = np.array(s.values) 41 | predicted_values = (values > self.upper_bound) | (values < self.lower_bound) 42 | return Sequence(timestamps=s.timestamps, values=predicted_values) 43 | -------------------------------------------------------------------------------- /dbmind/common/algorithm/anomaly_detection/quantile_detector.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | import numpy as np 15 | 16 | from ._abstract_detector import AbstractDetector 17 | from ...types import Sequence 18 | 19 | 20 | class QuantileDetector(AbstractDetector): 21 | def __init__(self, high=1, low=0): 22 | self.high = high 23 | self.low = low 24 | 25 | def _fit(self, s: Sequence) -> None: 26 | if len(s.values) == 0: 27 | raise RuntimeError("Valid values are not enough for training.") 28 | 29 | self.upper_bound = np.nanquantile(s.values, self.high) 30 | self.lower_bound = np.nanquantile(s.values, self.low) 31 | 32 | def _predict(self, s: Sequence) -> Sequence: 33 | np_values = np.array(s.values) 34 | predicted_values = (np_values > self.upper_bound) | (np_values < self.lower_bound) 35 | return Sequence(timestamps=s.timestamps, values=predicted_values) 36 | -------------------------------------------------------------------------------- /dbmind/common/algorithm/anomaly_detection/threshold_detector.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | import numpy as np 15 | 16 | from ._abstract_detector import AbstractDetector 17 | from ...types import Sequence 18 | 19 | 20 | class ThresholdDetector(AbstractDetector): 21 | def __init__(self, high=float("inf"), low=-float("inf"), percentage: float = None): 22 | self.high = high 23 | self.low = low 24 | if isinstance(percentage, (int, float)) and 0 <= percentage <= 1: 25 | self.percentage = percentage 26 | else: 27 | self.percentage = None 28 | 29 | def _fit(self, s: Sequence) -> None: 30 | """Nothing to impl""" 31 | 32 | def _predict(self, s: Sequence) -> Sequence: 33 | n = len(s.values) 34 | np_values = np.array(s.values) 35 | predicted_values = (np_values > self.high) | (np_values < self.low) 36 | if self.percentage is None: 37 | return Sequence(timestamps=s.timestamps, values=predicted_values) 38 | elif np.count_nonzero(predicted_values) >= self.percentage * n: 39 | return Sequence(timestamps=s.timestamps, values=(True,) * n) 40 | else: 41 | return Sequence(timestamps=s.timestamps, values=(False,) * n) 42 | -------------------------------------------------------------------------------- /dbmind/common/algorithm/forecasting/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | from .forecasting_algorithm import ForecastingFactory 15 | from .forecasting_algorithm import quickly_forecast 16 | -------------------------------------------------------------------------------- /dbmind/common/algorithm/forecasting/arima_model/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | -------------------------------------------------------------------------------- /dbmind/common/dispatcher/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | from .task_scheduler import TimedTaskManager 15 | from .task_scheduler import customized_timer 16 | from .task_worker import ProcessWorker 17 | from .task_worker import get_worker_instance 18 | -------------------------------------------------------------------------------- /dbmind/common/either.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | """This implementation is similar to Java-like Optional.""" 14 | from abc import abstractmethod 15 | 16 | 17 | class Maybe: 18 | @abstractmethod 19 | def get(self, *args, **kwargs): 20 | pass 21 | 22 | 23 | class OptionalValue(Maybe): 24 | def __init__(self, value): 25 | self.value = value 26 | 27 | def get(self, default=None): 28 | return default if self.value is None else self.value 29 | 30 | 31 | class OptionalContainer(Maybe): 32 | def __init__(self, container): 33 | self.container = container 34 | 35 | def __bool__(self): 36 | return bool(self.container) 37 | 38 | def get(self, item, default=None): 39 | try: 40 | return self.container.__getitem__(item) 41 | except (IndexError, KeyError): 42 | return default 43 | 44 | def __getitem__(self, item): 45 | return self.get(item) 46 | -------------------------------------------------------------------------------- /dbmind/common/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | class ApiClientException(Exception): 16 | """API client exception, raises when response status code != 200.""" 17 | pass 18 | 19 | 20 | class SetupError(Exception): 21 | def __init__(self, msg, *args, **kwargs): 22 | self.msg = msg 23 | 24 | 25 | class InvalidCredentialException(Exception): 26 | pass 27 | 28 | 29 | class SQLExecutionError(Exception): 30 | pass 31 | 32 | 33 | class ConfigSettingError(Exception): 34 | pass 35 | 36 | 37 | class DuplicateTableError(Exception): 38 | pass 39 | -------------------------------------------------------------------------------- /dbmind/common/http/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | from ._service_impl import HttpService 15 | from ._service_impl import OAuth2 16 | from ._service_impl import Response, JSONResponse 17 | from ._service_impl import request_mapping 18 | from ._service_impl import standardized_api_output 19 | from ._service_impl import Request 20 | 21 | __all__ = ['HttpService', 'OAuth2', 'Response', 'JSONResponse', 22 | 'request_mapping', 'standardized_api_output', 'Request'] 23 | -------------------------------------------------------------------------------- /dbmind/common/parser/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | -------------------------------------------------------------------------------- /dbmind/common/platform/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | import os 16 | 17 | _PLATFORM = os.sys.platform 18 | LINUX = _PLATFORM == 'linux' 19 | WIN32 = _PLATFORM == 'win32' 20 | 21 | # declaration 22 | if WIN32: 23 | from ._win32 import win32_get_process_cwd 24 | from ._win32 import win32_get_process_cmdline 25 | from ._win32 import win32_get_process_path 26 | from ._win32 import win32_is_process_running 27 | -------------------------------------------------------------------------------- /dbmind/common/rpc/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from .base import RPCJSONAble 14 | from .base import RPCRequest, RPCResponse 15 | from .client import RPCClient, ping_rpc_url 16 | from .register import RPCFunctionRegister 17 | from .server import RPCServer, start_rpc_service, stop_rpc_service 18 | 19 | __all__ = ['RPCJSONAble', 'RPCRequest', 'RPCResponse', 20 | 'RPCFunctionRegister', 'RPCClient', 'RPCServer', 21 | 'start_rpc_service', 'stop_rpc_service', 22 | 'ping_rpc_url'] 23 | -------------------------------------------------------------------------------- /dbmind/common/rpc/errors.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | class RPCError(Exception): 16 | pass 17 | 18 | 19 | class SerializationFormatError(RPCError): 20 | pass 21 | 22 | 23 | class RPCExecutionError(RPCError): 24 | pass 25 | 26 | 27 | class AuthorizationError(RPCError): 28 | pass 29 | 30 | 31 | class UnregisteredFunction(RPCError): 32 | pass 33 | 34 | 35 | class RPCConnectionError(RPCError, ConnectionError): 36 | pass 37 | -------------------------------------------------------------------------------- /dbmind/common/rpc/register.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | class RPCFunctionRegister(dict): 16 | def __init__(self): 17 | """A dict that can not be modified after setting.""" 18 | super().__init__() 19 | 20 | def _undeleted(self, *args, **kws): 21 | raise TypeError('RPCFunctionRegister is undeleted.') 22 | 23 | def __setitem__(self, key, value): 24 | if not (isinstance(key, str) and callable(value)): 25 | raise TypeError('Key must be str and value must be callable.') 26 | if key in self.keys(): 27 | raise TypeError('Forbidden to modify.') 28 | self.setdefault(key, value) 29 | 30 | def __getitem__(self, item): 31 | def dummy(*args, **kwargs): 32 | raise NotImplementedError('Not found this function %s.' % item) 33 | 34 | return self.get(item, dummy) 35 | 36 | def register(self): 37 | def decorator(f): 38 | self.setdefault(f.__name__, f) 39 | return f 40 | 41 | return decorator 42 | 43 | __delitem__ = _undeleted 44 | clear = _undeleted 45 | update = _undeleted 46 | pop = _undeleted 47 | popitem = _undeleted 48 | -------------------------------------------------------------------------------- /dbmind/common/tsdb/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | from .tsdb_client_factory import TsdbClientFactory 15 | -------------------------------------------------------------------------------- /dbmind/common/tsdb/opentsdb_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | raise NotImplementedError() 14 | -------------------------------------------------------------------------------- /dbmind/common/types/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from .alarm import Alarm 14 | from .enums import ALARM_LEVEL, ALARM_TYPES 15 | from .misc import Log 16 | from .root_cause import RootCause 17 | from .sequence import Sequence, EMPTY_SEQUENCE 18 | from .ssl import SSLContext 19 | -------------------------------------------------------------------------------- /dbmind/common/types/_typing.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from typing import ( 14 | List, 15 | Tuple, 16 | Union, 17 | ) 18 | 19 | Values = Union[Tuple, List] 20 | -------------------------------------------------------------------------------- /dbmind/common/types/enums.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from enum import IntEnum 14 | 15 | 16 | class ALARM_LEVEL(IntEnum): 17 | CRITICAL = 50 18 | FATAL = CRITICAL 19 | ERROR = 40 20 | WARNING = 30 21 | WARN = WARNING 22 | INFO = 20 23 | NOTICE = INFO 24 | DEBUG = 10 25 | NOTSET = 0 26 | 27 | def __str__(self): 28 | return self._name_ 29 | 30 | 31 | class ALARM_TYPES: 32 | SYSTEM = 'SYSTEM' 33 | SLOW_QUERY = 'SLOW_QUERY' 34 | ALARM_LOG = 'ALARM_LOG' 35 | ALARM = 'ALARM' 36 | SECURITY = 'SECURITY' 37 | PERFORMANCE = 'PERFORMANCE' 38 | -------------------------------------------------------------------------------- /dbmind/common/types/misc.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | class Log: 16 | def __init__(self, occurrence_timestamp, log_type, host, content): 17 | self.occurrence_timestamp = occurrence_timestamp 18 | self.log_type = log_type 19 | self.host = host 20 | self.content = content 21 | -------------------------------------------------------------------------------- /dbmind/common/types/ssl.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | class SSLContext: 16 | def __init__(self, cert, key, key_pwd=None, ca=None): 17 | self.ssl_certfile = cert 18 | self.ssl_keyfile = key 19 | self.ssl_keyfile_password = key_pwd 20 | self.ssl_ca_file = ca 21 | 22 | def __bool__(self): 23 | return bool(self.ssl_certfile) and bool(self.ssl_keyfile) 24 | -------------------------------------------------------------------------------- /dbmind/common/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from .base import (dbmind_assert, 14 | cached_property, 15 | ttl_cache, 16 | TTLOrderedDict, 17 | NaiveQueue, 18 | where_am_i, 19 | read_simple_config_file, 20 | MultiProcessingRFHandler, 21 | is_integer_string, 22 | cast_to_int_or_float, 23 | ExceptionCatcher, 24 | split, 25 | string_to_dict 26 | ) 27 | from dbmind.common.utils.cli import write_to_terminal, raise_fatal_and_exit 28 | -------------------------------------------------------------------------------- /dbmind/components/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | import importlib 14 | import os 15 | import pkgutil 16 | import sys 17 | 18 | from dbmind.common.utils import where_am_i 19 | 20 | 21 | def list_components(): 22 | """Return all components in current directory.""" 23 | curr_dir = os.path.realpath(os.path.dirname(__file__)) 24 | components = list( 25 | map(lambda tup: tup[1], 26 | pkgutil.iter_modules((curr_dir,))) 27 | ) 28 | 29 | return components 30 | 31 | 32 | def call_component(name, arguments): 33 | component = importlib.import_module('.' + name, where_am_i(globals())) 34 | if not hasattr(component, 'main'): 35 | print('FATAL: Component %s must define function main() in the __init__.py.', 36 | file=sys.stderr) 37 | exit(1) 38 | component.main(arguments) 39 | -------------------------------------------------------------------------------- /dbmind/components/cmd_exporter/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from .core.main import main 14 | -------------------------------------------------------------------------------- /dbmind/components/cmd_exporter/__main__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | import os 14 | import sys 15 | 16 | try: 17 | from dbmind.components.cmd_exporter import main 18 | except ImportError: 19 | libpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..') 20 | sys.path.append(libpath) 21 | from cmd_exporter import main 22 | 23 | main(sys.argv[1:]) 24 | -------------------------------------------------------------------------------- /dbmind/components/cmd_exporter/core/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | -------------------------------------------------------------------------------- /dbmind/components/cmd_exporter/core/controller.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from dbmind.common.http import HttpService 14 | from dbmind.common.http import Response 15 | from .service import query_all_metrics 16 | 17 | app = HttpService('DBMind-cmd-exporter') 18 | 19 | 20 | @app.route('/', methods=['GET', 'POST']) 21 | def index(*args): 22 | return Response('cmd exporter (DBMind)') 23 | 24 | 25 | def metrics(*args): 26 | return Response(query_all_metrics()) 27 | 28 | 29 | def run(host, port, telemetry_path, ssl_keyfile, ssl_certfile, 30 | ssl_keyfile_password, ssl_ca_file): 31 | app.attach(metrics, telemetry_path) 32 | app.start_listen(host, port, ssl_keyfile, ssl_certfile, 33 | ssl_keyfile_password, ssl_ca_file) 34 | -------------------------------------------------------------------------------- /dbmind/components/deployment/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | from .prometheus_deploy import main 15 | -------------------------------------------------------------------------------- /dbmind/components/deployment/__main__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | import os 14 | import sys 15 | 16 | try: 17 | from dbmind.components.deployment import main 18 | except ImportError: 19 | libpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..') 20 | sys.path.append(libpath) 21 | from deployment import main 22 | 23 | main(sys.argv[1:]) 24 | -------------------------------------------------------------------------------- /dbmind/components/fetch_statement/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | from .fetch_statement import main 15 | -------------------------------------------------------------------------------- /dbmind/components/index_advisor/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | from .index_advisor_workload import main 15 | -------------------------------------------------------------------------------- /dbmind/components/index_advisor/__main__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | import os 15 | import sys 16 | 17 | try: 18 | from dbmind.components.index_advisor import main 19 | except ImportError: 20 | libpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..') 21 | sys.path.append(libpath) 22 | from index_advisor import main 23 | 24 | main(sys.argv[1:]) 25 | -------------------------------------------------------------------------------- /dbmind/components/index_advisor/executors/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | -------------------------------------------------------------------------------- /dbmind/components/index_advisor/executors/common.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | from abc import abstractmethod 15 | from typing import List 16 | 17 | 18 | class BaseExecutor: 19 | def __init__(self, dbname, user, password, host, port, schema, driver=None): 20 | self.dbname = dbname 21 | self.user = user 22 | self.password = password 23 | self.host = host 24 | self.port = port 25 | self.schema = schema 26 | self.driver = driver 27 | 28 | def get_schema(self): 29 | return self.schema 30 | 31 | @abstractmethod 32 | def execute_sqls(self, sqls) -> List[str]: 33 | pass 34 | 35 | @abstractmethod 36 | def session(self): 37 | pass 38 | -------------------------------------------------------------------------------- /dbmind/components/opengauss_exporter/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from .core.main import main 14 | -------------------------------------------------------------------------------- /dbmind/components/opengauss_exporter/__main__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | import os 14 | import sys 15 | 16 | try: 17 | from dbmind.components.opengauss_exporter import main 18 | except ImportError: 19 | libpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..') 20 | sys.path.append(libpath) 21 | from opengauss_exporter import main 22 | 23 | main(sys.argv[1:]) 24 | -------------------------------------------------------------------------------- /dbmind/components/opengauss_exporter/core/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | -------------------------------------------------------------------------------- /dbmind/components/opengauss_exporter/core/controller.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from dbmind.common.http import HttpService 14 | from dbmind.common.http import Response, JSONResponse 15 | from . import service 16 | 17 | app = HttpService('DBMind-openGauss-exporter') 18 | 19 | 20 | @app.route('/', methods=['GET', 'POST']) 21 | def index(*args): 22 | return Response( 23 | 'openGauss exporter (DBMind)\n' 24 | 'metric URI: /metrics \n' 25 | 'info URI: /info' 26 | ) 27 | 28 | 29 | @app.route('/info', methods=['GET', 'POST']) 30 | def info(*args): 31 | return JSONResponse(service.EXPORTER_FIXED_INFO) 32 | 33 | 34 | def metrics(*args): 35 | return Response(service.query_all_metrics()) 36 | 37 | 38 | def bind_rpc_service(rpc_service, uri='/rpc'): 39 | def invoking_adaptor(_json: dict): 40 | return rpc_service.invoke_handler(_json) 41 | 42 | app.attach(invoking_adaptor, uri, methods=['POST'], api=True) 43 | 44 | 45 | def run(host, port, telemetry_path, ssl_keyfile, ssl_certfile, ssl_keyfile_password, ssl_ca_file): 46 | app.attach(metrics, telemetry_path) 47 | app.start_listen(host, port, ssl_keyfile, ssl_certfile, ssl_keyfile_password, ssl_ca_file) 48 | -------------------------------------------------------------------------------- /dbmind/components/opengauss_exporter/yamls/pg_settings.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | pg_settings: 15 | name: pg_settings 16 | desc: OpenGauss database settings 17 | query: 18 | - name: pg_settings 19 | sql: "select name, 20 | case when vartype = 'bool' then 21 | (case when setting = 'on' then 1. else 0. end) else setting::float end as setting, 22 | vartype from pg_settings 23 | where vartype not in ('enum', 'string') 24 | and name not similar to '(audit_%|dcf_%|debug_%|password_%)';" 25 | version: '>=0.0.0' 26 | timeout: 1 27 | status: enable 28 | 29 | metrics: 30 | - name: name 31 | description: GUC name 32 | usage: LABEL 33 | - name: setting 34 | description: GUC value 35 | usage: GAUGE 36 | - name: vartype 37 | description: GUC type 38 | usage: LABEL 39 | 40 | status: enable 41 | ttl: 600 42 | timeout: 1 43 | -------------------------------------------------------------------------------- /dbmind/components/reprocessing_exporter/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from .core.main import main 14 | -------------------------------------------------------------------------------- /dbmind/components/reprocessing_exporter/__main__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | import os 14 | import sys 15 | 16 | try: 17 | from dbmind.components.reprocessing_exporter import main 18 | except ImportError: 19 | libpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..') 20 | sys.path.append(libpath) 21 | from reprocessing_exporter import main 22 | 23 | main(sys.argv[1:]) 24 | -------------------------------------------------------------------------------- /dbmind/components/reprocessing_exporter/core/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | -------------------------------------------------------------------------------- /dbmind/components/reprocessing_exporter/core/controller.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from dbmind.common.http import HttpService 14 | from dbmind.common.http import Response 15 | 16 | from .service import query_all_metrics 17 | 18 | app = HttpService('Reprocessing Exporter') 19 | 20 | 21 | @app.route('/', methods=['GET', 'POST']) 22 | def index(*args): 23 | return Response('Hello Reprocessing Exporter!') 24 | 25 | 26 | @app.route('/metrics', methods=['GET']) 27 | def metrics(*args): 28 | return Response(query_all_metrics()) 29 | 30 | 31 | def run(host, port, ssl_keyfile, ssl_certfile, ssl_keyfile_password, ssl_ca_file): 32 | app.start_listen(host=host, port=port, 33 | ssl_keyfile=ssl_keyfile, ssl_certfile=ssl_certfile, 34 | ssl_keyfile_password=ssl_keyfile_password, ssl_ca_file=ssl_ca_file) 35 | -------------------------------------------------------------------------------- /dbmind/components/sql_rewriter/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from .sql_rewriter import main, SQLRewriter, get_all_involved_tables, get_offline_rewriter, TableInfo 14 | -------------------------------------------------------------------------------- /dbmind/components/sqldiag/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from .main import main 14 | -------------------------------------------------------------------------------- /dbmind/components/sqldiag/__main__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | import os 14 | import sys 15 | 16 | try: 17 | from dbmind.components.sqldiag import main 18 | except ImportError: 19 | libpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..') 20 | sys.path.append(libpath) 21 | from sqldiag import main 22 | 23 | main(sys.argv[1:]) 24 | -------------------------------------------------------------------------------- /dbmind/components/sqldiag/algorithm/duration_time_model/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | import abc 14 | 15 | 16 | class AbstractModel: 17 | def __init__(self, params): 18 | self.params = params 19 | 20 | @abc.abstractmethod 21 | def fit(self, data): 22 | pass 23 | 24 | @abc.abstractmethod 25 | def transform(self, data): 26 | pass 27 | 28 | @abc.abstractmethod 29 | def load(self, filepath): 30 | pass 31 | 32 | @abc.abstractmethod 33 | def save(self, filepath): 34 | pass 35 | -------------------------------------------------------------------------------- /dbmind/components/sqldiag/algorithm/sql_similarity/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | def calc_sql_distance(algorithm): 16 | if algorithm == 'list': 17 | from .list_distance import distance 18 | elif algorithm == 'levenshtein': 19 | from .levenshtein import distance 20 | elif algorithm == 'parse_tree': 21 | from .parse_tree import distance 22 | elif algorithm == 'cosine_distance': 23 | from .cosine_distance import distance 24 | else: 25 | raise NotImplementedError("Not supported '{}'.".format(algorithm)) 26 | return distance 27 | -------------------------------------------------------------------------------- /dbmind/components/sqldiag/algorithm/sql_similarity/cosine_distance.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | import math 14 | from collections import Counter 15 | 16 | 17 | def distance(str1, str2): 18 | c_1 = Counter(str1) 19 | c_2 = Counter(str2) 20 | c_union = set(c_1).union(c_2) 21 | dot_product = sum(c_1.get(item, 0) * c_2.get(item, 0) for item in c_union) 22 | mag_c1 = math.sqrt(sum(c_1.get(item, 0) ** 2 for item in c_union)) 23 | mag_c2 = math.sqrt(sum(c_2.get(item, 0) ** 2 for item in c_union)) 24 | return dot_product / (mag_c1 * mag_c2) 25 | -------------------------------------------------------------------------------- /dbmind/components/sqldiag/algorithm/sql_similarity/levenshtein.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | def distance(str1, str2): 16 | """ 17 | func: calculate levenshtein distance between two strings. 18 | :param str1: string1 19 | :param str2: string2 20 | :return: distance 21 | """ 22 | len_str1 = len(str1) + 1 23 | len_str2 = len(str2) + 1 24 | 25 | mat = [[0] * len_str2 for i in range(len_str1)] 26 | mat[0][0] = 0 27 | for i in range(1, len_str1): 28 | mat[i][0] = mat[i - 1][0] + 1 29 | for j in range(1, len_str2): 30 | mat[0][j] = mat[0][j - 1] + 1 31 | for i in range(1, len_str1): 32 | for j in range(1, len_str2): 33 | if str1[i - 1] == str2[j - 1]: 34 | mat[i][j] = mat[i - 1][j - 1] 35 | else: 36 | mat[i][j] = min(mat[i - 1][j - 1], mat[i - 1][j], mat[i][j - 1]) + 1 37 | 38 | # Polish later. 39 | return 1 / mat[len_str1 - 1][j - 1] 40 | -------------------------------------------------------------------------------- /dbmind/components/sqldiag/algorithm/sql_similarity/list_distance.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | def distance(str1, str2): 16 | sql_distance = 0.0 17 | list1 = str1.split() 18 | list2 = str2.split() 19 | sorted_list1 = sorted(list1) 20 | sorted_list2 = sorted(list2) 21 | max_len = max(len(sorted_list1), len(sorted_list2)) 22 | min_len = min(len(sorted_list1), len(sorted_list2)) 23 | short_list = sorted_list1 if len(sorted_list1) < len(sorted_list2) else sorted_list2 24 | long_list = sorted_list1 if len(sorted_list1) > len(sorted_list2) else sorted_list2 25 | for item in short_list: 26 | if item in long_list: 27 | sql_distance += 1.0 28 | length_similarity = float(min_len / max_len) 29 | return sql_distance + length_similarity 30 | -------------------------------------------------------------------------------- /dbmind/components/sqldiag/sqldiag.conf: -------------------------------------------------------------------------------- 1 | # ----------------------------- 2 | # SQLdiag configuration file 3 | # ----------------------------- 4 | # 5 | # This file consists of lines of the form: 6 | # 7 | # name = value 8 | # 9 | # Comments are introduced with "#" anywhere on a line. 10 | 11 | #------------------------------------------------------------------------------ 12 | # Main Configurations 13 | #------------------------------------------------------------------------------ 14 | [Master] 15 | 16 | #------------------------------------------------------------------------------ 17 | # DNN Learning 18 | #------------------------------------------------------------------------------ 19 | [dnn] 20 | epoch = 30 21 | max_limit = 115.46 22 | min_limit = 6.78e-05 23 | 24 | 25 | #------------------------------------------------------------------------------ 26 | # Template Methed 27 | #------------------------------------------------------------------------------ 28 | [template] 29 | # [cosine_distance, levenshtein, list, parse_tree] 30 | similarity_algorithm = cosine_distance 31 | time_list_size = 20 32 | knn_number = 1 33 | -------------------------------------------------------------------------------- /dbmind/components/xtuner/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | from .tuner.main import main 15 | -------------------------------------------------------------------------------- /dbmind/components/xtuner/__main__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | import os 15 | import sys 16 | 17 | try: 18 | from dbmind.components.xtuner.tuner.main import main 19 | except ImportError: 20 | libpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..') 21 | sys.path.append(libpath) 22 | from xtuner.tuner.main import main 23 | 24 | main(sys.argv[1:]) 25 | -------------------------------------------------------------------------------- /dbmind/components/xtuner/share/knobs.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "work_mem": { 3 | "default": 65536, 4 | "min": 65536, 5 | "max": 655360, 6 | "type": "int", 7 | "restart": false 8 | }, 9 | "shared_buffers": { 10 | "default": 32000, 11 | "min": 16000, 12 | "max": 64000, 13 | "type": "int", 14 | "restart": true 15 | }, 16 | "random_page_cost": { 17 | "default": 4.0, 18 | "min": 1.0, 19 | "max": 4.0, 20 | "type": "float", 21 | "restart": false 22 | }, 23 | "enable_nestloop": { 24 | "default": true, 25 | "type": "bool", 26 | "restart": false 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /dbmind/components/xtuner/share/server.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "db_name": "postgres", 3 | "db_user": "dba", 4 | "host": "127.0.0.1", 5 | "host_user": "dba", 6 | "port": 5432, 7 | "ssh_port": 22 8 | } 9 | -------------------------------------------------------------------------------- /dbmind/components/xtuner/tuner/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | -------------------------------------------------------------------------------- /dbmind/components/xtuner/tuner/algorithms/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | -------------------------------------------------------------------------------- /dbmind/components/xtuner/tuner/benchmark/README.md: -------------------------------------------------------------------------------- 1 | # Benchmark 2 | This directory contains benchmark scripts. We implemented some demos here, they are: 3 | 4 | |Benchmark|Filename|Scenario|Website| 5 | | ------- | ------ | -------| ----- | 6 | |TPC-C|tpcc.py|heavy concurrent transactions|http://www.tpc.org/tpcc/| 7 | |TPC-H|tpch.py|data analytic for complex queries|http://www.tpc.org/tpch/| 8 | |TPC-DS|tpds.py|simulate a decision support system|http://www.tpc.org/tpcds/| 9 | |sysbench|sysbench.py|some simple queries for light concurrent.|https://github.com/akopytov/sysbench| 10 | 11 | # Implementation 12 | If you want to implement your benchmark which simulate your 13 | production scenario, you should do as the following. 14 | **Firstly, we assume that xxx is your benchmark name.** 15 | 16 | * Set file name as ```xxx.py``` in the benchmark directory; 17 | * Implement a function named 'run' in xxx.py and declare two global variables of the string type, one called 'path' and the other called 'cmd'.; 18 | * The signature of `run()` must be ```def run(remote_server_ssh, local_host_ssh) -> float```, that 19 | means you could use two SSH sessions to implement your code logic if they are useful, and you should 20 | return a numeric value as feedback; 21 | * You can set xxx, the name of benchmark you want to run, in the xtuner.conf. The parameter name is `benchmark_script`. 22 | 23 | # References 24 | 1. https://opengauss.org/zh/docs/1.0.1/docs/Developerguide/%E6%B5%8B%E8%AF%95TPCC%E6%80%A7%E8%83%BD.html 25 | 2. https://www.modb.pro/db/29135 26 | 3. https://www.modb.pro/db/23243 27 | 4. https://ankane.org/tpc-h 28 | 5. https://ankane.org/tpc-ds 29 | 6. https://severalnines.com/database-blog/how-benchmark-postgresql-performance-using-sysbench 30 | 31 | -------------------------------------------------------------------------------- /dbmind/components/xtuner/tuner/benchmark/sysbench.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | from ..exceptions import ExecutionError 15 | 16 | # WARN: You should first install the sysbench test tool on the system, 17 | # then fill in the following path and cmd. 18 | 19 | path = "/path/to/sysbench_install/share/sysbench/tests/include/oltp_legacy/oltp.lua" 20 | cmd = "sysbench --test=%s --db-driver=pgsql " \ 21 | "--pgsql-db={db} --pgsql-user={user} --pgsql-password={password} --pgsql-port={port} --pgsql-host=127.0.0.1 " \ 22 | "--oltp-tables-count=20 --oltp-table-size=1000 --max-time=30 --max-requests=0" \ 23 | " --num-threads=20 --report-interval=3 --forced-shutdown=1 run" % path 24 | 25 | 26 | def run(remote_server, local_host): 27 | stdout, stderr = remote_server.exec_command_sync(cmd) 28 | if len(stderr) > 0: 29 | raise ExecutionError(stderr) 30 | try: 31 | return float(stdout.split('queries:')[1].split('(')[1].split('per')[0].strip()) 32 | except Exception as e: 33 | raise ExecutionError('Failed to parse sysbench result, because %s.' % e) 34 | -------------------------------------------------------------------------------- /dbmind/components/xtuner/tuner/benchmark/template.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | # WARN: You need to import data into the database. 16 | # The program automatically collects the execution performance of workload you defined in the following function and 17 | # return the performance value to the X-Tuner. 18 | path = '' 19 | cmd = '' 20 | 21 | 22 | def run(remote_server, local_host) -> float: 23 | return 0 24 | -------------------------------------------------------------------------------- /dbmind/components/xtuner/tuner/benchmark/tpcds.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | import sys 15 | import time 16 | 17 | # WARN: You need to import data into the database and SQL statements in the following path will be executed. 18 | # The program automatically collects the total execution duration of these SQL statements. 19 | path = '/path/to/tpcds/queries' # modify this path which contains benchmark SQL files. 20 | cmd = "find %s -type f -name '*.sql' -exec gsql -U {user} -W {password} -d {db} -p {port} -f {} > /dev/null \\;" 21 | 22 | 23 | def run(remote_server, local_host): 24 | time_start = time.time() 25 | # Check whether the path is valid. 26 | stdout, stderr = remote_server.exec_command_sync('ls %s' % path) 27 | if len(stderr) > 0: 28 | print('You should correct the parameter `benchmark_path` that the path contains several executable SQL files ' 29 | 'in the configuration file.') 30 | exit(-1) 31 | 32 | stdout, stderr = remote_server.exec_command_sync(cmd % path) 33 | if len(stderr) > 0: 34 | print(stderr, file=sys.stderr) 35 | cost = time.time() - time_start 36 | return - cost 37 | -------------------------------------------------------------------------------- /dbmind/components/xtuner/tuner/benchmark/tpch.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | import sys 15 | import time 16 | 17 | # WARN: You need to import data into the database and SQL statements in the following path will be executed. 18 | # The program automatically collects the total execution duration of these SQL statements. 19 | path = '/path/to/tpch/queries' # modify this path which contains benchmark SQL files. 20 | cmd = "find %s -type f -name '*.sql' -exec gsql -U {user} -W {password} -d {db} -p {port} -f {} > /dev/null \\;" 21 | 22 | 23 | def run(remote_server, local_host): 24 | time_start = time.time() 25 | # Check whether the path is valid. 26 | stdout, stderr = remote_server.exec_command_sync('ls %s' % path) 27 | if len(stderr) > 0: 28 | print('You should correct the parameter `benchmark_path` that the path contains several executable SQL files ' 29 | 'in the configuration file.') 30 | exit(-1) 31 | 32 | stdout, stderr = remote_server.exec_command_sync(cmd % path) 33 | if len(stderr) > 0: 34 | print(stderr, file=sys.stderr) 35 | cost = time.time() - time_start 36 | return - cost 37 | -------------------------------------------------------------------------------- /dbmind/components/xtuner/tuner/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | class ExecutionError(Exception): 16 | pass 17 | 18 | 19 | class OptionError(Exception): 20 | pass 21 | 22 | 23 | class ConfigureError(Exception): 24 | pass 25 | 26 | 27 | class SecurityError(Exception): 28 | pass 29 | 30 | 31 | class DBStatusError(Exception): 32 | pass 33 | -------------------------------------------------------------------------------- /dbmind/controllers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | import os 14 | 15 | from ..common.utils import where_am_i 16 | 17 | 18 | def get_dbmind_controller(): 19 | _, _, files = next( 20 | os.walk(os.path.realpath(os.path.dirname(__file__)), topdown=True) 21 | ) 22 | base = where_am_i(globals()) 23 | return ['%s.%s' % (base, c.rsplit('.')[0]) for c in filter(lambda x: x.endswith('.py'), files)] 24 | -------------------------------------------------------------------------------- /dbmind/controllers/om_transponding.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | -------------------------------------------------------------------------------- /dbmind/controllers/static_files.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from starlette.responses import RedirectResponse 14 | 15 | from dbmind.common.http import request_mapping 16 | from dbmind.common.utils import dbmind_assert 17 | 18 | 19 | # Serve static assets. 20 | # It would be better if the user deploys with Nginx. 21 | @request_mapping('/', methods=['GET']) 22 | def index(req): 23 | dbmind_assert(req) 24 | return RedirectResponse(url='/index.html') 25 | -------------------------------------------------------------------------------- /dbmind/global_vars.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2# 8 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 9 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 10 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 11 | # See the Mulan PSL v2 for more details. 12 | """Using this global_vars must import as the following: 13 | 14 | >>> from dbmind import global_vars 15 | 16 | Notice: The variables in the following should be used across files. 17 | Otherwise, if a variable is not used across files, 18 | it should be placed where the nearest used position is. 19 | """ 20 | # The following modules should be enough clean because 21 | # this global_vars is an underlying module. 22 | from dbmind.service import multicluster 23 | from dbmind.common.dispatcher.task_worker import AbstractWorker 24 | 25 | configs: "ReadonlyConfig" = None 26 | dynamic_configs: "DynamicConfig" = None 27 | metric_map = {} 28 | metric_value_range_map = {} 29 | must_filter_labels = {} 30 | worker: "AbstractWorker" = None 31 | confpath = '' 32 | default_timed_task = [] 33 | timed_task = {} 34 | is_dry_run_mode = False 35 | agent_proxy = multicluster.AgentProxy() 36 | -------------------------------------------------------------------------------- /dbmind/metadatabase/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | from .base import ResultDbBase, DynamicConfigDbBase 15 | from .schema import load_all_schema_models 16 | 17 | -------------------------------------------------------------------------------- /dbmind/metadatabase/base.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from sqlalchemy import Column, String 14 | from sqlalchemy.orm import declarative_base 15 | 16 | # To storage at remote database server, mainly saving large scale data business, such as 17 | # the result of time-series forecasting and slow query analysis. 18 | ResultDbBase = declarative_base() 19 | 20 | 21 | # To record dynamic config not likes static text-based file. 22 | # The dynamic config can be modified by user frequently and fresh immediately. 23 | class DynamicConfigCommon: 24 | category = Column(String, primary_key=True) 25 | name = Column(String, primary_key=True) 26 | value = Column(String, nullable=False) 27 | annotation = Column(String, nullable=True) 28 | 29 | @classmethod 30 | def default_values(cls): 31 | default = getattr(cls, '__default__', {}) 32 | rows = [] 33 | for category, params in default.items(): 34 | for name, value, annotation in params: 35 | obj = cls() 36 | obj.category = category 37 | obj.name = name 38 | obj.value = value 39 | obj.annotation = annotation 40 | rows.append(obj) 41 | return rows 42 | 43 | 44 | DynamicConfigDbBase = declarative_base( 45 | name='DynamicConfig', cls=DynamicConfigCommon 46 | ) 47 | -------------------------------------------------------------------------------- /dbmind/metadatabase/dao/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from . import alarms 14 | from . import dynamic_config 15 | from . import healing_records 16 | from . import index_recommendation 17 | from . import knob_recommendation 18 | from . import slow_queries 19 | from . import regular_inspections 20 | -------------------------------------------------------------------------------- /dbmind/metadatabase/dynamic_config_db_session.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | import contextlib 14 | 15 | from sqlalchemy.engine import create_engine 16 | from sqlalchemy.orm import sessionmaker 17 | 18 | from dbmind.constants import DYNAMIC_CONFIG 19 | from .utils import create_dsn 20 | 21 | _session_maker = None 22 | 23 | 24 | @contextlib.contextmanager 25 | def get_session(): 26 | global _session_maker 27 | 28 | if not _session_maker: 29 | # Notice: Current working directory is the confpath, so we can 30 | # use the relative path directly. 31 | dsn = create_dsn('sqlite', DYNAMIC_CONFIG) 32 | engine = create_engine(dsn) 33 | _session_maker = sessionmaker(engine) 34 | 35 | session = _session_maker() 36 | try: 37 | yield session 38 | session.commit() 39 | except Exception as exception: 40 | session.rollback() 41 | raise exception 42 | finally: 43 | session.close() 44 | -------------------------------------------------------------------------------- /dbmind/metadatabase/schema/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from .existing_index import ExistingIndexes 14 | from .future_alarms import FutureAlarms 15 | from .healing_records import HealingRecords 16 | from .history_alarms import HistoryAlarms 17 | from .index_recomm import IndexRecommendation 18 | from .index_recomm_stats import IndexRecommendationStats 19 | from .index_recomm_stmt_details import IndexRecommendationStmtDetails 20 | from .index_recomm_stmt_templates import IndexRecommendationStmtTemplates 21 | from .knob_recomm_details import KnobRecommendationDetails 22 | from .knob_recomm_metric_snapshot import KnobRecommendationMetricSnapshot 23 | from .knob_recomm_warnings import KnobRecommendationWarnings 24 | from .slow_queries import SlowQueries 25 | from .slow_queries_journal import SlowQueriesJournal 26 | from .slow_queries_killed import SlowQueriesKilled 27 | from .regular_inspections import RegularInspection 28 | 29 | 30 | def load_all_schema_models(): 31 | """Dummy function: 32 | Loading all the table schema models can be realized by ```import *```. This 33 | function only serves as a self-comment in the form and has no actual action. """ 34 | -------------------------------------------------------------------------------- /dbmind/metadatabase/schema/existing_index.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from sqlalchemy import Column, Integer, String, TEXT 14 | 15 | from .. import ResultDbBase 16 | 17 | 18 | class ExistingIndexes(ResultDbBase): 19 | __tablename__ = "tb_existing_indexes" 20 | 21 | id = Column(Integer, primary_key=True, autoincrement=True) 22 | instance = Column(String(24), nullable=False) 23 | db_name = Column(String(32), nullable=False) 24 | tb_name = Column(String(64), nullable=False) 25 | columns = Column(String(256)) 26 | index_stmt = Column(TEXT, nullable=False) 27 | -------------------------------------------------------------------------------- /dbmind/metadatabase/schema/future_alarms.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | from sqlalchemy import Column, String, Integer, BigInteger, CHAR, Index, TEXT 15 | 16 | from .. import ResultDbBase 17 | 18 | 19 | class FutureAlarms(ResultDbBase): 20 | __tablename__ = "tb_future_alarms" 21 | 22 | future_alarm_id = Column(Integer, primary_key=True, autoincrement=True) 23 | instance = Column(CHAR(24), nullable=False) 24 | metric_name = Column(String(64), nullable=False) 25 | alarm_type = Column(String(16), nullable=False) 26 | alarm_level = Column(String(16)) 27 | start_at = Column(BigInteger) # unix timestamp 28 | end_at = Column(BigInteger) 29 | alarm_content = Column(String(1024)) 30 | extra_info = Column(TEXT) 31 | 32 | idx_future_alarms = Index("idx_future_alarms", metric_name, instance, start_at) 33 | 34 | -------------------------------------------------------------------------------- /dbmind/metadatabase/schema/healing_records.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | from sqlalchemy import Column, String, Integer, BigInteger, CHAR, Index, Boolean 15 | 16 | from .. import ResultDbBase 17 | 18 | 19 | class HealingRecords(ResultDbBase): 20 | __tablename__ = "tb_healing_records" 21 | 22 | id = Column(Integer, primary_key=True, autoincrement=True) 23 | instance = Column(CHAR(64), nullable=False) 24 | trigger_events = Column(String(1024), nullable=True) 25 | trigger_root_causes = Column(String(1024), nullable=True) 26 | action = Column(String(64), nullable=True) 27 | called_method = Column(String(128), nullable=False) 28 | success = Column(Boolean, nullable=False) 29 | detail = Column(String(256), nullable=True) 30 | occurrence_at = Column(BigInteger, nullable=False) # unix timestamp 31 | 32 | idx_healing_records = Index("idx_healing_records", occurrence_at, called_method) 33 | -------------------------------------------------------------------------------- /dbmind/metadatabase/schema/history_alarms.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | from sqlalchemy import Column, String, Integer, BigInteger, CHAR, Index, TEXT 16 | 17 | from .. import ResultDbBase 18 | 19 | 20 | class HistoryAlarms(ResultDbBase): 21 | __tablename__ = "tb_history_alarms" 22 | 23 | history_alarm_id = Column(Integer, primary_key=True, autoincrement=True) 24 | instance = Column(CHAR(24), nullable=False) 25 | metric_name = Column(String(64), nullable=False) 26 | metric_filter = Column(TEXT) 27 | alarm_type = Column(String(16), nullable=False) 28 | alarm_level = Column(Integer, nullable=False) 29 | start_at = Column(BigInteger, nullable=False) # unix timestamp 30 | end_at = Column(BigInteger, nullable=False) # unix timestamp 31 | alarm_content = Column(String(1024)) 32 | extra_info = Column(TEXT) 33 | anomaly_type = Column(String(64), nullable=False) 34 | 35 | idx_history_alarms = Index("idx_history_alarms", alarm_type, instance, start_at, alarm_level) 36 | -------------------------------------------------------------------------------- /dbmind/metadatabase/schema/index_recomm.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from sqlalchemy import Column, Integer, String, Numeric, TEXT 14 | 15 | from .. import ResultDbBase 16 | 17 | 18 | class IndexRecommendation(ResultDbBase): 19 | __tablename__ = "tb_index_recommendation" 20 | 21 | id = Column(Integer, primary_key=True, autoincrement=True) 22 | instance = Column(String(24), nullable=False) 23 | db_name = Column(String(64), nullable=False) 24 | schema_name = Column(String(32), nullable=False) 25 | tb_name = Column(String(64), nullable=False) 26 | columns = Column(String(256)) 27 | optimized = Column(String(32)) 28 | 29 | # 1:recommend, 2: redundancy, 3: invalid 30 | # the corresponding database field: index_type 31 | index_type = Column(Integer) 32 | stmt_count = Column(Integer) 33 | 34 | select_ratio = Column(Numeric(10, 6)) 35 | insert_ratio = Column(Numeric(10, 6)) 36 | update_ratio = Column(Numeric(10, 6)) 37 | delete_ratio = Column(Numeric(10, 6)) 38 | index_stmt = Column(TEXT, nullable=False) 39 | -------------------------------------------------------------------------------- /dbmind/metadatabase/schema/index_recomm_stats.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from sqlalchemy import Column, Integer, String, BigInteger 14 | 15 | from .. import ResultDbBase 16 | 17 | 18 | class IndexRecommendationStats(ResultDbBase): 19 | __tablename__ = "tb_index_recommendation_stats" 20 | 21 | id = Column(Integer, primary_key=True, autoincrement=True) 22 | instance = Column(String(24), nullable=False) 23 | db_name = Column(String(32), nullable=False) 24 | recommend_index_count = Column(Integer) 25 | redundant_index_count = Column(Integer) 26 | invalid_index_count = Column(Integer) 27 | stmt_count = Column(Integer) 28 | positive_stmt_count = Column(Integer) 29 | table_count = Column(Integer) 30 | stmt_source = Column(String(24), nullable=False) 31 | occurrence_time = Column(BigInteger) 32 | -------------------------------------------------------------------------------- /dbmind/metadatabase/schema/index_recomm_stmt_details.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from sqlalchemy import Column, Integer, String, BigInteger, TEXT 14 | 15 | from .. import ResultDbBase 16 | 17 | 18 | class IndexRecommendationStmtDetails(ResultDbBase): 19 | __tablename__ = 'tb_index_recommendation_stmt_details' 20 | 21 | id = Column(Integer, primary_key=True, autoincrement=True) 22 | instance = Column(String(24), nullable=False) 23 | db_name = Column(String(32), nullable=False) 24 | # ForeignKey('tb_index_recommendation.id', ondelete='CASCADE') 25 | index_id = Column(BigInteger) 26 | # ForeignKey('tb_index_recommendation_stmt_templates.id', ondelete='CASCADE') 27 | template_id = Column(BigInteger) 28 | stmt = Column(TEXT) 29 | optimized = Column(String(16)) 30 | correlation_type = Column(Integer) 31 | stmt_count = Column(Integer) 32 | -------------------------------------------------------------------------------- /dbmind/metadatabase/schema/index_recomm_stmt_templates.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from sqlalchemy import Column, Integer, String, TEXT 14 | 15 | from .. import ResultDbBase 16 | 17 | 18 | class IndexRecommendationStmtTemplates(ResultDbBase): 19 | __tablename__ = 'tb_index_recommendation_stmt_templates' 20 | 21 | id = Column(Integer, primary_key=True, autoincrement=True) 22 | instance = Column(String(24), nullable=False) 23 | db_name = Column(String(32), nullable=False) 24 | template = Column(TEXT) 25 | -------------------------------------------------------------------------------- /dbmind/metadatabase/schema/knob_recomm_details.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from sqlalchemy import Column, Integer, String, Boolean 14 | 15 | from .. import ResultDbBase 16 | 17 | 18 | class KnobRecommendationDetails(ResultDbBase): 19 | __tablename__ = "tb_knob_recommendation_details" 20 | 21 | id = Column(Integer, primary_key=True, autoincrement=True) 22 | instance = Column(String(24), nullable=False) 23 | name = Column(String(128), nullable=False) 24 | current = Column(String, nullable=False) 25 | recommend = Column(String, nullable=False) 26 | min = Column(String, nullable=False) 27 | max = Column(String, nullable=False) 28 | restart = Column(Boolean(), nullable=False) 29 | -------------------------------------------------------------------------------- /dbmind/metadatabase/schema/knob_recomm_metric_snapshot.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from sqlalchemy import Column, Integer, String 14 | 15 | from .. import ResultDbBase 16 | 17 | 18 | class KnobRecommendationMetricSnapshot(ResultDbBase): 19 | __tablename__ = "tb_knob_recommendation_metric_snapshot" 20 | 21 | id = Column(Integer, primary_key=True, autoincrement=True) 22 | instance = Column(String(24), nullable=False) 23 | metric = Column(String(128), nullable=False) 24 | value = Column(String(128), nullable=False) 25 | -------------------------------------------------------------------------------- /dbmind/metadatabase/schema/knob_recomm_warnings.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from sqlalchemy import Column, Integer, String 14 | 15 | from .. import ResultDbBase 16 | 17 | 18 | class KnobRecommendationWarnings(ResultDbBase): 19 | __tablename__ = "tb_knob_recommendation_warnings" 20 | 21 | id = Column(Integer, primary_key=True, autoincrement=True) 22 | instance = Column(String(24), nullable=False) 23 | comment = Column(String(2048), nullable=False) 24 | level = Column(String(16), nullable=True) 25 | -------------------------------------------------------------------------------- /dbmind/metadatabase/schema/regular_inspections.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from sqlalchemy import Column, String, Integer, BigInteger, Index, TEXT, JSON, Float 14 | 15 | from .. import ResultDbBase 16 | 17 | 18 | class RegularInspection(ResultDbBase): 19 | __tablename__ = "tb_regular_inspections" 20 | id = Column(Integer, primary_key=True, autoincrement=True) 21 | instance = Column(String(24), nullable=False) 22 | inspection_type = Column(String(64), nullable=False) 23 | report = Column(JSON) 24 | conclusion = Column(TEXT) 25 | start = Column(BigInteger, nullable=False) 26 | end = Column(BigInteger, nullable=False) 27 | state = Column(String(64), nullable=False) 28 | cost_time = Column(Float, nullable=False) 29 | idx_knob_inspection = Index("idx_knob_inspection", inspection_type) 30 | -------------------------------------------------------------------------------- /dbmind/metadatabase/schema/slow_queries_journal.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from sqlalchemy import Column, BigInteger, Integer, Float, Index, String 14 | 15 | from .. import ResultDbBase 16 | 17 | 18 | class SlowQueriesJournal(ResultDbBase): 19 | __tablename__ = "tb_slow_queries_journal" 20 | 21 | journal_id = Column(BigInteger().with_variant(Integer, 'sqlite'), primary_key=True, autoincrement=True) 22 | # Refer to tb_slow_queries.slow_query_id. 23 | slow_query_id = Column(BigInteger().with_variant(Integer, 'sqlite'), nullable=False) 24 | start_at = Column(BigInteger, nullable=False) 25 | round_start_at = Column(BigInteger, nullable=False) 26 | duration_time = Column(Float, nullable=False) 27 | instance = Column(String, nullable=False) 28 | 29 | idx_faked_foreign_key = Index("idx_slow_queries_journal_slow_query_id", slow_query_id) 30 | -------------------------------------------------------------------------------- /dbmind/metadatabase/schema/slow_queries_killed.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from sqlalchemy import Column, String, TEXT, Integer, Float, Boolean, BigInteger 14 | 15 | from .. import ResultDbBase 16 | 17 | 18 | class SlowQueriesKilled(ResultDbBase): 19 | __tablename__ = "tb_killed_slow_queries" 20 | 21 | killed_query_id = Column(Integer, primary_key=True, autoincrement=True) 22 | instance = Column(String(24), nullable=False) 23 | db_name = Column(String(64), nullable=False) 24 | query = Column(TEXT, nullable=False) 25 | killed = Column(Boolean, nullable=False) 26 | username = Column(String(64), nullable=False) 27 | elapsed_time = Column(Float, nullable=False) 28 | killed_time = Column(BigInteger, nullable=False) 29 | -------------------------------------------------------------------------------- /dbmind/misc/VERSION: -------------------------------------------------------------------------------- 1 | 3.1.0 -------------------------------------------------------------------------------- /dbmind/misc/filter_label.conf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | # For time-series database, there may be a value with multiple fields (or tags, labels), 15 | # many of sequence values are not what we want to collect, thus we need to filter by 16 | # these fields, by setting some conditions. In this configuration file, users can 17 | # define the fields (or conditions) for filtering sequence values​by themselves. 18 | 19 | # For example, 20 | # 1) we want to filter sequence values with the label 'app_name' from Prometheus, configure this: 21 | # app_name = 22 | # 2) we want to filter sequence values from Prometheus that have the label 'db_name' and 23 | # the label value is 'monitor_db' and 'system_db', we can configure it as: 24 | # db_name = monitor_db 25 | # db_name = system_db 26 | 27 | -------------------------------------------------------------------------------- /dbmind/misc/metric_value_range.conf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | #This configuration file specifies the upper and lower values ​​of the metric values, 15 | #the numeric type supports float and integer and infinity 16 | 17 | os_cpu_iowait = 0, 1 18 | os_cpu_usage = 0, 1 19 | os_mem_usage = 0, 1 20 | io_read_total = 0, inf 21 | io_write_total = 0, inf 22 | io_read_bytes = 0, inf 23 | io_write_bytes = 0, inf 24 | io_queue_number = 0, inf 25 | io_read_delay_time = 0, inf 26 | io_write_delay_time = 0, inf 27 | os_disk_iops = 0, inf 28 | os_disk_ioutils = 0, 1 29 | os_disk_iocapacity = 0, 1 30 | os_disk_usage = 0, 1 31 | os_cpu_processor_number = 0, inf 32 | gaussdb_qps_by_instance = 0, inf 33 | gaussdb_invalid_logins_rate = 0, 1 34 | gaussdb_lock_wait_time = 0, inf 35 | -------------------------------------------------------------------------------- /dbmind/service/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | -------------------------------------------------------------------------------- /dbmind/service/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | from dbmind.common.types import Sequence 15 | from dbmind.constants import DISTINGUISHING_INSTANCE_LABEL, EXPORTER_INSTANCE_LABEL 16 | 17 | 18 | class SequenceUtils: 19 | @staticmethod 20 | def from_server(s: Sequence): 21 | distinguishing = s.labels.get(DISTINGUISHING_INSTANCE_LABEL) 22 | if distinguishing: 23 | return distinguishing 24 | # If the metric does not come from reprocessing-exporter, 25 | # then return the exporter IP directly. 26 | return SequenceUtils.exporter_ip(s) 27 | 28 | @staticmethod 29 | def exporter_address(s: Sequence): 30 | return s.labels.get(EXPORTER_INSTANCE_LABEL) 31 | 32 | @staticmethod 33 | def exporter_ip(s: Sequence): 34 | address = SequenceUtils.exporter_address(s) 35 | if address: 36 | return address.split(':')[0].strip() 37 | 38 | 39 | -------------------------------------------------------------------------------- /dbmind/service/web/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | """This module is merely for web service 14 | and does not disturb internal operations in DBMind.""" 15 | -------------------------------------------------------------------------------- /dbmind/service/web/context_manager.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | import threading 14 | 15 | _access_context = threading.local() 16 | 17 | 18 | class ACCESS_CONTEXT_NAME: 19 | TSDB_FROM_SERVERS_REGEX = 'tsdb_from_servers_regex' 20 | INSTANCE_IP_WITH_PORT_LIST = 'instance_ip_with_port_list' 21 | INSTANCE_IP_LIST = 'instance_ip_list' 22 | AGENT_INSTANCE_IP_WITH_PORT = 'agent_instance_ip_with_port' 23 | 24 | 25 | def set_access_context(**kwargs): 26 | """Since the web front-end login user can specify 27 | a cope, we should also pay attention 28 | to this context when returning data to the user. 29 | Through this function, set the effective visible field.""" 30 | for k, v in kwargs.items(): 31 | setattr(_access_context, k, v) 32 | 33 | 34 | def get_access_context(name): 35 | return getattr(_access_context, name, None) 36 | 37 | -------------------------------------------------------------------------------- /docs/dbmind.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/docs/dbmind.png -------------------------------------------------------------------------------- /docs/glossary.md: -------------------------------------------------------------------------------- 1 | # DBMind Glossary 2 | 3 | *If you add new entries, keep the alphabetical sorting!* 4 | 5 | ## Glossary 6 | ``agent`` 7 | Firstly, DBMind diagnoses the database instance by using monitoring metrics, then stores the diagnosis results. But if users want DBMind to perform some operations which can heal the database instance, under this scenario, DBMind needs an agent to receive command from DBMind then perform it. This is the responsibility of the agent. 8 | 9 | ``alarm`` 10 | When DBMind detects abnormal events, the notification generated is called alarm. 11 | Alarm sources include many aspects, such as from historical logs, anomalies from historical KPI, and forecasts of KPI. 12 | 13 | ``anomaly detection`` 14 | Anomaly Detection (AD, aka outlier analysis) is a step in data mining that identifies events, and/or observations that deviate from a dataset's normal behavior. In the DBMind, we use it to detect abnormal events from monitoring metrics. 15 | 16 | ``component`` 17 | Plugins of DBMind. The components are all independent functionalities. Users can execute them by using shell command `gs_dbmind component`, also can call/import them from DBMind. 18 | 19 | ``confile`` 20 | The name of configuration file. 21 | 22 | ``confpath`` 23 | The directory path which stores common data, including configuration, log, pid, etc. 24 | 25 | ``exporter`` 26 | [Prometheus](https://prometheus.io/)'s plugin. The purpose of exporters is to scrape metrics from monitored object. See more via [Prometheus exporter](https://prometheus.io/docs/instrumenting/exporters/). 27 | 28 | ``metadatabase`` 29 | The database which you configure in the configuration file is to store monitoring, prediction and forecast result in periodical tasks. Hence, the response time for users to browse the results is quicker. 30 | 31 | -------------------------------------------------------------------------------- /flake8.conf: -------------------------------------------------------------------------------- 1 | [flake8] 2 | ignore = F401, W291, W504 3 | exclude = 4 | .git, 5 | __pycache__ 6 | max-complexity = 15 7 | max-line-length = 120 8 | -------------------------------------------------------------------------------- /package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | platform=`uname -p` 4 | if [ $platform == 'x86_64' ] 5 | then 6 | version='x64' 7 | elif [ $platform == 'aarch64' ] 8 | then 9 | version='arm64' 10 | else 11 | echo 'Not supported platform, please download the compiled nodejs and Python runtime manually.' 12 | exit 1 13 | fi 14 | wget https://repo.anaconda.com/miniconda/Miniconda3-py39_24.4.0-0-Linux-${platform}.sh -O miniconda.sh --no-check-certificate && sh miniconda.sh -b -p python 15 | wget https://nodejs.org/dist/v16.9.0/node-v16.9.0-linux-${version}.tar.xz --no-check-certificate && tar -xJvf node-v16.9.0-linux-${version}.tar.xz 16 | export CI=False 17 | export PATH=`pwd`/node-v16.9.0-linux-${version}/bin:`pwd`/python/bin:$PATH 18 | make package 19 | make test 20 | -------------------------------------------------------------------------------- /requirements-aarch64.txt: -------------------------------------------------------------------------------- 1 | ## For DBMind-core ## 2 | cryptography 3 | paramiko>=2.7.2 4 | numpy 5 | scipy 6 | requests 7 | sqlparse 8 | fastapi<=0.99.0 9 | uvicorn 10 | sqlalchemy==1.4.44 11 | # Use `#` to set an alternative psycopg2 12 | psycopg2-binary # psycopg2 13 | pycryptodome 14 | ## For components ## 15 | prettytable>=2.5.0 16 | ## Prometheus Exporter 17 | pyyaml 18 | prometheus-client==0.16.0 # prometheus_client 19 | # Rewriter 20 | sql-metadata # sql_metadata 21 | mo-sql-parsing>=9.262.22323 22 | 23 | -------------------------------------------------------------------------------- /requirements-optional.txt: -------------------------------------------------------------------------------- 1 | ## X-Tuner ## 2 | bayesian-optimization 3 | protobuf==3.20.* # for tensorflow 4 | tensorflow ~=2.3.0 5 | keras-rl2~=1.0.4 6 | gensim==3.8.3 7 | -------------------------------------------------------------------------------- /requirements-x86.txt: -------------------------------------------------------------------------------- 1 | ## For DBMind-core ## 2 | paramiko>=2.7.2 3 | numpy 4 | scipy 5 | requests 6 | sqlparse 7 | fastapi<=0.99.0 8 | uvicorn 9 | sqlalchemy==1.4.44 10 | # Use `#` to set an alternative psycopg2 11 | psycopg2-binary # psycopg2 12 | pycryptodome 13 | ## For components ## 14 | prettytable>=2.5.0 15 | ## Prometheus Exporter 16 | pyyaml 17 | prometheus-client==0.16.0 # prometheus_client 18 | # Rewriter 19 | sql-metadata # sql_metadata 20 | mo-sql-parsing==9.262.22323 21 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | 15 | def auto_test_all(): 16 | pass 17 | -------------------------------------------------------------------------------- /tests/features: -------------------------------------------------------------------------------- 1 | 1,0,1,0,0,1 2 | 0,1,1,0,0,2 3 | 0,0,1,0,1,3 -------------------------------------------------------------------------------- /tests/test_detection.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | from dbmind.common.algorithm.forecasting import ForecastingFactory 15 | from dbmind.common.types import Sequence 16 | 17 | linear_seq = Sequence(tuple(range(1, 10)), tuple(range(1, 10))) 18 | 19 | 20 | def roughly_compare(list1, list2, threshold=1): 21 | if len(list1) != len(list2): 22 | return False 23 | for v1, v2 in zip(list1, list2): 24 | if abs(v1 - v2) > threshold: 25 | return False 26 | return True 27 | 28 | 29 | def test_linear_regression(): 30 | linear = ForecastingFactory.get_instance(linear_seq) 31 | linear.fit(linear_seq) 32 | result = linear.forecast(10) 33 | assert len(result) == 10 34 | assert roughly_compare(result, range(10, 20)) 35 | 36 | assert ForecastingFactory.get_instance(linear_seq) is linear 37 | -------------------------------------------------------------------------------- /tests/test_edbmind.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | import os 14 | import shutil 15 | import logging 16 | from unittest import mock 17 | 18 | import pytest 19 | 20 | from dbmind import constants 21 | from dbmind.cmd import edbmind 22 | from dbmind.common.dispatcher import task_scheduler 23 | 24 | 25 | def mock_setup_directory(confpath): 26 | os.makedirs(confpath, exist_ok=True) 27 | src_confile = os.path.join(constants.MISC_PATH, constants.CONFILE_NAME) 28 | dst_confile = os.path.join(confpath, constants.CONFILE_NAME) 29 | shutil.copyfile(src_confile, dst_confile) 30 | 31 | 32 | @pytest.fixture 33 | def startup(tmpdir): 34 | import importlib 35 | 36 | importlib.reload(task_scheduler) 37 | 38 | confpath = tmpdir.realpath() 39 | logging.debug('confpath: %s.', confpath) 40 | mock_setup_directory(confpath) 41 | task_scheduler.TimedTaskManager.start = mock.Mock() 42 | assert len(task_scheduler.TimedTaskManager.timers) == 0 43 | _dbmind = edbmind.DBMindMain(confpath) 44 | _dbmind.daemonize = mock.Mock() 45 | _dbmind.run = mock.Mock() 46 | _dbmind.start() 47 | _dbmind.daemonize.assert_called_once_with() 48 | tmpdir.remove() 49 | 50 | 51 | def test_startup(startup): 52 | pass 53 | -------------------------------------------------------------------------------- /tests/test_preprocessing.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | import numpy as np 15 | 16 | from dbmind.common.algorithm import preprocessing 17 | 18 | 19 | def test_min_max_scaler(): 20 | scaler = preprocessing.MinMaxScaler(feature_range=(0, 1)) 21 | x = [1, 2, 3, 4, np.nan, 5] 22 | y = [2, 3, 4, 5, 6] 23 | 24 | scaler.fit(x) 25 | scaled_y = scaler.transform(y) 26 | assert all(scaled_y == [0.25, 0.5, 0.75, 1., 1.25]) 27 | inversed_y = scaler.inverse_transform(scaled_y) 28 | assert all(inversed_y == y) 29 | 30 | scaled_x = scaler.fit_transform(x) 31 | assert ( 32 | np.isnan(scaled_x).any() and 33 | np.nanmax(scaled_x) == 1.0 and 34 | np.nanmin(scaled_x) == 0.0 35 | ) 36 | scaled_y = scaler.fit_transform(y) 37 | assert all(scaled_y == [0.0, 0.25, 0.5, 0.75, 1.0]) 38 | -------------------------------------------------------------------------------- /tests/test_security.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | import random 14 | 15 | from dbmind.common import security 16 | 17 | 18 | def test_encryption_and_decryption(): 19 | for i in range(100): 20 | s1 = security.safe_random_string(16) 21 | s2 = security.safe_random_string(16) 22 | # Test whether the function supports unfixed length. 23 | plain = security.unsafe_random_string(random.randint(0, 64)) 24 | iv = security.generate_an_iv() 25 | cipher = security.encrypt(s1, s2, iv, plain) 26 | decrypted_text = security.decrypt(s1, s2, iv, cipher) 27 | assert plain == decrypted_text 28 | -------------------------------------------------------------------------------- /tests/test_timed_app.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | from dbmind.app import timed_app 14 | 15 | 16 | def test_anomaly_detection(): 17 | timed_app.anomaly_detection() 18 | -------------------------------------------------------------------------------- /tests/test_worker.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Huawei Technologies Co.,Ltd. 2 | # 3 | # openGauss is licensed under Mulan PSL v2. 4 | # You can use this software according to the terms and conditions of the Mulan PSL v2. 5 | # You may obtain a copy of Mulan PSL v2 at: 6 | # 7 | # http://license.coscl.org.cn/MulanPSL2 8 | # 9 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 10 | # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 11 | # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 12 | # See the Mulan PSL v2 for more details. 13 | 14 | import time 15 | 16 | from dbmind.common.dispatcher.task_worker import ProcessWorker 17 | 18 | 19 | def square(v): 20 | return v * v 21 | 22 | 23 | def sleepy_square(v): 24 | time.sleep(0.2) 25 | return v * v 26 | 27 | 28 | process_worker = ProcessWorker(10) 29 | 30 | 31 | def test_process_worker(): 32 | assert process_worker.apply(square, True, (2,)) == 4 33 | assert process_worker.parallel_execute(square, ((0,), (1,), (2,), (3,), (4,))) == [0, 1, 4, 9, 16] 34 | 35 | # Should execute in parallel, only waiting for the slowest one. 36 | start_time = time.time() 37 | process_worker.parallel_execute(sleepy_square, [(v,) for v in range(10)]) 38 | end_time = time.time() 39 | assert 0.2 < (end_time - start_time) < 0.3 40 | 41 | 42 | def test_blocking_task(): 43 | start_time = time.time() 44 | process_worker._parallel_execute(sleepy_square, [[1], [1], [1], [1], [1]]) 45 | end_time = time.time() 46 | 47 | interval = end_time - start_time 48 | assert 0.2 < interval < 0.3 49 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | skipsdist = true 3 | envlist = py36,py37,py38,py39 4 | 5 | [testenv] 6 | # install pytest in the virtualenv where commands will be executed 7 | commands = pytest tests 8 | deps = 9 | -rrequirements-x86.txt 10 | 11 | -------------------------------------------------------------------------------- /ui/README.md: -------------------------------------------------------------------------------- 1 | Code here for DBMind UI. -------------------------------------------------------------------------------- /ui/build/index.html: -------------------------------------------------------------------------------- 1 | 2 | openGauss DBMind 3 | 4 | The page you see is a test page for DBMind.
5 | It would help if you built DBMind UI using npm then deployed it into 6 | the current directory. 7 |
8 |

9 | You can build the UI asserts by using Makefile in the root directory as follows: 10 |

11 | 12 | make ui 13 | 14 |

15 | Or build them using npm: 16 |

17 | 18 | cd ui
19 | npm install
20 | npm run build
21 |
22 | 23 | -------------------------------------------------------------------------------- /ui/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dbmind", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@ant-design/icons": "5.0.1", 7 | "antd": "^4.16.11", 8 | "axios": "^0.27.2", 9 | "echarts": "^5.1.2", 10 | "echarts-for-react": "^3.0.1", 11 | "moment": "^2.29.1", 12 | "prop-types": "^15.8.1", 13 | "qs": "^6.10.1", 14 | "react": "^17.0.2", 15 | "react-dom": "^17.0.2", 16 | "react-resizable": "^3.0.4", 17 | "react-router-dom": "^5.3.0", 18 | "react-scripts": "4.0.3", 19 | "html2canvas": "^1.4.1", 20 | "jspdf": "^2.5.1" 21 | }, 22 | "scripts": { 23 | "start": "react-scripts start", 24 | "build": "react-scripts build", 25 | "test": "react-scripts test", 26 | "eject": "react-scripts eject" 27 | }, 28 | "eslintConfig": { 29 | "extends": "react-app", 30 | "rules": { 31 | "no-undef": "off", 32 | "no-restricted-globals": "off", 33 | "no-unused-vars": "off", 34 | "no-useless-escape": "off" 35 | } 36 | }, 37 | "browserslist": { 38 | "production": [ 39 | ">0.2%", 40 | "not dead", 41 | "not op_mini all" 42 | ], 43 | "development": [ 44 | "last 1 chrome version", 45 | "last 1 firefox version", 46 | "last 1 safari version" 47 | ] 48 | }, 49 | "devDependencies": { 50 | "babel-eslint": "^10.1.0", 51 | "eslint": "^7.32.0", 52 | "eslint-plugin-import": "^2.26.0", 53 | "eslint-plugin-jsx-a11y": "^6.6.1", 54 | "eslint-plugin-react": "^7.30.1", 55 | "http-proxy-middleware": "^2.0.4", 56 | "@babel/plugin-proposal-private-property-in-object":"^7.16.7" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /ui/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | openGauss DBMind 9 | 10 | 11 | 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /ui/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Route, HashRouter as Router, Switch } from 'react-router-dom'; 3 | import history from './utils/history'; 4 | import LogIn from './pages/LogIn.jsx'; 5 | import Main from './Main'; 6 | 7 | function App() { 8 | return ( 9 | 10 | 11 | 12 | 13 | 14 | 15 | ); 16 | } 17 | export default App; 18 | -------------------------------------------------------------------------------- /ui/src/api/aiTool.js: -------------------------------------------------------------------------------- 1 | import { 2 | post, 3 | get 4 | } from './request'; 5 | 6 | export const getItemListInterface = () => { 7 | return get('/list/database'); 8 | }; 9 | export const getUserItemListInterface = () => { 10 | return get('/list/users'); 11 | }; 12 | export const getListIndexAdvisorInterface = (data) => { 13 | return post(`/toolkit/advise/index?database=${data.database}&instance=${data.instance}&max_index_num=${data.max_index_num}&max_index_storage=${data.max_index_storage}¤t=${data.current}&pagesize=${data.pagesize}`, data.textareaVal); 14 | }; 15 | export const getQueryTuningInterface = (data) => { 16 | return post(`/toolkit/advise/query?database=${data.database}&instance=${data.instance}&sql=${data.sql}&use_rewrite=${data.use_rewrite}&use_hinter=${data.use_hinter}&use_materialized=${data.use_materialized}`); 17 | }; 18 | export const getIntelligentSqlAnalysisInterface = (data) => { 19 | return post('/toolkit/slow_sql_rca', data) 20 | }; 21 | -------------------------------------------------------------------------------- /ui/src/api/clusterInformation.js: -------------------------------------------------------------------------------- 1 | import { get } from './request'; 2 | 3 | export const getRegularInspectionsInterface = (data) => { 4 | return get('/summary/regular_inspections', data); 5 | }; -------------------------------------------------------------------------------- /ui/src/api/common.js: -------------------------------------------------------------------------------- 1 | import { post, get } from './request'; 2 | 3 | export const loginInterface = data => { 4 | return post('/token', data); 5 | }; 6 | export const getAgentListInterface = () => { 7 | return get('/list/agent'); 8 | }; -------------------------------------------------------------------------------- /ui/src/api/dbmindSettings.js: -------------------------------------------------------------------------------- 1 | import { get,post } from './request'; 2 | 3 | export const getSettingListInterface = () => { 4 | return get('/setting/list'); 5 | }; 6 | export const putSettingDetailInterface = (data) => { 7 | return get('/setting/set', data); 8 | }; 9 | export const updateSetting = (data) => { 10 | return post('/setting/update_dynamic_config', data); 11 | }; 12 | export const getSettingDefaults = (data) => { 13 | return get('/default_values', data); 14 | }; 15 | export const getSettingCurrentValue = (data) => { 16 | return get('/values', data); 17 | }; -------------------------------------------------------------------------------- /ui/src/api/intelligentInspection.js: -------------------------------------------------------------------------------- 1 | import { get } from "./request"; 2 | 3 | export const getTaskSubmit = (data) => { 4 | return get( 5 | `/summary/real-time-inspection/exec?inspection_type=${data.inspectionType}&start_time=${data.startTime}&end_time=${data.endTime}&select_metrics=${data.selectMetrics}` 6 | ); 7 | }; 8 | export const getRealtimeInspectionList = () => { 9 | return get(`/summary/real-time-inspection/list`); 10 | }; 11 | export const getTaskReport = (data) => { 12 | return get(`/summary/real-time-inspection/report?spec_id=${data}`); 13 | }; 14 | export const deleteTask = (data) => { 15 | return get(`/summary/real-time-inspection/delete?spec_id=${data}`); 16 | }; 17 | -------------------------------------------------------------------------------- /ui/src/api/overview.js: -------------------------------------------------------------------------------- 1 | import { get, post } from './request'; 2 | 3 | export const getInterface = () => { 4 | return get('/overview'); 5 | }; 6 | 7 | export const getResponseTime = (data) => { 8 | return get(`/summary/metrics/${data.label}?latest_minutes=3&instance=${data.instance}`); 9 | }; 10 | 11 | export const getConnection = (data) => { 12 | return get(`/summary/metrics/${data.label}?&latest_minutes=3&instance=${data.instance}`); 13 | }; 14 | 15 | export const getProxy = () => { 16 | return get('/agent/status'); 17 | }; 18 | 19 | export const getDistribution = (data) => { 20 | return get(`/summary/metrics/${data.label}?&latest_minutes=0&instance=${data.instance}`); 21 | }; 22 | 23 | export const getTransaction = (data) => { 24 | return get(`/summary/metrics/${data.label}?latest_minutes=0&fetch_all=True&instance=${data.instance}`); 25 | }; 26 | 27 | export const getDatabaseSize = (data) => { 28 | return get(`/summary/metrics/${data.label}?latest_minutes=0&fetch_all=True&instance=${data.instance}`); 29 | }; 30 | 31 | export const getCollectionTable = () => { 32 | return get('/collection/status'); 33 | }; 34 | export const getNode = () => { 35 | return get('/instance/status'); 36 | }; 37 | 38 | export const getDataDisk = (data) => { 39 | return get(`/data-directory/status?latest_minutes=3&instance=${data}`); 40 | }; 41 | 42 | export const getTimedTaskStatus = () => { 43 | return get('/app/timed-task/status'); 44 | }; 45 | 46 | export const getStopTimed = (data) => { 47 | return post(`/app/stop_timed_task?funcname=${data}`) 48 | }; 49 | 50 | export const getStartTimed = (data) => { 51 | return post(`/app/start_timed_task?funcname=${data}`) 52 | }; 53 | 54 | export const getResetInterval = (data) => { 55 | return post(`/app/reset_interval?funcname=${data.funcname}&seconds=${data.seconds}`) 56 | }; -------------------------------------------------------------------------------- /ui/src/api/securityManagement.js: -------------------------------------------------------------------------------- 1 | import { get } from './request'; -------------------------------------------------------------------------------- /ui/src/assets/css/logIn.css: -------------------------------------------------------------------------------- 1 | .loginbox{ 2 | width: 100%; 3 | display: flex; 4 | height: 100%; 5 | flex-direction: row; 6 | flex-wrap: nowrap; 7 | justify-content: center; 8 | align-items: center; 9 | overflow: hidden; 10 | background-color: #001529; 11 | } 12 | .loginwrap{ 13 | position: relative; 14 | width: 1100px; 15 | background: #808a94; 16 | border-radius: 10px; 17 | height: 100px; 18 | } 19 | .logintip{ 20 | position: absolute; 21 | left: -2.64%; 22 | top: -25%; 23 | } 24 | .btnboxrow{ 25 | width: 100%; 26 | height: 100px; 27 | position: relative; 28 | } 29 | .btnboxrow .ant-form{ 30 | height: 100%; 31 | width: 100%; 32 | position: absolute; 33 | display: flex; 34 | justify-content: center; 35 | } 36 | #loginbtn{ 37 | width: 10%; 38 | border-radius: 10px; 39 | } 40 | .LogInTwoBtn{ 41 | border-radius: 10px; 42 | } 43 | .LogInTwoBtn .ant-select-selector{ 44 | border-radius: 10px !important; 45 | } 46 | .ant-form-item-with-help .ant-form-item-explain{ 47 | height: 0 !important; 48 | } 49 | .btnboxrow .ant-select-single:not(.ant-select-customize-input) .ant-select-selector { 50 | height: 40px !important; 51 | line-height: 40px !important; 52 | padding: 4px 11px !important; 53 | } -------------------------------------------------------------------------------- /ui/src/assets/css/main/aiToolkit.css: -------------------------------------------------------------------------------- 1 | 2 | .flexbox { 3 | display: flex; 4 | } 5 | .flextitle1 { 6 | width: 120px; 7 | } 8 | .flextitle2 { 9 | width: 130px; 10 | } 11 | .ant-spin-container ul { 12 | justify-content: flex-end; 13 | background-color: #fff; 14 | } 15 | .flexcheckbox { 16 | display: flex; 17 | justify-content: space-around; 18 | } 19 | .ant-form-horizontal .ant-form-item-label{ 20 | width: 120px!important; 21 | } 22 | .errorinvalid .ant-form-item-explain-error{ 23 | width: 200px; 24 | } 25 | .uploadcss .ant-upload-list{ 26 | display: inline-block; 27 | margin: 0px 20px; 28 | } 29 | .uploadcss .ant-upload-list-item{ 30 | margin-top: 0px; 31 | } 32 | .analysis .ant-col{ 33 | margin-bottom: 20px; 34 | } 35 | .insertclass{ 36 | width:100px; 37 | height: 22px; 38 | float: right; 39 | line-height: 22px; 40 | padding: 6px 0px; 41 | } 42 | .insertclass span{ 43 | display: block; 44 | height: 10px; 45 | float: left; 46 | margin-right: 1%; 47 | } 48 | 49 | .indexadvisor .ant-card-head-title{ 50 | padding: 10px 0px; 51 | } 52 | .indexadvisor .recommended .ant-card-body{ 53 | padding: 8px 20px; 54 | } 55 | .indexadvisor .backcolor{ 56 | margin-bottom: 10px; 57 | } 58 | .indexadvisor .backcolor .ant-card-body{ 59 | padding: 10px; 60 | } 61 | .indexadvisor .backcolor .ant-card-head-title{ 62 | padding: 1px 0px; 63 | } 64 | .indexadvisor .backcolor .ant-card-head{ 65 | background-color: #f6f6f6; 66 | padding: 0px 14px; 67 | min-height: 28px; 68 | color: #393939; 69 | } 70 | .indexadvisor .backcolor .ant-btn{ 71 | padding: 0; 72 | } 73 | 74 | .indexadvisor .ant-card-head, .intelligent .ant-card-head, .querytuning .ant-card-head, .riskanalysis .ant-card-head{ 75 | min-height: 50px; 76 | padding: 0; 77 | margin: 0px 20px; 78 | border-bottom: 1px solid #dddddd; 79 | } 80 | .intelligent .ant-picker-separator,.ant-picker-suffix{ 81 | color: #5990FD; 82 | } -------------------------------------------------------------------------------- /ui/src/assets/css/main/alarm.css: -------------------------------------------------------------------------------- 1 | .selfhealing .ant-card-head { 2 | border-bottom: none; 3 | } 4 | .selfhealing .ant-card-body { 5 | padding: 0 24px 24px 24px; 6 | } 7 | .selfhealing .ant-card-head-title { 8 | padding: 11px 0; 9 | } 10 | .selfhealing .childstyle .ant-card-head-title { 11 | padding: 4px 0; 12 | } 13 | .selfhealing .childstyle .ant-card-extra { 14 | padding: 4px 0; 15 | } 16 | .selfhealing .childstyle .ant-card-head { 17 | min-height: 36px; 18 | } 19 | .selfhealing .ant-switch { 20 | height: 2px; 21 | line-height: 2px; 22 | } 23 | .selfhealing .ant-switch { 24 | height: 2px; 25 | line-height: 2px; 26 | min-width: 32px; 27 | } 28 | .selfhealing .ant-switch-checked .ant-switch-handle { 29 | left: calc(100% - 8px - 2px); 30 | } 31 | .selfhealing .ant-switch-handle { 32 | position: absolute; 33 | top: -3px; 34 | width: 8px; 35 | height: 8px; 36 | border: 1px solid #5990FD; 37 | border-radius: 50%; 38 | } 39 | .selfhealing .lockstyle{ 40 | display: flex; 41 | align-items: center; 42 | } 43 | .selfhealing .spanleft{ 44 | text-align: left; 45 | width: 75%; 46 | color: #272727; 47 | font-size: 14px; 48 | font-weight : 400 ; 49 | cursor:pointer; 50 | } 51 | .selfhealing .spanright{ 52 | text-align: right; 53 | width: 25%; 54 | font-size: 18px; 55 | font-weight: Bold; 56 | cursor:pointer; 57 | } 58 | .formlistclass .ant-row { 59 | justify-content: space-around; 60 | } -------------------------------------------------------------------------------- /ui/src/assets/css/main/clusterInfo.css: -------------------------------------------------------------------------------- 1 | .treeOperate li{ 2 | padding: 2px; 3 | } 4 | .treeOperate li:hover{ 5 | background-color: #2d93f3; 6 | color: aliceblue; 7 | } -------------------------------------------------------------------------------- /ui/src/assets/css/main/dbmindSettings.css: -------------------------------------------------------------------------------- 1 | .editable-cell { 2 | position: relative; 3 | } 4 | 5 | .editable-cell-value-wrap { 6 | padding: 5px 12px; 7 | cursor: pointer; 8 | } 9 | 10 | .editable-row:hover .editable-cell-value-wrap { 11 | padding: 4px 11px; 12 | border: 1px solid #d9d9d9; 13 | border-radius: 2px; 14 | } 15 | 16 | [data-theme='dark'] .editable-row:hover .editable-cell-value-wrap { 17 | border: 1px solid #434343; 18 | } 19 | 20 | @keyframes blink{ 21 | 0%{opacity: 1;} 22 | 100%{opacity: 0;} 23 | } 24 | .blink{ 25 | color:#ff5500; 26 | font-size: 14px; 27 | animation: blink 500ms linear infinite; 28 | } 29 | .dbmindTable .ant-table-pagination.ant-pagination { 30 | padding-right: 300px; 31 | } 32 | .ant-collapse-icon-position-end > .ant-collapse-item > .ant-collapse-header { 33 | padding: 8px 40px 0 8px; 34 | } 35 | .ant-collapse > .ant-collapse-item > .ant-collapse-header .ant-collapse-header-text{ 36 | flex: none; 37 | background-color: #5990FD; 38 | color: #ffffff; 39 | border-radius: 4px 4px 0 0; 40 | font-size: 12px; 41 | padding: 2px 10px; 42 | font-weight : bold ; 43 | } 44 | .ant-collapse-content { 45 | border-top: none; 46 | } 47 | .panelStyle{ 48 | margin-bottom: 15px; 49 | background-color: #f6f6f6; 50 | border-radius:4px 4px 0 0; 51 | } 52 | .settingstyle .ant-card-head { 53 | border-bottom: none; 54 | } 55 | .settingstyle .ant-card-body { 56 | padding: 0 24px 24px 24px; 57 | } 58 | .settingstyle .ant-card-head-title { 59 | padding: 11px 0; 60 | } -------------------------------------------------------------------------------- /ui/src/assets/css/main/header.css: -------------------------------------------------------------------------------- 1 | .menu_top { 2 | width: 100%; 3 | background: #001529; 4 | height: 60px; 5 | } 6 | .menu_top .top{ 7 | width: 100%; 8 | height: 100%; 9 | padding: 0 30px; 10 | display: flex; 11 | justify-content: space-between; 12 | align-items: center; 13 | } 14 | .menu_top .top .userInfoContent{ 15 | display: flex; 16 | height: 100%; 17 | align-items: center; 18 | } 19 | .menu_top .top .userInfo1{ 20 | height: 60px; 21 | color: rgb(192, 188, 188); 22 | font-weight: 400; 23 | display: flex; 24 | justify-content: space-between; 25 | } 26 | .menu_top .top .userInfo1 .info1,.info2{ 27 | display: flex; 28 | justify-content: space-between; 29 | align-items: center; 30 | font-size: 14px; 31 | } 32 | .menu_top .top .userInfo1 .info1{ 33 | margin-right: 20px; 34 | } 35 | .menu_top .top .userInfo1 .info1,.info2 .infoName{ 36 | margin: 0 10px; 37 | } 38 | .menu_top .top .userInfo1 .info2{ 39 | margin-right: 30px; 40 | } 41 | .menu_top .top .userInfo2{ 42 | width: 140px; 43 | display: flex; 44 | align-items: center; 45 | } 46 | .menu_top .top .userInfo2 .info{ 47 | color: rgb(192, 188, 188); 48 | } 49 | .menu_top .top .userInfo2 .info .infoName{ 50 | margin-right: 10px; 51 | } 52 | .changeInstance .ant-select-arrow{ 53 | color: #c0bcbc; 54 | } 55 | .changeInstance .ant-select-selection-item{ 56 | color: #c0bcbc; 57 | } 58 | 59 | 60 | -------------------------------------------------------------------------------- /ui/src/assets/css/main/index.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin: 0; 3 | padding: 0; 4 | } 5 | .container { 6 | width: 100%; 7 | height: 100% !important; 8 | } 9 | #menu_left { 10 | width: 100%; 11 | } 12 | ul li{ 13 | list-style: none; 14 | } 15 | -------------------------------------------------------------------------------- /ui/src/assets/css/main/indexTuning.css: -------------------------------------------------------------------------------- 1 | .indexTuning .ant-card-head { 2 | border-bottom: none; 3 | } 4 | 5 | .indexTuning .ant-card-extra { 6 | padding: 0 7 | } 8 | 9 | .indexTuning .ant-card-body { 10 | padding-top: 0; 11 | } 12 | 13 | .indexTuning .ant-select-selector { 14 | height: 26px !important; 15 | } 16 | 17 | .indexTuning .ant-select-selection-item { 18 | line-height: 26px !important; 19 | } 20 | 21 | .insertclass { 22 | width: 100px; 23 | height: 22px; 24 | float: right; 25 | line-height: 22px; 26 | padding: 6px 0px; 27 | } 28 | 29 | .insertclass span { 30 | display: block; 31 | height: 10px; 32 | float: left; 33 | margin-right: 1%; 34 | } 35 | 36 | .topShowList p { 37 | font-size: 18px; 38 | color: #272727; 39 | font-family: Arial; 40 | text-align: left; 41 | font-weight: Bold; 42 | } 43 | 44 | .topShowList h3 { 45 | font-size: 14px; 46 | color: #737a80; 47 | font-family: Arial; 48 | text-align: left; 49 | font-weight: Regular; 50 | 51 | } -------------------------------------------------------------------------------- /ui/src/assets/css/main/slowQueryAnaly.css: -------------------------------------------------------------------------------- 1 | .rightGrid{ 2 | margin-left: 10px; 3 | } 4 | .cardName .ant-card-head-title { 5 | font-size : 14px ; 6 | color : #737a80 ; 7 | font-family : Arial ; 8 | text-align : left ; 9 | font-weight : Regular ; 10 | } 11 | .slowQueryAnaly .ant-table-content,.tableSlowQuery .ant-table-content{ 12 | height:170px; 13 | overflow-y: auto !important; 14 | } 15 | .slowQueryAnaly .ant-card-head{ 16 | border-bottom: none; 17 | padding: 0 12px 0 20px; 18 | } 19 | .slowQueryAnaly .ant-card-body { 20 | padding: 0 24px; 21 | text-align: left; 22 | } 23 | .slowQueryAnaly .ant-card-head-title,.queryTable .ant-card-head-title { 24 | font-size : 18px ; 25 | color : #272727 ; 26 | font-family : Arial ; 27 | text-align : left ; 28 | font-weight : Regular ; 29 | 30 | } 31 | .slowQueryAnaly .ant-card-head-title span,.slowQueryTitle .ant-card-head-title span { 32 | font-size: 18px; 33 | color: #272727; 34 | font-family: Arial; 35 | text-align: left; 36 | font-weight: Bold; 37 | } 38 | .slowQueryAnaly .ant-card{ 39 | height:240px; 40 | } 41 | 42 | .slowSetting .ant-modal-content{ 43 | min-width: 907px; 44 | } 45 | .slowSetting p{ 46 | min-width: 850px; 47 | } 48 | .labelInfo{ 49 | font-size : 12px ; 50 | font-family : Arial ; 51 | font-weight : Regular ; 52 | } 53 | .labelInfo span{ 54 | margin-right: 12px; 55 | } 56 | .mainContent{ 57 | min-height: 900px; 58 | } -------------------------------------------------------------------------------- /ui/src/assets/imgs/Analyze.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Analyze.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Available.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Available.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Average Queue Length.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Average Queue Length.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Average request delay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Average request delay.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Average request size.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Average request size.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Bandwidth Utilization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Bandwidth Utilization.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Buffer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Buffer.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Cache.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Cache.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Create.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Create.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Current Receive Rate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Current Receive Rate.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Current Sending Rate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Current Sending Rate.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Detail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Detail.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Details.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Empty.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Error packet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Error packet.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/ExecutionPlan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/ExecutionPlan.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Export.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Help.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Initiate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Initiate.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/IsDeveloping.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/IsDeveloping.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Packet loss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Packet loss.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Pause.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Read rate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Read rate.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Receive_drop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Receive_drop.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Receive_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Receive_error.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Refresh.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Setup.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Single Read Time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Single Read Time.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Single Write Time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Single Write Time.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Svctm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Svctm.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/System.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/System.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Tps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Tps.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Transmit_drop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Transmit_drop.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Transmit_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Transmit_error.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Used.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Used.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/User.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/User.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Wait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Wait.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/Write rate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/Write rate.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/alarm1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/alarm1.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/alarm2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/alarm2.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/alarm3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/alarm3.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/alarm4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/alarm4.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/cn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/cn.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/dlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/dlogo.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/dn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/dn.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/end.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/end.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/failure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/failure.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/getback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/getback.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/icon1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/icon1.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/icon10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/icon10.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/icon2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/icon2.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/icon3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/icon3.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/icon4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/icon4.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/icon5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/icon5.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/icon6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/icon6.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/icon7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/icon7.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/icon8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/icon8.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/icon9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/icon9.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/iconok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/iconok.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/iconokgreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/iconokgreen.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/iconstop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/iconstop.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/instance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/instance.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/logo.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/logotip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/logotip.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/main.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/master.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/master.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/nb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/nb.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/not.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/not.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/notstarted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/notstarted.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/over.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/particular.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/particular.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/run.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/running.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/running.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/slave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/slave.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/stop.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/threshold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/threshold.png -------------------------------------------------------------------------------- /ui/src/assets/imgs/update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengauss-mirror/openGauss-DBMind/3198424ad1cf8a0c0a641f319018e51bba9fb80a/ui/src/assets/imgs/update.png -------------------------------------------------------------------------------- /ui/src/components/AutonomousManagement/Alarms.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import SelfhealingRecordsTable from './AlarmsModules/SelfhealingRecordsTable'; 3 | import HistoryAlarms from './AlarmsModules/HistoryAlarms'; 4 | export default class Alarms extends Component { 5 | constructor() { 6 | super() 7 | this.state = {} 8 | } 9 | componentDidMount () { } 10 | render () { 11 | return ( 12 |
13 | 14 | 15 |
16 | ) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ui/src/components/AutonomousManagement/IntelligentInspection.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import InspectionTask from "./IntelligentInspectionModules/InspectionTask"; 3 | import InspectionRecords from "./IntelligentInspectionModules/InspectionRecords"; 4 | import "../../assets/css/main/IntelligentInspection.css"; 5 | import IntelligentInspectionDetail from "./IntelligentInspectionModules/IntelligentInspectionDetail"; 6 | 7 | export default class IntelligentInspection extends Component { 8 | constructor(props) { 9 | super(props); 10 | this.reportRef = React.createRef(); 11 | this.state = { 12 | showDetails: false, 13 | inspectionMode: {}, 14 | isShowBtn: false 15 | }; 16 | } 17 | getData = (data, e, i) => { 18 | this.setState({ 19 | showDetails: data, 20 | inspectionMode: e, 21 | isShowBtn: i 22 | }); 23 | }; 24 | getBack = (data) => { 25 | this.setState({ 26 | showDetails: data, 27 | }); 28 | } 29 | componentDidMount() { } 30 | render() { 31 | return ( 32 | <> 33 | {this.state.showDetails ? ( 34 | 39 | ) : ( 40 |
41 | 42 | 45 |
46 | )} 47 | 48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ui/src/components/AutonomousManagement/IntelligentInspectionModules/RealtimeSystem.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import SystemCpu from "./RealtimeInspectionModule/SystemCpu"; 3 | import SystemMemory from "./RealtimeInspectionModule/SystemMemory"; 4 | import SystemIO from "./RealtimeInspectionModule/SystemIO" 5 | import SystemNetwork from "./RealtimeInspectionModule/SystemNetwork" 6 | import PropTypes from "prop-types"; 7 | export default class RealtimeSystem extends Component { 8 | static propTypes = { 9 | realtimeInspections: PropTypes.object.isRequired, 10 | }; 11 | constructor(props) { 12 | super(props); 13 | this.state = { 14 | systemCpu: {}, 15 | systemMemory: {}, 16 | systemIO: {}, 17 | systemNetwork: {} 18 | }; 19 | } 20 | 21 | getRealtimeInspections(data) { 22 | 23 | this.setState({ 24 | systemCpu: data.cpu, 25 | systemMemory: data.memory, 26 | systemIO: data.io, 27 | systemNetwork: data.network, 28 | }); 29 | } 30 | componentDidMount() { 31 | if (JSON.stringify(this.props.realtimeInspections) !== "{}") { 32 | this.getRealtimeInspections(this.props.realtimeInspections) 33 | } 34 | } 35 | render() { 36 | return ( 37 |
38 | 39 | 40 | 41 | 42 |
43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ui/src/components/AutonomousManagement/SecurityManagement.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import {Col, Row} from 'antd'; 3 | import IsDeveloping from '../../assets/imgs/IsDeveloping.png'; 4 | export default class SecurityManagement extends Component { 5 | constructor() { 6 | super() 7 | this.state = {} 8 | } 9 | componentDidMount () { } 10 | render () { 11 | return ( 12 |
13 |
Don't worry, the current page is under development.....
14 |
15 | ) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ui/src/components/DatabaseOptimization/IndexTuningModules/TopShowList.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Col, Row, Space } from 'antd'; 3 | import PropTypes from 'prop-types'; 4 | import '../../../assets/css/main/databaseOptimization.css'; 5 | import { formatTableTitleToUpper } from '../../../utils/function'; 6 | let widthNum = 0 7 | 8 | export default class TopShowList extends Component { 9 | static propTypes={ 10 | topList:PropTypes.array.isRequired 11 | } 12 | constructor(props) { 13 | super(props) 14 | this.state = {} 15 | } 16 | render () { 17 | widthNum = (100 / this.props.topList.length).toFixed(2) + '%' 18 | const style = { maxWidth: '14.2%!important', flex: `0 0 ${widthNum}` } 19 | return ( 20 |
21 | 22 | { 23 | this.props.topList.map(item => 24 | 25 |
26 |

{formatTableTitleToUpper(item.name)}

27 | {item.img} 28 |
29 |

{item.num}

30 | 31 |
32 | ) 33 | } 34 | 35 |
36 |
37 | ) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ui/src/components/Foot.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | export default class Foot extends Component { 4 | constructor() { 5 | super() 6 | this.state = { 7 | footerData: [ 8 | { 9 | key: 1, 10 | name: 'About openGauss DBMind' 11 | }, { 12 | key: 2, 13 | name: 'Community' 14 | }, { 15 | key: 3, 16 | name: 'More products' 17 | }, { 18 | key: 4, 19 | name: 'Helps' 20 | } 21 | ] 22 | } 23 | } 24 | render () { 25 | return ( 26 |
27 |
28 | { 29 | this.state.footerData.map(item => { 30 | return ( 31 | {item.name} 32 | ) 33 | }) 34 | } 35 |
36 |
37 | ) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ui/src/components/MenuLeft.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import 'antd/dist/antd.css'; 3 | import '../assets/css/main/index.css'; 4 | import { Layout, Menu } from 'antd'; 5 | import { withRouter } from 'react-router-dom'; 6 | import menuList from '../router/menu.js'; 7 | 8 | const { Sider } = Layout; 9 | class MenuLeft extends Component { 10 | constructor(props) { 11 | super(props) 12 | this.state = { 13 | collapsed: false, 14 | selectedKey:this.props.location.pathname, 15 | openKey: '' 16 | }; 17 | } 18 | toggle = () => { 19 | this.setState({ 20 | collapsed: !this.state.collapsed, 21 | }); 22 | }; 23 | componentDidMount(){ 24 | this.openHierarchy() 25 | } 26 | openHierarchy(){ 27 | const {pathname} = this.props.location; 28 | let path = pathname.split('/'); 29 | if(pathname.split('/').length>2){ 30 | path = path[path.length-2]; 31 | this.setState(()=>({openKey:'/'+path})) 32 | } 33 | } 34 | onOpenChange = (k) => { 35 | if(k.length>1){ 36 | this.setState({openKey:k[k.length-1],}) 37 | } else{ 38 | this.setState({openKey:'',}) 39 | }} 40 | componentDidUpdate(prevProps) { 41 | if (prevProps.location.pathname !== this.props.location.pathname) { 42 | this.openHierarchy() 43 | this.setState({selectedKey:this.props.location.pathname}) 44 | } 45 | } 46 | render () { 47 | const { history } = this.props 48 | const onClick = (MenuItem) => { 49 | history.push(MenuItem.key) 50 | this.setState({selectedKey:MenuItem.key}) 51 | } 52 | return ( 53 | 54 | 55 | 56 | ) 57 | } 58 | } 59 | export default withRouter(MenuLeft) 60 | -------------------------------------------------------------------------------- /ui/src/components/NodeInformation/DBLockingAndCaching.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Tabs, Select, message, Input } from 'antd'; 3 | import CacheInformation from '../NodeInformation/CacheInformation'; 4 | import LockInformation from '../NodeInformation/LockInformation'; 5 | import Refresh from '../../assets/imgs/Refresh.png'; 6 | 7 | export default class DBLockingAndCaching extends Component { 8 | constructor(props) { 9 | super(props) 10 | this.state = { 11 | ifShow: true, 12 | tabChildkey:"1", 13 | } 14 | } 15 | onChange = (key) => { 16 | this.setState(() => ({tabChildkey: key})) 17 | }; 18 | handleRefresh(){ 19 | this.LockInformationRef.getLockingQueryData() 20 | } 21 | componentDidMount () { 22 | 23 | } 24 | render() { 25 | let items = [ 26 | { 27 | key: '1', 28 | label: `Lock Information`, 29 | children: {this.LockInformationRef = e}} tabkey={this.props.tabkey} tabChildkey={this.state.tabChildkey} />, 30 | }, 31 | { 32 | key: '2', 33 | label: `Cache Information`, 34 | children: {this.CacheInformationRef = e}} tabkey={this.props.tabkey} tabChildkey={this.state.tabChildkey} startTime={this.props.startTime} endTime={this.props.endTime} selValue={this.props.selValue} selTimeValue={this.props.selTimeValue} />, 35 | } 36 | ] 37 | return ( 38 |
39 | {this.state.ifShow ? 40 | this.handleRefresh()} 46 | > 47 | } /> : ''} 48 |
49 | ) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /ui/src/components/NodeInformation/SessionTopQuery.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Tabs, Select, message, Input } from 'antd'; 3 | import TopQuery from '../NodeInformation/TopQuery'; 4 | import Session from '../NodeInformation/Session'; 5 | import Refresh from '../../assets/imgs/Refresh.png'; 6 | 7 | export default class SessionTopQuery extends Component { 8 | constructor(props) { 9 | super(props) 10 | this.state = { 11 | ifShow: true, 12 | tabSessionkey:"1", 13 | } 14 | } 15 | onChange = (key) => { 16 | this.setState(() => ({tabSessionkey: key})) 17 | }; 18 | handleRefresh(){ 19 | if(this.state.tabSessionkey === "1"){ 20 | this.SessionRef.getSessionData() 21 | } else { 22 | this.TopQueryRef.getTopQueryData() 23 | } 24 | } 25 | componentDidMount () { 26 | 27 | } 28 | render() { 29 | let items = [ 30 | { 31 | key: '1', 32 | label: `Session`, 33 | children: {this.SessionRef = e}} tabkey={this.props.tabkey} tabSessionkey={this.state.tabSessionkey} />, 34 | }, 35 | { 36 | key: '2', 37 | label: `Top Query`, 38 | children: {this.TopQueryRef = e}} tabkey={this.props.tabkey} tabSessionkey={this.state.tabSessionkey} />, 39 | } 40 | ] 41 | return ( 42 |
43 | {this.state.ifShow ? 44 | this.handleRefresh()} 50 | > 51 | } /> : ''} 52 |
53 | ) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /ui/src/components/Overview/Proxy.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Empty, Progress, message } from 'antd'; 3 | import icon10 from '../../assets/imgs/icon10.png'; 4 | import icon8 from '../../assets/imgs/icon8.png'; 5 | import { getProxy } from '../../api/overview'; 6 | 7 | export default class Proxy extends Component { 8 | constructor() { 9 | super() 10 | this.state = { 11 | ifShow: false, 12 | status:true, 13 | proxy_name:'', 14 | proxy_host:'', 15 | } 16 | } 17 | async getProxy () { 18 | const { success, data, msg } = await getProxy() 19 | if (success) { 20 | this.setState(() => ({ 21 | ifShow: true, 22 | status:data.status, 23 | proxy_host:data.agent_address, 24 | })) 25 | } else { 26 | this.setState({ifShow: false}) 27 | message.error(msg) 28 | } 29 | } 30 | componentDidMount () { 31 | this.getProxy() 32 | } 33 | render () { 34 | return ( 35 |
36 | {this.state.ifShow ? 37 | <> 38 |

39 | normal 40 | false 41 |

42 | 43 |

{this.state.proxy_host}

44 | 45 | : } 46 |
47 | ) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ui/src/components/common/ResizeableTitle.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Resizable } from 'react-resizable'; 3 | 4 | const ResizeableTitle = props => { 5 | const { onResize, width, ...restProps } = props; 6 | if (!width) { 7 | return ; 8 | } 9 | return ( 10 | 16 | 17 | 18 | ); 19 | }; 20 | export default ResizeableTitle; -------------------------------------------------------------------------------- /ui/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import 'antd/dist/antd.css'; 4 | import App from './App.js'; 5 | 6 | ReactDOM.render( 7 | , 8 | document.getElementById('root') 9 | ); 10 | -------------------------------------------------------------------------------- /ui/src/pages/NodeInformation.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Tabs } from 'antd'; 3 | import '../assets/css/common.css'; 4 | import '../assets/css/main/nodeinformation.css'; 5 | import Node from '../components/NodeInformation/Node'; 6 | import Host from '../components/NodeInformation/Host'; 7 | 8 | const { TabPane } = Tabs; 9 | export default class Cluster extends Component { 10 | constructor() { 11 | super() 12 | this.state = {} 13 | } 14 | render () { 15 | return ( 16 |
17 | 18 | 21 | System resource 22 | 23 | } 24 | key="1" 25 | > 26 | 27 | 28 | 31 | DB 32 | 33 | } 34 | key="2" 35 | > 36 | 37 | 38 | 39 |
40 | ); 41 | } 42 | } -------------------------------------------------------------------------------- /ui/src/setupProxy.js: -------------------------------------------------------------------------------- 1 | const { createProxyMiddleware } = require('http-proxy-middleware'); 2 | module.exports = function (app) { 3 | app.use(createProxyMiddleware('/transpond', { 4 | target: process.env.REACT_APP_BASE_URL? process.env.REACT_APP_BASE_URL : '127.0.0.1:8080', 5 | changeOrigin: true, 6 | pathRewrite: { 7 | '^/transpond': '/api' 8 | } 9 | })) 10 | } -------------------------------------------------------------------------------- /ui/src/utils/history.js: -------------------------------------------------------------------------------- 1 | import { createHashHistory } from 'history'; 2 | 3 | const history = createHashHistory() 4 | 5 | export default history -------------------------------------------------------------------------------- /ui/src/utils/storage.js: -------------------------------------------------------------------------------- 1 | const ls = localStorage; 2 | const ss = sessionStorage; 3 | const db = { 4 | ls: { 5 | get (key) { 6 | try { 7 | return JSON.parse(ls.getItem(key)); 8 | } catch (err) { 9 | return ls.getItem(key); 10 | } 11 | }, 12 | set (key, value) { 13 | ls.setItem(key, JSON.stringify(value)); 14 | }, 15 | remove (key) { 16 | ls.removeItem(key); 17 | }, 18 | clear () { 19 | ls.clear(); 20 | } 21 | }, 22 | ss: { 23 | get (key) { 24 | try { 25 | return JSON.parse(ss.getItem(key)); 26 | } catch (err) { 27 | return ss.getItem(key); 28 | } 29 | }, 30 | set (key, value) { 31 | ss.setItem(key, JSON.stringify(value)); 32 | }, 33 | remove (key) { 34 | ss.removeItem(key); 35 | }, 36 | clear () { 37 | ss.clear(); 38 | } 39 | } 40 | }; 41 | export default db; --------------------------------------------------------------------------------