Changeset 230
- Timestamp:
- 01/07/10 08:10:43 (2 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 12 edited
-
include/settings/Settings.h (modified) (1 diff)
-
include/settings/macros.h (modified) (4 diffs)
-
include/settings/settings_ini.hpp (modified) (2 diffs)
-
include/strEx.h (modified) (1 diff)
-
modules/Scheduler/Scheduler.cpp (modified) (1 diff)
-
modules/Scheduler/Scheduler.h (modified) (1 diff)
-
modules/Scheduler/simple_scheduler.cpp (modified) (1 diff)
-
modules/Scheduler/simple_scheduler.hpp (modified) (6 diffs)
-
service/CMakeLists.txt (modified) (1 diff)
-
service/NSCPlugin.cpp (modified) (1 diff)
-
service/NSClient++.cpp (modified) (9 diffs)
-
service/NSClient++.h (modified) (1 diff)
-
service/settings_client.hpp (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/settings/Settings.h
r216 r230 754 754 get()->set_int(*cit, *citk, strEx::stoi(desc.defValue)); 755 755 else 756 throw SettingsException(_T("Unknown keytype for: ") + *cit + _T(".") + *citk);756 get_logger()->err(__FILEW__, __LINE__, _T("Unknown keytype for: ") + *cit + _T(".") + *citk); 757 757 } else { 758 get_logger()->debug(__FILEW__, __LINE__, _T("Skipping (already exists): ") + *cit + _T(".") + *citk); 758 std::wstring val = get()->get_string(*cit, *citk); 759 get_logger()->debug(__FILEW__, __LINE__, _T("Setting old (already exists): ") + *cit + _T(".") + *citk + _T(" = ") + val); 760 if (desc.type == key_string) 761 get()->set_string(*cit, *citk, val); 762 else if (desc.type == key_bool) 763 get()->set_bool(*cit, *citk, val==_T("true")); 764 else if (desc.type == key_integer) 765 get()->set_int(*cit, *citk, strEx::stoi(val)); 766 else 767 get_logger()->err(__FILEW__, __LINE__, _T("Unknown keytype for: ") + *cit + _T(".") + *citk); 759 768 } 760 769 } else { -
trunk/include/settings/macros.h
r207 r230 83 83 #define CHECK_SYSTEM_SERVICES_SECTION "/settings/system/services" 84 84 #define NSCA_SECTION "/settings/NSCA" 85 #define SCHEDULER_SECTION "/settings/scheduler" 86 #define SCHEDULER_SECTION_SCH "/settings/scheduler/schedules" 87 #define SCHEDULER_SECTION_FAKE "/settings/scheduler/schedules/<schedule name>" 88 #define SCHEDULER_SECTION_DEF "/settings/scheduler/default" 85 89 #define NSCA_SERVER_SECTION "/settings/NSCA/server" 86 90 #define NSCA_CMD_SECTION "/settings/NSCA/server/commands" … … 310 314 } 311 315 316 312 317 namespace nsca { 313 318 DEFINE_PATH(SECTION, NSCA_SECTION); … … 349 354 DEFINE_SETTING_S(TIME_DELTA_DEFAULT, NSCA_SECTION, "delay", "0"); 350 355 DESCRIBE_SETTING(TIME_DELTA_DEFAULT, "TODO", "TODO"); 351 356 352 357 DEFINE_SETTING_I(PAYLOAD_LENGTH, NSCA_SECTION, "payload length", 512); 353 358 DESCRIBE_SETTING_ADVANCED(PAYLOAD_LENGTH, "PAYLOAD LENGTH", "Length of payload to/from the NSCA agent. This is a hard specific value so you have to \"configure\" (read recompile) your NSCA server to use the same value for it to work."); … … 355 360 DEFINE_SETTING_I(READ_TIMEOUT, NSCA_SERVER_SECTION, GENERIC_KEY_SOCK_READ_TIMEOUT, 30); 356 361 DESCRIBE_SETTING(READ_TIMEOUT, "SOCKET TIMEOUT", "Timeout when reading packets on incoming sockets. If the data has not arrived withint this time we will bail out."); 362 363 } 364 365 namespace scheduler { 366 DEFINE_PATH(SECTION, SCHEDULER_SECTION); 367 DESCRIBE_SETTING(SECTION, "SCHEDULER SECTION", "Section for the Scheduler module."); 368 369 DEFINE_PATH(SCHEDULES_SECTION, SCHEDULER_SECTION_SCH); 370 DESCRIBE_SETTING(SCHEDULES_SECTION, "SCHEDULES SECTION", "Section for defining schedules for the Scheduler module."); 371 372 DEFINE_PATH(DEFAULT_SCHEDULE_SECTION, SCHEDULER_SECTION_DEF); 373 DESCRIBE_SETTING(DEFAULT_SCHEDULE_SECTION, "DEFAULT SCHEDULER SECTION", "Default settings for all scheduled commands"); 374 375 DEFINE_SETTING_I(THREADS, SCHEDULER_SECTION, "debug threads", 1); 376 DESCRIBE_SETTING_ADVANCED(THREADS, "THREADS", "Number of threads to use int he thread pool (increase if you have many scheduled items)"); 377 378 DEFINE_SETTING_S(INTERVAL, SCHEDULER_SECTION_FAKE, "interval", "5m"); 379 DESCRIBE_SETTING(INTERVAL, "SCHEDULE INTERVAL", "Time in seconds between each check"); 380 381 DEFINE_SETTING_S(COMMAND, SCHEDULER_SECTION_FAKE, "command", "check_ok"); 382 DESCRIBE_SETTING(COMMAND, "SCHEDULE COMMAND", "Command to run"); 383 384 DEFINE_SETTING_S(CHANNEL, SCHEDULER_SECTION_FAKE, "channel", "NSCA"); 385 DESCRIBE_SETTING(CHANNEL, "SCHEDULE CHANNEL", "Channel to send results on"); 386 387 DEFINE_SETTING_S(REPORT_MODE, SCHEDULER_SECTION_FAKE, "report", "all"); 388 DESCRIBE_SETTING(REPORT_MODE, "REPORT MODE", "What to report to the server (any of the following: all, critical, warning, unknown, ok)"); 389 390 DEFINE_SETTING_S(INTERVAL_D, SCHEDULER_SECTION_DEF, "interval", "5m"); 391 DESCRIBE_SETTING(INTERVAL_D, "SCHEDULE INTERVAL", "Time in seconds between each check"); 392 393 DEFINE_SETTING_S(COMMAND_D, SCHEDULER_SECTION_DEF, "command", "check_ok"); 394 DESCRIBE_SETTING(COMMAND_D, "SCHEDULE COMMAND", "Command to run"); 395 396 DEFINE_SETTING_S(CHANNEL_D, SCHEDULER_SECTION_DEF, "channel", "NSCA"); 397 DESCRIBE_SETTING(CHANNEL_D, "SCHEDULE CHANNEL", "Channel to send results on"); 398 399 DEFINE_SETTING_S(REPORT_MODE_D, SCHEDULER_SECTION_DEF, "report", "all"); 400 DESCRIBE_SETTING(REPORT_MODE_D, "REPORT MODE", "What to report to the server (any of the following: all, critical, warning, unknown, ok)"); 357 401 358 402 } -
trunk/include/settings/settings_ini.hpp
r216 r230 78 78 /// @author mickem 79 79 virtual bool has_real_key(SettingsCore::key_path_type key) { 80 return false;80 return ini.GetValue(key.first.c_str(), key.second.c_str()) != NULL; 81 81 } 82 82 ////////////////////////////////////////////////////////////////////////// … … 115 115 strEx::replace(comment, _T("\n"), _T(" ")); 116 116 get_core()->get_logger()->quick_debug(_T("saving: ") + key.first + _T("//") + key.second); 117 118 ini.Delete(key.first.c_str(), key.second.c_str()); 117 119 ini.SetValue(key.first.c_str(), key.second.c_str(), value.get_string().c_str(), comment.c_str()); 118 120 } catch (KeyNotFoundException e) { 119 ini.SetValue(key.first.c_str(), key.second.c_str(), value.get_string().c_str() );121 ini.SetValue(key.first.c_str(), key.second.c_str(), value.get_string().c_str(), _T("; Undocumented key")); 120 122 } catch (SettingsException e) { 121 123 get_core()->get_logger()->err(__FILEW__, __LINE__, std::wstring(_T("Failed to write key: ") + e.getError())); -
trunk/include/strEx.h
r216 r230 366 366 inline unsigned stoui_as_time(std::wstring time, unsigned int smallest_unit = 1000) { 367 367 std::wstring::size_type p = time.find_first_of(_T("sSmMhHdDwW")); 368 unsigned int value = boost::lexical_cast<unsigned int>(time.c_str()); 368 std::wstring::size_type pend = time.find_first_not_of(_T("0123456789")); 369 unsigned int value = boost::lexical_cast<unsigned int>(pend==std::wstring::npos?time:time.substr(0,pend).c_str()); 369 370 if (p == std::wstring::npos) 370 371 return value * smallest_unit; -
trunk/modules/Scheduler/Scheduler.cpp
r229 r230 24 24 #include <time.h> 25 25 #include <utils.h> 26 #include <settings/macros.h> 26 27 27 28 Scheduler gInstance; 28 29 30 bool Scheduler::loadModule(NSCAPI::moduleLoadMode mode) { 31 try { 32 SETTINGS_REG_PATH(scheduler::SECTION); 33 SETTINGS_REG_PATH(scheduler::DEFAULT_SCHEDULE_SECTION); 34 SETTINGS_REG_PATH(scheduler::SCHEDULES_SECTION); 29 35 30 bool Scheduler::loadModule(NSCAPI::moduleLoadMode mode) { 31 if (mode == NSCAPI::normalStart) { 32 scheduler_.start(); 36 SETTINGS_REG_KEY_S(scheduler::INTERVAL_D); 37 SETTINGS_REG_KEY_S(scheduler::COMMAND_D); 38 SETTINGS_REG_KEY_S(scheduler::CHANNEL_D); 39 SETTINGS_REG_KEY_S(scheduler::REPORT_MODE_D); 40 41 SETTINGS_REG_KEY_I(scheduler::THREADS); 42 } catch (NSCModuleHelper::NSCMHExcpetion &e) { 43 NSC_LOG_ERROR_STD(_T("Failed to register command: ") + e.msg_); 44 } catch (...) { 45 NSC_LOG_ERROR_STD(_T("Failed to register command.")); 33 46 } 34 add_schedule(_T("test 001")); 35 add_schedule(_T("test 002")); 47 48 49 try { 50 51 scheduler_.set_threads(SETTINGS_GET_INT(scheduler::THREADS)); 52 53 if (mode == NSCAPI::normalStart) { 54 scheduler_.start(); 55 } 56 57 bool found = false; 58 scheduler::target def = read_schedule(setting_keys::scheduler::DEFAULT_SCHEDULE_SECTION_PATH); 59 std::list<std::wstring> items = NSCModuleHelper::getSettingsSection(setting_keys::scheduler::SCHEDULES_SECTION_PATH); 60 61 for (std::list<std::wstring>::const_iterator cit = items.begin(); cit != items.end(); ++cit) { 62 found = true; 63 add_schedule(*cit, def); 64 } 65 66 if (!found) { 67 NSC_DEBUG_MSG_STD(_T("No scheduled commands found!")); 68 SETTINGS_REG_KEY_S(scheduler::INTERVAL); 69 SETTINGS_REG_KEY_S(scheduler::COMMAND); 70 SETTINGS_REG_KEY_S(scheduler::CHANNEL); 71 SETTINGS_REG_KEY_S(scheduler::REPORT_MODE); 72 73 } 74 /* 75 add_schedule(_T("test: FIRST")); 76 for (int i=0;i<1000;i++) 77 add_schedule(_T("test: ") + to_wstring(i)); 78 add_schedule(_T("test: LAST")); 79 */ 80 } catch (NSCModuleHelper::NSCMHExcpetion &e) { 81 NSC_LOG_ERROR_STD(_T("Exception in module Scheduler: ") + e.msg_); 82 return false; 83 } catch (...) { 84 NSC_LOG_ERROR_STD(_T("Unknown Exception in module Scheduler!")); 85 return false; 86 } 36 87 return true; 37 88 } 38 89 90 scheduler::target Scheduler::read_schedule(std::wstring path) { 91 scheduler::target item; 92 item.channel = NSCModuleHelper::getSettingsString(path, setting_keys::scheduler::CHANNEL, setting_keys::scheduler::CHANNEL_DEFAULT); 93 item.command = NSCModuleHelper::getSettingsString(path, setting_keys::scheduler::COMMAND, setting_keys::scheduler::COMMAND_PATH); 94 /* 95 std::wstring report = SETTINGS_GET_STRING(scheduler::REPORT_MODE); 96 item.report = parse_report_string(report); 97 */ 98 std::wstring duration = NSCModuleHelper::getSettingsString(path, setting_keys::scheduler::INTERVAL, setting_keys::scheduler::INTERVAL_DEFAULT); 99 item.duration = boost::posix_time::seconds(strEx::stoui_as_time(duration)); 100 return item; 101 } 102 scheduler::target Scheduler::read_schedule(std::wstring path, scheduler::target def) { 103 scheduler::target item; 104 105 item.channel = NSCModuleHelper::getSettingsString(path, setting_keys::scheduler::CHANNEL, def.channel); 106 item.command = NSCModuleHelper::getSettingsString(path, setting_keys::scheduler::COMMAND, def.command); 107 /* 108 std::wstring report = NSCModuleHelper::getSettingsString(path, setting_keys::scheduler::REPORT_MODE, def.report); 109 item.report = parse_report_string(report); 110 */ 111 std::wstring duration = NSCModuleHelper::getSettingsString(path, setting_keys::scheduler::INTERVAL, to_wstring(def.duration.total_seconds()) + _T("s")); 112 item.duration = boost::posix_time::seconds(strEx::stoui_as_time(duration)); 113 return item; 114 } 39 115 40 void Scheduler::add_schedule(std::wstring command) { 41 scheduler::target item; 116 void Scheduler::add_schedule(std::wstring command, scheduler::target def) { 117 NSC_DEBUG_MSG_STD(_T("Adding scheduled command: ") + command); 118 scheduler::target item = read_schedule(setting_keys::scheduler::SCHEDULES_SECTION_PATH + _T("/") + command, def); 119 120 // std::wstring report = SETTINGS_GET_STRING(scheduler::REPORT_MODE); 121 // report_ = parse_report_string(report); 122 42 123 item.command = command; 43 item.duration = boost::posix_time::time_duration(0,0,5); 124 item.set_duration(boost::posix_time::seconds(5)); 125 scheduler_.add_task(item); 126 /* 44 127 std::wcout << _T("*** DURATION ") << item.duration << _T(" ***") << std::endl; 45 scheduler_.add_task(item);128 */ 46 129 } 47 130 bool Scheduler::unloadModule() { -
trunk/modules/Scheduler/Scheduler.h
r229 r230 39 39 40 40 41 void add_schedule(std::wstring command); 41 void add_schedule(std::wstring command, scheduler::target def); 42 scheduler::target read_schedule(std::wstring path, scheduler::target def); 43 scheduler::target read_schedule(std::wstring path); 42 44 43 45 std::wstring getModuleName() { -
trunk/modules/Scheduler/simple_scheduler.cpp
r229 r230 18 18 targets_.erase(it); 19 19 } 20 targetsimple_scheduler::get_task(int id) {20 boost::optional<target> simple_scheduler::get_task(int id) { 21 21 boost::mutex::scoped_lock l(mutex_); 22 22 target_list_type::iterator it = targets_.find(id); 23 if (it == targets_.end())24 return target::empty();25 return (*it).second;23 if (it == targets_.end()) 24 return boost::optional<target>(); 25 return boost::optional<target>((*it).second); 26 26 } 27 27 28 28 void simple_scheduler::start() { 29 running_ = true; 29 30 if (!queue_.empty()) 30 31 start_thread(); 31 32 } 32 33 void simple_scheduler::stop() { 33 if (thread_) 34 return; 34 running_ = false; 35 //if (!thread_) 36 // return; 35 37 stop_requested_ = true; 36 thread_->join(); 38 threads_.interrupt_all(); 39 threads_.join_all(); 40 /* 41 if (!threads.join_all(boost::posix_time::seconds(5))) { 42 std::wcout << _T("FAILED TO TERMINATE!!!") << std::endl; 43 } else { 44 std::wcout << _T("THREAD TERMINATED NICELY!") << std::endl; 45 } 46 */ 37 47 } 38 48 39 49 void simple_scheduler::start_thread() { 50 if (!running_) 51 return; 40 52 stop_requested_ = false; 41 thread_ = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&simple_scheduler::thread_proc, this))); 53 int missing_threads = thread_count_ - threads_.size(); 54 if (missing_threads > 0 && missing_threads <= thread_count_) { 55 for (int i=0;i<missing_threads;i++) { 56 std::wcout << _T("***START_THREAD***") << std::endl; 57 threads_.create_thread(boost::bind(&simple_scheduler::thread_proc, this)); 58 } 59 } 60 //thread_ = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&simple_scheduler::thread_proc, this))); 42 61 } 43 62 44 63 void simple_scheduler::thread_proc() { 45 64 int iteration = 0; 46 schedule_ instance instance;65 schedule_queue_type::value_type instance; 47 66 while (!stop_requested_) { 48 { 49 boost::mutex::scoped_lock l(mutex_); 50 //std::wcout << _T("#### COUNT: ") << queue_.size() << _T(" ####") << std::endl; 51 if (queue_.empty()) 67 instance = queue_.pop(); 68 if (!instance) 69 return; 70 71 try { 72 73 boost::posix_time::time_duration off = now() - (*instance).time; 74 if (off.total_seconds() > 0) { 75 std::wcout << _T("MISSED IT!") << off.total_seconds() << std::endl; 76 } 77 boost::thread::sleep((*instance).time); 78 } catch (boost::thread_interrupted &e) { 79 if (!queue_.push(*instance)) 80 std::wcout << _T("ERROR") << std::endl; 81 if (stop_requested_) 52 82 return; 53 instance = queue_.top(); 54 queue_.pop(); 55 } 56 target item = get_task(instance.schedule_id); 57 //boost::posix_time::ptime delay = now() + instance.time; 58 59 try { 60 boost::thread::sleep(instance.time); 83 continue; 61 84 } catch (...) { 62 std::wcout << _T("Excepting...") << std::endl; 85 if (!queue_.push(*instance)) 86 std::wcout << _T("ERROR") << std::endl; 87 std::wcout << _T("ERROR!!!") << std::endl; 63 88 return; 64 89 } 65 boost::posix_time::ptime ctime = now(); 66 execute(item); 67 reschedule(item,ctime); 90 91 boost::posix_time::ptime now_time = now(); 92 boost::optional<target> item = get_task((*instance).schedule_id); 93 if (item) { 94 try { 95 execute(*item); 96 reschedule(*item,now_time); 97 } catch (...) { 98 std::wcout << _T("UNKNOWN ERROR RUNING TASK: ") << std::endl; 99 reschedule(*item); 100 } 101 } else { 102 std::wcout << _T("Task not found: ") << (*instance).schedule_id << std::endl; 103 } 68 104 } 69 105 } 70 106 71 107 void simple_scheduler::reschedule(target item) { 72 reschedule (item, now());108 reschedule_wnext(item, now() + boost::posix_time::seconds(rand()%item.duration.total_seconds())); 73 109 } 74 110 void simple_scheduler::reschedule(target item, boost::posix_time::ptime now) { 75 boost::mutex::scoped_lock l(mutex_); 111 reschedule_wnext(item, now + item.duration); 112 } 113 void simple_scheduler::reschedule_wnext(target item, boost::posix_time::ptime next) { 76 114 schedule_instance instance; 77 115 instance.schedule_id = item.id; 78 instance.time = now + item.duration; 79 queue_.push(instance); 80 if (!thread_) 81 start_thread(); 116 instance.time = next; 117 if (!queue_.push(instance)) { 118 std::wcout << _T("ERROR") << std::endl; 119 } 120 start_thread(); 82 121 } 83 122 void simple_scheduler::execute(target item) { 84 std::wcout << _T("Running: ") << item.command << std::endl;123 //std::wcout << _T("Running: ") << item.command << std::endl; 85 124 } 86 87 125 88 126 } -
trunk/modules/Scheduler/simple_scheduler.hpp
r229 r230 8 8 #include <boost/thread.hpp> 9 9 #include <boost/date_time/local_time/local_time.hpp> 10 #include <boost/optional.hpp> 10 11 11 12 namespace scheduler { 12 13 14 class task_not_found { 15 int id_; 16 public: 17 task_not_found(int id) : id_(id) {} 18 int get_id() {return id_; } 19 }; 13 20 class target { 14 21 public: … … 18 25 std::wstring tag; 19 26 boost::posix_time::time_duration duration; 27 std::wstring channel; 28 //std::wstring duration; 20 29 21 target() {} 22 target(const target &other) : id(other.id), command(other.command), duration(other.duration) {} 30 31 void set_duration(boost::posix_time::time_duration duration_) { 32 duration = duration_; 33 // TODO! 34 } 35 36 target() : duration(boost::posix_time::minutes(0)) 37 {} 38 39 target(const target &other) : id(other.id), command(other.command), duration(other.duration) {} 23 40 target& operator=(target const& other) { 24 41 command = other.command; … … 27 44 return *this; 28 45 } 29 static target empty() { 30 return target(); 31 } 46 ~target() {} 32 47 }; 33 48 struct schedule_instance { … … 39 54 }; 40 55 56 template<typename T> 57 class safe_schedule_queue { 58 public: 59 typedef boost::optional<T> value_type; 60 private: 61 typedef std::priority_queue<T> schedule_queue_type; 62 schedule_queue_type queue_; 63 boost::shared_mutex mutex_; 64 public: 65 bool empty(unsigned int timeout = 5) { 66 boost::shared_lock<boost::shared_mutex> lock(mutex_, boost::get_system_time() + boost::posix_time::seconds(5)); 67 if (!lock.owns_lock()) 68 return false; 69 return queue_.empty(); 70 } 71 72 boost::optional<T> top(unsigned int timeout = 5) { 73 boost::shared_lock<boost::shared_mutex> lock(mutex_, boost::get_system_time() + boost::posix_time::seconds(5)); 74 if (!lock || queue_.empty()) 75 return boost::optional<T>(); 76 return boost::optional<T>(queue_.top()); 77 } 78 79 boost::optional<T> pop(unsigned int timeout = 5) { 80 boost::unique_lock<boost::shared_mutex> lock(mutex_, boost::get_system_time() + boost::posix_time::seconds(timeout)); 81 if (!lock || queue_.empty()) 82 return boost::optional<T>(); 83 boost::optional<T> ret = queue_.top(); 84 queue_.pop(); 85 return ret; 86 } 87 88 bool push(T instance, unsigned int timeout = 5) { 89 boost::unique_lock<boost::shared_mutex> lock(mutex_, boost::get_system_time() + boost::posix_time::seconds(timeout)); 90 if (!lock) { 91 return false; 92 } 93 queue_.push(instance); 94 return true; 95 } 96 }; 97 41 98 class simple_scheduler { 42 99 private: 43 100 typedef std::map<int,target> target_list_type; 44 typedef s td::priority_queue<schedule_instance> schedule_queue_type;101 typedef safe_schedule_queue<schedule_instance> schedule_queue_type; 45 102 target_list_type targets_; 46 103 unsigned int target_id_; 47 104 schedule_queue_type queue_; 105 unsigned int thread_count_; 48 106 49 107 50 108 // thread variables 51 109 volatile bool stop_requested_; 52 boost::shared_ptr<boost::thread> thread_; 110 volatile bool running_; 111 boost::thread_group threads_; 112 //boost::shared_ptr<boost::thread> thread_; 53 113 boost::mutex mutex_; 54 114 55 115 public: 56 116 57 simple_scheduler() : target_id_(0) {}117 simple_scheduler() : target_id_(0), stop_requested_(false), running_(false), thread_count_(10) {} 58 118 ~simple_scheduler() {} 59 119 … … 61 121 int add_task(target item); 62 122 void remove_task(int id); 63 targetget_task(int id);123 boost::optional<target> get_task(int id); 64 124 65 125 void start(); 66 126 void stop(); 127 128 void set_threads(int threads) { 129 thread_count_ = threads; 130 start_thread(); 131 } 67 132 68 133 … … 72 137 void reschedule(target item); 73 138 void reschedule(target item, boost::posix_time::ptime now); 139 void reschedule_wnext(target item, boost::posix_time::ptime next); 74 140 void execute(target item); 75 141 void start_thread(); 76 142 77 boost::posix_time::ptime now() {143 inline boost::posix_time::ptime now() { 78 144 return boost::get_system_time(); 79 145 } -
trunk/service/CMakeLists.txt
r219 r230 33 33 settings_manager_impl.h 34 34 simple_client.hpp 35 settings_client.hpp 35 36 36 37 commands.hpp -
trunk/service/NSCPlugin.cpp
r220 r230 253 253 void NSCPlugin::unload() { 254 254 if (!isLoaded()) 255 throw NSPluginException(module_, _T("Library is not loaded"));255 return; 256 256 bLoaded_ = false; 257 257 if (!fUnLoadModule) -
trunk/service/NSClient++.cpp
r224 r230 37 37 #include <NSCHelper.h> 38 38 #include "simple_client.hpp" 39 #include "settings_client.hpp" 39 40 #include "service_manager.hpp" 40 41 … … 396 397 client.start(); 397 398 return 0; 399 } else if ( _wcsicmp( _T("settings"), argv[1]+1 ) == 0 ) { 400 nsclient::settings_client client(&mainClient); 401 g_bConsoleLog = true; 402 if (argc > 2) 403 client.parse(argv[2], argc-3, argv+3); 404 else 405 client.help(); 406 return 0; 398 407 } else { 399 408 std::wcerr << _T("Usage: -version, -about, -install, -uninstall, -start, -stop, -encrypt -settings") << std::endl; … … 491 500 } else { 492 501 std::wstring desc; 502 std::wstring name = file.string(); 493 503 try { 494 504 NSCPlugin plugin(modPath / file); 505 name = plugin.getModule(); 495 506 plugin.load_dll(); 496 507 plugin.load_plugin(mode); … … 505 516 LOG_CRITICAL_STD(_T("Unknown Error loading: ") + file.string()); 506 517 } 507 settings_manager::get_core()->register_key(MAIN_MODULES_SECTION, file.string(), Settings::SettingsCore::key_string, desc, desc, _T("disabled"), false);518 settings_manager::get_core()->register_key(MAIN_MODULES_SECTION, name, Settings::SettingsCore::key_string, desc, desc, _T("disabled"), false); 508 519 } 509 520 } … … 643 654 644 655 if (enable_shared_session_) { 645 LOG_ MESSAGE_STD(_T("Enabling shared session..."));656 LOG_DEBUG_STD(_T("Enabling shared session...")); 646 657 if (boot) { 647 LOG_MESSAGE_STD(_T(" Starting shared session..."));658 LOG_MESSAGE_STD(_T("shared session not ported yet!...")); 648 659 // try { 649 660 // shared_server_.reset(new nsclient_session::shared_server_session(this)); … … 662 673 // } 663 674 } else { 664 LOG_MESSAGE_STD(_T(" Attaching to shared session..."));675 LOG_MESSAGE_STD(_T("shared session not ported yet!...")); 665 676 // try { 666 677 // std::wstring id = _T("_attached_") + strEx::itos(GetCurrentProcessId()) + _T("_"); … … 1018 1029 try { 1019 1030 if (!(*it)->load_plugin(NSCAPI::normalStart)) { 1031 LOG_ERROR_CORE_STD(_T("Plugin refused to load: ") + (*it)->getModule()); 1020 1032 it = plugins_.erase(it); 1021 LOG_ERROR_CORE_STD(_T("Plugin refused to load: ") + (*it)->getModule()); 1022 } 1023 ++it; 1033 } else 1034 ++it; 1024 1035 } catch (NSPluginException e) { 1025 1036 it = plugins_.erase(it); … … 1073 1084 if (plugin->hasMessageHandler()) 1074 1085 messageHandlers_.insert(messageHandlers_.end(), plugin); 1075 settings_manager::get_core()->register_key(_T("/modules"), plugin->get Filename(), Settings::SettingsCore::key_string, plugin->getName(), plugin->getDescription(), _T(""), false);1086 settings_manager::get_core()->register_key(_T("/modules"), plugin->getModule(), Settings::SettingsCore::key_string, plugin->getName(), plugin->getDescription(), _T(""), false); 1076 1087 } 1077 1088 return plugin; … … 1246 1257 #ifdef WIN32 1247 1258 OutputDebugString(msg.c_str()); 1259 #else 1260 std::wcout << _T("--BROKEN MESSAGE: ") << msg << _T("--") << std::endl; 1248 1261 #endif 1249 std::wcout << msg << std::endl;1250 1262 } 1251 1263 /** -
trunk/service/NSClient++.h
r220 r230 201 201 202 202 203 204 private: 205 plugin_type addPlugin(plugin_type plugin); 206 void load_all_plugins(int mode); 203 public: 204 void load_all_plugins(int mode); 205 206 207 private: 208 plugin_type addPlugin(plugin_type plugin); 207 209 }; 208 210
Note: See TracChangeset
for help on using the changeset viewer.







