Changeset 42ff14d in nscp


Ignore:
Timestamp:
01/24/10 18:53:20 (3 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
91f567f, 9bb220f
Parents:
208a88c
Message:

2009-01-24 MickeM

  • Fixed so files locked for reading can be chcked (basic checks)
  • Improved speed of file chyecking (does not check file data twice)

2009-01-23 MickeM

+ Added checks for missing path and missing filter on CheckFile2 thus

CheckFile2 without paths and/or filters will have status unknown.

  • Changed "missing" disks are now a critical error and not unknown
  • Improved CheckDriveSize bad FilterType? error message + Added checks for missing counters to CheckCounter + Added new thread safe PDH subsystem (switch using the new option pdh_subsystem=thread-safe (normal mode is fast). The reason for this new subsystem is to allow reloading counters and get around some quirks in various PDH implementations (mainly HP) Added benefits of this new mode is that you can now reload counters which are changed during runtime. This is done by adding the reload flag to the CheckCounter command. THIS IS AN ADVANCED FEATURE (so dont use unless you know what you are doing) + Added new index option to CheckCounter to allow looking up index and thus you can use the same checks on multiple locales and also use characters not present in "NRPE charset)

CheckCounter index "Counter=\1450(_Total)\1458" ShowAll MaxWarn=500 MaxCrit=1000

same as

CheckCounter "Counter=
Utskriftskö(_Total)
Utskrifter" ShowAll MaxWarn=500 MaxCrit=1000

To find index you can use the command line options:

nsclient++ -noboot CheckSystem pdhlookup Utskrifter

Files:
10 added
2 deleted
17 edited
1 moved

Legend:

Unmodified
Added
Removed
  • AutoBuild.h

    r208a88c r42ff14d  
    33// change the FALSE to TRUE for autoincrement of build number 
    44#define INCREMENT_VERSION TRUE 
    5 #define FILEVER        0,3,8,3 
    6 #define PRODUCTVER     0,3,8,3 
    7 #define STRFILEVER     _T("0.3.8.3") 
    8 #define STRPRODUCTVER  _T("0.3.8.3") 
    9 #define STRPRODUCTDATE  _T("2009-12-31") 
     5#define FILEVER        0,3,8,10 
     6#define PRODUCTVER     0,3,8,10 
     7#define STRFILEVER     _T("0.3.8.10") 
     8#define STRPRODUCTVER  _T("0.3.8.10") 
     9#define STRPRODUCTDATE  _T("2010-01-24") 
    1010#endif // AUTOBUILD_H 
  • NSC.dist

    r1fc246c r42ff14d  
    179179;allow_nasty_meta_chars=0 
    180180; 
    181 ;# COMMAND ALLOW NASTY META CHARS 
    182 ;  This option determines whether or not the NRPE daemon will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments. 
     181;# SCRIPT DIRECTORY 
     182;  All files in this directory will become check commands. 
     183;  *WARNING* This is undoubtedly dangerous so use with care! 
    183184;script_dir=c:\my\script\dir 
    184185 
  • changelog

    r208a88c r42ff14d  
    66 * Fix depend onservice LanManWorkStation (old win) 
    77 * Fix RtlStringFromGUID problem on NT4 
     8 
     92009-01-24 MickeM 
     10 * Fixed so files locked for reading can be chcked (basic checks) 
     11 * Improved speed of file chyecking (does not check file data twice) 
     12 
     132009-01-23 MickeM 
     14 + Added checks for missing path and missing filter on CheckFile2 thus 
     15    CheckFile2 without paths and/or filters will have status unknown. 
     16 * Changed "missing" disks are now a critical error and not unknown 
     17 * Improved CheckDriveSize bad FilterType error message 
     18 + Added checks for missing counters to CheckCounter 
     19 + Added new thread safe PDH subsystem (switch using the new option pdh_subsystem=thread-safe (normal mode is fast). 
     20   The reason for this new subsystem is to allow reloading counters and get around some quirks in various PDH implementations (mainly HP) 
     21   Added benefits of this new mode is that you can now reload counters which are changed during runtime. 
     22   This is done by adding the reload flag to the CheckCounter command. 
     23   THIS IS AN ADVANCED FEATURE (so dont use unless you know what you are doing) 
     24 + Added new index option to CheckCounter to allow looking up index and thus you can use the same checks on multiple locales and also use characters not present in "NRPE charset) 
     25    CheckCounter index "Counter=\1450(_Total)\1458" ShowAll MaxWarn=500 MaxCrit=1000 
     26   same as 
     27    CheckCounter "Counter=\\Utskriftskö(_Total)\\Utskrifter" ShowAll MaxWarn=500 MaxCrit=1000 
     28   To find index you can use the command line options: 
     29    nsclient++ -noboot CheckSystem pdhlookup Utskrifter 
    830 
    9312009-12-31 MickeM 
  • include/config.h

    re7dbac9 r42ff14d  
    140140#define C_SYSTEM_IGNORE_COLLECTION _T("debug_skip_data_collection") 
    141141#define C_SYSTEM_IGNORE_COLLECTION_DEFAULT 0 
     142#define C_SYSTEM_PDH_SUBSYSTEM _T("pdh_subsystem") 
     143#define C_SYSTEM_PDH_SUBSYSTEM_DEFAULT _T("fast") 
    142144 
    143145#define C_SYSTEM_MEM_PAGE_LIMIT _T("MemoryCommitLimit") 
  • include/error.hpp

    rdcd5462 r42ff14d  
    1717      TCHAR *szBuf = new TCHAR[dwRet + 100]; 
    1818      wsprintf(szBuf, _T("%d: %s"), dwError, lpMsgBuf);  
     19      strEx::strip_CRLF(szBuf); 
    1920      std::wstring str = szBuf; 
    2021      delete [] szBuf; 
     
    3031      } 
    3132      TCHAR *szBuf = new TCHAR[dwRet + 100]; 
    32       wsprintf(szBuf, _T("%d: %s"), dwError, lpMsgBuf);  
     33      wsprintf(szBuf, _T("%s (%X)"), lpMsgBuf, dwError); 
     34      strEx::strip_CRLF(szBuf); 
    3335      std::wstring str = szBuf; 
    3436      delete [] szBuf; 
     
    4951      } 
    5052      TCHAR *szBuf = new TCHAR[dwRet + 100]; 
    51       wsprintf(szBuf, _T("%d: %s"), dwError, lpMsgBuf);  
     53      wsprintf(szBuf, _T("%s (%X)"), lpMsgBuf, dwError); 
     54      strEx::strip_CRLF(szBuf); 
    5255      std::wstring str = szBuf; 
    5356      delete [] szBuf; 
  • include/pdh/collectors.hpp

    r3692371 r42ff14d  
    2121#pragma once 
    2222 
    23 #include <PDHCounter.h> 
     23#include <pdh/core.hpp> 
     24#include <pdh/counters.hpp> 
     25//#include <pdh.hpp> 
    2426#include <Mutex.h> 
    2527namespace PDHCollectors { 
     
    208210      PDHCounterMutexHandler mutex(&mutex_); 
    209211      if (!mutex.hasLock()) 
    210         throw PDHException(get_name(), _T("Could not get mutex")); 
     212        throw PDHException(get_name(), std::wstring(_T("Could not get mutex"))); 
    211213      if (!hasValue_) 
    212         throw PDHException(get_name(), _T("No value has been collected yet")); 
     214        throw PDHException(get_name(), std::wstring(_T("No value has been collected yet"))); 
    213215      return value_; 
    214216    } 
  • include/strEx.h

    r1fc246c r42ff14d  
    209209    filetime /= SECS_TO_100NS; 
    210210    return format_date(static_cast<time_t>(filetime), format); 
     211  } 
     212 
     213  inline void strip_CRLF(wchar_t *string) { 
     214    int len = wcslen(string); 
     215    for (int i=0;i<len;i++) { 
     216      if (string[i] == 10 || string[i] == 13) 
     217        string[i] = L' '; 
     218    } 
    211219  } 
    212220 
  • modules/CheckDisk/CheckDisk.cpp

    r208a88c r42ff14d  
    7575 
    7676 
     77 
    7778struct file_finder_data { 
    7879  file_finder_data(const WIN32_FIND_DATA wfd_, const std::wstring path_, error_reporter *errors_) : wfd(wfd_), path(path_), errors(errors_) {} 
     
    169170  bool bFilterFixed = false; 
    170171  bool bFilterCDROM = false; 
     172  bool bFilterNoRootDir = false; 
    171173  bool bCheckAllDrives = false; 
    172174  bool bCheckAllOthers = false; 
     
    184186    MAP_OPTIONS_BOOL_VALUE(_T("FilterType"), bFilterRemovable, _T("REMOVABLE")) 
    185187    MAP_OPTIONS_BOOL_VALUE(_T("FilterType"), bFilterRemote, _T("REMOTE")) 
     188    MAP_OPTIONS_BOOL_VALUE(_T("FilterType"), bFilterNoRootDir, _T("NO_ROOT_DIR")) 
    186189    MAP_OPTIONS_BOOL_FALSE(IGNORE_PERFDATA, bPerfData) 
    187190    MAP_OPTIONS_BOOL_TRUE(NSCLIENT, bNSClient) 
     
    213216 
    214217        UINT drvType = GetDriveType(drv.c_str()); 
    215         if ( ((!bFilter)&&(drvType == DRIVE_FIXED))  || 
     218        if (  
     219          ((!bFilter)&&(drvType == DRIVE_FIXED))  || 
    216220          ((bFilter)&&(bFilterFixed)&&(drvType==DRIVE_FIXED)) || 
    217221          ((bFilter)&&(bFilterCDROM)&&(drvType==DRIVE_CDROM)) || 
    218222          ((bFilter)&&(bFilterRemote)&&(drvType==DRIVE_REMOTE)) || 
    219           ((bFilter)&&(bFilterRemovable)&&(drvType==DRIVE_REMOVABLE)) ) 
     223          ((bFilter)&&(bFilterRemovable)&&(drvType==DRIVE_REMOVABLE)) || 
     224          ((bFilter)&&(bFilterNoRootDir)&&(drvType==DRIVE_NO_ROOT_DIR))  
     225          ) 
    220226          drives.push_back(DriveContainer(drv, tmpObject.warn, tmpObject.crit)); 
    221227 
     
    240246          ((bFilter)&&(bFilterCDROM)&&(drvType==DRIVE_CDROM)) || 
    241247          ((bFilter)&&(bFilterRemote)&&(drvType==DRIVE_REMOTE)) || 
    242           ((bFilter)&&(bFilterRemovable)&&(drvType==DRIVE_REMOVABLE)) ) 
     248          ((bFilter)&&(bFilterRemovable)&&(drvType==DRIVE_REMOVABLE)) || 
     249          ((bFilter)&&(bFilterNoRootDir)&&(drvType==DRIVE_NO_ROOT_DIR))  
     250          ) 
    243251          drives.push_back(DriveContainer(drv, tmpObject.warn, tmpObject.crit)); 
    244252      } 
     
    260268          ((bFilter)&&(bFilterCDROM)&&(drvType==DRIVE_CDROM)) || 
    261269          ((bFilter)&&(bFilterRemote)&&(drvType==DRIVE_REMOTE)) || 
    262           ((bFilter)&&(bFilterRemovable)&&(drvType==DRIVE_REMOVABLE)) )   
     270          ((bFilter)&&(bFilterRemovable)&&(drvType==DRIVE_REMOVABLE)) || 
     271          ((bFilter)&&(bFilterNoRootDir)&&(drvType==DRIVE_NO_ROOT_DIR))  
     272          )   
    263273        { 
    264274          bool bFound = false; 
     
    289299      message = _T("UNKNOWN: Drive is not a fixed drive: ") + drive.getAlias() + _T(" (it is a ") + get_filter(drvType) + _T(" drive)"); 
    290300      return NSCAPI::returnUNKNOWN; 
    291     } else if ( (bFilter)&&( (!bFilterFixed)&&((drvType==DRIVE_FIXED)||(drvType==DRIVE_NO_ROOT_DIR))) || 
     301    } else if ( (bFilter)&& 
     302      ( 
     303      ((!bFilterFixed)&&((drvType==DRIVE_FIXED)||(drvType==DRIVE_NO_ROOT_DIR))) || 
    292304      ((!bFilterCDROM)&&(drvType==DRIVE_CDROM)) || 
    293305      ((!bFilterRemote)&&(drvType==DRIVE_REMOTE)) || 
    294       ((!bFilterRemovable)&&(drvType==DRIVE_REMOVABLE)) ) { 
    295         message = _T("UNKNOWN: Drive does not match the current filter: ") + drive.getAlias() + _T(" (it is a ") + get_filter(drvType) + _T(" drive)"); 
     306      ((!bFilterRemovable)&&(drvType==DRIVE_REMOVABLE))  
     307      )) { 
     308        message = _T("UNKNOWN: Drive does not match the current filter: ") + drive.getAlias() + _T(" (add FilterType=") + get_filter(drvType) + _T(" to check this drive)"); 
    296309        return NSCAPI::returnUNKNOWN; 
    297310    } 
     
    301314    ULARGE_INTEGER totalNumberOfFreeBytes; 
    302315    if (!GetDiskFreeSpaceEx(drive.data.c_str(), &freeBytesAvailableToCaller, &totalNumberOfBytes, &totalNumberOfFreeBytes)) { 
    303       message = _T("UNKNOWN: Could not get free space for: ") + drive.getAlias() + _T(" ") + drive.data + _T(" reason: ") + error::lookup::last_error(); 
    304       return NSCAPI::returnUNKNOWN; 
     316      message = _T("CRITICAL: Could not get free space for: ") + drive.getAlias() + _T(" ") + drive.data + _T(" reason: ") + error::lookup::last_error(); 
     317      return NSCAPI::returnCRIT; 
    305318    } 
    306319 
     
    329342std::wstring CheckDisk::get_filter(unsigned int drvType) { 
    330343  if (drvType==DRIVE_FIXED) 
    331     return _T("fixed"); 
     344    return _T("FIXED"); 
    332345  if (drvType==DRIVE_NO_ROOT_DIR) 
    333     return _T("no_root"); 
     346    return _T("NO_ROOT_DIR"); 
    334347  if (drvType==DRIVE_CDROM) 
    335     return _T("cdrom"); 
     348    return _T("CDROM"); 
    336349  if (drvType==DRIVE_REMOTE) 
    337     return _T("remote"); 
     350    return _T("REMOTE"); 
    338351  if (drvType==DRIVE_REMOVABLE) 
    339     return _T("removable"); 
     352    return _T("REMOVABLE"); 
    340353  return _T("unknown: ") + strEx::itos(drvType); 
    341354} 
     
    437450 
    438451struct file_info { 
     452 
     453  std::wstring error; 
     454  bool has_error; 
     455 
     456  static file_info get(std::wstring path, std::wstring file) { 
     457    return get_2(path, file); 
     458  } 
     459  static file_info get(file_finder_data data) { 
     460    return file_info(data.wfd, data.path, data.wfd.cFileName); 
     461  } 
     462 
     463  static file_info get_2(std::wstring path, std::wstring file) { 
     464    WIN32_FILE_ATTRIBUTE_DATA data; 
     465    if (!GetFileAttributesEx((path + _T("\\") + file).c_str(), GetFileExInfoStandard, reinterpret_cast<LPVOID>(&data))) { 
     466      file_info ret; 
     467      ret.error = _T("Could not open file (2) ") + path + _T("\\") + file + _T(": ") + error::lookup::last_error(); 
     468      return ret; 
     469    } 
     470    return file_info(data, path, file); 
     471  } 
     472  static file_info get_1(std::wstring path, std::wstring file) { 
     473    HANDLE hFile = CreateFile((path + _T("\\") + file).c_str(), FILE_READ_ATTRIBUTES, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); 
     474    if (hFile == INVALID_HANDLE_VALUE) { 
     475      file_info ret; 
     476      ret.error = _T("Could not open file (1) ") + path + _T("\\") + file + _T(": ") + error::lookup::last_error(); 
     477      return ret; 
     478    } 
     479    BY_HANDLE_FILE_INFORMATION _info; 
     480    GetFileInformationByHandle(hFile, &_info); 
     481    CloseHandle(hFile); 
     482    return file_info(_info, path, file); 
     483  } 
     484 
    439485  file_info()  
    440486    : ullCreationTime(0) 
     
    445491    , cached_count(false, 0) 
    446492  {} 
     493  file_info(const WIN32_FILE_ATTRIBUTE_DATA info, std::wstring path_, std::wstring filename_)  
     494    : path(path_) 
     495    , filename(filename_) 
     496    , ullCreationTime(0) 
     497    , ullLastAccessTime(0) 
     498    , ullLastWriteTime(0) 
     499    , ullSize(0) 
     500    , cached_version(false, _T(""))  
     501    , cached_count(false, 0) 
     502  { 
     503    ullSize = ((info.nFileSizeHigh * ((unsigned long long)MAXDWORD+1)) + (unsigned long long)info.nFileSizeLow); 
     504    ullCreationTime = ((info.ftCreationTime.dwHighDateTime * ((unsigned long long)MAXDWORD+1)) + (unsigned long long)info.ftCreationTime.dwLowDateTime); 
     505    ullLastAccessTime = ((info.ftLastAccessTime.dwHighDateTime * ((unsigned long long)MAXDWORD+1)) + (unsigned long long)info.ftLastAccessTime.dwLowDateTime); 
     506    ullLastWriteTime = ((info.ftLastWriteTime.dwHighDateTime * ((unsigned long long)MAXDWORD+1)) + (unsigned long long)info.ftLastWriteTime.dwLowDateTime); 
     507  }; 
    447508  file_info(const BY_HANDLE_FILE_INFORMATION info, std::wstring path_, std::wstring filename_)  
    448509    : path(path_) 
     
    455516    , cached_count(false, 0) 
    456517  { 
    457     std::wcout << _T("[") << filename_ << _T("]") << std::endl; 
    458     std::cout << "C: " << info.ftCreationTime.dwHighDateTime << ":" << info.ftCreationTime.dwLowDateTime << std::endl; 
    459     std::cout << "A: " << info.ftLastAccessTime.dwHighDateTime << ":" << info.ftLastAccessTime.dwLowDateTime << std::endl; 
    460     std::cout << "M: " << info.ftLastWriteTime.dwHighDateTime << ":" << info.ftLastWriteTime.dwLowDateTime << std::endl; 
     518    ullSize = ((info.nFileSizeHigh * ((unsigned long long)MAXDWORD+1)) + (unsigned long long)info.nFileSizeLow); 
     519    ullCreationTime = ((info.ftCreationTime.dwHighDateTime * ((unsigned long long)MAXDWORD+1)) + (unsigned long long)info.ftCreationTime.dwLowDateTime); 
     520    ullLastAccessTime = ((info.ftLastAccessTime.dwHighDateTime * ((unsigned long long)MAXDWORD+1)) + (unsigned long long)info.ftLastAccessTime.dwLowDateTime); 
     521    ullLastWriteTime = ((info.ftLastWriteTime.dwHighDateTime * ((unsigned long long)MAXDWORD+1)) + (unsigned long long)info.ftLastWriteTime.dwLowDateTime); 
     522  }; 
     523  file_info(const WIN32_FIND_DATA info, std::wstring path_, std::wstring filename_)  
     524    : path(path_) 
     525    , filename(filename_) 
     526    , ullCreationTime(0) 
     527    , ullLastAccessTime(0) 
     528    , ullLastWriteTime(0) 
     529    , ullSize(0) 
     530    , cached_version(false, _T(""))  
     531    , cached_count(false, 0) 
     532  { 
    461533    ullSize = ((info.nFileSizeHigh * ((unsigned long long)MAXDWORD+1)) + (unsigned long long)info.nFileSizeLow); 
    462534    ullCreationTime = ((info.ftCreationTime.dwHighDateTime * ((unsigned long long)MAXDWORD+1)) + (unsigned long long)info.ftCreationTime.dwLowDateTime); 
     
    626698    if (is_directory(ffd.wfd.dwFileAttributes)) 
    627699      return true; 
     700 
     701    file_info info = file_info::get(ffd); 
     702    if (!info.error.empty()) { 
     703      setError(ffd.errors, info.error); 
     704      return false; 
     705    } 
     706    return false; 
     707    /* 
    628708    BY_HANDLE_FILE_INFORMATION _info; 
    629709 
    630     HANDLE hFile = CreateFile((ffd.path + _T("\\") + ffd.wfd.cFileName).c_str(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 
     710    HANDLE hFile = CreateFile((ffd.path + _T("\\") + ffd.wfd.cFileName).c_str(), FILE_READ_ATTRIBUTES, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 
    631711      0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); 
    632712    if (hFile == INVALID_HANDLE_VALUE) { 
     
    638718    info = file_info(_info, ffd.path, ffd.wfd.cFileName); 
    639719    return false; 
     720    */ 
    640721  } 
    641722  inline const bool hasError() const { 
     
    665746    if (is_directory(ffd.wfd.dwFileAttributes)) 
    666747      return true; 
     748 
     749    file_info info = file_info::get(ffd); 
     750    if (!info.error.empty()) { 
     751      setError(ffd.errors, info.error); 
     752      return true; 
     753    } 
     754    /* 
    667755    BY_HANDLE_FILE_INFORMATION _info; 
    668756 
    669     HANDLE hFile = CreateFile((ffd.path + _T("\\") + ffd.wfd.cFileName).c_str(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 
     757    HANDLE hFile = CreateFile((ffd.path + _T("\\") + ffd.wfd.cFileName).c_str(), FILE_READ_ATTRIBUTES, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 
    670758      0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); 
    671759    if (hFile == INVALID_HANDLE_VALUE) { 
     
    677765    file_info info(_info, ffd.path, ffd.wfd.cFileName); 
    678766    info.ullNow = now; 
     767    */ 
    679768 
    680769    for (std::list<file_filter>::const_iterator cit3 = filter_chain.begin(); cit3 != filter_chain.end(); ++cit3 ) { 
     
    741830    if (is_directory(ffd.wfd.dwFileAttributes)) 
    742831      return true; 
     832 
     833    file_info info = file_info::get(ffd); 
     834    if (!info.error.empty()) { 
     835      setError(ffd.errors, info.error); 
     836      return true; 
     837    } 
     838    /* 
    743839    BY_HANDLE_FILE_INFORMATION _info; 
    744840 
    745     HANDLE hFile = CreateFile((ffd.path + _T("\\") + ffd.wfd.cFileName).c_str(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 
     841    HANDLE hFile = CreateFile((ffd.path + _T("\\") + ffd.wfd.cFileName).c_str(), FILE_READ_ATTRIBUTES, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 
    746842      0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); 
    747843    if (hFile == INVALID_HANDLE_VALUE) { 
     
    753849    file_info info(_info, ffd.path, ffd.wfd.cFileName); 
    754850    info.ullNow = now; 
     851    */ 
    755852 
    756853    bool bMatch = !bFilterIn; 
     
    808905    strEx::replace(syntax, _T("%files%"), strEx::itos(file_count)); 
    809906    return syntax; 
     907  } 
     908 
     909  bool has_filter() { 
     910    return !filter_chain.empty(); 
    810911  } 
    811912 
     
    10101111    message = e.getMessage(); 
    10111112    return NSCAPI::returnUNKNOWN; 
    1012     } 
    1013     FILETIME now; 
    1014     GetSystemTimeAsFileTime(&now); 
    1015     finder.debug_ = debug; 
    1016     finder.now = ((now.dwHighDateTime * ((unsigned long long)MAXDWORD+1)) + (unsigned long long)now.dwLowDateTime); 
    1017     if (debug) 
    1018       NSC_DEBUG_MSG_STD(_T("NOW: ") + strEx::format_filetime(finder.now)); 
    1019     finder.syntax = syntax; 
    1020     NSC_error errors; 
    1021     for (std::list<std::wstring>::const_iterator pit = paths.begin(); pit != paths.end(); ++pit) { 
    1022       recursive_scan<file_filter_function_ex>(*pit, pattern, 0, max_dir_depth, finder, &errors, debug); 
    1023       if (!ignoreError && finder.hasError()) { 
    1024         message = _T("Error when scanning: ") + (*pit) + _T(" check log for details (") + strEx::itos(finder.error_count) + _T(": ") + finder.last_error + _T(")"); 
    1025         return NSCAPI::returnUNKNOWN; 
    1026       } 
    1027     } 
    1028     message  = finder.render(masterSyntax); 
    1029     if (!alias.empty()) 
    1030       query.alias = alias; 
    1031     else 
    1032       query.alias = _T("found files"); 
    1033     query.runCheck(finder.hit_count, returnCode, message, perf); 
    1034     if ((truncate > 0) && (message.length() > (truncate-4))) { 
    1035       message = message.substr(0, truncate-4) + _T("..."); 
    1036       //perf = _T(""); 
    1037     } 
    1038     if (message.empty()) 
    1039       message = _T("CheckFile ok"); 
    1040     return returnCode; 
     1113  } 
     1114  if (paths.empty()) { 
     1115    message = _T("Missing path argument"); 
     1116    return NSCAPI::returnUNKNOWN; 
     1117  } 
     1118  if (!finder.has_filter()) { 
     1119    message = _T("Missing filter argument"); 
     1120    return NSCAPI::returnUNKNOWN; 
     1121  } 
     1122  FILETIME now; 
     1123  GetSystemTimeAsFileTime(&now); 
     1124  finder.debug_ = debug; 
     1125  finder.now = ((now.dwHighDateTime * ((unsigned long long)MAXDWORD+1)) + (unsigned long long)now.dwLowDateTime); 
     1126  if (debug) 
     1127    NSC_DEBUG_MSG_STD(_T("NOW: ") + strEx::format_filetime(finder.now)); 
     1128  finder.syntax = syntax; 
     1129  NSC_error errors; 
     1130  for (std::list<std::wstring>::const_iterator pit = paths.begin(); pit != paths.end(); ++pit) { 
     1131    recursive_scan<file_filter_function_ex>(*pit, pattern, 0, max_dir_depth, finder, &errors, debug); 
     1132    if (!ignoreError && finder.hasError()) { 
     1133      message = _T("Error when scanning: ") + (*pit) + _T(" check log for details (") + strEx::itos(finder.error_count) + _T(": ") + finder.last_error + _T(")"); 
     1134      return NSCAPI::returnUNKNOWN; 
     1135    } 
     1136  } 
     1137  message  = finder.render(masterSyntax); 
     1138  if (!alias.empty()) 
     1139    query.alias = alias; 
     1140  else 
     1141    query.alias = _T("found files"); 
     1142  query.runCheck(finder.hit_count, returnCode, message, perf); 
     1143  if ((truncate > 0) && (message.length() > (truncate-4))) { 
     1144    message = message.substr(0, truncate-4) + _T("..."); 
     1145    //perf = _T(""); 
     1146  } 
     1147  if (message.empty()) 
     1148    message = _T("CheckFile ok"); 
     1149  return returnCode; 
    10411150} 
    10421151struct file_container : public file_info { 
    10431152  std::wstring error_; 
    1044    
     1153 
     1154  static file_container get(std::wstring file, unsigned long long now) { 
     1155 
     1156    BY_HANDLE_FILE_INFORMATION _info; 
     1157 
     1158    HANDLE hFile = CreateFile(file.c_str(), FILE_READ_ATTRIBUTES, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 
     1159      0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); 
     1160    if (hFile == INVALID_HANDLE_VALUE) { 
     1161      return file_container(file, _T("Could not open file: ") + file); 
     1162    } 
     1163    GetFileInformationByHandle(hFile, &_info); 
     1164    CloseHandle(hFile); 
     1165    file_container info(_info, file); 
     1166    info.ullNow = now; 
     1167    return info; 
     1168  } 
     1169 
    10451170 
    10461171  file_container(const BY_HANDLE_FILE_INFORMATION info, std::wstring file) : file_info(info, file_helpers::meta::get_path(file), file_helpers::meta::get_filename(file)) {} 
     
    11201245  } 
    11211246}; 
    1122  
    1123 file_container get_file_info(std::wstring file, unsigned long long now) { 
    1124  
    1125   BY_HANDLE_FILE_INFORMATION _info; 
    1126  
    1127   HANDLE hFile = CreateFile(file.c_str(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 
    1128     0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); 
    1129   if (hFile == INVALID_HANDLE_VALUE) { 
    1130     return file_container(file, _T("Could not open file: ") + file); 
    1131   } 
    1132   GetFileInformationByHandle(hFile, &_info); 
    1133   CloseHandle(hFile); 
    1134   file_container info(_info, file); 
    1135   info.ullNow = now; 
    1136   return info; 
    1137 } 
    11381247 
    11391248#define MAP_FACTORY_PB(value, obj) \ 
     
    11921301  //finder.syntax = syntax; 
    11931302  for (std::list<std::wstring>::const_iterator pit = files.begin(); pit != files.end(); ++pit) { 
    1194     file_container info = get_file_info(*pit, nowi64); 
     1303    file_container info = file_container::get(*pit, nowi64); 
    11951304    checker.alias = info.render(syntax); 
    11961305    checker.runCheck(info, returnCode, message, perf); 
  • modules/CheckSystem/CheckSystem-2005.vcproj

    r3692371 r42ff14d  
    6969      <Tool 
    7070        Name="VCLinkerTool" 
    71         AdditionalDependencies="Pdh.lib" 
    7271        OutputFile="$(OutDir)\$(ProjectName).dll" 
    7372        LinkIncremental="2" 
     
    20382037      </File> 
    20392038      <File 
    2040         RelativePath="..\..\include\PDHCounter.cpp" 
    2041         > 
    2042         <FileConfiguration 
    2043           Name="Debug|Win32" 
    2044           > 
    2045           <Tool 
    2046             Name="VCCLCompilerTool" 
    2047             UsePrecompiledHeader="0" 
    2048           /> 
    2049         </FileConfiguration> 
    2050         <FileConfiguration 
    2051           Name="Debug|x64" 
    2052           > 
    2053           <Tool 
    2054             Name="VCCLCompilerTool" 
    2055             UsePrecompiledHeader="0" 
    2056           /> 
    2057         </FileConfiguration> 
    2058         <FileConfiguration 
    2059           Name="Release|Win32" 
    2060           > 
    2061           <Tool 
    2062             Name="VCCLCompilerTool" 
    2063             UsePrecompiledHeader="0" 
    2064           /> 
    2065         </FileConfiguration> 
    2066         <FileConfiguration 
    2067           Name="Release|x64" 
    2068           > 
    2069           <Tool 
    2070             Name="VCCLCompilerTool" 
    2071             UsePrecompiledHeader="0" 
    2072           /> 
    2073         </FileConfiguration> 
    2074         <FileConfiguration 
    2075           Name="Distribution|Win32" 
    2076           > 
    2077           <Tool 
    2078             Name="VCCLCompilerTool" 
    2079             UsePrecompiledHeader="0" 
    2080           /> 
    2081         </FileConfiguration> 
    2082         <FileConfiguration 
    2083           Name="Distribution|x64" 
    2084           > 
    2085           <Tool 
    2086             Name="VCCLCompilerTool" 
    2087             UsePrecompiledHeader="0" 
    2088           /> 
    2089         </FileConfiguration> 
    2090         <FileConfiguration 
    2091           Name="Nightly|Win32" 
    2092           > 
    2093           <Tool 
    2094             Name="VCCLCompilerTool" 
    2095             UsePrecompiledHeader="0" 
    2096           /> 
    2097         </FileConfiguration> 
    2098         <FileConfiguration 
    2099           Name="Nightly|x64" 
    2100           > 
    2101           <Tool 
    2102             Name="VCCLCompilerTool" 
    2103             UsePrecompiledHeader="0" 
    2104           /> 
    2105         </FileConfiguration> 
    2106         <FileConfiguration 
    2107           Name="Debug-MemCheck|Win32" 
    2108           > 
    2109           <Tool 
    2110             Name="VCCLCompilerTool" 
    2111             UsePrecompiledHeader="0" 
    2112           /> 
    2113         </FileConfiguration> 
    2114         <FileConfiguration 
    2115           Name="Debug-MemCheck|x64" 
    2116           > 
    2117           <Tool 
    2118             Name="VCCLCompilerTool" 
    2119             UsePrecompiledHeader="0" 
    2120           /> 
    2121         </FileConfiguration> 
    2122         <FileConfiguration 
    2123           Name="OP5|Win32" 
    2124           > 
    2125           <Tool 
    2126             Name="VCCLCompilerTool" 
    2127             UsePrecompiledHeader="0" 
    2128           /> 
    2129         </FileConfiguration> 
    2130         <FileConfiguration 
    2131           Name="OP5|x64" 
    2132           > 
    2133           <Tool 
    2134             Name="VCCLCompilerTool" 
    2135             UsePrecompiledHeader="0" 
    2136           /> 
    2137         </FileConfiguration> 
    2138       </File> 
    2139       <File 
    21402039        RelativePath=".\stdafx.cpp" 
    21412040        > 
     
    25732472      </File> 
    25742473      <File 
    2575         RelativePath="..\..\include\PDHCollectors.h" 
    2576         > 
    2577       </File> 
    2578       <File 
    2579         RelativePath="..\..\include\PDHCounter.h" 
    2580         > 
    2581       </File> 
    2582       <File 
    25832474        RelativePath=".\stdafx.h" 
    25842475        > 
     
    25942485      <File 
    25952486        RelativePath="..\..\include\utils.h" 
     2487        > 
     2488      </File> 
     2489    </Filter> 
     2490    <Filter 
     2491      Name="PDH" 
     2492      > 
     2493      <File 
     2494        RelativePath="..\..\include\pdh\basic_impl.cpp" 
     2495        > 
     2496        <FileConfiguration 
     2497          Name="Debug|Win32" 
     2498          > 
     2499          <Tool 
     2500            Name="VCCLCompilerTool" 
     2501            UsePrecompiledHeader="0" 
     2502          /> 
     2503        </FileConfiguration> 
     2504        <FileConfiguration 
     2505          Name="Debug|x64" 
     2506          > 
     2507          <Tool 
     2508            Name="VCCLCompilerTool" 
     2509            UsePrecompiledHeader="0" 
     2510          /> 
     2511        </FileConfiguration> 
     2512        <FileConfiguration 
     2513          Name="Release|Win32" 
     2514          > 
     2515          <Tool 
     2516            Name="VCCLCompilerTool" 
     2517            UsePrecompiledHeader="0" 
     2518          /> 
     2519        </FileConfiguration> 
     2520        <FileConfiguration 
     2521          Name="Release|x64" 
     2522          > 
     2523          <Tool 
     2524            Name="VCCLCompilerTool" 
     2525            UsePrecompiledHeader="0" 
     2526          /> 
     2527        </FileConfiguration> 
     2528        <FileConfiguration 
     2529          Name="Distribution|Win32" 
     2530          > 
     2531          <Tool 
     2532            Name="VCCLCompilerTool" 
     2533            UsePrecompiledHeader="0" 
     2534          /> 
     2535        </FileConfiguration> 
     2536        <FileConfiguration 
     2537          Name="Distribution|x64" 
     2538          > 
     2539          <Tool 
     2540            Name="VCCLCompilerTool" 
     2541            UsePrecompiledHeader="0" 
     2542          /> 
     2543        </FileConfiguration> 
     2544        <FileConfiguration 
     2545          Name="Nightly|Win32" 
     2546          > 
     2547          <Tool 
     2548            Name="VCCLCompilerTool" 
     2549            UsePrecompiledHeader="0" 
     2550          /> 
     2551        </FileConfiguration> 
     2552        <FileConfiguration 
     2553          Name="Nightly|x64" 
     2554          > 
     2555          <Tool 
     2556            Name="VCCLCompilerTool" 
     2557            UsePrecompiledHeader="0" 
     2558          /> 
     2559        </FileConfiguration> 
     2560        <FileConfiguration 
     2561          Name="Debug-MemCheck|Win32" 
     2562          > 
     2563          <Tool 
     2564            Name="VCCLCompilerTool" 
     2565            UsePrecompiledHeader="0" 
     2566          /> 
     2567        </FileConfiguration> 
     2568        <FileConfiguration 
     2569          Name="Debug-MemCheck|x64" 
     2570          > 
     2571          <Tool 
     2572            Name="VCCLCompilerTool" 
     2573            UsePrecompiledHeader="0" 
     2574          /> 
     2575        </FileConfiguration> 
     2576        <FileConfiguration 
     2577          Name="OP5|Win32" 
     2578          > 
     2579          <Tool 
     2580            Name="VCCLCompilerTool" 
     2581            UsePrecompiledHeader="0" 
     2582          /> 
     2583        </FileConfiguration> 
     2584        <FileConfiguration 
     2585          Name="OP5|x64" 
     2586          > 
     2587          <Tool 
     2588            Name="VCCLCompilerTool" 
     2589            UsePrecompiledHeader="0" 
     2590          /> 
     2591        </FileConfiguration> 
     2592      </File> 
     2593      <File 
     2594        RelativePath="..\..\include\pdh\basic_impl.hpp" 
     2595        > 
     2596      </File> 
     2597      <File 
     2598        RelativePath="..\..\include\pdh\collectors.hpp" 
     2599        > 
     2600      </File> 
     2601      <File 
     2602        RelativePath="..\..\include\pdh\core.cpp" 
     2603        > 
     2604        <FileConfiguration 
     2605          Name="Debug|Win32" 
     2606          > 
     2607          <Tool 
     2608            Name="VCCLCompilerTool" 
     2609            UsePrecompiledHeader="0" 
     2610          /> 
     2611        </FileConfiguration> 
     2612        <FileConfiguration 
     2613          Name="Debug|x64" 
     2614          > 
     2615          <Tool 
     2616            Name="VCCLCompilerTool" 
     2617            UsePrecompiledHeader="0" 
     2618          /> 
     2619        </FileConfiguration> 
     2620        <FileConfiguration 
     2621          Name="Release|Win32" 
     2622          > 
     2623          <Tool 
     2624            Name="VCCLCompilerTool" 
     2625            UsePrecompiledHeader="0" 
     2626          /> 
     2627        </FileConfiguration> 
     2628        <FileConfiguration 
     2629          Name="Release|x64" 
     2630          > 
     2631          <Tool 
     2632            Name="VCCLCompilerTool" 
     2633            UsePrecompiledHeader="0" 
     2634          /> 
     2635        </FileConfiguration> 
     2636        <FileConfiguration 
     2637          Name="Distribution|Win32" 
     2638          > 
     2639          <Tool 
     2640            Name="VCCLCompilerTool" 
     2641            UsePrecompiledHeader="0" 
     2642          /> 
     2643        </FileConfiguration> 
     2644        <FileConfiguration 
     2645          Name="Distribution|x64" 
     2646          > 
     2647          <Tool 
     2648            Name="VCCLCompilerTool" 
     2649            UsePrecompiledHeader="0" 
     2650          /> 
     2651        </FileConfiguration> 
     2652        <FileConfiguration 
     2653          Name="Nightly|Win32" 
     2654          > 
     2655          <Tool 
     2656            Name="VCCLCompilerTool" 
     2657            UsePrecompiledHeader="0" 
     2658          /> 
     2659        </FileConfiguration> 
     2660        <FileConfiguration 
     2661          Name="Nightly|x64" 
     2662          > 
     2663          <Tool 
     2664            Name="VCCLCompilerTool" 
     2665            UsePrecompiledHeader="0" 
     2666          /> 
     2667        </FileConfiguration> 
     2668        <FileConfiguration 
     2669          Name="Debug-MemCheck|Win32" 
     2670          > 
     2671          <Tool 
     2672            Name="VCCLCompilerTool" 
     2673            UsePrecompiledHeader="0" 
     2674          /> 
     2675        </FileConfiguration> 
     2676        <FileConfiguration 
     2677          Name="Debug-MemCheck|x64" 
     2678          > 
     2679          <Tool 
     2680            Name="VCCLCompilerTool" 
     2681            UsePrecompiledHeader="0" 
     2682          /> 
     2683        </FileConfiguration> 
     2684        <FileConfiguration 
     2685          Name="OP5|Win32" 
     2686          > 
     2687          <Tool 
     2688            Name="VCCLCompilerTool" 
     2689            UsePrecompiledHeader="0" 
     2690          /> 
     2691        </FileConfiguration> 
     2692        <FileConfiguration 
     2693          Name="OP5|x64" 
     2694          > 
     2695          <Tool 
     2696            Name="VCCLCompilerTool" 
     2697            UsePrecompiledHeader="0" 
     2698          /> 
     2699        </FileConfiguration> 
     2700      </File> 
     2701      <File 
     2702        RelativePath="..\..\include\pdh\core.hpp" 
     2703        > 
     2704      </File> 
     2705      <File 
     2706        RelativePath="..\..\include\pdh\counters.hpp" 
     2707        > 
     2708      </File> 
     2709      <File 
     2710        RelativePath="..\..\include\pdh\enumerations.hpp" 
     2711        > 
     2712      </File> 
     2713      <File 
     2714        RelativePath="..\..\include\pdh\query.hpp" 
     2715        > 
     2716      </File> 
     2717      <File 
     2718        RelativePath="..\..\include\pdh\resolver.hpp" 
     2719        > 
     2720      </File> 
     2721      <File 
     2722        RelativePath="..\..\include\pdh\single_threaded_impl.hpp" 
    25962723        > 
    25972724      </File> 
  • modules/CheckSystem/CheckSystem.cpp

    rb39c1f3 r42ff14d  
    133133            std::wstring error; 
    134134            bool bStatus = true; 
    135             if (PDH::Enumerations::validate(counter, error)) { 
     135            if (PDH::PDHResolver::validate(counter, error, false)) { 
    136136              status.push_back(_T("open")); 
    137137            } else { 
     
    210210          std::wcout << _T("testing: ") << counter << _T(": "); 
    211211          std::wstring error; 
    212           if (PDH::Enumerations::validate(counter, error)) { 
     212          if (PDH::PDHResolver::validate(counter, error, false)) { 
    213213            std::wcout << _T(" found "); 
    214214          } else { 
     
    262262        return 0; 
    263263      } 
    264       DWORD dw = PDH::PDHQuery::lookupIndex(name); 
     264      DWORD dw = PDH::PDHResolver::lookupIndex(name); 
    265265      NSC_LOG_MESSAGE_STD(_T("--+--[ Lookup Result ]----------------------------------------")); 
    266266      NSC_LOG_MESSAGE_STD(_T("  | Index for '") + name + _T("' is ") + strEx::itos(dw)); 
     
    10281028  unsigned int averageDelay = 1000; 
    10291029  CounterContainer tmpObject; 
     1030  bool bExpandIndex = false; 
     1031  bool bForceReload = false; 
    10301032 
    10311033  MAP_OPTIONS_BEGIN(stl_args) 
     
    10411043    MAP_OPTIONS_BOOL_EX(_T("Averages"), bCheckAverages, _T("true"), _T("false")) 
    10421044    MAP_OPTIONS_BOOL_TRUE(NSCLIENT, bNSClient) 
     1045    MAP_OPTIONS_BOOL_TRUE(_T("index"), bExpandIndex) 
     1046    MAP_OPTIONS_BOOL_TRUE(_T("reload"), bForceReload) 
    10431047    MAP_OPTIONS_FIRST_CHAR('\\', tmpObject.data, counters.push_back(tmpObject)) 
    10441048    MAP_OPTIONS_SECONDARY_BEGIN(_T(":"), p2) 
     
    10521056    MAP_OPTIONS_FALLBACK_AND(tmpObject.data, counters.push_back(tmpObject)) 
    10531057  MAP_OPTIONS_END() 
     1058 
     1059  if (counters.empty()) { 
     1060    msg = _T("No counters specified"); 
     1061    return NSCAPI::returnUNKNOWN; 
     1062  } 
     1063 
    10541064  for (std::list<CounterContainer>::const_iterator cit = counters.begin(); cit != counters.end(); ++cit) { 
    10551065    CounterContainer counter = (*cit); 
    10561066    try { 
    10571067      std::wstring tstr; 
    1058       if (!PDH::Enumerations::validate(counter.data, tstr)) { 
     1068      if (bExpandIndex) { 
     1069        PDH::PDHResolver::expand_index(counter.data); 
     1070      } 
     1071      if (!PDH::PDHResolver::validate(counter.data, tstr, bForceReload)) { 
    10591072        NSC_LOG_ERROR_STD(_T("ERROR: Counter not found: ") + counter.data + _T(": ") + tstr); 
    10601073        if (bNSClient) { 
     
    10621075          //msg = _T("0"); 
    10631076        } else { 
    1064           //msg = tstr; 
    1065           //msg += _T(" (") + counter.getAlias() + _T("|") + counter.data + _T(")"); 
     1077          msg = _T("CRIT: Counter not found: ") + counter.data + _T(": ") + tstr; 
     1078          return NSCAPI::returnCRIT; 
    10661079        } 
    1067         //return NSCHelper::translateReturn(invalidStatus); 
    10681080      } 
    10691081      PDH::PDHQuery pdh; 
  • modules/CheckSystem/CheckSystem.h

    r1d53fe0 r42ff14d  
    2121#pragma once 
    2222 
     23#include <pdh.hpp> 
    2324#include "PDHCollector.h" 
    2425#include <CheckMemory.h> 
  • modules/CheckSystem/Jamfile

    r1d53fe0 r42ff14d  
    11local target = CheckSystem ; 
    22local source = $(target) ; 
    3  
    4 project  
    5   : requirements 
    6   <find-static-library>Pdh 
    7   ; 
    8  
    9  
    103 
    114lib $(target) 
     
    1710  ../../include/arrayBuffer.cpp 
    1811  ../../include/EnumProcess.cpp 
    19   ../../include/PDHCounter.cpp 
    2012  ../../include/EnumNtSrv.cpp 
    2113  ../../include/sysinfo.cpp 
     14  ../../include/pdh/basic_impl.cpp 
     15  ../../include/pdh/core.cpp 
    2216 
    2317  : # requirements 
  • modules/CheckSystem/PDHCollector.cpp

    rb39c1f3 r42ff14d  
    3030  unsigned int i = strEx::stoui_as_time(s, checkIntervall_*100); 
    3131  cpu.resize(i/(checkIntervall_*100)+10); 
     32  std::wstring subsystem = NSCModuleHelper::getSettingsString(C_SYSTEM_SECTION_TITLE, C_SYSTEM_PDH_SUBSYSTEM, C_SYSTEM_PDH_SUBSYSTEM_DEFAULT); 
     33  if (subsystem == C_SYSTEM_PDH_SUBSYSTEM_DEFAULT) { 
     34  } else if (subsystem == _T("thread-safe")) { 
     35    PDH::PDHFactory::set_threadSafe(); 
     36  } else { 
     37    NSC_LOG_ERROR_STD(_T("Unknown PDH subsystem (") + subsystem + _T(") valid values are: fast and thread-safe")); 
     38  } 
    3239} 
    3340 
     
    102109    if (bUseIndex) { 
    103110      NSC_DEBUG_MSG_STD(_T("Using index to retrive counternames")); 
    104       proc = _T("\\") + pdh.lookupIndex(238) + _T("(_total)\\") + pdh.lookupIndex(6); 
    105       uptime = _T("\\") + pdh.lookupIndex(2) + _T("\\") + pdh.lookupIndex(674); 
    106       memCl = _T("\\") + pdh.lookupIndex(4) + _T("\\") + pdh.lookupIndex(30); 
    107       memCb = _T("\\") + pdh.lookupIndex(4) + _T("\\") + pdh.lookupIndex(26); 
     111      proc = _T("\\") + PDH::PDHResolver::lookupIndex(238) + _T("(_total)\\") + PDH::PDHResolver::lookupIndex(6); 
     112      uptime = _T("\\") + PDH::PDHResolver::lookupIndex(2) + _T("\\") + PDH::PDHResolver::lookupIndex(674); 
     113      memCl = _T("\\") + PDH::PDHResolver::lookupIndex(4) + _T("\\") + PDH::PDHResolver::lookupIndex(30); 
     114      memCb = _T("\\") + PDH::PDHResolver::lookupIndex(4) + _T("\\") + PDH::PDHResolver::lookupIndex(26); 
    108115    } else { 
    109116      settings_core settings; 
  • modules/CheckSystem/PDHCollector.h

    rdd02c15 r42ff14d  
    2121#pragma once 
    2222 
    23 #include "PDHCollectors.h" 
     23#include <pdh.hpp> 
    2424#include <thread.h> 
    2525#include <MutexRW.h> 
  • modules/DebugLogMetrics/DebugLogMetrics-2005.vcproj

    r3692371 r42ff14d  
    17371737      </File> 
    17381738      <File 
    1739         RelativePath="..\..\include\PDHCounter.cpp" 
    1740         > 
    1741         <FileConfiguration 
    1742           Name="Debug|Win32" 
    1743           > 
    1744           <Tool 
    1745             Name="VCCLCompilerTool" 
    1746             UsePrecompiledHeader="0" 
    1747           /> 
    1748         </FileConfiguration> 
    1749         <FileConfiguration 
    1750           Name="Debug|x64" 
    1751           > 
    1752           <Tool 
    1753             Name="VCCLCompilerTool" 
    1754             UsePrecompiledHeader="0" 
    1755           /> 
    1756         </FileConfiguration> 
    1757         <FileConfiguration 
    1758           Name="Release|Win32" 
    1759           > 
    1760           <Tool 
    1761             Name="VCCLCompilerTool" 
    1762             UsePrecompiledHeader="0" 
    1763           /> 
    1764         </FileConfiguration> 
    1765         <FileConfiguration 
    1766           Name="Release|x64" 
    1767           > 
    1768           <Tool 
    1769             Name="VCCLCompilerTool" 
    1770             UsePrecompiledHeader="0" 
    1771           /> 
    1772         </FileConfiguration> 
    1773         <FileConfiguration 
    1774           Name="Distribution|Win32" 
    1775           > 
    1776           <Tool 
    1777             Name="VCCLCompilerTool" 
    1778             UsePrecompiledHeader="0" 
    1779           /> 
    1780         </FileConfiguration> 
    1781         <FileConfiguration 
    1782           Name="Distribution|x64" 
    1783           > 
    1784           <Tool 
    1785             Name="VCCLCompilerTool" 
    1786             UsePrecompiledHeader="0" 
    1787           /> 
    1788         </FileConfiguration> 
    1789         <FileConfiguration 
    1790           Name="Nightly|Win32" 
    1791           > 
    1792           <Tool 
    1793             Name="VCCLCompilerTool" 
    1794             UsePrecompiledHeader="0" 
    1795           /> 
    1796         </FileConfiguration> 
    1797         <FileConfiguration 
    1798           Name="Nightly|x64" 
    1799           > 
    1800           <Tool 
    1801             Name="VCCLCompilerTool" 
    1802             UsePrecompiledHeader="0" 
    1803           /> 
    1804         </FileConfiguration> 
    1805         <FileConfiguration 
    1806           Name="Debug-MemCheck|Win32" 
    1807           > 
    1808           <Tool 
    1809             Name="VCCLCompilerTool" 
    1810             UsePrecompiledHeader="0" 
    1811           /> 
    1812         </FileConfiguration> 
    1813         <FileConfiguration 
    1814           Name="Debug-MemCheck|x64" 
    1815           > 
    1816           <Tool 
    1817             Name="VCCLCompilerTool" 
    1818             UsePrecompiledHeader="0" 
    1819           /> 
    1820         </FileConfiguration> 
    1821         <FileConfiguration 
    1822           Name="OP5|Win32" 
    1823           > 
    1824           <Tool 
    1825             Name="VCCLCompilerTool" 
    1826             UsePrecompiledHeader="0" 
    1827           /> 
    1828         </FileConfiguration> 
    1829         <FileConfiguration 
    1830           Name="OP5|x64" 
    1831           > 
    1832           <Tool 
    1833             Name="VCCLCompilerTool" 
    1834             UsePrecompiledHeader="0" 
    1835           /> 
    1836         </FileConfiguration> 
    1837       </File> 
    1838       <File 
    18391739        RelativePath=".\stdafx.cpp" 
    18401740        > 
     
    21772077      UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" 
    21782078      > 
     2079    </Filter> 
     2080    <Filter 
     2081      Name="PDH" 
     2082      > 
     2083      <File 
     2084        RelativePath="..\..\include\pdh\basic_impl.cpp" 
     2085        > 
     2086        <FileConfiguration 
     2087          Name="Debug|Win32" 
     2088          > 
     2089          <Tool 
     2090            Name="VCCLCompilerTool" 
     2091            UsePrecompiledHeader="0" 
     2092          /> 
     2093        </FileConfiguration> 
     2094        <FileConfiguration 
     2095          Name="Debug|x64" 
     2096          > 
     2097          <Tool 
     2098            Name="VCCLCompilerTool" 
     2099            UsePrecompiledHeader="0" 
     2100          /> 
     2101        </FileConfiguration> 
     2102        <FileConfiguration 
     2103          Name="Release|Win32" 
     2104          > 
     2105          <Tool 
     2106            Name="VCCLCompilerTool" 
     2107            UsePrecompiledHeader="0" 
     2108          /> 
     2109        </FileConfiguration> 
     2110        <FileConfiguration 
     2111          Name="Release|x64" 
     2112          > 
     2113          <Tool 
     2114            Name="VCCLCompilerTool" 
     2115            UsePrecompiledHeader="0" 
     2116          /> 
     2117        </FileConfiguration> 
     2118        <FileConfiguration 
     2119          Name="Distribution|Win32" 
     2120          > 
     2121          <Tool 
     2122            Name="VCCLCompilerTool" 
     2123            UsePrecompiledHeader="0" 
     2124          /> 
     2125        </FileConfiguration> 
     2126        <FileConfiguration 
     2127          Name="Distribution|x64" 
     2128          > 
     2129          <Tool 
     2130            Name="VCCLCompilerTool" 
     2131            UsePrecompiledHeader="0" 
     2132          /> 
     2133        </FileConfiguration> 
     2134        <FileConfiguration 
     2135          Name="Nightly|Win32" 
     2136          > 
     2137          <Tool 
     2138            Name="VCCLCompilerTool" 
     2139            UsePrecompiledHeader="0" 
     2140          /> 
     2141        </FileConfiguration> 
     2142        <FileConfiguration 
     2143          Name="Nightly|x64" 
     2144          > 
     2145          <Tool 
     2146            Name="VCCLCompilerTool" 
     2147            UsePrecompiledHeader="0" 
     2148          /> 
     2149        </FileConfiguration> 
     2150        <FileConfiguration 
     2151          Name="Debug-MemCheck|Win32" 
     2152          > 
     2153          <Tool 
     2154            Name="VCCLCompilerTool" 
     2155            UsePrecompiledHeader="0" 
     2156          /> 
     2157        </FileConfiguration> 
     2158        <FileConfiguration 
     2159          Name="Debug-MemCheck|x64" 
     2160          > 
     2161          <Tool 
     2162            Name="VCCLCompilerTool" 
     2163            UsePrecompiledHeader="0" 
     2164          /> 
     2165        </FileConfiguration> 
     2166        <FileConfiguration 
     2167          Name="OP5|Win32" 
     2168          > 
     2169          <Tool 
     2170            Name="VCCLCompilerTool" 
     2171            UsePrecompiledHeader="0" 
     2172          /> 
     2173        </FileConfiguration> 
     2174        <FileConfiguration 
     2175          Name="OP5|x64" 
     2176          > 
     2177          <Tool 
     2178            Name="VCCLCompilerTool" 
     2179            UsePrecompiledHeader="0" 
     2180          /> 
     2181        </FileConfiguration> 
     2182      </File> 
     2183      <File 
     2184        RelativePath="..\..\include\pdh\basic_impl.hpp" 
     2185        > 
     2186      </File> 
     2187      <File 
     2188        RelativePath="..\..\include\pdh\collectors.hpp" 
     2189        > 
     2190      </File> 
     2191      <File 
     2192        RelativePath="..\..\include\pdh\core.cpp" 
     2193        > 
     2194        <FileConfiguration 
     2195          Name="Debug|Win32" 
     2196          > 
     2197          <Tool 
     2198            Name="VCCLCompilerTool" 
     2199            UsePrecompiledHeader="0" 
     2200          /> 
     2201        </FileConfiguration> 
     2202        <FileConfiguration 
     2203          Name="Debug|x64" 
     2204          > 
     2205          <Tool 
     2206            Name="VCCLCompilerTool" 
     2207            UsePrecompiledHeader="0" 
     2208          /> 
     2209        </FileConfiguration> 
     2210        <FileConfiguration 
     2211          Name="Release|Win32" 
     2212          > 
     2213          <Tool 
     2214            Name="VCCLCompilerTool" 
     2215            UsePrecompiledHeader="0" 
     2216          /> 
     2217        </FileConfiguration> 
     2218        <FileConfiguration 
     2219          Name="Release|x64" 
     2220          > 
     2221          <Tool 
     2222            Name="VCCLCompilerTool" 
     2223            UsePrecompiledHeader="0" 
     2224          /> 
     2225        </FileConfiguration> 
     2226        <FileConfiguration 
     2227          Name="Distribution|Win32" 
     2228          > 
     2229          <Tool 
     2230            Name="VCCLCompilerTool" 
     2231            UsePrecompiledHeader="0" 
     2232          /> 
     2233        </FileConfiguration> 
     2234        <FileConfiguration 
     2235          Name="Distribution|x64" 
     2236          > 
     2237          <Tool 
     2238            Name="VCCLCompilerTool" 
     2239            UsePrecompiledHeader="0" 
     2240          /> 
     2241        </FileConfiguration> 
     2242        <FileConfiguration 
     2243          Name="Nightly|Win32" 
     2244          > 
     2245          <Tool 
     2246            Name="VCCLCompilerTool" 
     2247            UsePrecompiledHeader="0" 
     2248          /> 
     2249        </FileConfiguration> 
     2250        <FileConfiguration 
     2251          Name="Nightly|x64" 
     2252          > 
     2253          <Tool 
     2254            Name="VCCLCompilerTool" 
     2255            UsePrecompiledHeader="0" 
     2256          /> 
     2257        </FileConfiguration> 
     2258        <FileConfiguration 
     2259          Name="Debug-MemCheck|Win32" 
     2260          > 
     2261          <Tool 
     2262            Name="VCCLCompilerTool" 
     2263            UsePrecompiledHeader="0" 
     2264          /> 
     2265        </FileConfiguration> 
     2266        <FileConfiguration 
     2267          Name="Debug-MemCheck|x64" 
     2268          > 
     2269          <Tool 
     2270            Name="VCCLCompilerTool" 
     2271            UsePrecompiledHeader="0" 
     2272          /> 
     2273        </FileConfiguration> 
     2274        <FileConfiguration 
     2275          Name="OP5|Win32" 
     2276          > 
     2277          <Tool 
     2278            Name="VCCLCompilerTool" 
     2279            UsePrecompiledHeader="0" 
     2280          /> 
     2281        </FileConfiguration> 
     2282        <FileConfiguration 
     2283          Name="OP5|x64" 
     2284          > 
     2285          <Tool 
     2286            Name="VCCLCompilerTool" 
     2287            UsePrecompiledHeader="0" 
     2288          /> 
     2289        </FileConfiguration> 
     2290      </File> 
     2291      <File 
     2292        RelativePath="..\..\include\pdh\core.hpp" 
     2293        > 
     2294      </File> 
     2295      <File 
     2296        RelativePath="..\..\include\pdh\counters.hpp" 
     2297        > 
     2298      </File> 
     2299      <File 
     2300        RelativePath="..\..\include\pdh\enumerations.hpp" 
     2301        > 
     2302      </File> 
     2303      <File 
     2304        RelativePath="..\..\include\pdh\query.hpp" 
     2305        > 
     2306      </File> 
     2307      <File 
     2308        RelativePath="..\..\include\pdh\resolver.hpp" 
     2309        > 
     2310      </File> 
     2311      <File 
     2312        RelativePath="..\..\include\pdh\thread_Safe_impl.hpp" 
     2313        > 
     2314      </File> 
    21792315    </Filter> 
    21802316    <File 
  • modules/DebugLogMetrics/Jamfile

    r1d53fe0 r42ff14d  
    11local target = A_DebugLogMetrics ; 
    22local source = DebugLogMetrics ; 
    3  
    4 project  
    5   : requirements 
    6   <find-static-library>Pdh 
    7   ; 
    83 
    94lib $(target) 
     
    138  PDHCollector.cpp 
    149  ../../include/NSCHelper.cpp 
    15   ../../include/PDHCounter.cpp 
    1610  ../../include/arrayBuffer.cpp 
     11  ../../include/pdh/basic_impl.cpp 
     12  ../../include/pdh/core.cpp 
    1713 
    1814  : # requirements 
  • modules/DebugLogMetrics/PDHCollector.cpp

    rb1ac2fa r42ff14d  
    2222#include <Settings.h> 
    2323#include <sysinfo.h> 
     24#include <pdh/enumerations.hpp> 
    2425 
    2526 
     
    5960  // Open counters via .defs file or index. 
    6061  try { 
    61     std::wstring process_counter_name = pdh.lookupIndex(230); 
     62    std::wstring process_counter_name = PDH::PDHResolver::lookupIndex(230); 
    6263    PDH::Enumerations::pdh_object_details list = PDH::Enumerations::EnumObjectInstances(process_counter_name); 
    6364    int count = 0; 
     
    6970    PDHCollectors::StaticPDHCounterListener<unsigned int, PDHCollectors::format_long, PDHCollectors::PDHCounterNormalMutex> *pid_list =  
    7071      new PDHCollectors::StaticPDHCounterListener<unsigned int, PDHCollectors::format_long, PDHCollectors::PDHCounterNormalMutex>[count]; 
    71     std::wstring name = _T("\\") + process_counter_name + _T("(") + process_name_ + _T(")\\") + pdh.lookupIndex(784); 
     72    std::wstring name = _T("\\") + process_counter_name + _T("(") + process_name_ + _T(")\\") + PDH::PDHResolver::lookupIndex(784); 
    7273    NSC_DEBUG_MSG_STD(_T("Adding counter: ") + name); 
    7374    pdh.addCounter(name, &pid_list[0]); 
    7475    for (int i=1;i<count;i++) { 
    75       name = _T("\\") + process_counter_name + _T("(") + process_name_ + _T("#") + strEx::itos(i) + _T(")\\") + pdh.lookupIndex(784); 
     76      name = _T("\\") + process_counter_name + _T("(") + process_name_ + _T("#") + strEx::itos(i) + _T(")\\") + PDH::PDHResolver::lookupIndex(784); 
    7677      NSC_DEBUG_MSG_STD(_T("Adding counter: ") + name); 
    7778      pdh.addCounter(name, &pid_list[i]); 
     
    110111    list_.push_back(new pdh_value(184)); 
    111112 
    112     std::wstring base_name = _T("\\") + pdh.lookupIndex(230) + _T("(") + my_process_name + _T(")\\"); 
     113    std::wstring base_name = _T("\\") + PDH::PDHResolver::lookupIndex(230) + _T("(") + my_process_name + _T(")\\"); 
    113114    for (pdh_list::iterator it = list_.begin(); it != list_.end(); ++it) { 
    114       (*it)->key = pdh.lookupIndex((*it)->index); 
     115      (*it)->key = PDH::PDHResolver::lookupIndex((*it)->index); 
    115116      std::wstring name = base_name + (*it)->key; 
    116117      NSC_DEBUG_MSG_STD(_T("Adding counter: ") + name); 
  • modules/DebugLogMetrics/PDHCollector.h

    r3692371 r42ff14d  
    2121#pragma once 
    2222 
    23 #include "PDHCollectors.h" 
     23#include <pdh/collectors.hpp> 
     24#include <pdh/query.hpp> 
    2425#include <thread.h> 
    2526#include <MutexRW.h> 
Note: See TracChangeset for help on using the changeset viewer.