Changeset 228
- Timestamp:
- 12/31/09 16:21:31 (2 years ago)
- Location:
- branches/stable
- Files:
-
- 6 edited
-
AutoBuild.h (modified) (1 diff)
-
changelog (modified) (1 diff)
-
include/checkHelpers.hpp (modified) (2 diffs)
-
include/filter_framework.hpp (modified) (2 diffs)
-
modules/CheckDisk/CheckDisk.cpp (modified) (10 diffs)
-
modules/CheckEventLog/CheckEventLog.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/AutoBuild.h
r227 r228 3 3 // change the FALSE to TRUE for autoincrement of build number 4 4 #define INCREMENT_VERSION TRUE 5 #define FILEVER 0,3, 7,5126 #define PRODUCTVER 0,3, 7,5127 #define STRFILEVER _T("0.3. 7.512")8 #define STRPRODUCTVER _T("0.3. 7.512")9 #define STRPRODUCTDATE _T("2009-12- 13")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") 10 10 #endif // AUTOBUILD_H -
branches/stable/changelog
r227 r228 6 6 * Fix depend onservice LanManWorkStation (old win) 7 7 * Fix RtlStringFromGUID problem on NT4 8 9 2009-12-31 MickeM 10 * Fixed CheckFile* time handling so it is "signed" 11 This means you can check for "future dates" as well as future dates works correctly: 12 Like so: 13 CheckFile2 debug path=D:\tmp\dates filter+creation=>30m MaxWarn=1 MaxCrit=1 "syntax=%filename%: %creation%" 14 CRITICAL:past.txt: Thursday, December 31, 2009 08:47:30, found files: 1 > critical|'found files'=1;1;1; 15 CheckFile2 debug path=D:\tmp\dates filter+creation=<-30m MaxWarn=1 MaxCrit=1 "syntax=%filename%: %creation%" 16 CRITICAL:future.txt: C: Thursday, December 31, 2009 12:47:11, found files: 1 > critical|'found files'=1;1;1; 17 + Added volume support for CheckDriveSize (CHeckAll) like so: 18 Like so: 19 CheckDriveSize MinWarn=50% MinCrit=25% CheckAll=volumes FilterType=FIXED FilterType=REMOTE 20 + Added %user% to syntax to print user who generated message. 21 Like so: 22 CheckEventLog file=application file=system filter=new filter=out MaxWarn=1 MaxCrit=1 filter-generated=>2w filter-severity==success filter-severity==informational truncate=1023 unique descriptions "syntax=%user% (%count%)" 23 CRITICAL: (1), (2), NT INSTANS\SYSTEM (3), NT INSTANS\SYSTEM (3), NT INSTANS\SYSTEM (3), missing (3), missing (5), (4), missing (2), missing (2), missing (2), missing (2), (1), eventlog: 33 > critical|'eventlog'=33;1;1; 24 25 2009-12-21 MickeM 26 ! BREAKING CHANGE! 27 ! New perfoamcen data syntax for ALL % checks 28 Alias is '<alias> %' and it also has the "full" non % data as '<alias>' 29 Like so: 30 CheckDriveSize CheckAll MaxWarnUsed=80% MaxCritUsed=90% 31 CRITICAL:CRITICAL: C:\: Total: 146G - Used: 140G (95%) - Free: 6.31G (5%) > critical, D:\: Total: 152G - Used: 148G (97%) - Free: 3.59G (3%) > critical|'C:\ %'=95%;80;90; 'C:\'=140.17G;117.18;131.83;0;146.48; 'D:\ %'=97%;80;90; 'D:\'=147.93G;121.21;136.3;0;151.52; 32 CheckDriveSize CheckAll MaxWarnFree=20% MaxCritFree=10% 33 OK:OK: All drives within bounds.|'C:\ %'=5%;20;10; 'C:\'=140.17G;29.29;14.64;0;146.48; 'D:\ %'=3%;20;10; 'D:\'=147.93G;30.30;15.15;0;151.52; 34 CheckDriveSize CheckAll MaxWarnUsed=100G MaxCritUsed=150G 35 WARNING:WARNING: C:\: Total: 146G - Used: 140G (95%) - Free: 6.31G (5%) > warning, D:\: Total: 152G - Used: 148G (97%) - Free: 3.59G (3%) > warning|'C:\ %'=95%;32;4294967294; 'C:\'=140.17G;100;150;0;146.48; 'D:\ %'=97%;35;2; 'D:\'=147.93G;100;150;0;151.52; 36 CheckDriveSize CheckAll MaxWarnFree=20G MaxCritFree=10G 37 OK:OK: All drives within bounds.|'C:\ %'=5%;87;94; 'C:\'=140.17G;20;10;0;146.48; 'D:\ %'=3%;87;94; 'D:\'=147.93G;20;10;0;151.52; 8 38 9 39 2009-12-13 MickeM -
branches/stable/include/checkHelpers.hpp
r227 r228 25 25 26 26 #define MAKE_PERFDATA(alias, value, unit, warn, crit) _T("'") + alias + _T("'=") + value + unit + _T(";") + warn + _T(";") + crit + _T("; ") 27 #define MAKE_PERFDATA_EX(alias, value, unit, warn, crit, xmin, xmax) _T("'") + alias + _T("'=") + value + unit + _T(";") + warn + _T(";") + crit + _T(";") + xmin + _T(";") + xmax + _T("; ") 27 28 28 29 namespace checkHolders { … … 694 695 } 695 696 std::wstring gatherPerfData(std::wstring alias, TType &value, typename TType::TValueType warn, typename TType::TValueType crit) { 697 unsigned int value_p, warn_p, crit_p; 698 TType::TValueType value_v, warn_v, crit_v; 696 699 if (type_ == percentage_upper) { 697 return 698 MAKE_PERFDATA(alias, THandler::print_unformated(value.getUpperPercentage()), _T("%"), 699 THandler::print_unformated(warn), THandler::print_unformated(crit)); 700 value_p = value.getUpperPercentage(); 701 warn_p = warn; 702 crit_p = crit; 703 warn_v = static_cast<double>(value.total)*static_cast<double>(warn)/100.0; 704 crit_v = value.total*(double(crit)/100);; 700 705 } else if (type_ == percentage_lower) { 701 return 702 MAKE_PERFDATA(alias, THandler::print_unformated(value.getLowerPercentage()), _T("%"), 703 THandler::print_unformated(warn), THandler::print_unformated(crit)); 706 value_p = value.getLowerPercentage(); 707 warn_p = warn; 708 crit_p = crit; 709 warn_v = static_cast<double>(value.total)*static_cast<double>(warn)/100.0; 710 crit_v = value.total*(double(crit)/100); 704 711 } else if (type_ == value_upper) { 705 std::wstring unit = THandler::get_perf_unit(min(warn, min(crit, value.value))); 706 return 707 MAKE_PERFDATA(alias, THandler::print_perf((value.value), unit), unit, 708 THandler::print_perf(value.total-warn, unit), THandler::print_perf(value.total-crit, unit)); 712 value_p = value.getUpperPercentage(); 713 warn_p = 100-(warn*100/value.total); 714 crit_p = 100-(crit*100/value.total); 715 warn_v = warn; 716 crit_v = crit; 709 717 } else { 710 std::wstring unit = THandler::get_perf_unit(min(warn, min(crit, value.value))); 711 return 712 MAKE_PERFDATA(alias, THandler::print_perf(value.value, unit), unit, 713 THandler::print_perf(warn, unit), THandler::print_perf(crit, unit)); 714 } 718 value_p = value.getLowerPercentage(); 719 warn_p = 100-(warn*100/value.total); 720 crit_p = 100-(crit*100/value.total); 721 warn_v = warn; 722 crit_v = crit; 723 } 724 std::wstring unit = THandler::get_perf_unit(min(warn_v, min(crit_v, value.value))); 725 return 726 MAKE_PERFDATA(alias + _T(" %"), THandler::print_unformated(value_p), _T("%"), THandler::print_unformated(warn_p), THandler::print_unformated(crit_p)) 727 + 728 MAKE_PERFDATA_EX(alias, THandler::print_perf(value.value, unit), unit, THandler::print_perf(warn_v, unit), THandler::print_perf(crit_v, unit), 729 THandler::print_perf(0, unit), THandler::print_perf(value.total, unit)) 730 ; 715 731 } 716 732 private: -
branches/stable/include/filter_framework.hpp
r225 r228 55 55 struct not_string_filter { 56 56 static bool filter(std::wstring filter, std::wstring str) { 57 std::wcout << str << _T("=") << filter << _T(": ") << (!(bool)(str == filter)) << std::endl;58 57 return !(str == filter); 59 58 } … … 380 379 } 381 380 }; 382 typedef filter_all_numeric< unsigned long long, checkHolders::time_handler<unsigned long long> > filter_all_times;381 typedef filter_all_numeric<__int64, checkHolders::time_handler<__int64> > filter_all_times; 383 382 typedef filter_all_numeric<unsigned long, checkHolders::int_handler > filter_all_num_ul; 384 383 -
branches/stable/modules/CheckDisk/CheckDisk.cpp
r227 r228 169 169 bool bFilterFixed = false; 170 170 bool bFilterCDROM = false; 171 bool bCheckAll = false;171 bool bCheckAllDrives = false; 172 172 bool bCheckAllOthers = false; 173 173 bool bNSClient = false; 174 174 bool bPerfData = true; 175 175 std::list<DriveContainer> drives; 176 std::wstring strCheckAll; 176 177 177 178 MAP_OPTIONS_BEGIN(args) … … 185 186 MAP_OPTIONS_BOOL_FALSE(IGNORE_PERFDATA, bPerfData) 186 187 MAP_OPTIONS_BOOL_TRUE(NSCLIENT, bNSClient) 187 MAP_OPTIONS_BOOL_TRUE(CHECK_ALL, bCheckAll) 188 //MAP_OPTIONS_BOOL_TRUE(CHECK_ALL, bCheckAll) 189 MAP_OPTIONS_STR(CHECK_ALL, strCheckAll) 188 190 MAP_OPTIONS_BOOL_TRUE(CHECK_ALL_OTHERS, bCheckAllOthers) 189 191 MAP_OPTIONS_SECONDARY_BEGIN(_T(":"), p2) … … 199 201 bFilter = bFilterFixed || bFilterCDROM || bFilterRemote || bFilterRemovable; 200 202 201 if (drives.size() == 0) 202 bCheckAll = true; 203 204 if (bCheckAll) { 203 if ((drives.size() == 0) && strCheckAll.empty()) 204 bCheckAllDrives = true; 205 206 if (strCheckAll == _T("volumes")) { 207 208 DWORD bufSize = GetLogicalDriveStrings(0, NULL)+5; 209 TCHAR *buffer = new TCHAR[bufSize+10]; 210 if (GetLogicalDriveStrings(bufSize, buffer)>0) { 211 while (buffer[0] != 0) { 212 std::wstring drv = buffer; 213 214 UINT drvType = GetDriveType(drv.c_str()); 215 if ( ((!bFilter)&&(drvType == DRIVE_FIXED)) || 216 ((bFilter)&&(bFilterFixed)&&(drvType==DRIVE_FIXED)) || 217 ((bFilter)&&(bFilterCDROM)&&(drvType==DRIVE_CDROM)) || 218 ((bFilter)&&(bFilterRemote)&&(drvType==DRIVE_REMOTE)) || 219 ((bFilter)&&(bFilterRemovable)&&(drvType==DRIVE_REMOVABLE)) ) 220 drives.push_back(DriveContainer(drv, tmpObject.warn, tmpObject.crit)); 221 222 buffer = &buffer[drv.size()]; 223 buffer++; 224 } 225 } else { 226 NSC_LOG_ERROR_STD(_T("Failed to get buffer size: ") + error::lookup::last_error()); 227 } 228 } 229 230 if (bCheckAllDrives) { 205 231 DWORD dwDrives = GetLogicalDrives(); 206 232 int idx = 0; … … 429 455 , cached_count(false, 0) 430 456 { 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; 431 461 ullSize = ((info.nFileSizeHigh * ((unsigned long long)MAXDWORD+1)) + (unsigned long long)info.nFileSizeLow); 432 462 ullCreationTime = ((info.ftCreationTime.dwHighDateTime * ((unsigned long long)MAXDWORD+1)) + (unsigned long long)info.ftCreationTime.dwLowDateTime); … … 447 477 448 478 unsigned long long ullSize; 449 unsigned long longullCreationTime;450 unsigned long longullLastAccessTime;451 unsigned long longullLastWriteTime;452 unsigned long longullNow;479 __int64 ullCreationTime; 480 __int64 ullLastAccessTime; 481 __int64 ullLastWriteTime; 482 __int64 ullNow; 453 483 std::wstring filename; 454 484 std::wstring path; … … 456 486 std::pair<bool,unsigned long> cached_count; 457 487 488 static const __int64 MSECS_TO_100NS = 10000; 489 490 __int64 get_creation() { 491 return (ullNow-ullCreationTime)/MSECS_TO_100NS; 492 } 493 __int64 get_access() { 494 return (ullNow-ullLastAccessTime)/MSECS_TO_100NS; 495 } 496 __int64 get_write() { 497 return (ullNow-ullLastWriteTime)/MSECS_TO_100NS; 498 } 458 499 std::wstring render(std::wstring syntax) { 459 500 strEx::replace(syntax, _T("%path%"), path); … … 462 503 strEx::replace(syntax, _T("%access%"), strEx::format_filetime(ullLastAccessTime, DATE_FORMAT)); 463 504 strEx::replace(syntax, _T("%write%"), strEx::format_filetime(ullLastWriteTime, DATE_FORMAT)); 505 /* 506 strEx::replace(syntax, _T("%creation-d%"), strEx::format_filetime(ullCreationTime, DATE_FORMAT)); 507 strEx::replace(syntax, _T("%access-d%"), strEx::format_filetime(ullLastAccessTime, DATE_FORMAT)); 508 strEx::replace(syntax, _T("%write-d%"), strEx::format_filetime(ullLastWriteTime, DATE_FORMAT)); 509 */ 464 510 strEx::replace(syntax, _T("%size%"), strEx::itos_as_BKMG(ullSize)); 465 511 if (cached_version.first) … … 531 577 filters::filter_all_strings version; 532 578 filters::filter_all_num_ul line_count; 533 static const __int64 MSECS_TO_100NS = 10000;534 579 535 580 inline bool hasFilter() { … … 540 585 if ((size.hasFilter())&&(size.matchFilter(value.ullSize))) 541 586 return true; 542 else if ( (creation.hasFilter())&&(creation.matchFilter((value.ullNow-value.ullCreationTime)/MSECS_TO_100NS)))587 else if (creation.hasFilter()&&creation.matchFilter(value.get_creation())) 543 588 return true; 544 else if ( (accessed.hasFilter())&&(accessed.matchFilter((value.ullNow-value.ullLastAccessTime)/MSECS_TO_100NS)))589 else if (accessed.hasFilter()&&accessed.matchFilter(value.get_access())) 545 590 return true; 546 else if ( (written.hasFilter())&&(written.matchFilter((value.ullNow-value.ullLastWriteTime)/MSECS_TO_100NS)))591 else if (written.hasFilter()&&written.matchFilter(value.get_write())) 547 592 return true; 548 593 else if ((version.hasFilter())&&(version.matchFilter(value.get_version()))) … … 970 1015 finder.debug_ = debug; 971 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)); 972 1019 finder.syntax = syntax; 973 1020 NSC_error errors; -
branches/stable/modules/CheckEventLog/CheckEventLog.cpp
r177 r228 223 223 return pevlr_->EventType; 224 224 } 225 /* 225 226 226 std::wstring userSID() const { 227 227 if (pevlr_->UserSidOffset == 0) 228 return "";228 return _T(""); 229 229 PSID p = reinterpret_cast<PSID>(reinterpret_cast<LPBYTE>(pevlr_) + + pevlr_->UserSidOffset); 230 LPSTR user = new CHAR[1025]; 231 LPSTR domain = new CHAR[1025]; 232 DWORD userLen = 1024; 233 DWORD domainLen = 1024; 230 DWORD userLen = 0; 231 DWORD domainLen = 0; 234 232 SID_NAME_USE sidName; 233 234 LookupAccountSid(NULL, p, NULL, &userLen, NULL, &domainLen, &sidName); 235 LPTSTR user = new TCHAR[userLen+10]; 236 LPTSTR domain = new TCHAR[domainLen+10]; 237 235 238 LookupAccountSid(NULL, p, user, &userLen, domain, &domainLen, &sidName); 236 239 user[userLen] = 0; 237 240 domain[domainLen] = 0; 238 return std::wstring(domain) + "\\" + std::wstring(user); 239 } 240 */ 241 std::wstring ustr = user; 242 std::wstring dstr = domain; 243 delete [] user; 244 delete [] domain; 245 if (!dstr.empty()) 246 dstr = dstr + _T("\\"); 247 if (ustr.empty() && dstr.empty()) 248 return _T("missing"); 249 250 return dstr + ustr; 251 } 241 252 242 253 std::wstring enumStrings() const { … … 394 405 strEx::replace(syntax, _T("%strings%"), enumStrings()); 395 406 strEx::replace(syntax, _T("%id%"), strEx::itos(eventID())); 407 strEx::replace(syntax, _T("%user%"), userSID()); 396 408 return syntax; 397 409 }
Note: See TracChangeset
for help on using the changeset viewer.







