VirtualBox

Changeset 43445 in vbox for trunk/src/VBox/Main/include


Ignore:
Timestamp:
Sep 27, 2012 8:28:59 AM (12 years ago)
Author:
vboxsync
Message:

Main/Metrics: Host network metrics, linux only (#6345)

Location:
trunk/src/VBox/Main/include
Files:
3 edited

Legend:

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

    r36615 r43445  
    145145#endif
    146146
     147    HRESULT updateNetIfList();
     148
    147149#ifdef VBOX_WITH_RESOURCE_USAGE_API
    148150    void registerMetrics(PerformanceCollector *aCollector);
  • trunk/src/VBox/Main/include/HostNetworkInterfaceImpl.h

    r42551 r43445  
    7979
    8080    HRESULT setVirtualBox(VirtualBox *pVBox);
     81    void registerMetrics(PerformanceCollector *aCollector, ComPtr<IUnknown> objptr);
     82    void unregisterMetrics(PerformanceCollector *aCollector, ComPtr<IUnknown> objptr);
    8183
    8284private:
     
    112114};
    113115
     116typedef std::list<ComObjPtr<HostNetworkInterface> > HostNetworkInterfaceList;
     117
    114118#endif // ____H_H_HOSTNETWORKINTERFACEIMPL
    115119/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/include/Performance.h

    r40358 r43445  
    4040    /* CPU load is measured in 1/1000 of per cent. */
    4141    const uint64_t PM_CPU_LOAD_MULTIPLIER = UINT64_C(100000);
     42    /* Network load is measured in 1/1000 of per cent. */
     43    const uint64_t PM_NETWORK_LOAD_MULTIPLIER = UINT64_C(100000);
     44    /* Sampler precision in milliseconds. */
     45    const uint64_t PM_SAMPLER_PRECISION_MS = 50;
    4246
    4347    /* Sub Metrics **********************************************************/
     
    6367    {
    6468    public:
    65         SubMetric(const char *name, const char *description)
     69        SubMetric(com::Utf8Str name, const char *description)
    6670        : mName(name), mDescription(description) {};
    6771        void query(ULONG *data);
    68         const char *getName() { return mName; };
     72        const char *getName() { return mName.c_str(); };
    6973        const char *getDescription() { return mDescription; };
    7074    private:
    71         const char *mName;
     75        const com::Utf8Str mName;
    7276        const char *mDescription;
    7377    };
     
    357361        /** Returns CPU usage counters in platform-specific units. */
    358362        virtual int getRawHostCpuLoad(uint64_t *user, uint64_t *kernel, uint64_t *idle);
     363        /** Returns received and transmitted bytes as well as link speed. */
     364        virtual int getRawHostNetworkLoad(const char *name, uint64_t *rx, uint64_t *tx, uint64_t *speed);
    359365        /** Returns process' CPU usage counter in platform-specific units. */
    360366        virtual int getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total);
     
    367373    {
    368374    public:
    369         BaseMetric(CollectorHAL *hal, const char *name, ComPtr<IUnknown> object)
     375        BaseMetric(CollectorHAL *hal, const com::Utf8Str name, ComPtr<IUnknown> object)
    370376            : mPeriod(0), mLength(0), mHAL(hal), mName(name), mObject(object),
    371377              mLastSampleTaken(0), mEnabled(false), mUnregistered(false) {};
     
    390396        ULONG getPeriod() { return mPeriod; };
    391397        ULONG getLength() { return mLength; };
    392         const char *getName() { return mName; };
     398        const char *getName() { return mName.c_str(); };
    393399        ComPtr<IUnknown> getObject() { return mObject; };
    394400        bool associatedWith(ComPtr<IUnknown> object) { return mObject == object; };
     
    398404        ULONG           mLength;
    399405        CollectorHAL    *mHAL;
    400         const char      *mName;
     406        const com::Utf8Str mName;
    401407        ComPtr<IUnknown> mObject;
    402408        uint64_t         mLastSampleTaken;
     
    486492        SubMetric *mAvailable;
    487493    };
     494
     495    class HostNetworkLoadRaw : public BaseMetric
     496    {
     497    public:
     498        HostNetworkLoadRaw(CollectorHAL *hal, ComPtr<IUnknown> object, com::Utf8Str name, com::Utf8Str ifname, SubMetric *rx, SubMetric *tx)
     499            : BaseMetric(hal, name, object), mInterfaceName(ifname), mRx(rx), mTx(tx), mRxPrev(0), mTxPrev(0) {};
     500        ~HostNetworkLoadRaw() { delete mRx; delete mTx; };
     501
     502        void init(ULONG period, ULONG length);
     503
     504        void preCollect(CollectorHints& hints, uint64_t iTick);
     505        void collect();
     506        const char *getUnit() { return "%"; };
     507        ULONG getMinValue() { return 0; };
     508        ULONG getMaxValue() { return PM_NETWORK_LOAD_MULTIPLIER; };
     509        ULONG getScale() { return PM_NETWORK_LOAD_MULTIPLIER / 100; }
     510
     511    private:
     512        com::Utf8Str  mInterfaceName;
     513        SubMetric    *mRx;
     514        SubMetric    *mTx;
     515        uint64_t      mRxPrev;
     516        uint64_t      mTxPrev;
     517    };
     518
    488519
    489520#ifndef VBOX_COLLECTOR_TEST_CASE
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