]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
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 | ||
1e59de90 TL |
6 | import argparse |
7 | ||
11fdf7f2 TL |
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 | |
1e59de90 | 11 | from advisor.rule_parser import RulesSpec |
11fdf7f2 TL |
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 | |
1e59de90 | 22 | db_logs = DatabaseLogs(args.log_files_path_prefix, db_options.get_column_families()) |
11fdf7f2 TL |
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], | |
1e59de90 | 30 | DataSource.Type.TIME_SERIES: [db_log_stats], |
11fdf7f2 TL |
31 | } |
32 | if args.ods_client: | |
1e59de90 TL |
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 | ) | |
11fdf7f2 TL |
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 | ||
1e59de90 TL |
48 | if __name__ == "__main__": |
49 | parser = argparse.ArgumentParser( | |
50 | description="Use this script to get\ | |
51 | suggestions for improving Rocksdb performance." | |
11fdf7f2 TL |
52 | ) |
53 | parser.add_argument( | |
1e59de90 TL |
54 | "--rules_spec", |
55 | required=True, | |
56 | type=str, | |
57 | help="path of the file containing the expert-specified Rules", | |
11fdf7f2 TL |
58 | ) |
59 | parser.add_argument( | |
1e59de90 TL |
60 | "--rocksdb_options", |
61 | required=True, | |
62 | type=str, | |
63 | help="path of the starting Rocksdb OPTIONS file", | |
11fdf7f2 TL |
64 | ) |
65 | parser.add_argument( | |
1e59de90 TL |
66 | "--log_files_path_prefix", |
67 | required=True, | |
68 | type=str, | |
69 | help="path prefix of the Rocksdb LOG files", | |
11fdf7f2 | 70 | ) |
11fdf7f2 | 71 | parser.add_argument( |
1e59de90 TL |
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", | |
11fdf7f2 | 77 | ) |
1e59de90 TL |
78 | # ODS arguments |
79 | parser.add_argument("--ods_client", type=str, help="the ODS client binary") | |
11fdf7f2 | 80 | parser.add_argument( |
1e59de90 TL |
81 | "--ods_entity", |
82 | type=str, | |
83 | help="the servers for which the ODS stats need to be fetched", | |
11fdf7f2 TL |
84 | ) |
85 | parser.add_argument( | |
1e59de90 TL |
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", | |
11fdf7f2 TL |
90 | ) |
91 | parser.add_argument( | |
1e59de90 | 92 | "--ods_tstart", type=int, help="start time of timeseries to be fetched from ODS" |
11fdf7f2 TL |
93 | ) |
94 | parser.add_argument( | |
1e59de90 | 95 | "--ods_tend", type=int, help="end time of timeseries to be fetched from ODS" |
11fdf7f2 TL |
96 | ) |
97 | args = parser.parse_args() | |
98 | main(args) |