Changeset 440c0cb in nscp
- Timestamp:
- 04/05/12 07:16:26 (14 months ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- 682ccd2
- Parents:
- acc2c60
- Files:
-
- 24 edited
-
changelog (modified) (1 diff)
-
helpers/installer-dlls/main_dll/main_dll.cpp (modified) (1 diff)
-
helpers/installers/installer/Product.wxs (modified) (2 diffs)
-
include/NSCAPI.h (modified) (1 diff)
-
include/nscapi/nscapi_core_wrapper.cpp (modified) (1 diff)
-
include/nscapi/nscapi_helper.cpp (modified) (3 diffs)
-
include/nscapi/nscapi_protobuf_functions.hpp (modified) (1 diff)
-
include/nscapi/settings_proxy.hpp (modified) (1 diff)
-
include/nsclient/base_logger_impl.cpp (modified) (2 diffs)
-
include/nsclient/base_logger_impl.hpp (modified) (1 diff)
-
include/nsclient/logger.hpp (modified) (1 diff)
-
modules/CheckEventLog/CheckEventLog.cpp (modified) (1 diff)
-
modules/CheckEventLog/CheckEventLog.h (modified) (1 diff)
-
modules/NRPEServer/handler_impl.cpp (modified) (1 diff)
-
modules/NSCPServer/CMakeLists.txt (modified) (1 diff)
-
modules/NSClientServer/CMakeLists.txt (modified) (1 diff)
-
modules/NSClientServer/NSClientServer.cpp (modified) (1 diff)
-
service/NSClient++.cpp (modified) (3 diffs)
-
service/NSClient++.h (modified) (1 diff)
-
service/cli_parser.hpp (modified) (8 diffs)
-
service/logger_impl.cpp (modified) (2 diffs)
-
service/settings_client.hpp (modified) (1 diff)
-
version.hpp (modified) (1 diff)
-
version.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
changelog
r8d89d7a r440c0cb 5 5 * Fix RtlStringFromGUID problem on NT4 6 6 7 2012-04-04 MickeM 8 * Fixed issue with empty filters in active eventlog 9 10 2012-04-04 MickeM 11 * Resolved some issues with loggingin default set to debug. 12 * Fixed so --debug actually works 13 * Added --log-to-file and set "nscp test" to not log to file. 14 * Fixed typo related to allow arguments option 15 * Added levels to comment for log level in config. 7 16 8 17 2012-04-01 MickeM -
helpers/installer-dlls/main_dll/main_dll.cpp
r8d89d7a r440c0cb 33 33 34 34 std::string nsclient::logging::logger_helper::create(NSCAPI::log_level::level level, const char* file, const int line, std::wstring message) { 35 if (level < NSCAPI::log_level:: log)35 if (level < NSCAPI::log_level::info) 36 36 return "E" + utf8::cvt<std::string>(message); 37 37 return "I" + utf8::cvt<std::string>(message); -
helpers/installers/installer/Product.wxs
r8d89d7a r440c0cb 121 121 <File Id="NSCAServerDLL" Name="NSCAServer.dll" DiskId="1" Source="$(var.Source)/modules/NSCAServer.dll" Vital="no" /> 122 122 <File Id="SchedulerDLL" Name="Scheduler.dll" DiskId="1" Source="$(var.Source)/modules/Scheduler.dll" Vital="no" /> 123 </Component>124 <Component Id="NSCP" Guid="B185B8F1-3718-4e8e-ADA4-38049A0721EA" Win64="$(var.Win64)">125 <File Id="NSCPClientDLL" Name="NSCPClient.dll" DiskId="1" Source="$(var.Source)/modules/NSCPClient.dll" Vital="no" />126 <File Id="NSCPServerDLL" Name="NSCPServer.dll" DiskId="1" Source="$(var.Source)/modules/NSCPServer.dll" Vital="no" />127 123 </Component> 128 124 <Component Id="PythonScript" Guid="49C2120D-634D-48ef-B82E-F2E9B219A768" Win64="$(var.Win64)"> … … 268 264 <ComponentRef Id="ExtraClients" /> 269 265 </Feature> 270 <Feature Id="NSCPPlugin" Title="NSCP plugin (experimental)" Description="Plugin to submit passive results to an NSCP server" Level="1" Absent="disallow">271 <ComponentRef Id="NSCP" />272 </Feature>273 266 <Feature Id="PythonScript" Title="Python Scripting" Description="Python scripting requires python to be installed)" Level="1" Absent="disallow"> 274 267 <ComponentRef Id="PythonScript" /> -
include/NSCAPI.h
r8d89d7a r440c0cb 101 101 const int error = 10; // Error 102 102 const int warning = 50; // Warning <<< Default for command line interface 103 const int log = 100; // Log message <<< Default for service103 //const int log = 100; // Log message <<< Default for service 104 104 const int info = 150; // information 105 105 const int debug = 500; // Debug messages <<< Default for test -
include/nscapi/nscapi_core_wrapper.cpp
ree52cdd r440c0cb 41 41 bool nscapi::core_wrapper::should_log(NSCAPI::nagiosReturn msgType) { 42 42 enum log_status {unknown, set }; 43 static NSCAPI::log_level::level level = NSCAPI::log_level:: log;43 static NSCAPI::log_level::level level = NSCAPI::log_level::info; 44 44 static log_status status = unknown; 45 45 if (status == unknown) { -
include/nscapi/nscapi_helper.cpp
r8d89d7a r440c0cb 90 90 PARSE_LOGLEVEL_BEGIN() 91 91 PARSE_LOGLEVEL("all", NSCAPI::log_level::trace) 92 PARSE_LOGLEVEL("normal", NSCAPI::log_level::info)93 PARSE_LOGLEVEL("service", NSCAPI::log_level::log)94 PARSE_LOGLEVEL("log", NSCAPI::log_level::log)95 PARSE_LOGLEVEL("message", NSCAPI::log_level::info)96 92 PARSE_LOGLEVEL("error", NSCAPI::log_level::error) 97 93 PARSE_LOGLEVEL("critical", NSCAPI::log_level::critical) … … 115 111 RENDER_LOGLEVEL_BEGIN() 116 112 RENDER_LOGLEVEL("all", NSCAPI::log_level::trace) 117 RENDER_LOGLEVEL("normal", NSCAPI::log_level::info)118 RENDER_LOGLEVEL("log", NSCAPI::log_level::log)119 RENDER_LOGLEVEL("message", NSCAPI::log_level::info)120 113 RENDER_LOGLEVEL("error", NSCAPI::log_level::error) 121 114 RENDER_LOGLEVEL("critical", NSCAPI::log_level::critical) … … 182 175 case NSCAPI::log_level::warning: 183 176 return _T("warning"); 184 case NSCAPI::log_level::log: 185 return _T("message"); 177 case NSCAPI::log_level::info: 178 return _T("info"); 179 case NSCAPI::log_level::trace: 180 return _T("trace"); 186 181 case NSCAPI::log_level::debug: 187 182 return _T("debug"); -
include/nscapi/nscapi_protobuf_functions.hpp
r83c2453 r440c0cb 85 85 if (ret == NSCAPI::log_level::error) 86 86 return Plugin::LogEntry_Entry_Level_LOG_ERROR; 87 if (ret == NSCAPI::log_level::log)88 return Plugin::LogEntry_Entry_Level_LOG_INFO;89 87 if (ret == NSCAPI::log_level::info) 90 88 return Plugin::LogEntry_Entry_Level_LOG_INFO; -
include/nscapi/settings_proxy.hpp
r8d89d7a r440c0cb 58 58 } 59 59 virtual void info(const char* file, int line, std::wstring message) { 60 core_->log(NSCAPI::log_level:: log, file, line, message);60 core_->log(NSCAPI::log_level::info, file, line, message); 61 61 } 62 62 virtual void debug(const char* file, int line, std::wstring message) { -
include/nsclient/base_logger_impl.cpp
r8d89d7a r440c0cb 11 11 case NSCAPI::log_level::error: 12 12 return _T("e"); 13 case NSCAPI::log_level::log:14 return _T("l");15 13 case NSCAPI::log_level::info: 16 14 return _T("l"); … … 30 28 case NSCAPI::log_level::warning: 31 29 return _T("warning"); 32 case NSCAPI::log_level::log:33 return _T("message");34 30 case NSCAPI::log_level::info: 35 31 return _T("message"); -
include/nsclient/base_logger_impl.hpp
r8d89d7a r440c0cb 17 17 bool console_log_; 18 18 public: 19 logging_interface_impl() : level_(NSCAPI::log_level:: trace), console_log_(false) {}19 logging_interface_impl() : level_(NSCAPI::log_level::info), console_log_(false) {} 20 20 21 21 -
include/nsclient/logger.hpp
r8d89d7a r440c0cb 41 41 static void set_log_level(std::wstring level); 42 42 43 static void set_backend(std::string backend); 44 static void destroy(); 45 43 46 }; 44 47 } -
modules/CheckEventLog/CheckEventLog.cpp
r83c2453 r440c0cb 332 332 c.filter = key; 333 333 filters_.push_back(c); 334 } else if (key.empty() && query.empty()) { 335 return; 334 336 } else { 335 337 c.alias = key; -
modules/CheckEventLog/CheckEventLog.h
r822454f r440c0cb 87 87 void set_language(std::string lang); 88 88 void set_filter(std::wstring flt) { 89 add_realtime_filter(_T("filter"), flt); 89 if (!flt.empty()) 90 add_realtime_filter(_T("filter"), flt); 90 91 } 91 92 bool has_filters() { -
modules/NRPEServer/handler_impl.cpp
ree52cdd r440c0cb 15 15 if (!allowArgs_) { 16 16 if (!cmd.second.empty()) { 17 NSC_LOG_ERROR(_T("Request contained arguments (not currently allowed, check the allow _arguments option)."));18 throw nrpe::nrpe_exception(_T("Request contained arguments (not currently allowed, check the allow _arguments option)."));17 NSC_LOG_ERROR(_T("Request contained arguments (not currently allowed, check the allow arguments option).")); 18 throw nrpe::nrpe_exception(_T("Request contained arguments (not currently allowed, check the allow arguments option).")); 19 19 } 20 20 } -
modules/NSCPServer/CMakeLists.txt
r8d89d7a r440c0cb 24 24 25 25 ADD_DEFINITIONS(${NSCP_GLOBAL_DEFINES}) 26 IF(OPENSSL_FOUND) 27 ADD_DEFINITIONS(-DUSE_SSL) 28 ENDIF(OPENSSL_FOUND) 26 29 27 30 IF(WIN32) -
modules/NSClientServer/CMakeLists.txt
r8d89d7a r440c0cb 23 23 24 24 ADD_DEFINITIONS(${NSCP_GLOBAL_DEFINES}) 25 IF(OPENSSL_FOUND) 26 ADD_DEFINITIONS(-DUSE_SSL) 27 ENDIF(OPENSSL_FOUND) 25 28 26 29 IF(WIN32) -
modules/NSClientServer/NSClientServer.cpp
r84cdb9b r440c0cb 78 78 _T("TIMEOUT"), _T("Timeout when reading packets on incoming sockets. If the data has not arrived within this time we will bail out.")) 79 79 80 (_T("use ssl"), sh::bool_key(&info_.use_ssl, true),80 (_T("use ssl"), sh::bool_key(&info_.use_ssl, false), 81 81 _T("ENABLE SSL ENCRYPTION"), _T("This option controls if SSL should be enabled.")) 82 82 -
service/NSClient++.cpp
r8d89d7a r440c0cb 334 334 addPlugin(pluginPath / v.second, v.first); 335 335 } catch (const NSPluginException &e) { 336 LOG_CRITICAL_CORE_STD(_T("Failed to register plugin: ") + e.wwhat()); 336 if (e.file_.find(_T("FileLogger")) != std::wstring::npos) { 337 LOG_DEBUG_CORE_STD(_T("Failed to register plugin: ") + e.wwhat()); 338 } else { 339 LOG_ERROR_CORE(_T("Failed to register plugin: ") + e.wwhat()); 340 } 337 341 } catch (...) { 338 342 LOG_CRITICAL_CORE_STD(_T("Failed to register plugin key: ") + v.second); … … 402 406 settings.add_key_to_settings(_T("log")) 403 407 (_T("level"), sh::wstring_key(&log_level, _T("info")), 404 _T("LOG LEVEL"), _T("Log level to use "))408 _T("LOG LEVEL"), _T("Log level to use. Avalible levels are error,warning,info,debug,trace")) 405 409 ; 406 410 … … 542 546 addPlugin(pluginPath / boost::filesystem::wpath(file), alias); 543 547 } catch(const NSPluginException& e) { 544 LOG_ERROR_CORE_STD(_T("Exception raised: '") + e.error_ + _T("' in module: ") + e.file_); 548 if (e.file_.find(_T("FileLogger")) != std::wstring::npos) { 549 LOG_DEBUG_CORE_STD(_T("Exception raised: '") + e.error_ + _T("' in module: ") + e.file_); 550 } else { 551 LOG_ERROR_CORE_STD(_T("Exception raised: '") + e.error_ + _T("' in module: ") + e.file_); 552 } 545 553 } catch (std::exception e) { 546 554 LOG_ERROR_CORE_STD(_T("exception loading plugin: ") + file + strEx::string_to_wstring(e.what())); -
service/NSClient++.h
r8d89d7a r440c0cb 177 177 std::wstring getFolder(std::wstring key); 178 178 std::wstring expand_path(std::wstring file); 179 void set_console_log() {180 nsclient::logging::logger::get_logger()->set_console_log(true);181 }182 179 183 180 typedef boost::function<int(plugin_type)> run_function; -
service/cli_parser.hpp
r8d89d7a r440c0cb 16 16 po::options_description common; 17 17 po::options_description unittest; 18 po::options_description test; 18 19 19 20 bool help; … … 21 22 std::wstring log_level; 22 23 std::wstring settings_store; 24 bool log_debug; 23 25 24 26 static nsclient::logging::logger_interface* get_logger() { … … 34 36 , service("Service Options") 35 37 , client("Client Options") 36 , unittest("Unittest Options") 38 , unittest("Unit-test Options") 39 , test("Test Options") 37 40 , help(false) 38 41 , version(false) 42 , log_debug(false) 39 43 { 40 44 root.add_options() … … 42 46 ("version", po::bool_switch(&version), "Show version information") 43 47 ; 48 44 49 common.add_options() 45 50 ("settings", po::value<std::wstring>(&settings_store), "Override (temporarily) settings subsystem to use") 46 51 ("help", po::bool_switch(&help), "produce help message") 47 ("debug", "Set log level to debug (and show debug information)")52 ("debug", po::bool_switch(&log_debug), "Set log level to debug (and show debug information)") 48 53 ("log", po::value<std::wstring>(&log_level), "The log level to use") 49 54 ("version", po::bool_switch(&version), "Show version information") … … 84 89 ("raw-argument", po::wvalue<std::vector<std::wstring> >(), "List of arguments (does not get -- prefixed)") 85 90 ; 91 86 92 unittest.add_options() 87 93 ("language,l", po::value<std::wstring>()->implicit_value(_T("")), "Language tests are written in") … … 90 96 ; 91 97 98 test.add_options() 99 ("log-to-file", "Enable file logger (defaults is console only)") 100 ; 101 92 102 } 93 103 94 104 bool process_common_options(std::string context, po::options_description &desc) { 95 core_->set_console_log(); 105 nsclient::logging::logger::get_logger()->set_console_log(true); 106 if (log_debug) { 107 log_level = _T("debug"); 108 } 96 109 if (!log_level.empty()) 97 110 nsclient::logging::logger::set_log_level(log_level); … … 191 204 192 205 int parse_test(int argc, wchar_t* argv[]) { 193 bool server = false; 206 207 po::options_description all("Allowed options (test)"); 208 all.add(common).add(test); 209 210 po::variables_map vm; 211 po::store(po::parse_command_line(argc, argv, all), vm); 212 po::notify(vm); 213 194 214 if (log_level.empty()) 195 215 log_level = _T("debug"); 196 216 197 core_->set_console_log(); 217 if (process_common_options("test", all)) 218 return 1; 219 220 if (vm.count("log-to-file") == 0) { 221 nsclient::logging::logger::set_backend("console"); 222 } 223 198 224 try { 199 225 po::options_description all("Allowed options (settings)"); … … 300 326 } 301 327 if (nsclient::logging::logger::get_logger()->should_log(NSCAPI::log_level::debug)) { 302 get_logger()-> info(__FILE__, __LINE__, _T("Service name: ") + name);303 get_logger()-> info(__FILE__, __LINE__, _T("Service description: ") + desc);328 get_logger()->debug(__FILE__, __LINE__, _T("Service name: ") + name); 329 get_logger()->debug(__FILE__, __LINE__, _T("Service description: ") + desc); 304 330 } 305 331 -
service/logger_impl.cpp
racc2c60 r440c0cb 212 212 213 213 214 class simple_console_logger : public nsclient::logging::logging_interface_impl { 215 std::string format_; 216 public: 217 simple_console_logger() : format_("%Y-%m-%d %H:%M:%S") { 218 } 219 220 void do_log(const std::string &data) { 221 if (get_console_log()) { 222 std::wcout << render_console_message(data) << std::endl; 223 } 224 } 225 void configure() { 226 try { 227 std::wstring file; 228 229 sh::settings_registry settings(settings_manager::get_proxy()); 230 settings.set_alias(_T("log/file")); 231 232 settings.add_path_to_settings() 233 (_T("log"),_T("LOG SECTION"), _T("Configure log properties.")) 234 ; 235 236 settings.add_key_to_settings(_T("log")) 237 (_T("date format"), sh::string_key(&format_, "%Y-%m-%d %H:%M:%S"), 238 _T("DATEMASK"), _T("The size of the buffer to use when getting messages this affects the speed and maximum size of messages you can recieve.")) 239 240 ; 241 242 settings.register_all(); 243 settings.notify(); 244 245 } catch (nscapi::nscapi_exception &e) { 246 log_fatal(std::string("Failed to register command: ") + e.what()); 247 } catch (std::exception &e) { 248 log_fatal(std::string("Exception caught: ") + e.what()); 249 } catch (...) { 250 log_fatal("Failed to register command."); 251 } 252 } 253 bool startup() { return true; } 254 bool shutdown() { return true; } 255 }; 256 257 214 258 215 259 … … 283 327 }; 284 328 285 static nsclient::logging::logging_interface_impl *impl = NULL; 286 329 static nsclient::logging::logging_interface_impl *logger_impl_ = NULL; 330 331 #define CONSOLE_BACKEND "console" 332 #define THREADED_FILE_BACKEND "threaded-file" 333 #define FILE_BACKEND "file" 334 335 336 void nsclient::logging::logger::set_backend(std::string backend) { 337 nsclient::logging::logging_interface_impl *tmp = NULL; 338 if (backend == CONSOLE_BACKEND) { 339 tmp = new simple_console_logger(); 340 } else if (backend == THREADED_FILE_BACKEND) { 341 tmp = new threaded_logger(log_impl_type(new simple_file_logger("nsclient.log"))); 342 } else if (backend == FILE_BACKEND) { 343 tmp = new simple_file_logger("nsclient.log"); 344 } else { 345 tmp = new simple_console_logger(); 346 } 347 nsclient::logging::logging_interface_impl *old = logger_impl_ ; 348 logger_impl_ = tmp; 349 delete old; 350 old = NULL; 351 } 352 353 354 #define DEFAULT_BACKEND THREADED_FILE_BACKEND 287 355 nsclient::logging::logging_interface_impl* get_impl() { 288 if (impl == NULL) 289 impl = new threaded_logger(log_impl_type(new simple_file_logger("nsclient.log"))); 290 return impl; 356 if (logger_impl_ == NULL) 357 nsclient::logging::logger::set_backend(DEFAULT_BACKEND); 358 return logger_impl_ ; 359 } 360 void nsclient::logging::logger::destroy() { 361 nsclient::logging::logging_interface_impl* old = logger_impl_; 362 logger_impl_ = NULL; 363 delete old; 291 364 } 292 365 -
service/settings_client.hpp
r8d89d7a r440c0cb 20 20 21 21 void boot(std::wstring log) { 22 core_->set_console_log();23 22 if (!current_.empty()) 24 23 core_->set_settings_context(current_); -
version.hpp
racc2c60 r440c0cb 1 1 #ifndef VERSION_HPP 2 2 #define VERSION_HPP 3 #define PRODUCTVER 0,4,0,15 34 #define STRPRODUCTVER "0,4,0,15 3"5 #define STRPRODUCTDATE "2012-04-0 2"3 #define PRODUCTVER 0,4,0,156 4 #define STRPRODUCTVER "0,4,0,156" 5 #define STRPRODUCTDATE "2012-04-05" 6 6 #endif // VERSION_HPP -
version.txt
r8d89d7a r440c0cb 1 1 version=0.4.0 2 build=15 33 date=2012-04-0 22 build=156 3 date=2012-04-05
Note: See TracChangeset
for help on using the changeset viewer.








