Changeset 822454f in nscp
- Timestamp:
- 03/20/12 23:34:15 (14 months ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- 83c2453
- Parents:
- 74e060a
- Files:
-
- 9 edited
-
changelog (modified) (1 diff)
-
helpers/installers/installer/Product.wxs (modified) (2 diffs)
-
helpers/installers/ui/SelectConfigurationDlg.wxs (modified) (1 diff)
-
modules/CheckEventLog/CheckEventLog.cpp (modified) (7 diffs)
-
modules/CheckEventLog/CheckEventLog.h (modified) (3 diffs)
-
modules/CheckEventLog/eventlog_record.hpp (modified) (2 diffs)
-
modules/CheckEventLog/filter.hpp (modified) (1 diff)
-
version.hpp (modified) (1 diff)
-
version.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
changelog
r74e060a r822454f 4 4 * Fixa dependonservice LanManWorkStation (old win) 5 5 * Fix RtlStringFromGUID problem on NT4 6 7 2012-03-20 MickeM 8 * Fixed alias/service name for real-time event log filters 9 * Added smtp/syslog and graphite clients to installer 10 * Fixed so eventlog wont crahs on invalid messages 6 11 7 12 2012-03-19 MickeM -
helpers/installers/installer/Product.wxs
r74e060a r822454f 140 140 <Component Id="PythonScript" Guid="8820A304-C696-4393-A72F-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 141 141 <File Id="PythonScript" Name="PythonScript.dll" DiskId="1" Source="$(var.Source)/modules/PythonScript.dll" Vital="no" /> 142 </Component> 143 <Component Id="ExtraClients" Guid="8820A304-C696-4393-A72F-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 144 <File Id="GraphiteClient" Name="GraphiteClient.dll" DiskId="1" Source="$(var.Source)/modules/GraphiteClient.dll" Vital="no" /> 145 <File Id="SMTPClient" Name="SMTPClient.dll" DiskId="1" Source="$(var.Source)/modules/SMTPClient.dll" Vital="no" /> 146 <File Id="SyslogClient" Name="SyslogClient.dll" DiskId="1" Source="$(var.Source)/modules/SyslogClient.dll" Vital="no" /> 142 147 </Component> 143 148 <Component Id="Plugins" Guid="9B490E67-5472-4266-96DC-$(var.Postfix.GUID)" Win64="$(var.Win64)"> … … 270 275 <ComponentRef Id="NSCA" /> 271 276 </Feature> 277 <Feature Id="ExtraClientPlugin" Title="Various client plugins" Description="Plugins to connect to various sytems such as syslog, graphite and smtp" Level="1" Absent="disallow"> 278 <ComponentRef Id="ExtraClients" /> 279 </Feature> 272 280 <Feature Id="NSCPPlugin" Title="NSCP plugin (experimental)" Description="Plugin to submit passive results to an NSCP server" Level="1" Absent="disallow"> 273 281 <ComponentRef Id="NSCP" /> -
helpers/installers/ui/SelectConfigurationDlg.wxs
rc88cf98 r822454f 19 19 <Condition Action="disable"><![CDATA[CONFIGURATION_TYPE <> "ini://${exe-path}/nsclient.ini"]]></Condition> 20 20 </Control> 21 <Control Id="userWriteConfig" Type="CheckBox" X="60" Y="88" Width="260" Height="20" Property="USER_WRITABLE_CONFIG" Text="Allow Everyoneto write config file" CheckBoxValue="1">21 <Control Id="userWriteConfig" Type="CheckBox" X="60" Y="88" Width="260" Height="20" Property="USER_WRITABLE_CONFIG" Text="Allow all users to write config file" CheckBoxValue="1"> 22 22 <Condition Action="enable">CONFIGURATION_TYPE = "ini://${exe-path}/nsclient.ini" AND INSTALL_SAMPLE_CONFIG</Condition> 23 23 <Condition Action="disable"><![CDATA[CONFIGURATION_TYPE <> "ini://${exe-path}/nsclient.ini" OR NOT INSTALL_SAMPLE_CONFIG]]></Condition> -
modules/CheckEventLog/CheckEventLog.cpp
r74e060a r822454f 147 147 } 148 148 149 void real_time_thread::process_no_events( ) {149 void real_time_thread::process_no_events(std::wstring alias) { 150 150 std::wstring response; 151 if (!nscapi::core_helper::submit_simple_message(info.target, info.alias, NSCAPI::returnCRIT, info.ok_msg, info.perf_msg, response)) { 151 if (alias.empty()) 152 alias = info.alias; 153 if (!nscapi::core_helper::submit_simple_message(info.target, alias, NSCAPI::returnCRIT, info.ok_msg, info.perf_msg, response)) { 152 154 NSC_LOG_ERROR(_T("Failed to submit evenhtlog result: ") + response); 153 155 } 154 156 } 155 157 156 void real_time_thread::process_record( const EventLogRecord &record) {158 void real_time_thread::process_record(std::wstring alias, const EventLogRecord &record) { 157 159 std::wstring response; 158 160 std::wstring message = record.render(true, info.syntax, DATE_FORMAT, info.dwLang); 159 if (!nscapi::core_helper::submit_simple_message(info.target, info.alias, NSCAPI::returnCRIT, message, info.perf_msg, response)) { 161 if (alias.empty()) 162 alias = info.alias; 163 if (!nscapi::core_helper::submit_simple_message(info.target, alias, NSCAPI::returnCRIT, message, info.perf_msg, response)) { 160 164 NSC_LOG_ERROR(_T("Failed to submit evenhtlog result: ") + response); 161 165 } … … 199 203 200 204 std::list<eventlog_filter::filter_engine> filters; 201 BOOST_FOREACH( std::wstringfilter, filters_) {205 BOOST_FOREACH(const filter_container &filter, filters_) { 202 206 eventlog_filter::filter_argument fargs = eventlog_filter::factories::create_argument(info.syntax, DATE_FORMAT); 203 fargs->filter = filter; 204 fargs->debug = true; 207 fargs->filter = filter.filter; 208 fargs->debug = debug_; 209 fargs->alias = filter.alias; 205 210 eventlog_filter::filter_engine engine = eventlog_filter::factories::create_engine(fargs); 206 211 207 212 if (!engine) { 208 NSC_LOG_ERROR_STD(_T("Invalid filter: ") + filter );213 NSC_LOG_ERROR_STD(_T("Invalid filter: ") + filter.filter); 209 214 continue; 210 215 } 211 216 212 217 if (!engine->boot()) { 213 NSC_LOG_ERROR_STD(_T("Error booting filter: ") + filter );218 NSC_LOG_ERROR_STD(_T("Error booting filter: ") + filter.filter); 214 219 continue; 215 220 } … … 253 258 DWORD dwWaitReason = WaitForMultipleObjects(list.size()+1, handles, FALSE, dwWaitTime==0?INFINITE:dwWaitTime); 254 259 if (dwWaitReason == WAIT_TIMEOUT) { 255 process_no_events(); 260 BOOST_FOREACH(eventlog_filter::filter_engine engine, filters) { 261 process_no_events(engine->data->alias); 262 } 256 263 } else if (dwWaitReason == WAIT_OBJECT_0) { 257 264 delete [] handles; … … 277 284 BOOST_FOREACH(eventlog_filter::filter_engine engine, filters) { 278 285 if (engine->match(arg)) { 279 process_record(e lr);286 process_record(engine->data->alias, elr); 280 287 matched = true; 281 288 } … … 320 327 321 328 void real_time_thread::add_realtime_filter(std::wstring key, std::wstring query) { 322 if (!key.empty() && query.empty()) 323 filters_.push_back(key); 324 else 325 filters_.push_back(query); 329 filter_container c; 330 if (!key.empty() && query.empty()) { 331 c.filter = key; 332 filters_.push_back(c); 333 } else { 334 c.alias = key; 335 c.filter = query; 336 filters_.push_back(c); 337 } 326 338 } 327 339 … … 374 386 375 387 (_T("maximum age"), sh::string_fun_key<std::wstring>(boost::bind(&real_time_thread::set_max_age, &thread_, _1), _T("5m")), 376 _T("MAGIMUM AGE"), _T("How long befor reporting \"ok\" (if this is set to off no ok will be reported only errors)"))388 _T("MAGIMUM AGE"), _T("How long before reporting \"ok\" (if this is set to off no ok will be reported only errors)")) 377 389 378 390 (_T("filter"), sh::string_fun_key<std::wstring>(boost::bind(&real_time_thread::set_filter, &thread_, _1), _T("")), … … 394 406 _T("ENABLE ACTIVE MONITORING"), _T("This will store all matches so you can use real-time filters from active monitoring (use CheckEventlogCache).")) 395 407 408 (_T("ok message"), sh::wstring_key(&thread_.info.ok_msg, _T("eventlog found no records")), 409 _T("OK MESSAGE"), _T("This is the message sent periodically whenever no error is discovered.")) 410 411 (_T("alias"), sh::wstring_key(&thread_.info.alias, _T("eventlog")), 412 _T("ALIAS"), _T("The alias to use for this event (in NSCA this constitutes the service name).")) 396 413 ; 397 414 -
modules/CheckEventLog/CheckEventLog.h
r74e060a r822454f 37 37 std::wstring syntax; 38 38 std::wstring ok_msg; 39 std::wstring perf_msg; 40 bool perf;39 std::wstring perf_msg; // 40 //bool perf; 41 41 DWORD dwLang; 42 42 43 }; 44 45 struct filter_container { 46 std::wstring filter; 47 std::wstring alias; 43 48 }; 44 49 … … 49 54 unsigned long long max_age_; 50 55 //std::wstring syntax_; 51 std::list< std::wstring> filters_;56 std::list<filter_container> filters_; 52 57 boost::shared_ptr<boost::thread> thread_; 53 58 HANDLE stop_event_; … … 94 99 void thread_proc(); 95 100 // void process_events(eventlog_filter::filter_engine engine, eventlog_wrapper &eventlog); 96 void process_no_events( );97 void process_record( const EventLogRecord &record);101 void process_no_events(std::wstring alias); 102 void process_record(std::wstring alias, const EventLogRecord &record); 98 103 void debug_miss(const EventLogRecord &record); 99 104 // void process_event(eventlog_filter::filter_engine engine, const EVENTLOGRECORD* record); -
modules/CheckEventLog/eventlog_record.hpp
r74e060a r822454f 188 188 }; 189 189 190 boost::tuple<DWORD,std::wstring> wrapped_format(HMODULE hDLL, DWORD dwLang, DWORD id, tchar_array &buffer) const {190 boost::tuple<DWORD,std::wstring> safe_format(HMODULE hDLL, DWORD dwLang) const { 191 191 LPVOID lpMsgBuf; 192 192 unsigned long dwRet = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_HMODULE|FORMAT_MESSAGE_ARGUMENT_ARRAY|FORMAT_MESSAGE_IGNORE_INSERTS,hDLL, 193 id,dwLang,(LPTSTR)&lpMsgBuf,0,reinterpret_cast<va_list*>(buffer.get_buffer_unsafe()));193 pevlr_->EventID,dwLang,(LPTSTR)&lpMsgBuf,0,NULL); 194 194 if (dwRet == 0) { 195 195 return boost::tuple<DWORD,std::wstring>(GetLastError(), _T("")); 196 196 } 197 LocalFree(lpMsgBuf);198 dwRet = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_HMODULE|FORMAT_MESSAGE_ARGUMENT_ARRAY,hDLL,199 id,dwLang,(LPTSTR)&lpMsgBuf,0,reinterpret_cast<va_list*>(buffer.get_buffer_unsafe()));200 if (dwRet == 0)201 return boost::make_tuple(GetLastError(), _T(""));202 197 std::wstring msg = reinterpret_cast<wchar_t*>(lpMsgBuf); 203 198 LocalFree(lpMsgBuf); 199 const TCHAR* p = reinterpret_cast<const TCHAR*>(reinterpret_cast<const BYTE*>(pevlr_) + pevlr_->StringOffset); 200 for (unsigned int i = 0;i<pevlr_->NumStrings;i++) { 201 strEx::replace(msg, _T("%")+strEx::itos(i+1), std::wstring(p)); 202 unsigned int len = wcslen(p); 203 p = &(p[len+1]); 204 } 204 205 return boost::make_tuple(0, msg); 205 206 } 206 207 std::wstring render_message(DWORD dwLang = 0) const { 207 208 std::vector<std::wstring> args; 208 const TCHAR* p = reinterpret_cast<const TCHAR*>(reinterpret_cast<const BYTE*>(pevlr_) + pevlr_->StringOffset);209 210 tchar_array buffer(pevlr_->NumStrings+10);211 for (unsigned int i = 0;i<pevlr_->NumStrings;i++) {212 unsigned int len = buffer.set(i, p);213 p = &(p[len+1]);214 }215 for (unsigned int i = pevlr_->NumStrings;i<pevlr_->NumStrings+10;i++) {216 unsigned int len = buffer.set(i, _T(""));217 }218 209 std::wstring ret; 219 210 strEx::splitList dlls = strEx::splitEx(get_dll(), _T(";")); … … 229 220 if (dwLang == 0) 230 221 dwLang = MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT); 231 boost::tuple<DWORD,std::wstring> formated_data = wrapped_format(hDLL, dwLang, pevlr_->EventID, buffer);222 boost::tuple<DWORD,std::wstring> formated_data = safe_format(hDLL, dwLang); 232 223 if (formated_data.get<0>() != 0) { 233 224 FreeLibrary(hDLL); -
modules/CheckEventLog/filter.hpp
r74e060a r822454f 140 140 bool bShowDescriptions; 141 141 unsigned long long now; 142 std::wstring alias; 142 143 143 144 data_arguments(parent_type::error_type error, std::wstring syntax, std::wstring datesyntax, bool debug = false) : where_filter::argument_interface(error, syntax, datesyntax) -
version.hpp
r74e060a r822454f 1 1 #ifndef VERSION_HPP 2 2 #define VERSION_HPP 3 #define PRODUCTVER 0,4,0,14 54 #define STRPRODUCTVER "0,4,0,14 5"5 #define STRPRODUCTDATE "2012-03- 18"3 #define PRODUCTVER 0,4,0,147 4 #define STRPRODUCTVER "0,4,0,147" 5 #define STRPRODUCTDATE "2012-03-20" 6 6 #endif // VERSION_HPP -
version.txt
r74e060a r822454f 1 1 version=0.4.0 2 build=14 53 date=2012-03- 182 build=147 3 date=2012-03-20
Note: See TracChangeset
for help on using the changeset viewer.








