Changeset dcd5462 in nscp for modules


Ignore:
Timestamp:
06/22/09 13:23:18 (4 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
4580c6c, cf87b57
Parents:
b39c1f3
Message:

post 0.3.6 build (fixes the CheckDisk errors)

Location:
modules
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • modules/CheckDisk/CheckDisk.cpp

    rb1ac2fa rdcd5462  
    2525#include <filter_framework.hpp> 
    2626#include <error.hpp> 
    27  
     27#include <file_helpers.hpp> 
    2828 
    2929CheckDisk gCheckDisk; 
     
    115115    NSC_DEBUG_MSG_STD(_T("Found a file dont do recursive scan: ") + dir); 
    116116    // It is a file check it an return (dont check recursivly) 
    117     pattern_type single_path = split_path(dir); 
     117    pattern_type single_path = split_path_ex(dir); 
     118    NSC_DEBUG_MSG_STD(_T("Path is: ") + single_path.first); 
    118119    HANDLE hFind = FindFirstFile(dir.c_str(), &wfd); 
    119120    if (hFind != INVALID_HANDLE_VALUE) { 
     
    318319}; 
    319320typedef std::pair<std::wstring,std::wstring> pattern_type; 
    320 pattern_type split_path(std::wstring path) { 
     321pattern_type split_path_ex(std::wstring path) { 
    321322  std::wstring baseDir; 
     323  if (file_helpers::checks::is_directory(path)) { 
     324    return pattern_type(path, _T("")); 
     325  } 
    322326  std::wstring::size_type pos = path.find_last_of('\\'); 
    323327  if (pos == std::wstring::npos) { 
     
    325329  } 
    326330  NSC_DEBUG_MSG_STD(_T("Looking for: path: ") + path.substr(0, pos) + _T(", pattern: ") + path.substr(pos+1)); 
     331  return pattern_type(path.substr(0, pos), path.substr(pos+1)); 
     332} 
     333 
     334typedef std::pair<std::wstring,std::wstring> pattern_type; 
     335pattern_type split_pattern(std::wstring path) { 
     336  std::wstring baseDir; 
     337  if (file_helpers::checks::exists(path)) { 
     338    return pattern_type(path, _T("")); 
     339  } 
     340  std::wstring::size_type pos = path.find_last_of('\\'); 
     341  if (pos == std::wstring::npos) { 
     342    pattern_type(path, _T("*.*")); 
     343  } 
     344  NSC_DEBUG_MSG_STD(_T("Looking for: pattern: ") + path.substr(0, pos) + _T(", pattern: ") + path.substr(pos+1)); 
    327345  return pattern_type(path.substr(0, pos), path.substr(pos+1)); 
    328346} 
     
    365383    get_size sizeFinder; 
    366384    NSC_error errors; 
    367     pattern_type splitpath = split_path(path.data); 
     385    pattern_type splitpath = split_pattern(path.data); 
    368386    recursive_scan<get_size>(splitpath.first, splitpath.second, -1, -1, sizeFinder, &errors); 
    369387    if (sizeFinder.hasError()) { 
     
    653671 
    654672  NSC_error errors; 
    655   pattern_type splitpath = split_path(path); 
     673  pattern_type splitpath = split_pattern(path); 
    656674  recursive_scan<find_first_file_info>(splitpath.first, splitpath.second, -1, -1, finder, &errors); 
    657675  if (finder.hasError()) { 
     
    717735  NSC_error errors; 
    718736  for (std::list<std::wstring>::const_iterator pit = paths.begin(); pit != paths.end(); ++pit) { 
    719     pattern_type path = split_path(*pit); 
     737    pattern_type path = split_pattern(*pit); 
    720738    recursive_scan<file_filter_function>(path.first, path.second, 0, max_dir_depth, finder, &errors); 
    721739    if (finder.hasError()) { 
  • modules/CheckEventLog/CheckEventLog-2005.vcproj

    r3692371 rdcd5462  
    613613        Name="VCCLCompilerTool" 
    614614        AdditionalIncludeDirectories="../include;../../include" 
    615         PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;USE_BOOST" 
     615        PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;" 
    616616        UsePrecompiledHeader="2" 
    617617        WarningLevel="3" 
  • modules/CheckEventLog/CheckEventLog.cpp

    r1d53fe0 rdcd5462  
    2929#include <error.hpp> 
    3030#include <map> 
     31#include <vector> 
    3132 
    3233CheckEventLog gCheckEventLog; 
     
    315316 
    316317  std::wstring render_message() { 
    317     DWORD *dwArgs = new DWORD[pevlr_->NumStrings+1]; 
     318    std::vector<std::wstring> args; 
     319    TCHAR* *pArgs = new TCHAR*[pevlr_->NumStrings+1]; 
    318320    TCHAR* p = reinterpret_cast<TCHAR*>(reinterpret_cast<LPBYTE>(pevlr_) + pevlr_->StringOffset); 
    319321    for (unsigned int i =0;i<pevlr_->NumStrings;i++) { 
    320       dwArgs[i] = reinterpret_cast<DWORD>(p); 
     322      args.push_back(p); 
     323      pArgs[i] = p; 
    321324      DWORD len = wcslen(p); 
    322       p += len+1; 
    323     } 
    324  
    325 /* 
    326     TCHAR **_sz = (TCHAR**)GlobalAlloc(GPTR, (pevlr_->NumStrings)*sizeof(TCHAR *)); 
    327     register UINT z; 
    328     TCHAR* p = reinterpret_cast<TCHAR*>(reinterpret_cast<LPBYTE>(pevlr_) + pevlr_->StringOffset); 
    329     for(unsigned int z = 0; z < pevlr_->NumStrings; z++) { 
    330       DWORD len = wcslen(p); 
    331       _sz[z] = (TCHAR *)GlobalAlloc(GPTR, (len+1) * sizeof(TCHAR)); 
    332       wcscpy_s(_sz[z], len, p); 
    333       p += len+1; 
    334     } 
    335 */ 
     325      p = &(p[len+1]); 
     326      //p += len+1; 
     327    } 
     328 
    336329    std::wstring ret; 
    337330    strEx::splitList dlls = strEx::splitEx(get_dll(), _T(";")); 
    338331    for (strEx::splitList::const_iterator cit = dlls.begin(); cit != dlls.end(); ++cit) { 
    339332      //std::wstring msg = error::format::message::from_module((*cit), eventID(), _sz); 
    340       std::wstring msg = error::format::message::from_module((*cit), eventID(), dwArgs); 
    341       if (msg.empty()) { 
    342         msg = error::format::message::from_module((*cit), pevlr_->EventID, dwArgs); 
     333      std::wstring msg; 
     334      try { 
     335        msg = error::format::message::from_module_x64((*cit), eventID(), pArgs, pevlr_->NumStrings); 
     336        if (msg.empty()) { 
     337          msg = error::format::message::from_module_x64((*cit), pevlr_->EventID, pArgs, pevlr_->NumStrings); 
     338        } 
     339      } catch (...) { 
     340        msg = _T("Unknown exception getting message"); 
    343341      } 
    344342      strEx::replace(msg, _T("\n"), _T(" ")); 
     
    354352      } 
    355353    } 
    356     delete [] dwArgs; 
     354    delete [] pArgs; 
    357355    return ret; 
    358356  } 
     
    597595    return NSCAPI::returnUNKNOWN; 
    598596  } 
     597  bool buffer_error_reported = false; 
    599598 
    600599  for (std::list<std::wstring>::const_iterator cit2 = files.begin(); cit2 != files.end(); ++cit2) { 
     
    628627        DWORD err = GetLastError(); 
    629628        if (err == ERROR_INSUFFICIENT_BUFFER) { 
    630           NSC_LOG_ERROR_STD(_T("EvenlogBuffer is too small change the value of ") + EVENTLOG_BUFFER + _T("=") + strEx::itos(dwNeeded+1) + _T(" under [EventLog] in nsc.ini : ") + error::lookup::last_error(err)); 
     629          if (!buffer_error_reported) { 
     630            NSC_LOG_ERROR_STD(_T("EvenlogBuffer is too small change the value of ") + EVENTLOG_BUFFER + _T("=") + strEx::itos(dwNeeded+1) + _T(" under [EventLog] in nsc.ini : ") + error::lookup::last_error(err)); 
     631            buffer_error_reported = true; 
     632          } 
    631633        } else if (err == ERROR_HANDLE_EOF) { 
    632634          break; 
  • modules/NRPEListener/NRPEListener.cpp

    rb39c1f3 rdcd5462  
    324324      } catch (NRPEPacket::NRPEPacketException e) { 
    325325        NSC_LOG_ERROR_STD(_T("NRPESocketException: ") + e.getMessage()); 
    326         NRPEPacket err(NRPEPacket::responsePacket, NRPEPacket::version2, NSCAPI::returnUNKNOWN, _T("Could not construct return paket in NRPE handler check clientside (nsclient.log) logs..."), buffer_length_); 
    327326        try { 
    328           block.copyFrom(out.getBuffer(), out.getBufferLength()); 
     327          NRPEPacket err(NRPEPacket::responsePacket, NRPEPacket::version2, NSCAPI::returnUNKNOWN, _T("Could not construct return paket in NRPE handler check clientside (nsclient.log) logs..."), buffer_length_); 
     328          block.copyFrom(err.getBuffer(), err.getBufferLength()); 
    329329        } catch (NRPEPacket::NRPEPacketException e) { 
    330330          NSC_LOG_ERROR_STD(_T("NRPESocketException (again): ") + e.getMessage()); 
  • modules/NSCAAgent/NSCAThread.cpp

    rb1ac2fa rdcd5462  
    7474  else 
    7575    timeDelta_ = strEx::stoui_as_time(tmpstr); 
     76  timeDelta_ = timeDelta_ / 1000; 
    7677  NSC_DEBUG_MSG_STD(_T("Time difference for NSCA server is: ") + strEx::itos(timeDelta_)); 
    7778  checkIntervall_ = NSCModuleHelper::getSettingsInt(NSCA_AGENT_SECTION_TITLE, NSCA_INTERVAL, NSCA_INTERVAL_DEFAULT); 
Note: See TracChangeset for help on using the changeset viewer.