Changeset 8c7d67f in nscp


Ignore:
Timestamp:
03/05/08 07:48:16 (5 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
c3057cd
Parents:
6d3bbc1
Message:

+ 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.

+ Added syntax to new section [Eventlog] used as a shorthand for the syntax to use as "default" (when no syntax=... option is given)

  • Fixed an issue with eventlog and . matching. + Added shorthand ! for != in "all" numeric filters (eventlog)
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • changelog

    r6d3bbc1 r8c7d67f  
    77 * "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. " 
    88 
     92008-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  
    9152008-02-26 MickeM 
    1016 + Added installer 
  • include/config.h

    r4c8d44d r8c7d67f  
    150150 
    151151 
     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 
    152158#define NSCA_AGENT_SECTION_TITLE _T("NSCA Agent") 
    153159#define NSCA_CMD_SECTION_TITLE _T("NSCA Commands") 
  • include/filter_framework.hpp

    r99e4d8f r8c7d67f  
    187187    TFilterType filter; 
    188188    bool hasFilter_; 
     189    std::wstring value_; 
    189190    filter_one() : hasFilter_(false) {} 
    190191    filter_one(const filter_one &other) : hasFilter_(other.hasFilter_), filter(other.filter) { 
     
    198199    } 
    199200    const filter_one & operator=(std::wstring value) { 
     201      value_ = value; 
    200202      hasFilter_ = false; 
    201203      try { 
     
    207209      return *this; 
    208210    } 
     211    std::wstring getValue() const { 
     212      return value_; 
     213    } 
    209214  }; 
    210215 
     
    218223    sub_string_filter sub; 
    219224    exact_string_filter exact; 
     225    std::wstring value_; 
    220226#ifndef NO_BOOST_DEP 
    221227    regexp_string_filter regexp; 
     
    241247      return false; 
    242248    } 
     249    std::wstring getValue() const { 
     250      return value_; 
     251    } 
    243252    const filter_all_strings & operator=(std::wstring value) { 
     253      value_ = value; 
    244254      strEx::token t = strEx::getToken(value, ':', false); 
    245255      if (t.first == _T("substr")) { 
     
    264274    filter_one<TType, TType, THandler, filter::numeric_nequals_filter<TType> > neq; 
    265275    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_; 
    266277 
    267278    filter_all_numeric() {} 
     
    290301    } 
    291302    const filter_all_numeric& operator=(std::wstring value) { 
     303      value_ = value; 
    292304      if (value.substr(0,1) == _T(">")) { 
    293305        max = value.substr(1); 
     
    298310      } else if (value.substr(0,2) == _T("!=")) { 
    299311        neq = value.substr(2); 
     312      } else if (value.substr(0,1) == _T("!")) { 
     313        neq = value.substr(1); 
    300314      } else if (value.substr(0,3) == _T("in:")) { 
    301315        inList = value.substr(3); 
     
    304318      } 
    305319      return *this; 
     320    } 
     321    std::wstring getValue() const { 
     322      return value_; 
    306323    } 
    307324  }; 
  • modules/CheckEventLog/CheckEventLog-2005.vcproj

    r3f569d3 r8c7d67f  
    17941794      </File> 
    17951795      <File 
     1796        RelativePath="..\..\include\checkHelpers.hpp" 
     1797        > 
     1798      </File> 
     1799      <File 
    17961800        RelativePath="..\..\include\filter_framework.hpp" 
    17971801        > 
  • modules/CheckEventLog/CheckEventLog.cpp

    r6b690bf r8c7d67f  
    4747  try { 
    4848    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); 
    4951  } catch (NSCModuleHelper::NSCMHExcpetion &e) { 
    5052    NSC_LOG_ERROR_STD(_T("Failed to register command: ") + e.msg_); 
     
    339341  filters::filter_all_times timeGenerated; 
    340342  filters::filter_all_numeric<DWORD, filters::handlers::eventtype_handler> eventID; 
     343  std::wstring value_; 
    341344 
    342345  inline bool hasFilter() { 
    343346    return eventSource.hasFilter() || eventType.hasFilter() || eventID.hasFilter() || eventSeverity.hasFilter() || message.hasFilter() ||  
    344347      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..."); 
    345365  } 
    346366  bool matchFilter(const EventLogRecord &value) const { 
     
    389409  bool unique = false; 
    390410  unsigned int truncate = 0; 
    391   std::wstring syntax; 
     411  std::wstring syntax = syntax_; 
    392412  const int filter_plus = 1; 
    393413  const int filter_minus = 2; 
     
    477497      while (dwRead > 0)  
    478498      {  
    479         bool bMatch = bFilterAll; 
     499        //bool bMatch = bFilterAll; 
     500        bool bMatch = !bFilterIn; 
    480501        EventLogRecord record((*cit2), pevlr, ltime); 
    481502 
     
    487508 
    488509        for (filterlist_type::const_iterator cit3 = filter_chain.begin(); cit3 != filter_chain.end(); ++cit3 ) { 
     510          std::wstring reason; 
    489511          int mode = (*cit3).first; 
    490512          bool bTmpMatched = (*cit3).second.matchFilter(record); 
     
    504526            if ((mode == filter_minus)&&(bTmpMatched)) { 
    505527              // 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)); 
    506530              bMatch = false; 
    507531              break; 
    508532            } 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; 
    512538            } else if (bTmpMatched) { 
     539              if (debug_) 
     540                NSC_DEBUG_MSG_STD(_T("Matched: . (contiunue): ") + (*cit3).second.getValue() + _T(" for: ") + record.render(bShowDescriptions, syntax)); 
    513541              bMatch = true; 
    514542            } 
  • modules/CheckEventLog/CheckEventLog.h

    r99e4d8f r8c7d67f  
    2929class CheckEventLog { 
    3030private: 
     31  bool debug_; 
     32  std::wstring syntax_; 
    3133 
    3234public: 
Note: See TracChangeset for help on using the changeset viewer.