Changeset 29ff7e1 in nscp


Ignore:
Timestamp:
08/07/12 23:29:55 (11 months ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.1, 0.4.2
Children:
a35c3b3, ca3e815
Parents:
fff754b
Message:
  • Fixed issue with performance data overflowing 32-bit integers (#550)
  • Fixed issue with CheckUptime? and time rendering being wrong (#549)
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • changelog

    rfff754b r29ff7e1  
    55 * Fix RtlStringFromGUID problem on NT4 
    66 
     72012-08-07 MickeM 
     8 * Fixed issue with perfoamnce data overflowing 32-bit integers (#550) 
     9 * Fixed issue with CheckUptime and time rendering beein wrong (#549) 
     10  
    7112012-08-04 MickeM 
    812 * Re implemented INSTANCES command via the new pdh exec subsystem. 
  • include/checkHelpers.hpp

    rc3f233d r29ff7e1  
    720720    }; 
    721721 
    722     checkTypes type_; 
    723     typename TType::TValueType value_; 
    724722    typedef typename TType TValueType; 
    725723    typedef THandler TFormatType; 
    726724    typedef NumericPercentageBounds<TType, THandler> TMyType; 
     725 
     726    checkTypes type_; 
     727    typename TType::TValueType value_; 
    727728    InternalValue upper; 
    728729    InternalValue lower; 
     
    730731    double magic; 
    731732 
    732     NumericPercentageBounds() : type_(none), upper(true), lower(false), magic(0), normal_size(20*1024*1024) { 
     733    NumericPercentageBounds() : type_(none), value_(0), upper(true), lower(false), normal_size(20*1024*1024), magic(0) { 
    733734      upper.setParent(this); 
    734735      lower.setParent(this); 
     
    738739      : type_(other.type_) 
    739740      , value_(other.value_) 
    740       , magic(other.magic) 
    741       , normal_size(other.normal_size) 
    742741      , upper(other.upper) 
    743742      , lower(other.lower) 
     743      , normal_size(other.normal_size) 
     744      , magic(other.magic) 
    744745    { 
    745746      upper.setParent(this); 
     
    751752      type_ = other.type_; 
    752753      value_ = other.value_; 
    753       magic = other.magic; 
    754       normal_size = other.normal_size; 
    755754      upper = other.upper; 
    756755      lower = other.lower; 
     756      normal_size = other.normal_size; 
     757      magic = other.magic; 
    757758      upper.setParent(this); 
    758759      lower.setParent(this); 
     
    839840        warn_p = evaluate_value_to_percentage(value.total, warn); 
    840841        crit_p = evaluate_value_to_percentage(value.total, crit); 
    841         warn_v = static_cast<unsigned int>(warn); 
    842         crit_v = static_cast<unsigned int>(crit); 
     842        warn_v = warn; 
     843        crit_v = crit; 
    843844      } else { 
    844845        value_p = static_cast<unsigned int>(value.getLowerPercentage()); 
    845846        warn_p = evaluate_value_to_percentage(value.total, warn); 
    846847        crit_p = evaluate_value_to_percentage(value.total, crit); 
    847         warn_v = static_cast<unsigned int>(warn); 
    848         crit_v = static_cast<unsigned int>(crit); 
    849       } 
    850       std::wstring unit = THandler::get_perf_unit(min(warn_v, min(crit_v, value.value))); 
     848        warn_v = warn; 
     849        crit_v = crit; 
     850      } 
     851      std::wstring unit = THandler::get_perf_unit(min_no_zero(warn_v, crit_v, value.value)); 
    851852      return  
    852853        MAKE_PERFDATA(alias + _T(" %"), THandler::print_unformated(value_p), _T("%"), THandler::print_unformated(warn_p), THandler::print_unformated(crit_p)) 
     
    855856          THandler::print_perf(0, unit), THandler::print_perf(value.total, unit)) 
    856857        ; 
     858    } 
     859    template<class T> 
     860    T min_no_zero(T v1, T v2, T v3) { 
     861      if (v1 == 0 && v2 == 0 && v3 == 0) 
     862        return 0; 
     863      T maximum = max(v1, max(v2, v3)); 
     864      if (v1 == 0) 
     865        v1 = maximum; 
     866      if (v2 == 0) 
     867        v2 = maximum; 
     868      if (v3 == 0) 
     869        v3 = maximum; 
     870      return min(v1, min(v2, v3)); 
    857871    } 
    858872    std::wstring gatherPerfData(std::wstring alias, TType &value) { 
  • include/strEx.h

    r6090c98 r29ff7e1  
    358358  inline std::wstring itos_as_time(unsigned long long time) { 
    359359    if (time > WEEK) { 
    360       unsigned int w = static_cast<unsigned int>(time/WEEK); 
    361       unsigned int d = static_cast<unsigned int>((time-(w*WEEK))/DAY); 
    362       unsigned int h = static_cast<unsigned int>((time-(w*WEEK)-(d*DAY))/HOUR); 
    363       unsigned int m = static_cast<unsigned int>((time-(w*WEEK)-(d*DAY)-(h*HOUR))/MIN); 
     360      long long w = time/WEEK; 
     361      long long d = (time-(w*WEEK))/DAY; 
     362      long long h = (time-(w*WEEK)-(d*DAY))/HOUR; 
     363      long long m = (time-(w*WEEK)-(d*DAY)-(h*HOUR))/MIN; 
    364364      return itos(w) + _T("w ") + itos(d) + _T("d ") + itos(h) + _T(":") + itos(m); 
    365365    } 
    366366    else if (time > DAY) { 
    367       unsigned int d = static_cast<unsigned int>((time)/DAY); 
    368       unsigned int h = static_cast<unsigned int>((time-(d*DAY))/HOUR); 
    369       unsigned int m = static_cast<unsigned int>((time-(d*DAY)-(h*HOUR))/MIN); 
     367      long long d = time/DAY; 
     368      long long h = (time-(d*DAY))/HOUR; 
     369      long long m = (time-(d*DAY)-(h*HOUR))/MIN; 
    370370      return itos(d) + _T("d ") + itos(h) + _T(":") + itos(m); 
    371371    } 
    372372    else if (time > HOUR) { 
    373       unsigned int h = static_cast<unsigned int>((time)/HOUR); 
    374       unsigned int m = static_cast<unsigned int>((time-(h*HOUR))/MIN); 
     373      long long h = time/HOUR; 
     374      long long m = (time-(h*HOUR))/MIN; 
    375375      return itos(h) + _T(":") + itos(m); 
    376376    } else if (time > MIN) { 
    377       return _T("0:") + itos(static_cast<unsigned int>(time/(60 * 1000))); 
     377      return _T("0:") + itos(time/MIN); 
    378378    } else if (time > SEC) 
    379       return itos(static_cast<unsigned int>(time/(1000))) + _T("s"); 
    380     return itos(static_cast<unsigned int>(time)); 
     379      return itos(time/SEC) + _T("s"); 
     380    return itos(time); 
    381381  } 
    382382 
  • service/NSClient++.cpp

    rf14ab71 r29ff7e1  
    393393  LOG_INFO_CORE(SERVICE_NAME _T(" booting...")); 
    394394  LOG_DEBUG_CORE(_T("Booted settings subsystem...")); 
     395  LOG_ERROR_CORE(_T("===> ") + strEx::itos_as_time(11171600000)); 
    395396 
    396397  bool crash_submit = false; 
  • version.txt

    r48b6b97 r29ff7e1  
    11version=0.4.1 
    2 build=32 
    3 date=2012-08-06 
     2build=35 
     3date=2012-08-07 
Note: See TracChangeset for help on using the changeset viewer.