VirtualBox

Changeset 44548 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Feb 5, 2013 3:52:49 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
83601
Message:

Main/Metrics: Update link status on metrics setup, do not collect metrics for interfaces brought down (#6613)

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/Performance.h

    r44529 r44548  
    523523    {
    524524    public:
    525         HostNetworkSpeed(CollectorHAL *hal, ComPtr<IUnknown> object, com::Utf8Str name, com::Utf8Str /* shortname */, com::Utf8Str /* ifname */, uint32_t speed, SubMetric *linkspeed)
    526         : BaseMetric(hal, name, object), mSpeed(speed), mLinkSpeed(linkspeed) {};
     525        HostNetworkSpeed(CollectorHAL *hal, ComPtr<IUnknown> object, com::Utf8Str name, com::Utf8Str shortname, com::Utf8Str /* ifname */, uint32_t speed, SubMetric *linkspeed)
     526        : BaseMetric(hal, name, object), mShortName(shortname), mSpeed(speed), mLinkSpeed(linkspeed) {};
    527527        ~HostNetworkSpeed() { delete mLinkSpeed; };
    528528
    529         void init(ULONG period, ULONG length) { mPeriod = period; mLength = length; mLinkSpeed->init(length); };
     529        void init(ULONG period, ULONG length);
     530
    530531        void preCollect(CollectorHints& /* hints */, uint64_t /* iTick */) {};
    531532        void collect() { if (mSpeed) mLinkSpeed->put(mSpeed); };
     
    535536        ULONG getScale() { return 1; }
    536537    private:
    537         ULONG mSpeed;
    538         SubMetric *mLinkSpeed;
     538        com::Utf8Str mShortName;
     539        ULONG        mSpeed;
     540        SubMetric   *mLinkSpeed;
    539541    };
    540542
  • trunk/src/VBox/Main/src-server/Performance.cpp

    r44529 r44548  
    2929#endif
    3030#include "Performance.h"
     31#include "HostNetworkInterfaceImpl.h"
     32#include "netif.h"
    3133
    3234#include <VBox/com/array.h>
     
    684686}
    685687
     688#ifndef VBOX_COLLECTOR_TEST_CASE
     689static bool getLinkSpeed(const char *szShortName, uint32_t *pSpeed)
     690{
     691    /*
     692     * Note that we do not need the full name in the info, so we do not
     693     * allocate the space for it and we rely on the fact that
     694     * NetIfGetConfigByName() never fills it.
     695     */
     696    NETIFINFO Info;
     697    memset(&Info, 0, sizeof(Info));
     698    strcpy(Info.szShortName, szShortName);
     699    int rc = NetIfGetConfigByName(&Info);
     700    if (RT_FAILURE(rc))
     701        return false;
     702    *pSpeed =  Info.enmStatus == NETIF_S_UP ? Info.uSpeedMbits : 0;
     703    return true;
     704}
     705
     706void HostNetworkSpeed::init(ULONG period, ULONG length)
     707{
     708    mPeriod = period;
     709    mLength = length;
     710    mLinkSpeed->init(length);
     711    /*
     712     * Retrieve the link speed now as it may be wrong if the metric was
     713     * registered at boot (see @bugref{6613}).
     714     */
     715    getLinkSpeed(mShortName.c_str(), &mSpeed);
     716}
     717
    686718void HostNetworkLoadRaw::init(ULONG period, ULONG length)
    687719{
     
    690722    mRx->init(mLength);
    691723    mTx->init(mLength);
     724    /*
     725     * Retrieve the link speed now as it may be wrong if the metric was
     726     * registered at boot (see @bugref{6613}).
     727     */
     728    uint32_t uSpeedMbit = 65535;
     729    if (getLinkSpeed(mShortName.c_str(), &uSpeedMbit))
     730        mSpeed = (uint64_t)uSpeedMbit * (1000000/8); /* Convert to bytes/sec */
    692731    /*int rc =*/ mHAL->getRawHostNetworkLoad(mShortName.c_str(), &mRxPrev, &mTxPrev);
    693732    //AssertRC(rc);
     
    736775                         " Will update the list of interfaces...\n", mRc,mRc));
    737776}
     777#endif /* !VBOX_COLLECTOR_TEST_CASE */
    738778
    739779void HostDiskLoadRaw::init(ULONG period, ULONG length)
Note: See TracChangeset for help on using the changeset viewer.

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