Changeset 3080680 in nscp
- Timestamp:
- 01/31/10 22:54:36 (3 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- c0d7e82
- Parents:
- dad34ea
- Files:
-
- 1 added
- 19 edited
-
build.cmake (modified) (1 diff)
-
cmake/NSCPPBuffer.cmake (modified) (1 diff)
-
include/service/win32_service.hpp (modified) (1 diff)
-
include/settings/Settings.h (modified) (12 diffs)
-
include/settings/macros.h (modified) (1 diff)
-
include/settings/settings_ini.hpp (modified) (1 diff)
-
include/settings/settings_old.hpp (modified) (1 diff)
-
include/settings/settings_registry.hpp (modified) (1 diff)
-
include/simpleini/simpleini.h (modified) (3 diffs)
-
modules/CheckExternalScripts/CMakeLists.txt (added)
-
modules/CheckExternalScripts/CheckExternalScripts.cpp (modified) (2 diffs)
-
modules/CheckExternalScripts/CheckExternalScripts.def (modified) (1 diff)
-
modules/CheckExternalScripts/CheckExternalScripts.h (modified) (2 diffs)
-
modules/CheckHelpers/CMakeLists.txt (modified) (2 diffs)
-
modules/NRPEClient/CMakeLists.txt (modified) (2 diffs)
-
modules/NRPEServer/CMakeLists.txt (modified) (2 diffs)
-
modules/NRPEServer/NRPEServer.def (modified) (1 diff)
-
modules/Scheduler/CMakeLists.txt (modified) (2 diffs)
-
service/NSCPlugin.cpp (modified) (1 diff)
-
service/NSClient++.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
build.cmake
r2018659 r3080680 13 13 SET(CMAKE_LIBRARY_PATH c:/src/lib/x86/) 14 14 15 SET(PROTOBUF_INCLUDE_DIR d:/source/protobuf-2.3.0/src)16 SET(PROTOBUF_LIBRARYDIR d:/source/protobuf-2.3.0/vsprojects/Debug)17 SET(PROTOBUF_BINARYDIR d:/source/protobuf-2.3.0/vsprojects/Debug)15 SET(PROTOBUF_INCLUDE_DIR C:/src/protobuf-2.3.0/src) 16 SET(PROTOBUF_LIBRARYDIR C:/src/protobuf-2.3.0/vsprojects/Debug) 17 SET(PROTOBUF_BINARYDIR C:/src/protobuf-2.3.0/vsprojects/Debug) 18 18 -
cmake/NSCPPBuffer.cmake
r920626f r3080680 32 32 ) 33 33 34 FIND_LIBRARY(PROTOBUF_LIBRARY NAMES protobuf 34 FIND_LIBRARY(PROTOBUF_LIBRARY NAMES protobuf libprotobuf 35 35 PATHS 36 36 ${GNUWIN32_DIR}/lib -
include/service/win32_service.hpp
r858ecc1 r3080680 185 185 handle_error(__LINE__, __FILEW__, _T("Unknown service error!")); 186 186 } 187 return 0; 187 188 } 188 189 static void WINAPI service_main_dispatch(DWORD dwArgc, LPTSTR *lpszArgv) { -
include/settings/Settings.h
r753ea6d r3080680 25 25 #include <string> 26 26 #include <map> 27 #include <set> 27 28 #include <boost/thread/thread.hpp> 28 29 #include <boost/thread/locks.hpp> … … 127 128 key_description() : advanced(false), type(SettingsCore::key_string) {} 128 129 }; 130 struct path_description { 131 std::wstring title; 132 std::wstring description; 133 bool advanced; 134 typedef std::map<std::wstring,key_description> keys_type; 135 keys_type keys; 136 path_description(std::wstring title_, std::wstring description_, bool advanced_) : title(title_), description(description_), advanced(advanced_) {} 137 path_description() : advanced(false) {} 138 void update(std::wstring title_, std::wstring description_, bool advanced_) { 139 title = title_; 140 description = description_; 141 advanced = advanced_; 142 } 143 }; 144 129 145 struct mapped_key { 130 146 mapped_key(key_path_type src_, key_path_type dst_) : src(src_), dst(dst_) {} … … 279 295 virtual key_description get_registred_key(std::wstring path, std::wstring key) = 0; 280 296 297 virtual SettingsCore::path_description get_registred_path(std::wstring path) = 0; 281 298 282 299 ////////////////////////////////////////////////////////////////////////// … … 550 567 virtual bool has_key(std::wstring path, std::wstring key) = 0; 551 568 569 virtual void add_path(std::wstring path) = 0; 552 570 // Misc Functions 553 571 ////////////////////////////////////////////////////////////////////////// … … 632 650 }; 633 651 */ 634 struct path_description {635 std::wstring title;636 std::wstring description;637 bool advanced;638 typedef std::map<std::wstring,key_description> keys_type;639 keys_type keys;640 path_description(std::wstring title_, std::wstring description_, bool advanced_) : title(title_), description(description_), advanced(advanced_) {}641 path_description() : advanced(false) {}642 void update(std::wstring title_, std::wstring description_, bool advanced_) {643 title = title_;644 description = description_;645 advanced = advanced_;646 }647 };648 652 class dummy_logger : public LoggerInterface { 649 653 void err(std::wstring file, int line, std::wstring message) {} … … 657 661 boost::filesystem::wpath base_path_; 658 662 LoggerInterface *logger_; 659 typedef std::map<std::wstring, path_description> reg_paths_type;663 typedef std::map<std::wstring,SettingsCore::path_description> reg_paths_type; 660 664 reg_paths_type registred_paths_; 661 665 typedef std::map<key_path_type,key_path_type> mapped_paths_type; … … 739 743 void update_defaults() { 740 744 get_logger()->warn(__FILEW__, __LINE__, _T("Updating settings with default values!")); 741 string_list s = get_reg_sections(); 742 for (string_list::const_iterator cit = s.begin(); cit != s.end(); ++cit) { 743 string_list k = get_reg_keys(*cit); 744 for (string_list::const_iterator citk = k.begin(); citk != k.end(); ++citk) { 745 SettingsCore::key_description desc = get_registred_key(*cit, *citk); 745 BOOST_FOREACH(std::wstring path, get_reg_sections()) { 746 get()->add_path(path); 747 BOOST_FOREACH(std::wstring key, get_reg_keys(path)) { 748 SettingsCore::key_description desc = get_registred_key(path, key); 746 749 if (!desc.advanced) { 747 if (!get()->has_key( *cit, *citk)) {748 get_logger()->debug(__FILEW__, __LINE__, _T("Adding: ") + *cit + _T(".") + *citk);750 if (!get()->has_key(path, key)) { 751 get_logger()->debug(__FILEW__, __LINE__, _T("Adding: ") + path + _T(".") + key); 749 752 if (desc.type == key_string) 750 get()->set_string( *cit, *citk, desc.defValue);753 get()->set_string(path, key, desc.defValue); 751 754 else if (desc.type == key_bool) 752 get()->set_bool( *cit, *citk, desc.defValue==_T("true"));755 get()->set_bool(path, key, desc.defValue==_T("true")); 753 756 else if (desc.type == key_integer) 754 get()->set_int( *cit, *citk, strEx::stoi(desc.defValue));757 get()->set_int(path, key, strEx::stoi(desc.defValue)); 755 758 else 756 get_logger()->err(__FILEW__, __LINE__, _T("Unknown keytype for: ") + *cit + _T(".") + *citk);759 get_logger()->err(__FILEW__, __LINE__, _T("Unknown keytype for: ") + path + _T(".") + key); 757 760 } else { 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);761 std::wstring val = get()->get_string(path, key); 762 get_logger()->debug(__FILEW__, __LINE__, _T("Setting old (already exists): ") + path + _T(".") + key + _T(" = ") + val); 760 763 if (desc.type == key_string) 761 get()->set_string( *cit, *citk, val);764 get()->set_string(path, key, val); 762 765 else if (desc.type == key_bool) 763 get()->set_bool( *cit, *citk, val==_T("true"));766 get()->set_bool(path, key, val==_T("true")); 764 767 else if (desc.type == key_integer) 765 get()->set_int( *cit, *citk, strEx::stoi(val));768 get()->set_int(path, key, strEx::stoi(val)); 766 769 else 767 get_logger()->err(__FILEW__, __LINE__, _T("Unknown keytype for: ") + *cit + _T(".") + *citk);770 get_logger()->err(__FILEW__, __LINE__, _T("Unknown keytype for: ") + path + _T(".") + key); 768 771 } 769 772 } else { 770 get_logger()->debug(__FILEW__, __LINE__, _T("Skipping (advanced): ") + *cit + _T(".") + *citk);773 get_logger()->debug(__FILEW__, __LINE__, _T("Skipping (advanced): ") + path + _T(".") + key); 771 774 } 772 775 } … … 1126 1129 throw KeyNotFoundException(path, key); 1127 1130 } 1131 SettingsCore::path_description get_registred_path(std::wstring path) { 1132 reg_paths_type::const_iterator cit = registred_paths_.find(path); 1133 if (cit != registred_paths_.end()) { 1134 return (*cit).second; 1135 } 1136 throw KeyNotFoundException(path); 1137 } 1128 1138 1129 1139 … … 1282 1292 typedef SettingsCore::key_path_type cache_key_type; 1283 1293 typedef std::map<cache_key_type,conainer> cache_type; 1294 typedef std::set<std::wstring> path_cache_type; 1284 1295 cache_type settings_cache_; 1296 path_cache_type path_cache_; 1285 1297 std::wstring context_; 1286 1298 … … 1376 1388 virtual void set_string(std::wstring path, std::wstring key, std::wstring value) { 1377 1389 settings_cache_[cache_key_type(path,key)] = value; 1390 } 1391 1392 virtual void add_path(std::wstring path) { 1393 path_cache_.insert(path); 1378 1394 } 1379 1395 … … 1668 1684 /// @author mickem 1669 1685 virtual void save() { 1686 BOOST_FOREACH(std::wstring path, path_cache_) { 1687 set_real_path(path); 1688 } 1689 std::set<std::wstring> sections; 1670 1690 for (cache_type::const_iterator cit = settings_cache_.begin(); cit != settings_cache_.end(); ++cit) { 1671 1691 set_real_value((*cit).first, (*cit).second); 1692 sections.insert((*cit).first.first); 1693 } 1694 BOOST_FOREACH(std::wstring str, get_core()->get_reg_sections()) { 1695 set_real_path(str); 1672 1696 } 1673 1697 } … … 1757 1781 /// @author mickem 1758 1782 virtual void set_real_value(SettingsCore::key_path_type key, conainer value) = 0; 1783 1784 ////////////////////////////////////////////////////////////////////////// 1785 /// Write a value to the resulting context. 1786 /// 1787 /// @param key The key to write to 1788 /// @param value The value to write 1789 /// 1790 /// @author mickem 1791 virtual void set_real_path(std::wstring path) = 0; 1759 1792 1760 1793 ////////////////////////////////////////////////////////////////////////// -
include/settings/macros.h
r753ea6d r3080680 251 251 DEFINE_PATH(ALIAS_SECTION, EXTSCRIPT_ALIAS_SECTION); 252 252 DESCRIBE_SETTING(ALIAS_SECTION, "EXTERNAL SCRIPT ALIAS SECTION", "Works like the \"inject\" concept of NRPE scripts module. But in short a list of aliases available. An alias is an internal command that has been \"wrapped\" (to add arguments). Be careful so you don't create loops (ie check_loop=check_a, check_a=check_loop)"); 253 253 254 } 254 255 -
include/settings/settings_ini.hpp
r753ea6d r3080680 126 126 } 127 127 } 128 129 virtual void set_real_path(std::wstring path) { 130 try { 131 get_core()->get_logger()->quick_debug(_T("Setting path: ") + path); 132 const SettingsCore::path_description desc = get_core()->get_registred_path(path); 133 if (!desc.description.empty()) { 134 std::wstring comment = _T("; ") + desc.description; 135 ini.SetValue(path.c_str(), NULL, NULL, comment.c_str()); 136 } 137 } catch (KeyNotFoundException e) { 138 ini.SetValue(path.c_str(), NULL, NULL, _T("; Undocumented section")); 139 } catch (SettingsException e) { 140 get_core()->get_logger()->err(__FILEW__, __LINE__, std::wstring(_T("Failed to write section: ") + e.getError())); 141 } catch (...) { 142 get_core()->get_logger()->err(__FILEW__, __LINE__, std::wstring(_T("Unknown filure when writing section: ") + path)); 143 } 144 } 145 128 146 ////////////////////////////////////////////////////////////////////////// 129 147 /// Get all (sub) sections (given a path). -
include/settings/settings_old.hpp
rd05c3f0 r3080680 298 298 } 299 299 } 300 301 virtual void set_real_path(std::wstring path) { 302 // NOT Supported (and not needed) so silently ignored! 303 } 304 300 305 ////////////////////////////////////////////////////////////////////////// 301 306 /// Get all (sub) sections (given a path). -
include/settings/settings_registry.hpp
r7f9c823 r3080680 123 123 } 124 124 } 125 virtual void set_real_path(std::wstring path) { 126 // NOT Supported (and not needed) so silently ignored! 127 } 128 125 129 ////////////////////////////////////////////////////////////////////////// 126 130 /// Get all (sub) sections (given a path). -
include/simpleini/simpleini.h
r3eedfa6 r3080680 1716 1716 iSection = i.first; 1717 1717 bInserted = true; 1718 } 1718 } else if (a_pComment && (!a_pKey || !a_pValue)) { 1719 Entry oKey(iSection->first.pItem, iSection->first.nOrder); 1720 oKey.pComment = a_pComment; 1721 1722 typename TSection::value_type oEntry(oKey, iSection->second); 1723 typedef typename TSection::iterator SectionIterator; 1724 m_data.erase(iSection); 1725 std::pair<SectionIterator,bool> i = m_data.insert(oEntry); 1726 1727 1728 iSection = i.first; 1729 } 1719 1730 if (!a_pKey || !a_pValue) { 1720 1731 // section only entries are specified with pItem and pVal as NULL … … 2019 2030 a_oOutput.Write(SI_NEWLINE_A); 2020 2031 bNeedNewLine = false; 2021 }2032 } 2022 2033 2023 2034 if (bNeedNewLine) { … … 2074 2085 return SI_FAIL; 2075 2086 } 2087 a_oOutput.Write("="); 2076 2088 if (iValue->pItem != NULL && !IsEmpty(iValue->pItem)) { 2077 a_oOutput.Write("=");2078 2089 if (m_bAllowMultiLine && IsMultiLineData(iValue->pItem)) { 2079 2090 // multi-line data needs to be processed specially to ensure -
modules/CheckExternalScripts/CheckExternalScripts.cpp
r79e734f r3080680 124 124 125 125 126 NSCAPI::nagiosReturn CheckExternalScripts::handleCommand(const st rEx::blindstr command, const unsigned int argLen, TCHAR **char_args, std::wstring &message, std::wstring &perf) {126 NSCAPI::nagiosReturn CheckExternalScripts::handleCommand(const std::wstring command, std::list<std::wstring> arguments, std::wstring &message, std::wstring &perf) { 127 127 std::wstring cmd = command.c_str(); 128 128 boost::to_lower(cmd); … … 139 139 std::wstring args = cd.arguments; 140 140 if (isAlias || allowArgs_) { 141 arrayBuffer::arrayList arr = arrayBuffer::arrayBuffer2list(argLen, char_args);142 arrayBuffer::arrayList::const_iterator cit2 = arr.begin();143 141 int i=1; 144 145 for (;cit2!=arr.end();cit2++,i++) { 142 BOOST_FOREACH(wstring str, arguments) { 146 143 if (isAlias || allowNasty_) { 147 if ( (*cit2).find_first_of(NASTY_METACHARS) != std::wstring::npos) {144 if (str.find_first_of(NASTY_METACHARS) != std::wstring::npos) { 148 145 NSC_LOG_ERROR(_T("Request string contained illegal metachars!")); 149 146 return NSCAPI::returnIgnored; 150 147 } 151 148 } 152 strEx::replace(args, _T("$ARG") + strEx::itos(i) + _T("$"), (*cit2));149 strEx::replace(args, _T("$ARG") + strEx::itos(i) + _T("$"), str); 153 150 } 154 151 } -
modules/CheckExternalScripts/CheckExternalScripts.def
rc1d545e r3080680 13 13 NSGetConfigurationMeta 14 14 NSGetModuleDescription 15 NSDeleteBuffer -
modules/CheckExternalScripts/CheckExternalScripts.h
r79e734f r3080680 25 25 #include <execute_process.hpp> 26 26 27 class CheckExternalScripts {27 class CheckExternalScripts : public NSCModuleHelper::SimpleCommand { 28 28 private: 29 29 struct command_data { … … 63 63 bool hasCommandHandler(); 64 64 bool hasMessageHandler(); 65 NSCAPI::nagiosReturn handleCommand(const st rEx::blindstr command, const unsigned int argLen, TCHAR **char_args, std::wstring &message, std::wstring &perf);65 NSCAPI::nagiosReturn handleCommand(const std::wstring command, std::list<std::wstring> arguments, std::wstring &message, std::wstring &perf); 66 66 std::wstring getConfigurationMeta(); 67 67 -
modules/CheckHelpers/CMakeLists.txt
r920626f r3080680 1 1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6) 2 2 3 PROJECT(CheckHelpers)3 SET(TARGET CheckHelpers) 4 4 5 # Workaround for bug 0003353 in cmake (aparently not fixed) 6 SET_SOURCE_FILES_PROPERTIES(${PB_PLUGIN} PROPERTIES GENERATED TRUE) 5 PROJECT(${TARGET}) 7 6 8 SET( CheckHelpers_SRCS7 SET(SRCS 9 8 stdafx.cpp 10 CheckHelpers.cpp9 "${TARGET}.cpp" 11 10 ${NSCP_DEF_PLUGIN_CPP} 12 11 ) … … 15 14 16 15 IF(WIN32) 17 SET( CheckHelpers_SRCS ${CheckHelpers_SRCS}16 SET(SRCS ${SRCS} 18 17 stdafx.h 19 CheckHelpers.def 18 "${TARGET}.h" 19 "${TARGET}.def" 20 20 21 ${NSCP_DEF_PLUGIN_HPP} 21 22 22 ) 23 23 ENDIF(WIN32) 24 24 25 add_library( CheckHelpers MODULE ${CheckHelpers_SRCS})25 add_library(${TARGET} MODULE ${SRCS}) 26 26 27 target_link_libraries( CheckHelpers27 target_link_libraries(${TARGET} 28 28 ${Boost_FILESYSTEM_LIBRARY} 29 29 ${NSCP_DEF_PLUGIN_LIB} -
modules/NRPEClient/CMakeLists.txt
r920626f r3080680 4 4 5 5 PROJECT(${TARGET}) 6 7 # Workaround for bug 0003353 in cmake (aparently not fixed)8 SET_SOURCE_FILES_PROPERTIES(${PB_PLUGIN} PROPERTIES GENERATED TRUE)9 6 10 7 SET(SRCS … … 22 19 stdafx.h 23 20 "${TARGET}.h" 21 "${TARGET}.def" 24 22 ${NSCP_INCLUDE_PATH}/nrpe/nrpepacket.hpp 25 23 ${NSCP_INCLUDE_PATH}/socket_helpers.hpp 26 "${TARGET}.def"27 24 28 25 ${NSCP_DEF_PLUGIN_HPP} -
modules/NRPEServer/CMakeLists.txt
r920626f r3080680 25 25 stdafx.h 26 26 "${TARGET}.h" 27 "${TARGET}.def" 27 28 nrpe_server.hpp 28 29 nrpe_connection.hpp … … 31 32 ${NSCP_INCLUDE_PATH}/nrpe/nrpepacket.hpp 32 33 ${NSCP_INCLUDE_PATH}/socket_helpers.hpp 33 "${TARGET}.def"34 34 35 35 ${NSCP_DEF_PLUGIN_HPP} -
modules/NRPEServer/NRPEServer.def
r2018659 r3080680 13 13 NSGetConfigurationMeta 14 14 NSGetModuleDescription 15 NSDeleteBuffer -
modules/Scheduler/CMakeLists.txt
r920626f r3080680 1 1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6) 2 2 3 PROJECT(Scheduler)3 SET(TARGET Scheduler) 4 4 5 # Workaround for bug 0003353 in cmake (aparently not fixed) 6 SET_SOURCE_FILES_PROPERTIES(${PB_PLUGIN} PROPERTIES GENERATED TRUE) 5 PROJECT(${TARGET}) 7 6 8 SET(S cheduler_SRCS7 SET(SRCS 9 8 stdafx.cpp 10 Scheduler.cpp9 "${TARGET}.cpp" 11 10 simple_scheduler.cpp 11 12 12 ${NSCP_DEF_PLUGIN_CPP} 13 13 ) … … 16 16 17 17 IF(WIN32) 18 SET(S cheduler_SRCS ${Scheduler_SRCS}18 SET(SRCS ${SRCS} 19 19 stdafx.h 20 "${TARGET}.h" 21 "${TARGET}.def" 20 22 simple_scheduler.hpp 23 21 24 ${NSCP_DEF_PLUGIN_HPP} 22 25 ) 23 26 ENDIF(WIN32) 24 27 25 add_library(Scheduler MODULE ${S cheduler_SRCS})28 add_library(Scheduler MODULE ${SRCS}) 26 29 27 30 target_link_libraries(Scheduler -
service/NSCPlugin.cpp
r2018659 r3080680 389 389 fShowTray = (lpShowTray)module_.load_proc("ShowIcon"); 390 390 fHideTray = (lpHideTray)module_.load_proc("HideIcon"); 391 392 } catch (NSPluginException &e) { 393 throw e; 391 394 } catch (dll::dll_exception &e) { 392 395 throw NSPluginException(module_, _T("Unhandled exception when loading proces: ") + e.what()); -
service/NSClient++.cpp
r920626f r3080680 325 325 name = plugin->getName(); 326 326 description = plugin->getDescription(); 327 } catch( constNSPluginException& e) {327 } catch(NSPluginException& e) { 328 328 LOG_ERROR_STD(_T("Exception raised: ") + e.error_ + _T(" in module: ") + e.file_); 329 329 } catch (std::exception e) {
Note: See TracChangeset
for help on using the changeset viewer.








