]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/tools/advisor/advisor/rule_parser_example.py
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / tools / advisor / advisor / rule_parser_example.py
1 # Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 # This source code is licensed under both the GPLv2 (found in the
3 # COPYING file in the root directory) and Apache 2.0 License
4 # (found in the LICENSE.Apache file in the root directory).
5
6 import argparse
7
8 from advisor.db_log_parser import DatabaseLogs, DataSource
9 from advisor.db_options_parser import DatabaseOptions
10 from advisor.db_stats_fetcher import LogStatsParser, OdsStatsFetcher
11 from advisor.rule_parser import RulesSpec
12
13
14 def main(args):
15 # initialise the RulesSpec parser
16 rule_spec_parser = RulesSpec(args.rules_spec)
17 rule_spec_parser.load_rules_from_spec()
18 rule_spec_parser.perform_section_checks()
19 # initialize the DatabaseOptions object
20 db_options = DatabaseOptions(args.rocksdb_options)
21 # Create DatabaseLogs object
22 db_logs = DatabaseLogs(args.log_files_path_prefix, db_options.get_column_families())
23 # Create the Log STATS object
24 db_log_stats = LogStatsParser(
25 args.log_files_path_prefix, args.stats_dump_period_sec
26 )
27 data_sources = {
28 DataSource.Type.DB_OPTIONS: [db_options],
29 DataSource.Type.LOG: [db_logs],
30 DataSource.Type.TIME_SERIES: [db_log_stats],
31 }
32 if args.ods_client:
33 data_sources[DataSource.Type.TIME_SERIES].append(
34 OdsStatsFetcher(
35 args.ods_client,
36 args.ods_entity,
37 args.ods_tstart,
38 args.ods_tend,
39 args.ods_key_prefix,
40 )
41 )
42 triggered_rules = rule_spec_parser.get_triggered_rules(
43 data_sources, db_options.get_column_families()
44 )
45 rule_spec_parser.print_rules(triggered_rules)
46
47
48 if __name__ == "__main__":
49 parser = argparse.ArgumentParser(
50 description="Use this script to get\
51 suggestions for improving Rocksdb performance."
52 )
53 parser.add_argument(
54 "--rules_spec",
55 required=True,
56 type=str,
57 help="path of the file containing the expert-specified Rules",
58 )
59 parser.add_argument(
60 "--rocksdb_options",
61 required=True,
62 type=str,
63 help="path of the starting Rocksdb OPTIONS file",
64 )
65 parser.add_argument(
66 "--log_files_path_prefix",
67 required=True,
68 type=str,
69 help="path prefix of the Rocksdb LOG files",
70 )
71 parser.add_argument(
72 "--stats_dump_period_sec",
73 required=True,
74 type=int,
75 help="the frequency (in seconds) at which STATISTICS are printed to "
76 + "the Rocksdb LOG file",
77 )
78 # ODS arguments
79 parser.add_argument("--ods_client", type=str, help="the ODS client binary")
80 parser.add_argument(
81 "--ods_entity",
82 type=str,
83 help="the servers for which the ODS stats need to be fetched",
84 )
85 parser.add_argument(
86 "--ods_key_prefix",
87 type=str,
88 help="the prefix that needs to be attached to the keys of time "
89 + "series to be fetched from ODS",
90 )
91 parser.add_argument(
92 "--ods_tstart", type=int, help="start time of timeseries to be fetched from ODS"
93 )
94 parser.add_argument(
95 "--ods_tend", type=int, help="end time of timeseries to be fetched from ODS"
96 )
97 args = parser.parse_args()
98 main(args)