Changeset 8c7d67f in nscp
- Timestamp:
- 03/05/08 07:48:16 (5 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2, stable
- Children:
- c3057cd
- Parents:
- 6d3bbc1
- Files:
-
- 6 edited
-
changelog (modified) (1 diff)
-
include/config.h (modified) (1 diff)
-
include/filter_framework.hpp (modified) (9 diffs)
-
modules/CheckEventLog/CheckEventLog-2005.vcproj (modified) (1 diff)
-
modules/CheckEventLog/CheckEventLog.cpp (modified) (6 diffs)
-
modules/CheckEventLog/CheckEventLog.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
changelog
r6d3bbc1 r8c7d67f 7 7 * "The message is blocked by User Interface Privilege Isolation, Administrative applications that need to see it can allow it through by calling ChangeWindowMessageFilter after making sure the necessary security precautions are in place. " 8 8 9 2008-03-05 MickeM 10 + Added debug to new section [Eventlog], when enabled it will (log) wat lines matched what, this is a pretty big performance overhead so dont run with this one. 11 + Added syntax to new section [Eventlog] used as a shorthand for the syntax to use as "default" (when no syntax=... option is given) 12 * Fixed an issue with eventlog and . matching. 13 + Added shorthand ! for != in "all" numeric filters (eventlog) 14 9 15 2008-02-26 MickeM 10 16 + Added installer -
include/config.h
r4c8d44d r8c7d67f 150 150 151 151 152 #define EVENTLOG_SECTION_TITLE _T("Eventlog") 153 #define EVENTLOG_DEBUG _T("debug") 154 #define EVENTLOG_DEBUG_DEFAULT 0 155 #define EVENTLOG_SYNTAX _T("syntax") 156 #define EVENTLOG_SYNTAX_DEFAULT _T("") 157 152 158 #define NSCA_AGENT_SECTION_TITLE _T("NSCA Agent") 153 159 #define NSCA_CMD_SECTION_TITLE _T("NSCA Commands") -
include/filter_framework.hpp
r99e4d8f r8c7d67f 187 187 TFilterType filter; 188 188 bool hasFilter_; 189 std::wstring value_; 189 190 filter_one() : hasFilter_(false) {} 190 191 filter_one(const filter_one &other) : hasFilter_(other.hasFilter_), filter(other.filter) { … … 198 199 } 199 200 const filter_one & operator=(std::wstring value) { 201 value_ = value; 200 202 hasFilter_ = false; 201 203 try { … … 207 209 return *this; 208 210 } 211 std::wstring getValue() const { 212 return value_; 213 } 209 214 }; 210 215 … … 218 223 sub_string_filter sub; 219 224 exact_string_filter exact; 225 std::wstring value_; 220 226 #ifndef NO_BOOST_DEP 221 227 regexp_string_filter regexp; … … 241 247 return false; 242 248 } 249 std::wstring getValue() const { 250 return value_; 251 } 243 252 const filter_all_strings & operator=(std::wstring value) { 253 value_ = value; 244 254 strEx::token t = strEx::getToken(value, ':', false); 245 255 if (t.first == _T("substr")) { … … 264 274 filter_one<TType, TType, THandler, filter::numeric_nequals_filter<TType> > neq; 265 275 filter_one<std::list<TType>, TType, handlers::numeric_list_handler<TType, THandler>, filter::numeric_inlist_filter<std::list<TType>, TType> > inList; 276 std::wstring value_; 266 277 267 278 filter_all_numeric() {} … … 290 301 } 291 302 const filter_all_numeric& operator=(std::wstring value) { 303 value_ = value; 292 304 if (value.substr(0,1) == _T(">")) { 293 305 max = value.substr(1); … … 298 310 } else if (value.substr(0,2) == _T("!=")) { 299 311 neq = value.substr(2); 312 } else if (value.substr(0,1) == _T("!")) { 313 neq = value.substr(1); 300 314 } else if (value.substr(0,3) == _T("in:")) { 301 315 inList = value.substr(3); … … 304 318 } 305 319 return *this; 320 } 321 std::wstring getValue() const { 322 return value_; 306 323 } 307 324 }; -
modules/CheckEventLog/CheckEventLog-2005.vcproj
r3f569d3 r8c7d67f 1794 1794 </File> 1795 1795 <File 1796 RelativePath="..\..\include\checkHelpers.hpp" 1797 > 1798 </File> 1799 <File 1796 1800 RelativePath="..\..\include\filter_framework.hpp" 1797 1801 > -
modules/CheckEventLog/CheckEventLog.cpp
r6b690bf r8c7d67f 47 47 try { 48 48 NSCModuleHelper::registerCommand(_T("CheckEventLog"), _T("Check for errors in the event logger!")); 49 debug_ = NSCModuleHelper::getSettingsInt(EVENTLOG_SECTION_TITLE, EVENTLOG_DEBUG, EVENTLOG_DEBUG_DEFAULT)==1; 50 syntax_ = NSCModuleHelper::getSettingsString(EVENTLOG_SECTION_TITLE, EVENTLOG_SYNTAX, EVENTLOG_SYNTAX_DEFAULT); 49 51 } catch (NSCModuleHelper::NSCMHExcpetion &e) { 50 52 NSC_LOG_ERROR_STD(_T("Failed to register command: ") + e.msg_); … … 339 341 filters::filter_all_times timeGenerated; 340 342 filters::filter_all_numeric<DWORD, filters::handlers::eventtype_handler> eventID; 343 std::wstring value_; 341 344 342 345 inline bool hasFilter() { 343 346 return eventSource.hasFilter() || eventType.hasFilter() || eventID.hasFilter() || eventSeverity.hasFilter() || message.hasFilter() || 344 347 timeWritten.hasFilter() || timeGenerated.hasFilter(); 348 } 349 std::wstring getValue() const { 350 if (eventSource.hasFilter()) 351 return eventSource.getValue(); 352 if (eventType.hasFilter()) 353 return eventType.getValue(); 354 if (eventSeverity.hasFilter()) 355 return eventSeverity.getValue(); 356 if (eventID.hasFilter()) 357 return eventID.getValue(); 358 if (message.hasFilter()) 359 return message.getValue(); 360 if (timeWritten.hasFilter()) 361 return timeWritten.getValue(); 362 if (timeGenerated.hasFilter()) 363 return timeGenerated.getValue(); 364 return _T("UNknown..."); 345 365 } 346 366 bool matchFilter(const EventLogRecord &value) const { … … 389 409 bool unique = false; 390 410 unsigned int truncate = 0; 391 std::wstring syntax ;411 std::wstring syntax = syntax_; 392 412 const int filter_plus = 1; 393 413 const int filter_minus = 2; … … 477 497 while (dwRead > 0) 478 498 { 479 bool bMatch = bFilterAll; 499 //bool bMatch = bFilterAll; 500 bool bMatch = !bFilterIn; 480 501 EventLogRecord record((*cit2), pevlr, ltime); 481 502 … … 487 508 488 509 for (filterlist_type::const_iterator cit3 = filter_chain.begin(); cit3 != filter_chain.end(); ++cit3 ) { 510 std::wstring reason; 489 511 int mode = (*cit3).first; 490 512 bool bTmpMatched = (*cit3).second.matchFilter(record); … … 504 526 if ((mode == filter_minus)&&(bTmpMatched)) { 505 527 // a -<filter> hit so thrash item and bail out! 528 if (debug_) 529 NSC_DEBUG_MSG_STD(_T("Matched: - ") + (*cit3).second.getValue() + _T(" for: ") + record.render(bShowDescriptions, syntax)); 506 530 bMatch = false; 507 531 break; 508 532 } else if ((mode == filter_plus)&&(!bTmpMatched)) { 509 // a +<filter> missed hit so thrash item and bail out! 510 bMatch = false; 511 break; 533 // a +<filter> missed hit so thrash item and bail out! 534 if (debug_) 535 NSC_DEBUG_MSG_STD(_T("Matched: + ") + (*cit3).second.getValue() + _T(" for: ") + record.render(bShowDescriptions, syntax)); 536 bMatch = false; 537 break; 512 538 } else if (bTmpMatched) { 539 if (debug_) 540 NSC_DEBUG_MSG_STD(_T("Matched: . (contiunue): ") + (*cit3).second.getValue() + _T(" for: ") + record.render(bShowDescriptions, syntax)); 513 541 bMatch = true; 514 542 } -
modules/CheckEventLog/CheckEventLog.h
r99e4d8f r8c7d67f 29 29 class CheckEventLog { 30 30 private: 31 bool debug_; 32 std::wstring syntax_; 31 33 32 34 public:
Note: See TracChangeset
for help on using the changeset viewer.








