VirtualBox

Ignore:
Timestamp:
Oct 12, 2012 9:26:07 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
81354
Message:

Main/Metrics: Linux fs/disk metrics, VBoxManage filtering + minor fixes (#6345)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/Performance.cpp

    r43618 r43629  
    6464}
    6565
     66int CollectorHAL::getRawHostDiskLoad(const char * /* name */, uint64_t * /* disk_ms */, uint64_t * /* total_ms */)
     67{
     68    return E_NOTIMPL;
     69}
     70
    6671int CollectorHAL::getRawProcessCpuLoad(RTPROCESS  /* process */, uint64_t * /* user */, uint64_t * /* kernel */, uint64_t * /* total */)
    6772{
     
    7075
    7176int CollectorHAL::getHostMemoryUsage(ULONG * /* total */, ULONG * /* used */, ULONG * /* available */)
     77{
     78    return E_NOTIMPL;
     79}
     80
     81int CollectorHAL::getHostFilesystemUsage(const char * /* name */, ULONG * /* total */, ULONG * /* used */, ULONG * /* available */)
    7282{
    7383    return E_NOTIMPL;
     
    705715}
    706716
     717void HostDiskLoadRaw::init(ULONG period, ULONG length)
     718{
     719    mPeriod = period;
     720    mLength = length;
     721    mUtil->init(mLength);
     722    int rc = mHAL->getRawHostDiskLoad(mDiskName.c_str(), &mDiskPrev, &mTotalPrev);
     723    AssertRC(rc);
     724}
     725
     726void HostDiskLoadRaw::preCollect(CollectorHints& hints, uint64_t /* iTick */)
     727{
     728    hints.collectHostCpuLoad();
     729}
     730
     731void HostDiskLoadRaw::collect()
     732{
     733    uint64_t disk, total;
     734
     735    int rc = mHAL->getRawHostDiskLoad(mDiskName.c_str(), &disk, &total);
     736    if (RT_SUCCESS(rc))
     737    {
     738        uint64_t diskDiff = disk - mDiskPrev;
     739        uint64_t totalDiff = total - mTotalPrev;
     740
     741        if (RT_UNLIKELY(totalDiff == 0))
     742        {
     743            Assert(totalDiff);
     744            LogFlowThisFunc(("Improbable! Less than millisecond passed! Disk=%s\n", mDiskName.c_str()));
     745            mUtil->put(0);
     746        }
     747        else if (diskDiff > totalDiff)
     748        {
     749            /*
     750             * It is possible that the disk spent more time than CPU because
     751             * CPU measurements are taken during the pre-collect phase. We try
     752             * to compensate for than by adding the extra to the next round of
     753             * measurements.
     754             */
     755            mUtil->put(PM_NETWORK_LOAD_MULTIPLIER);
     756            Assert((diskDiff - totalDiff) < mPeriod * 1000);
     757            if ((diskDiff - totalDiff) > mPeriod * 1000)
     758            {
     759                LogRel(("Disk utilization time exceeds CPU time by more"
     760                        " than the collection period (%llu ms)\n", diskDiff - totalDiff));
     761            }
     762            else
     763            {
     764                disk = mDiskPrev + totalDiff;
     765                LogFlowThisFunc(("Moved %u milliseconds to the next period.\n", (unsigned)(diskDiff - totalDiff)));
     766            }
     767        }
     768        else
     769        {
     770            mUtil->put((ULONG)(PM_NETWORK_LOAD_MULTIPLIER * diskDiff / totalDiff));
     771        }
     772
     773        mDiskPrev = disk;
     774        mTotalPrev = total;
     775    }
     776    else
     777        LogFlowThisFunc(("Failed to collect data: %Rrc (%d).\n", rc));
     778}
     779
    707780void HostCpuMhz::init(ULONG period, ULONG length)
    708781{
     
    738811    ULONG total, used, available;
    739812    int rc = mHAL->getHostMemoryUsage(&total, &used, &available);
     813    if (RT_SUCCESS(rc))
     814    {
     815        mTotal->put(total);
     816        mUsed->put(used);
     817        mAvailable->put(available);
     818
     819    }
     820}
     821
     822void HostFilesystemUsage::init(ULONG period, ULONG length)
     823{
     824    mPeriod = period;
     825    mLength = length;
     826    mTotal->init(mLength);
     827    mUsed->init(mLength);
     828    mAvailable->init(mLength);
     829}
     830
     831void HostFilesystemUsage::preCollect(CollectorHints& /* hints */, uint64_t /* iTick */)
     832{
     833}
     834
     835void HostFilesystemUsage::collect()
     836{
     837    ULONG total, used, available;
     838    int rc = mHAL->getHostFilesystemUsage(mFsName.c_str(), &total, &used, &available);
    740839    if (RT_SUCCESS(rc))
    741840    {
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette