VirtualBox

Changeset 27849 in vbox for trunk/src


Ignore:
Timestamp:
Mar 31, 2010 7:33:59 AM (15 years ago)
Author:
vboxsync
Message:

metrics update

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/MachineImpl.cpp

    r27835 r27849  
    89528952
    89538953    /* Create and register base metrics */
    8954     pm::BaseMetric *guestCpuLoad = new pm::GuestCpuLoad(hal, aMachine, guestLoadUser, guestLoadKernel, guestLoadIdle);
     8954    pm::BaseMetric *guestCpuLoad = new pm::GuestCpuLoad(&mGuestHAL, aMachine, guestLoadUser, guestLoadKernel, guestLoadIdle);
    89558955    aCollector->registerBaseMetric(guestCpuLoad);
    89568956
    8957     pm::BaseMetric *guestCpuMem = new pm::GuestRamUsage(hal, aMachine, guestMemTotal, guestMemFree, guestMemBalloon,
     8957    pm::BaseMetric *guestCpuMem = new pm::GuestRamUsage(&mGuestHAL, aMachine, guestMemTotal, guestMemFree, guestMemBalloon,
    89588958                                                        guestMemCache, guestPagedTotal, guestPagedFree);
    89598959    aCollector->registerBaseMetric(guestCpuMem);
    89608960
    8961     pm::BaseMetric *guestSystem = new pm::GuestSystemUsage(hal, aMachine, guestSystemProc, guestSystemThread);
     8961    pm::BaseMetric *guestSystem = new pm::GuestSystemUsage(&mGuestHAL, aMachine, guestSystemProc, guestSystemThread);
    89628962    aCollector->registerBaseMetric(guestSystem);
    89638963
  • trunk/src/VBox/Main/Performance.cpp

    r27822 r27849  
    6666}
    6767
     68int CollectorHAL::getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available)
     69{
     70    return E_NOTIMPL;
     71}
     72
     73int CollectorHAL::getProcessMemoryUsage(RTPROCESS process, ULONG *used)
     74{
     75    return E_NOTIMPL;
     76}
     77
     78int CollectorHAL::enable()
     79{
     80    return E_NOTIMPL;
     81}
     82
     83int  CollectorHAL::disable()
     84{
     85    return E_NOTIMPL;
     86}
     87
    6888/* Generic implementations */
    6989
     
    97117
    98118    return VINF_SUCCESS;
     119}
     120
     121CollectorGuestHAL::~CollectorGuestHAL()
     122{
     123//    if (cEnabled)
     124//
     125}
     126
     127int CollectorGuestHAL::enable()
     128{
     129    return S_OK;
     130}
     131
     132int CollectorGuestHAL::disable()
     133{
     134    return S_OK;
    99135}
    100136
  • trunk/src/VBox/Main/include/MachineImpl.h

    r27835 r27849  
    3737#include "VBox/settings.h"
    3838#ifdef VBOX_WITH_RESOURCE_USAGE_API
     39#include "Performance.h"
    3940#include "PerformanceImpl.h"
    4041#endif /* VBOX_WITH_RESOURCE_USAGE_API */
     
    794795    void registerMetrics(PerformanceCollector *aCollector, Machine *aMachine, RTPROCESS pid);
    795796    void unregisterMetrics(PerformanceCollector *aCollector, Machine *aMachine);
     797
     798    pm::CollectorGuestHAL   mGuestHAL;
    796799#endif /* VBOX_WITH_RESOURCE_USAGE_API */
    797800
  • trunk/src/VBox/Main/include/Performance.h

    r27822 r27849  
    2121 * additional information or have any questions.
    2222 */
    23 
     23#ifndef ___performance_h
     24#define ___performance_h
    2425
    2526#include <VBox/com/defs.h>
     
    7475    /* Collector Hardware Abstraction Layer *********************************/
    7576    enum {
    76         COLLECT_NONE      = 0x0,
    77         COLLECT_CPU_LOAD  = 0x1,
    78         COLLECT_RAM_USAGE = 0x2
     77        COLLECT_NONE        = 0x0,
     78        COLLECT_CPU_LOAD    = 0x1,
     79        COLLECT_RAM_USAGE   = 0x2
    7980    };
    8081    typedef int HintFlags;
     
    141142        virtual int getHostCpuMHz(ULONG *mhz);
    142143        /** Returns the amount of physical memory in kilobytes. */
    143         virtual int getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available) = 0;
     144        virtual int getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available);
    144145        /** Returns CPU usage in 1/1000th per cent by a particular process. */
    145146        virtual int getProcessCpuLoad(RTPROCESS process, ULONG *user, ULONG *kernel);
    146147        /** Returns the amount of memory used by a process in kilobytes. */
    147         virtual int getProcessMemoryUsage(RTPROCESS process, ULONG *used) = 0;
     148        virtual int getProcessMemoryUsage(RTPROCESS process, ULONG *used);
    148149
    149150        /** Returns CPU usage counters in platform-specific units. */
     
    151152        /** Returns process' CPU usage counter in platform-specific units. */
    152153        virtual int getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total);
     154
     155        /** Enable metrics collecting (if applicable) */
     156        virtual int enable();
     157        /** Disable metrics collecting (if applicable) */
     158        virtual int disable();
     159    };
     160
     161    class CollectorGuestHAL : public CollectorHAL
     162    {
     163    public:
     164        CollectorGuestHAL() : cEnabled(0) {};
     165        ~CollectorGuestHAL();
     166
     167        /** Enable metrics collecting (if applicable) */
     168        virtual int enable();
     169        /** Disable metrics collecting (if applicable) */
     170        virtual int disable();
     171    protected:
     172        unsigned        cEnabled;
    153173    };
    154174
     
    173193        bool collectorBeat(uint64_t nowAt);
    174194
    175         void enable() { mEnabled = true; };
    176         void disable() { mEnabled = false; };
     195        void enable()
     196        {
     197            mEnabled = true;
     198            mHAL->enable();
     199        };
     200        void disable()
     201        {
     202            mHAL->disable();
     203            mEnabled = false;
     204        };
    177205
    178206        bool isEnabled() { return mEnabled; };
     
    322350    {
    323351    public:
    324         GuestCpuLoad(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *user, SubMetric *kernel, SubMetric *idle)
     352        GuestCpuLoad(CollectorGuestHAL *hal, ComPtr<IUnknown> object, SubMetric *user, SubMetric *kernel, SubMetric *idle)
    325353        : BaseMetric(hal, "CPU/Load", object), mUser(user), mKernel(kernel), mIdle(idle) {};
    326354        ~GuestCpuLoad() { delete mUser; delete mKernel; delete mIdle; };
     
    342370    {
    343371    public:
    344         GuestRamUsage(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *total, SubMetric *free, SubMetric *balloon, SubMetric *cache, SubMetric *pagedtotal, SubMetric *pagedfree)
     372        GuestRamUsage(CollectorGuestHAL *hal, ComPtr<IUnknown> object, SubMetric *total, SubMetric *free, SubMetric *balloon, SubMetric *cache, SubMetric *pagedtotal, SubMetric *pagedfree)
    345373        : BaseMetric(hal, "RAM/Usage", object), mTotal(total), mFree(free), mBallooned(balloon), mCache(cache), mPagedTotal(pagedtotal), mPagedFree(pagedfree) {};
    346374        ~GuestRamUsage() { delete mTotal; delete mFree; delete mBallooned; delete mCache; delete mPagedTotal; delete mPagedFree; };
     
    360388    {
    361389    public:
    362         GuestSystemUsage(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *processes, SubMetric *threads)
     390        GuestSystemUsage(CollectorGuestHAL *hal, ComPtr<IUnknown> object, SubMetric *processes, SubMetric *threads)
    363391        : BaseMetric(hal, "System/Usage", object), mProcesses(processes), mThreads(threads) {};
    364392        ~GuestSystemUsage() { delete mProcesses; delete mThreads; };
     
    466494    };
    467495}
    468 
     496#endif /* ___performance_h */
    469497/* vi: set tabstop=4 shiftwidth=4 expandtab: */
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