Changeset ec3fbc5 in nscp


Ignore:
Timestamp:
02/22/06 23:25:11 (7 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
f42280d
Parents:
1b7ae3d
Message:

Added syntax option and some date formating code.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • changelog

    r6817602 rec3fbc5  
    77 * Add module for relaying events 
    88 * Check multitasking problems on the sockets. 
     9 * Add filtering to WMI module 
     10 * Fix WMI module 
     11 * Check date/time on eventlogs 
     12 * Add support for rendering results (eventlog etc) [In progress] 
    913 
    10142006-02-12 MickeM 
    11  + Added new Interface for MOdules (NSCommandLineExec that allows modules to execute things give from command line. 
    12    Syntax is NSClient++ <module name> <command> [arguments] and if a mpodule doesn't support this it is simply ignored. 
     15 + Added new Interface for Modules (NSCommandLineExec that allows modules to execute things give from command line. 
     16   Syntax is NSClient++ <module name> <command> [arguments] and if a module doesn't support this it is simply ignored. 
    1317 + Added new install/uninstall command to SystemTray module: 
    1418   NSClient++.exe SystemTray install  
     
    1620   That will install/uninstall the system tray module this sets the "Allow Service to Interact with Desktop" flag for the service. 
    1721 * Removed the "Allow Service to Interact with Desktop" flag from the /install option so that it no longer defaults to on (see commands to set this above). 
    18  * Fixed so checkProcess isn't case sensetive. 
     22 * Fixed so checkProcess isn't case sensitive. 
     23 * Added (not finished) syntax option to event log checker to format the outputted data 
    1924 
    20252006-02-12 MickeM 
     
    3338   This new command (in development) will allow various file checks such as age, size, date, etc on single or multiple files. 
    3439 + Added FILEAGE support to NSClient 
    35  + Started to convert the webpage to WIKI 
     40 + Started to convert the web page to WIKI 
    3641  
    37422006-01-21 MickeM 
  • include/strEx.h

    r6817602 rec3fbc5  
    77#include <list> 
    88#include <functional> 
     9#include <time.h> 
    910#ifdef _DEBUG 
    1011#include <iostream> 
     
    1920  } 
    2021 
     22  inline std::string format_date(time_t time, std::string format) { 
     23    char buf[51]; 
     24    size_t l = strftime(buf, 50, format.c_str(), gmtime(&time)); 
     25    if (l <= 0 || l >= 50) 
     26      return ""; 
     27    buf[l] = 0; 
     28    return buf; 
     29  } 
    2130 
    2231  inline void replace(std::string &string, std::string replace, std::string with) { 
  • modules/CheckEventLog/CheckEventLog.cpp

    r6817602 rec3fbc5  
    147147    return strEx::itos(dwType); 
    148148  } 
     149  std::string render(std::string syntax) { 
     150    strEx::replace(syntax, "%source%", eventSource()); 
     151    strEx::replace(syntax, "%generated%", strEx::format_date(pevlr_->TimeGenerated, DATE_FORMAT)); 
     152    strEx::replace(syntax, "%written%", strEx::format_date(pevlr_->TimeWritten, DATE_FORMAT)); 
     153    strEx::replace(syntax, "%type%", translateType(eventType())); 
     154    strEx::replace(syntax, "%severity%", translateSeverity(severity())); 
     155    strEx::replace(syntax, "%strings%", enumStrings()); 
     156    strEx::replace(syntax, "%id%", strEx::itos(eventID())); 
     157    return syntax; 
     158  } 
    149159}; 
    150160 
     
    203213  bool bShowDescriptions = false; 
    204214  unsigned int truncate = 0; 
     215  std::string syntax; 
    205216 
    206217  try { 
     
    212223      MAP_OPTIONS_BOOL_EX("filter", bFilterIn, "in", "out") 
    213224      MAP_OPTIONS_BOOL_EX("filter", bFilterAll, "all", "any") 
     225      MAP_OPTIONS_STR("syntax", syntax) 
    214226      MAP_FILTER("filter-eventType", eventType) 
    215227      MAP_FILTER("filter-severity", eventSeverity) 
     
    273285 
    274286        if ((bFilterIn&&bMatch)||(!bFilterIn&&!bMatch)) { 
    275           strEx::append_list(message, record.eventSource()); 
    276           if (bShowDescriptions) { 
     287          if (!syntax.empty()) { 
     288            strEx::append_list(message, record.render(syntax)); 
     289          } else if (bShowDescriptions) { 
     290            strEx::append_list(message, record.eventSource()); 
     291          } else { 
     292            strEx::append_list(message, record.eventSource()); 
    277293            message += "(" + EventLogRecord::translateType(record.eventType()) + ", " + strEx::itos(record.eventID()) + ", " + EventLogRecord::translateSeverity(record.severity()) + ")"; 
    278294            message += "[" + record.enumStrings() + "]"; 
  • modules/CheckEventLog/CheckEventLog.h

    r75d5e70 rec3fbc5  
    44#include <checkHelpers.hpp> 
    55#include <filter_framework.hpp> 
     6 
     7 
     8#define DATE_FORMAT "%#c" 
    69 
    710class CheckEventLog { 
Note: See TracChangeset for help on using the changeset viewer.