2 * @brief The updater class implementation. This class implements the updater logic.
6 * @copyright Intra2net AG
15 * Default constructor which initializes the member Conf.
20 LoggerPtr _log(new Logger);
24 ConfigPtr _config(new Config(Log));
27 Log->print_constructor_call("Updater");
36 Log->print_destructor_call("Updater");
41 * Parse the command line arguments and initialize corresponding options.
42 * @param argc Number command line arguments.
43 * @param argv[] Array with arguments.
44 * @return 0 if cmd options successfully parsed, 1 if usage or version.
46 int Updater::init_config_from_cmd(int argc, char *argv[])
48 // Load the command line parameters
49 if( Conf->parse_cmd_line( argc, argv ) != 0)
52 // If we have loaded the cmd options we need to init the log facility immediately in case debugging is enabled from cmd.
56 Log->print_cmd_parsed();
62 * Load the main config and the service definition files in config path.
63 * @return 0 if all is fine,
65 int Updater::init_config_from_files()
67 // Load the main and service config files in config path
68 if( Conf->load_config_from_files() != 0)
71 // Re-init log facility, perhaps new config file options for logger are set.
72 // These config file options will only overwrite the cmd options if the SIGHUP (reload config) is caught.
81 * Getter for member Config.
82 * @return Member Config.
84 ConfigPtr Updater::get_config()
91 * Getter for member Logger.
92 * @return Member Logger.
94 LoggerPtr Updater::get_logger()
101 * Reloading the config. Delete all Service objects and then init new Service objects from config files.
103 void Updater::reload_config()
105 // delete all service objects
106 Conf->delete_services();
108 // delete the actual Variables_map, perhaps with old cmd options which would overwrite new config file options.
109 Conf->delete_variables_map();
111 // load only config files
112 init_config_from_files();
117 * Initialize the logging facility with loglevel and syslog.
119 void Updater::init_log_facility()
121 Log->set_log_facility(Conf->get_loglevel(),Conf->get_syslog());
122 Log->print_init_log_facility();
127 * Update all configured services.
129 void Updater::update_services()
131 list<ServicePtr> services = this->Conf->get_services();
133 string ip = "192.168.1.1";
135 BOOST_FOREACH( ServicePtr service, services )