Changeset b67d231 in nscp
- Timestamp:
- 06/12/12 23:49:05 (12 months ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- 482e07e
- Parents:
- 81dbd0c
- Files:
-
- 14 edited
-
changelog (modified) (1 diff)
-
include/NSCAPI.h (modified) (1 diff)
-
include/nscapi/nscapi_helper.cpp (modified) (2 diffs)
-
include/nscapi/nscapi_protobuf_functions.cpp (modified) (1 diff)
-
include/nscapi/nscapi_targets.hpp (modified) (2 diffs)
-
include/nscapi/settings_object.hpp (modified) (4 diffs)
-
include/strEx.h (modified) (1 diff)
-
modules/CheckExternalScripts/CheckExternalScripts.cpp (modified) (5 diffs)
-
modules/CheckExternalScripts/commands.hpp (modified) (4 diffs)
-
modules/NSCAClient/NSCAClient.cpp (modified) (1 diff)
-
modules/Scheduler/schedules.hpp (modified) (1 diff)
-
service/NSClient++.cpp (modified) (2 diffs)
-
version.hpp (modified) (1 diff)
-
version.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
changelog
r1cc8566 rb67d231 4 4 * Fixa dependonservice LanManWorkStation (old win) 5 5 * Fix RtlStringFromGUID problem on NT4 6 7 2012-06-12 MickeM 8 * Added log level = off to disable logging. 9 * Added option in NSCAClient to hostname (auto-lc) to use lower case version of hostname. #533 10 * Reworked how commands are read. 11 If a command is defined without a section (default) no section will be added and instead a comment will be addded on how to add the section. 12 This should (I hope) resolve the "missing command" for good. 13 * Improved error messages for missing commands 14 * Fixed scientific notation on performance data (#) 6 15 7 16 2012-05-19 MickeM -
include/NSCAPI.h
r440c0cb rb67d231 98 98 namespace log_level { 99 99 typedef int level; 100 const int off = 0; // Used to disable logging 100 101 const int critical = 1; // Critical error 101 102 const int error = 10; // Error -
include/nscapi/nscapi_helper.cpp
r440c0cb rb67d231 79 79 } 80 80 81 #define PARSE_LOGLEVEL_BEGIN() if (false) {}82 #define PARSE_LOGLEVEL(key_str, value) else if (*key == _T(key_str) && level < value) { level = value; }83 #define PARSE_LOGLEVEL_END()84 85 81 NSCAPI::log_level::level nscapi::logging::parse(std::wstring str) { 86 unsigned int level = 0;87 82 std::transform(str.begin(), str.end(), str.begin(), ::tolower); 88 strEx::splitList lst = strEx::splitEx(str, _T(",")); 89 for (strEx::splitList::const_iterator key = lst.begin(); key != lst.end(); ++key) { 90 PARSE_LOGLEVEL_BEGIN() 91 PARSE_LOGLEVEL("all", NSCAPI::log_level::trace) 92 PARSE_LOGLEVEL("error", NSCAPI::log_level::error) 93 PARSE_LOGLEVEL("critical", NSCAPI::log_level::critical) 94 PARSE_LOGLEVEL("debug", NSCAPI::log_level::debug) 95 PARSE_LOGLEVEL("trace", NSCAPI::log_level::trace) 96 PARSE_LOGLEVEL("info", NSCAPI::log_level::info) 97 PARSE_LOGLEVEL("warning", NSCAPI::log_level::warning) 98 PARSE_LOGLEVEL_END() 99 } 100 return level; 83 if (_T("all") == str) { 84 return NSCAPI::log_level::trace; 85 } else if (_T("error") == str) { 86 return NSCAPI::log_level::error; 87 } else if (_T("critical") == str) { 88 return NSCAPI::log_level::critical; 89 } else if (_T("debug") == str) { 90 return NSCAPI::log_level::debug; 91 } else if (_T("trace") == str) { 92 return NSCAPI::log_level::trace; 93 } else if (_T("info") == str) { 94 return NSCAPI::log_level::info; 95 } else if (_T("warning") == str) { 96 return NSCAPI::log_level::warning; 97 } else if (_T("off") == str) { 98 return NSCAPI::log_level::off; 99 } 100 return NSCAPI::log_level::error; 101 101 } 102 102 bool nscapi::logging::matches(NSCAPI::log_level::level level, NSCAPI::nagiosReturn code) { … … 104 104 } 105 105 106 #define RENDER_LOGLEVEL_BEGIN()107 #define RENDER_LOGLEVEL(key_str, value) if (level == value) { return _T(key_str); }108 #define RENDER_LOGLEVEL_END()109 110 106 std::wstring nscapi::logging::to_string(NSCAPI::log_level::level level) { 111 RENDER_LOGLEVEL_BEGIN() 112 RENDER_LOGLEVEL("all", NSCAPI::log_level::trace) 113 RENDER_LOGLEVEL("error", NSCAPI::log_level::error) 114 RENDER_LOGLEVEL("critical", NSCAPI::log_level::critical) 115 RENDER_LOGLEVEL("debug", NSCAPI::log_level::debug) 116 RENDER_LOGLEVEL("trace", NSCAPI::log_level::trace) 117 RENDER_LOGLEVEL("info", NSCAPI::log_level::info) 118 RENDER_LOGLEVEL("warning", NSCAPI::log_level::warning) 119 RENDER_LOGLEVEL_END() 107 switch (level) { 108 case NSCAPI::log_level::trace: 109 return _T("trace"); 110 case NSCAPI::log_level::error: 111 return _T("error"); 112 case NSCAPI::log_level::critical: 113 return _T("critical"); 114 case NSCAPI::log_level::debug: 115 return _T("debug"); 116 case NSCAPI::log_level::info: 117 return _T("info"); 118 case NSCAPI::log_level::warning: 119 return _T("warning"); 120 case NSCAPI::log_level::off: 121 return _T("off"); 122 } 120 123 return strEx::itos(level); 121 124 } -
include/nscapi/nscapi_protobuf_functions.cpp
r308ae18 rb67d231 617 617 if (!fval.has_warning()) 618 618 continue; 619 ss << ";" << fval.warning();619 ss << ";" << strEx::s::itos_non_sci(fval.warning()); 620 620 if (!fval.has_critical()) 621 621 continue; 622 ss << ";" << fval.critical();622 ss << ";" << strEx::s::itos_non_sci(fval.critical()); 623 623 if (!fval.has_minimum()) 624 624 continue; 625 ss << ";" << fval.minimum();625 ss << ";" << strEx::s::itos_non_sci(fval.minimum()); 626 626 if (!fval.has_maximum()) 627 627 continue; 628 ss << ";" << fval.maximum();628 ss << ";" << strEx::s::itos_non_sci(fval.maximum()); 629 629 } 630 630 } -
include/nscapi/nscapi_targets.hpp
r83c2453 rb67d231 92 92 struct target_object_reader { 93 93 typedef target_object object_type; 94 static void read_object(boost::shared_ptr<nscapi::settings_proxy> proxy, object_type &object );94 static void read_object(boost::shared_ptr<nscapi::settings_proxy> proxy, object_type &object, bool oneliner); 95 95 static void apply_parent(object_type &object, object_type &parent); 96 96 }; … … 110 110 } 111 111 112 static void read_object(boost::shared_ptr<nscapi::settings_proxy> proxy, object_type &object ) {112 static void read_object(boost::shared_ptr<nscapi::settings_proxy> proxy, object_type &object, bool oneliner) { 113 113 object.address = net::parse(object.value, 0); 114 114 if (object.alias == _T("default")) -
include/nscapi/settings_object.hpp
r67c6d04 rb67d231 29 29 template<class object_type> 30 30 class default_object_reader { 31 static void read_object(boost::shared_ptr<nscapi::settings_proxy> proxy, object_type &object ) {}31 static void read_object(boost::shared_ptr<nscapi::settings_proxy> proxy, object_type &object, bool oneliner) {} 32 32 static void apply_parent(object_type &object, object_type &parent) {} 33 33 static void post_process_object(object_type &object) {} … … 64 64 object.is_template = false; 65 65 66 object_reader::read_object(proxy, object); 66 std::list<std::wstring> keys = proxy->get_keys(object.path); 67 object_reader::read_object(proxy, object, keys.empty()); 68 67 69 68 70 if (!object.parent.empty() && object.parent != alias & object.parent != object.alias) { … … 108 110 } 109 111 110 bool has_object(std::wstring alias) {112 bool has_object(std::wstring alias) const { 111 113 typename object_list_type::const_iterator cit = object_list.find(alias); 112 114 if (cit != object_list.end()) … … 116 118 return true; 117 119 return false; 120 } 121 122 bool empty() const { 123 return object_list.empty(); 118 124 } 119 125 -
include/strEx.h
rfa11893 rb67d231 282 282 ss << std::noshowpoint << std::fixed << i; 283 283 std::string s = ss.str(); 284 std::string::size_type pos = s.find_last_not_of('0'); 284 std::string::size_type pos = s.find('.'); 285 if (pos != std::string::npos && (s.length()-pos) > 6) { 286 s = s.substr(0, pos+6); 287 } 288 289 pos = s.find_last_not_of('0'); 285 290 if (pos == std::wstring::npos) 286 291 return s; -
modules/CheckExternalScripts/CheckExternalScripts.cpp
r67c6d04 rb67d231 87 87 , _T("EXTERNAL SCRIPT WRAPPINGS SECTION"), _T("A list of templates for wrapped scripts")) 88 88 89 (_T("alias"), sh::fun_values_path(boost::bind(&CheckExternalScripts::add_alias, this, _1, _2)), 90 _T("EXTERNAL SCRIPT ALIAS SECTION"), _T("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)")) 91 89 92 ; 90 93 … … 103 106 } 104 107 108 if (aliases_.empty()) { 109 NSC_DEBUG_MSG(_T("No aliases found (adding default)")); 110 111 add_alias(_T("alias_cpu"), _T("checkCPU warn=80 crit=90 time=5m time=1m time=30s")); 112 add_alias(_T("alias_cpu_ex"), _T("checkCPU warn=$ARG1$ crit=$ARG2$ time=5m time=1m time=30s")); 113 add_alias(_T("alias_mem"), _T("checkMem MaxWarn=80% MaxCrit=90% ShowAll=long type=physical type=virtual type=paged type=page")); 114 add_alias(_T("alias_up"), _T("checkUpTime MinWarn=1d MinWarn=1h")); 115 add_alias(_T("alias_disk"), _T("CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED")); 116 add_alias(_T("alias_disk_loose"), _T("CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED ignore-unreadable")); 117 add_alias(_T("alias_volumes"), _T("CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED")); 118 add_alias(_T("alias_volumes_loose"), _T("CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED ignore-unreadable ")); 119 add_alias(_T("alias_service"), _T("checkServiceState CheckAll")); 120 add_alias(_T("alias_service_ex"), _T("checkServiceState CheckAll \"exclude=Net Driver HPZ12\" \"exclude=Pml Driver HPZ12\" exclude=stisvc")); 121 add_alias(_T("alias_process"), _T("checkProcState \"$ARG1$=started\"")); 122 add_alias(_T("alias_process_stopped"), _T("checkProcState \"$ARG1$=stopped\"")); 123 add_alias(_T("alias_process_count"), _T("checkProcState MaxWarnCount=$ARG2$ MaxCritCount=$ARG3$ \"$ARG1$=started\"")); 124 add_alias(_T("alias_process_hung"), _T("checkProcState MaxWarnCount=1 MaxCritCount=1 \"$ARG1$=hung\"")); 125 add_alias(_T("alias_event_log"), _T("CheckEventLog file=application file=system MaxWarn=1 MaxCrit=1 \"filter=generated gt -2d AND severity NOT IN ('success', 'informational') AND source != 'SideBySide'\" truncate=800 unique descriptions \"syntax=%severity%: %source%: %message% (%count%)\"")); 126 add_alias(_T("alias_file_size"), _T("CheckFiles \"filter=size > $ARG2$\" \"path=$ARG1$\" MaxWarn=1 MaxCrit=1 \"syntax=%filename% %size%\" max-dir-depth=10")); 127 add_alias(_T("alias_file_age"), _T("checkFile2 filter=out \"file=$ARG1$\" filter-written=>1d MaxWarn=1 MaxCrit=1 \"syntax=%filename% %write%\"")); 128 add_alias(_T("alias_sched_all"), _T("CheckTaskSched \"filter=exit_code ne 0\" \"syntax=%title%: %exit_code%\" warn=>0")); 129 add_alias(_T("alias_sched_long"), _T("CheckTaskSched \"filter=status = 'running' AND most_recent_run_time < -$ARG1$\" \"syntax=%title% (%most_recent_run_time%)\" warn=>0")); 130 add_alias(_T("alias_sched_task"), _T("CheckTaskSched \"filter=title eq '$ARG1$' AND exit_code ne 0\" \"syntax=%title% (%most_recent_run_time%)\" warn=>0")); 131 add_alias(_T("alias_updates"), _T("check_updates -warning 0 -critical 0")); 132 add_alias(_T("check_ok"), _T("CheckOK Everything is fine!")); 133 } 134 105 135 settings.alias().add_path_to_settings() 106 136 (_T("EXTERNAL SCRIPT SECTION"), _T("Section for external scripts configuration options (CheckExternalScripts).")) … … 108 138 (_T("scripts"), sh::fun_values_path(boost::bind(&CheckExternalScripts::add_command, this, _1, _2)), 109 139 _T("EXTERNAL SCRIPT SCRIPT SECTION"), _T("A list of scripts available to run from the CheckExternalScripts module. Syntax is: <command>=<script> <arguments>")) 110 111 (_T("alias"), sh::fun_values_path(boost::bind(&CheckExternalScripts::add_alias, this, _1, _2)),112 _T("EXTERNAL SCRIPT ALIAS SECTION"), _T("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)"))113 140 114 141 (_T("wrapped scripts"), sh::fun_values_path(boost::bind(&CheckExternalScripts::add_wrapping, this, _1, _2)), … … 227 254 } 228 255 229 NSC_ LOG_MESSAGE(_T("Arguments: ") + xargs);256 NSC_DEBUG_MSG(_T("Arguments: ") + xargs); 230 257 231 258 … … 233 260 std::wstring message; 234 261 try { 235 return nscapi::core_helper::simple_query(cd.command, args, response); 262 int result = nscapi::core_helper::simple_query(cd.command, args, response); 263 if (result == NSCAPI::returnIgnored) { 264 nscapi::functions::create_simple_query_response_unknown(data.command, _T("No handler for command: ") + cd.command, response); 265 return NSCAPI::returnUNKNOWN; 266 } 267 return result; 236 268 } catch (boost::escaped_list_error &e) { 237 269 NSC_LOG_MESSAGE(_T("Failed to parse alias expression: ") + strEx::string_to_wstring(e.what())); -
modules/CheckExternalScripts/commands.hpp
r1cc8566 rb67d231 118 118 119 119 120 static void read_object(boost::shared_ptr<nscapi::settings_proxy> proxy, object_type &object ) {120 static void read_object(boost::shared_ptr<nscapi::settings_proxy> proxy, object_type &object, bool oneliner) { 121 121 object.set_command(object.value); 122 122 std::wstring alias; … … 126 126 nscapi::settings_helper::settings_registry settings(proxy); 127 127 128 /* 129 object_type::options_type options; 130 */ 131 /* 132 settings.path(object.path).add_path() 133 (object.alias, nscapi::settings_helper::wstring_map_path(&options), 134 _T("TARGET DEFENITION"), _T("Target definition for: ") + object.alias) 135 136 ; 137 */ 138 128 if (oneliner) { 129 std::wstring::size_type pos = object.path.find_last_of(_T("/")); 130 if (pos != std::wstring::npos) { 131 std::wstring path = object.path.substr(0, pos); 132 std::wstring key = object.path.substr(pos+1); 133 proxy->register_key(path, key, NSCAPI::key_string, object.alias, _T("Alias for ") + object.alias + _T(". To configure this item add a section called: ") + object.path, _T(""), false); 134 proxy->set_string(path, key, object.value); 135 return; 136 } 137 } 139 138 settings.path(object.path).add_path() 140 139 (_T("COMMAND DEFENITION"), _T("Command definition for: ") + object.alias) … … 169 168 if (!alias.empty()) 170 169 object.alias = alias; 171 172 /*173 BOOST_FOREACH(const object_type::options_type::value_type &kvp, options) {174 if (!object.has_option(kvp.first))175 object.options[kvp.first] = kvp.second;176 }177 */178 179 170 } 180 171 … … 184 175 import_string(object.password, parent.password); 185 176 import_string(object.command, parent.command); 186 //import_string(object.arguments, parent.arguments);187 177 if (object.arguments.empty() && !parent.arguments.empty()) 188 178 object.arguments = parent.arguments; 189 /*190 object.address.import(parent.address);191 BOOST_FOREACH(object_type::options_type::value_type i, parent.options) {192 if (object.options.find(i.first) == object.options.end())193 object.options[i.first] = i.second;194 }195 */196 179 } 197 180 -
modules/NSCAClient/NSCAClient.cpp
r308ae18 rb67d231 101 101 if (hostname_ == "auto") { 102 102 hostname_ = boost::asio::ip::host_name(); 103 } else if (hostname_ == "auto-lc") { 104 hostname_ = boost::asio::ip::host_name(); 105 std::transform(hostname_.begin(), hostname_.end(), hostname_.begin(), ::tolower); 103 106 } else { 104 107 std::pair<std::string,std::string> dn = strEx::split<std::string>(boost::asio::ip::host_name(), "."); -
modules/Scheduler/schedules.hpp
rc630d09 rb67d231 110 110 111 111 112 static void read_object(boost::shared_ptr<nscapi::settings_proxy> proxy, object_type &object ) {112 static void read_object(boost::shared_ptr<nscapi::settings_proxy> proxy, object_type &object, bool oneliner) { 113 113 object.set_command(object.value); 114 114 if (object.alias == _T("default")) { -
service/NSClient++.cpp
r682ccd2 rb67d231 942 942 if (!plugin) { 943 943 LOG_ERROR_CORE(_T("No handler for command: ") + cmd + _T(" avalible commands: ") + commands_.to_wstring()); 944 nscapi::functions::create_simple_query_response_unknown(cmd, _T("No handler for command: ") + cmd, response); 944 945 return NSCAPI::returnIgnored; 945 946 } … … 1065 1066 nsclient::commands::plugin_type plugin = commands_.get(command); 1066 1067 if (!plugin) { 1067 LOG_ERROR_CORE(_T("No handler for command: ") + command + _T(" avalible commands: ") + commands_.to_wstring()); 1068 LOG_ERROR_CORE(_T("No handler for command: ") + command + _T(" available commands: ") + commands_.to_wstring()); 1069 resp.push_back(_T("No handler for command: ") + command); 1068 1070 return NSCAPI::returnUNKNOWN; 1069 1071 } -
version.hpp
r81dbd0c rb67d231 1 1 #ifndef VERSION_HPP 2 2 #define VERSION_HPP 3 #define PRODUCTVER 0,4,0,17 44 #define STRPRODUCTVER "0,4,0,17 4"5 #define STRPRODUCTDATE "2012-0 5-19"3 #define PRODUCTVER 0,4,0,175 4 #define STRPRODUCTVER "0,4,0,175" 5 #define STRPRODUCTDATE "2012-06-12" 6 6 #endif // VERSION_HPP -
version.txt
r81dbd0c rb67d231 1 1 version=0.4.0 2 build=17 43 date=2012-0 5-192 build=175 3 date=2012-06-12
Note: See TracChangeset
for help on using the changeset viewer.








