]>
git.proxmox.com Git - ceph.git/blob - 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).
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
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
28 DataSource
.Type
.DB_OPTIONS
: [db_options
],
29 DataSource
.Type
.LOG
: [db_logs
],
30 DataSource
.Type
.TIME_SERIES
: [db_log_stats
],
33 data_sources
[DataSource
.Type
.TIME_SERIES
].append(
42 triggered_rules
= rule_spec_parser
.get_triggered_rules(
43 data_sources
, db_options
.get_column_families()
45 rule_spec_parser
.print_rules(triggered_rules
)
48 if __name__
== "__main__":
49 parser
= argparse
.ArgumentParser(
50 description
="Use this script to get\
51 suggestions for improving Rocksdb performance."
57 help="path of the file containing the expert-specified Rules",
63 help="path of the starting Rocksdb OPTIONS file",
66 "--log_files_path_prefix",
69 help="path prefix of the Rocksdb LOG files",
72 "--stats_dump_period_sec",
75 help="the frequency (in seconds) at which STATISTICS are printed to "
76 + "the Rocksdb LOG file",
79 parser
.add_argument("--ods_client", type=str, help="the ODS client binary")
83 help="the servers for which the ODS stats need to be fetched",
88 help="the prefix that needs to be attached to the keys of time "
89 + "series to be fetched from ODS",
92 "--ods_tstart", type=int, help="start time of timeseries to be fetched from ODS"
95 "--ods_tend", type=int, help="end time of timeseries to be fetched from ODS"
97 args
= parser
.parse_args()