Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef QE_OPTIONS_H_ 6 : #define QE_OPTIONS_H_ 7 : 8 : #include <boost/program_options.hpp> 9 : #include "io/event_manager.h" 10 : #include "sandesh/sandesh.h" 11 : 12 : #define ANALYTICS_DATA_TTL_DEFAULT 48 // g_viz_constants.AnalyticsTTL 13 : 14 : // Process command line/configuration file options for collector. 15 : class Options { 16 : public: 17 : Options(); 18 : bool Parse(EventManager &evm, int argc, char **argv); 19 : 20 78 : const std::vector<std::string> cassandra_server_list() const { 21 78 : return cassandra_server_list_; 22 : } 23 71 : const std::vector<std::string> collector_server_list() const { 24 71 : return collector_server_list_; 25 : } 26 0 : const std::vector<std::string> default_collector_server_list() const { 27 0 : return default_collector_server_list_; 28 : } 29 44 : std::vector<std::string> randomized_collector_server_list() const { 30 44 : return randomized_collector_server_list_; 31 : } 32 44 : const bool collectors_configured() const { 33 44 : return collector_server_list_.size() > 0; 34 : } 35 22 : const std::vector<std::string> config_file() const { 36 22 : return config_file_; 37 : } 38 76 : const std::vector<std::string> redis_server_list() const { 39 76 : return redis_server_list_; 40 : } 41 : 42 : const std::string redis_server() const { return redis_server_; } 43 6 : const uint16_t redis_port() const { return redis_port_; } 44 47 : const std::string redis_password() const { return redis_password_; } 45 47 : const bool redis_ssl_enable() const { return redis_ssl_enable_; } 46 45 : const std::string redis_keyfile() const { return redis_keyfile_; } 47 45 : const std::string redis_certfile() const { return redis_certfile_; } 48 45 : const std::string redis_ca_cert() const { return redis_ca_cert_; } 49 94 : const std::string hostname() const { return hostname_; } 50 50 : const std::string host_ip() const { return host_ip_; } 51 94 : const uint16_t http_server_port() const { return http_server_port_; } 52 6 : const uint64_t start_time() const { return start_time_; } 53 50 : const int max_tasks() const { return max_tasks_; } 54 94 : const int max_slice() const { return max_slice_; } 55 50 : const std::string log_category() const { return log_category_; } 56 44 : const std::string log_property_file() const { return log_property_file_; } 57 50 : const bool log_disable() const { return log_disable_; } 58 50 : const std::string log_file() const { return log_file_; } 59 50 : const int log_files_count() const { return log_files_count_; } 60 50 : const long log_file_size() const { return log_file_size_; } 61 94 : const std::string log_level() const { return log_level_; } 62 50 : const bool log_local() const { return log_local_; } 63 44 : const bool use_syslog() const { return use_syslog_; } 64 44 : const std::string syslog_facility() const { return syslog_facility_; } 65 6 : const int analytics_data_ttl() const { return analytics_data_ttl_; } 66 6 : const bool test_mode() const { return test_mode_; } 67 25 : const std::string cluster_id() const { return cluster_id_; } 68 46 : const std::string cassandra_user() const { return cassandra_user_; } 69 46 : const std::string cassandra_password() const { return cassandra_password_; } 70 50 : const bool cassandra_use_ssl() const { return cassandra_use_ssl_; } 71 46 : const std::string cassandra_ca_certs() const { return cassandra_ca_certs_; } 72 54 : const SandeshConfig &sandesh_config() const { return sandesh_config_; } 73 : 74 : void ParseReConfig(); 75 : 76 : private: 77 : 78 : void Process(int argc, char *argv[], 79 : boost::program_options::options_description &cmdline_options); 80 : void Initialize(EventManager &evm, 81 : boost::program_options::options_description &options); 82 : uint32_t GenerateHash(std::vector<std::string> &); 83 : 84 : std::vector<std::string> config_file_; 85 : std::vector<std::string> redis_server_list_; 86 : std::string redis_server_; 87 : uint16_t redis_port_; 88 : std::string redis_password_; 89 : bool redis_ssl_enable_; 90 : std::string redis_keyfile_; 91 : std::string redis_certfile_; 92 : std::string redis_ca_cert_; 93 : std::string hostname_; 94 : std::string host_ip_; 95 : uint16_t http_server_port_; 96 : std::string log_category_; 97 : std::string log_property_file_; 98 : bool log_disable_; 99 : std::string log_file_; 100 : int log_files_count_; 101 : long log_file_size_; 102 : std::string log_level_; 103 : bool log_local_; 104 : bool use_syslog_; 105 : std::string syslog_facility_; 106 : uint64_t start_time_; 107 : int max_tasks_; 108 : int max_slice_; 109 : bool test_mode_; 110 : int analytics_data_ttl_; 111 : uint32_t send_ratelimit_; 112 : std::vector<std::string> cassandra_server_list_; 113 : std::vector<std::string> collector_server_list_; 114 : std::vector<std::string> randomized_collector_server_list_; 115 : uint32_t collector_chksum_; 116 : std::vector<std::string> default_collector_server_list_; 117 : SandeshConfig sandesh_config_; 118 : 119 : boost::program_options::options_description config_file_options_; 120 : std::string cluster_id_; 121 : std::string cassandra_user_; 122 : std::string cassandra_password_; 123 : bool cassandra_use_ssl_; 124 : std::string cassandra_ca_certs_; 125 : }; 126 : 127 : #endif /* QE_OPTIONS_H_ */