Performance.h revision 52b9ffdb596974faf66a826097386ba74a9c7cd0
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync/* $Id$ */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync/** @file
6c6531128b39093daeac902a8705c0bdf15b31ccvboxsync * VirtualBox Main - Performance Classes declaration.
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync/*
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * Copyright (C) 2008 Oracle Corporation
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync *
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * available from http://www.virtualbox.org. This file is free software;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * you can redistribute it and/or modify it under the terms of the GNU
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * General Public License (GPL) as published by the Free Software
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync */
cb893baebb2af3f4fc9cd613a24d5a25e6687a6cvboxsync#ifndef ___performance_h
cb893baebb2af3f4fc9cd613a24d5a25e6687a6cvboxsync#define ___performance_h
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync#include <VBox/com/defs.h>
391cf11262671da62bcc02db361038e7ffbab8f7vboxsync#include <VBox/com/ptr.h>
054466641bb642a73b66938a9fb851bad1147749vboxsync#include <VBox/com/string.h>
cbf5a4260109bea05e1492f0b375b11a738cfb1dvboxsync#include <VBox/com/VirtualBox.h>
628ddfbd43ad5365d69fddda4007598242956577vboxsync
628ddfbd43ad5365d69fddda4007598242956577vboxsync#include <iprt/types.h>
628ddfbd43ad5365d69fddda4007598242956577vboxsync#include <iprt/err.h>
561574402775590253d11504354bfe21d80e4858vboxsync#include <iprt/cpp/lock.h>
628ddfbd43ad5365d69fddda4007598242956577vboxsync
75f285e6e38ebaee103de321814dbad59540b8f1vboxsync#include <algorithm>
02a759adb419d49bc2d50a196143c4f517510413vboxsync#include <functional> /* For std::fun_ptr in testcase */
f2fedb6cbb946e9dd6d418b1472373395e2ac34fvboxsync#include <list>
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync#include <vector>
561574402775590253d11504354bfe21d80e4858vboxsync#include <queue>
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
c2a7eba496481419a88aba56bbed51f7c8194926vboxsync/* Forward decl. */
c2a7eba496481419a88aba56bbed51f7c8194926vboxsyncclass Machine;
c2a7eba496481419a88aba56bbed51f7c8194926vboxsync
615105a2b89b7dd89a76504e6a9b8e099704c0d9vboxsyncnamespace pm
615105a2b89b7dd89a76504e6a9b8e099704c0d9vboxsync{
391cf11262671da62bcc02db361038e7ffbab8f7vboxsync /* CPU load is measured in 1/1000 of per cent. */
391cf11262671da62bcc02db361038e7ffbab8f7vboxsync const uint64_t PM_CPU_LOAD_MULTIPLIER = UINT64_C(100000);
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync /* Network load is measured in 1/1000 of per cent. */
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync const uint64_t PM_NETWORK_LOAD_MULTIPLIER = UINT64_C(100000);
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync /* Sampler precision in milliseconds. */
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync const uint64_t PM_SAMPLER_PRECISION_MS = 50;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /* Sub Metrics **********************************************************/
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync class CircularBuffer
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync public:
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync CircularBuffer() : mData(0), mLength(0), mEnd(0), mWrapped(false) {};
a2ee3f493c9808b3f1902dcda6d9449672ffaec9vboxsync ~CircularBuffer() { if (mData) RTMemFree(mData); };
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync void init(ULONG length);
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync ULONG length();
49207a1552ff3752904e36b9269f08fe643ba871vboxsync ULONG getSequenceNumber() { return mSequenceNumber; }
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync void put(ULONG value);
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync void copyTo(ULONG *data);
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync private:
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync ULONG *mData;
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync ULONG mLength;
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync ULONG mEnd;
49207a1552ff3752904e36b9269f08fe643ba871vboxsync ULONG mSequenceNumber;
49207a1552ff3752904e36b9269f08fe643ba871vboxsync bool mWrapped;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync class SubMetric : public CircularBuffer
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync public:
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync SubMetric(com::Utf8Str name, const char *description)
83c86878d483df62ca8db465c671995984838338vboxsync : mName(name), mDescription(description) {};
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync void query(ULONG *data);
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync const char *getName() { return mName.c_str(); };
83c86878d483df62ca8db465c671995984838338vboxsync const char *getDescription() { return mDescription; };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync private:
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync const com::Utf8Str mName;
83c86878d483df62ca8db465c671995984838338vboxsync const char *mDescription;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync enum {
cb893baebb2af3f4fc9cd613a24d5a25e6687a6cvboxsync COLLECT_NONE = 0x0,
cb893baebb2af3f4fc9cd613a24d5a25e6687a6cvboxsync COLLECT_CPU_LOAD = 0x1,
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync COLLECT_RAM_USAGE = 0x2,
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync COLLECT_GUEST_STATS = 0x4
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync };
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync typedef int HintFlags;
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync typedef std::pair<RTPROCESS, HintFlags> ProcessFlagsPair;
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync class CollectorHints
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync {
4dee4a4f4ff664b16f478e200e0d231407a2b097vboxsync public:
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync typedef std::list<ProcessFlagsPair> ProcessList;
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync CollectorHints() : mHostFlags(COLLECT_NONE) {}
e120ca0501a41ca43369b7ba984f4db2f720bdc8vboxsync void collectHostCpuLoad()
e120ca0501a41ca43369b7ba984f4db2f720bdc8vboxsync { mHostFlags |= COLLECT_CPU_LOAD; }
e120ca0501a41ca43369b7ba984f4db2f720bdc8vboxsync void collectHostRamUsage()
e120ca0501a41ca43369b7ba984f4db2f720bdc8vboxsync { mHostFlags |= COLLECT_RAM_USAGE; }
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync void collectHostRamVmm()
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync { mHostFlags |= COLLECT_GUEST_STATS; }
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync void collectProcessCpuLoad(RTPROCESS process)
e120ca0501a41ca43369b7ba984f4db2f720bdc8vboxsync { findProcess(process).second |= COLLECT_CPU_LOAD; }
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync void collectProcessRamUsage(RTPROCESS process)
e120ca0501a41ca43369b7ba984f4db2f720bdc8vboxsync { findProcess(process).second |= COLLECT_RAM_USAGE; }
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync void collectGuestStats(RTPROCESS process)
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync { findProcess(process).second |= COLLECT_GUEST_STATS; }
e120ca0501a41ca43369b7ba984f4db2f720bdc8vboxsync bool isHostCpuLoadCollected() const
e120ca0501a41ca43369b7ba984f4db2f720bdc8vboxsync { return (mHostFlags & COLLECT_CPU_LOAD) != 0; }
e120ca0501a41ca43369b7ba984f4db2f720bdc8vboxsync bool isHostRamUsageCollected() const
e120ca0501a41ca43369b7ba984f4db2f720bdc8vboxsync { return (mHostFlags & COLLECT_RAM_USAGE) != 0; }
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync bool isHostRamVmmCollected() const
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync { return (mHostFlags & COLLECT_GUEST_STATS) != 0; }
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync bool isProcessCpuLoadCollected(RTPROCESS process)
e120ca0501a41ca43369b7ba984f4db2f720bdc8vboxsync { return (findProcess(process).second & COLLECT_CPU_LOAD) != 0; }
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync bool isProcessRamUsageCollected(RTPROCESS process)
e120ca0501a41ca43369b7ba984f4db2f720bdc8vboxsync { return (findProcess(process).second & COLLECT_RAM_USAGE) != 0; }
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync bool isGuestStatsCollected(RTPROCESS process)
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync { return (findProcess(process).second & COLLECT_GUEST_STATS) != 0; }
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync void getProcesses(std::vector<RTPROCESS>& processes) const
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync {
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync processes.clear();
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync processes.reserve(mProcesses.size());
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync for (ProcessList::const_iterator it = mProcesses.begin(); it != mProcesses.end(); it++)
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync processes.push_back(it->first);
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync }
4dee4a4f4ff664b16f478e200e0d231407a2b097vboxsync const ProcessList& getProcessFlags() const
4dee4a4f4ff664b16f478e200e0d231407a2b097vboxsync {
4dee4a4f4ff664b16f478e200e0d231407a2b097vboxsync return mProcesses;
4dee4a4f4ff664b16f478e200e0d231407a2b097vboxsync }
4dee4a4f4ff664b16f478e200e0d231407a2b097vboxsync private:
4dee4a4f4ff664b16f478e200e0d231407a2b097vboxsync HintFlags mHostFlags;
4dee4a4f4ff664b16f478e200e0d231407a2b097vboxsync ProcessList mProcesses;
4dee4a4f4ff664b16f478e200e0d231407a2b097vboxsync
4dee4a4f4ff664b16f478e200e0d231407a2b097vboxsync ProcessFlagsPair& findProcess(RTPROCESS process)
4dee4a4f4ff664b16f478e200e0d231407a2b097vboxsync {
4dee4a4f4ff664b16f478e200e0d231407a2b097vboxsync ProcessList::iterator it;
054466641bb642a73b66938a9fb851bad1147749vboxsync for (it = mProcesses.begin(); it != mProcesses.end(); it++)
2f3e13b744091a6c1d3bc4b9dc6ef4e7f25bf1cdvboxsync if (it->first == process)
2f3e13b744091a6c1d3bc4b9dc6ef4e7f25bf1cdvboxsync return *it;
4dee4a4f4ff664b16f478e200e0d231407a2b097vboxsync
4dee4a4f4ff664b16f478e200e0d231407a2b097vboxsync /* Not found -- add new */
4dee4a4f4ff664b16f478e200e0d231407a2b097vboxsync mProcesses.push_back(ProcessFlagsPair(process, COLLECT_NONE));
4dee4a4f4ff664b16f478e200e0d231407a2b097vboxsync return mProcesses.back();
4dee4a4f4ff664b16f478e200e0d231407a2b097vboxsync }
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync };
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync /* Guest Collector Classes *********************************/
7a3d722456f70226ebc994df685bd736e4324d04vboxsync /*
7a3d722456f70226ebc994df685bd736e4324d04vboxsync * WARNING! The bits in the following masks must correspond to parameters
7a3d722456f70226ebc994df685bd736e4324d04vboxsync * of CollectorGuest::updateStats().
7a3d722456f70226ebc994df685bd736e4324d04vboxsync */
7a3d722456f70226ebc994df685bd736e4324d04vboxsync typedef enum
7a3d722456f70226ebc994df685bd736e4324d04vboxsync {
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_NONE = 0x00000000,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_CPUUSER = 0x00000001,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_CPUKERNEL = 0x00000002,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_CPUIDLE = 0x00000004,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_MEMTOTAL = 0x00000008,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_MEMFREE = 0x00000010,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_MEMBALLOON = 0x00000020,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_MEMSHARED = 0x00000040,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_MEMCACHE = 0x00000080,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_PAGETOTAL = 0x00000100,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_ALLOCVMM = 0x00000200,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_FREEVMM = 0x00000400,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_BALOONVMM = 0x00000800,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_SHAREDVMM = 0x00001000
7a3d722456f70226ebc994df685bd736e4324d04vboxsync } GUESTSTATMASK;
7a3d722456f70226ebc994df685bd736e4324d04vboxsync
7a3d722456f70226ebc994df685bd736e4324d04vboxsync const ULONG GUESTSTATS_CPULOAD =
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_CPUUSER|GUESTSTATMASK_CPUKERNEL|GUESTSTATMASK_CPUIDLE;
7a3d722456f70226ebc994df685bd736e4324d04vboxsync const ULONG GUESTSTATS_RAMUSAGE =
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_MEMTOTAL|GUESTSTATMASK_MEMFREE|GUESTSTATMASK_MEMBALLOON|
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_MEMSHARED|GUESTSTATMASK_MEMCACHE|
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_PAGETOTAL;
7a3d722456f70226ebc994df685bd736e4324d04vboxsync const ULONG GUESTSTATS_VMMRAM =
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_ALLOCVMM|GUESTSTATMASK_FREEVMM|
7a3d722456f70226ebc994df685bd736e4324d04vboxsync GUESTSTATMASK_BALOONVMM|GUESTSTATMASK_SHAREDVMM;
561574402775590253d11504354bfe21d80e4858vboxsync const ULONG GUESTSTATS_ALL = GUESTSTATS_CPULOAD|GUESTSTATS_RAMUSAGE|GUESTSTATS_VMMRAM;
561574402775590253d11504354bfe21d80e4858vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync class CollectorGuest;
561574402775590253d11504354bfe21d80e4858vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync class CollectorGuestRequest
561574402775590253d11504354bfe21d80e4858vboxsync {
561574402775590253d11504354bfe21d80e4858vboxsync public:
561574402775590253d11504354bfe21d80e4858vboxsync CollectorGuestRequest()
561574402775590253d11504354bfe21d80e4858vboxsync : mCGuest(0) {};
561574402775590253d11504354bfe21d80e4858vboxsync virtual ~CollectorGuestRequest() {};
561574402775590253d11504354bfe21d80e4858vboxsync void setGuest(CollectorGuest *aGuest) { mCGuest = aGuest; };
561574402775590253d11504354bfe21d80e4858vboxsync CollectorGuest *getGuest() { return mCGuest; };
561574402775590253d11504354bfe21d80e4858vboxsync virtual int execute() = 0;
561574402775590253d11504354bfe21d80e4858vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync virtual void debugPrint(void *aObject, const char *aFunction, const char *aText) = 0;
561574402775590253d11504354bfe21d80e4858vboxsync protected:
561574402775590253d11504354bfe21d80e4858vboxsync CollectorGuest *mCGuest;
561574402775590253d11504354bfe21d80e4858vboxsync const char *mDebugName;
561574402775590253d11504354bfe21d80e4858vboxsync };
561574402775590253d11504354bfe21d80e4858vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync class CGRQEnable : public CollectorGuestRequest
561574402775590253d11504354bfe21d80e4858vboxsync {
561574402775590253d11504354bfe21d80e4858vboxsync public:
561574402775590253d11504354bfe21d80e4858vboxsync CGRQEnable(ULONG aMask)
561574402775590253d11504354bfe21d80e4858vboxsync : mMask(aMask) {};
561574402775590253d11504354bfe21d80e4858vboxsync int execute();
561574402775590253d11504354bfe21d80e4858vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync void debugPrint(void *aObject, const char *aFunction, const char *aText);
561574402775590253d11504354bfe21d80e4858vboxsync private:
561574402775590253d11504354bfe21d80e4858vboxsync ULONG mMask;
561574402775590253d11504354bfe21d80e4858vboxsync };
561574402775590253d11504354bfe21d80e4858vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync class CGRQDisable : public CollectorGuestRequest
561574402775590253d11504354bfe21d80e4858vboxsync {
561574402775590253d11504354bfe21d80e4858vboxsync public:
561574402775590253d11504354bfe21d80e4858vboxsync CGRQDisable(ULONG aMask)
561574402775590253d11504354bfe21d80e4858vboxsync : mMask(aMask) {};
561574402775590253d11504354bfe21d80e4858vboxsync int execute();
561574402775590253d11504354bfe21d80e4858vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync void debugPrint(void *aObject, const char *aFunction, const char *aText);
561574402775590253d11504354bfe21d80e4858vboxsync private:
561574402775590253d11504354bfe21d80e4858vboxsync ULONG mMask;
561574402775590253d11504354bfe21d80e4858vboxsync };
561574402775590253d11504354bfe21d80e4858vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync class CGRQAbort : public CollectorGuestRequest
561574402775590253d11504354bfe21d80e4858vboxsync {
561574402775590253d11504354bfe21d80e4858vboxsync public:
561574402775590253d11504354bfe21d80e4858vboxsync CGRQAbort() {};
561574402775590253d11504354bfe21d80e4858vboxsync int execute();
561574402775590253d11504354bfe21d80e4858vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync void debugPrint(void *aObject, const char *aFunction, const char *aText);
561574402775590253d11504354bfe21d80e4858vboxsync };
561574402775590253d11504354bfe21d80e4858vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync class CollectorGuestQueue
561574402775590253d11504354bfe21d80e4858vboxsync {
561574402775590253d11504354bfe21d80e4858vboxsync public:
561574402775590253d11504354bfe21d80e4858vboxsync CollectorGuestQueue();
561574402775590253d11504354bfe21d80e4858vboxsync ~CollectorGuestQueue();
561574402775590253d11504354bfe21d80e4858vboxsync void push(CollectorGuestRequest* rq);
561574402775590253d11504354bfe21d80e4858vboxsync CollectorGuestRequest* pop();
561574402775590253d11504354bfe21d80e4858vboxsync private:
561574402775590253d11504354bfe21d80e4858vboxsync RTCLockMtx mLockMtx;
561574402775590253d11504354bfe21d80e4858vboxsync RTSEMEVENT mEvent;
561574402775590253d11504354bfe21d80e4858vboxsync std::queue<CollectorGuestRequest*> mQueue;
561574402775590253d11504354bfe21d80e4858vboxsync };
561574402775590253d11504354bfe21d80e4858vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync class CollectorGuestManager;
7a3d722456f70226ebc994df685bd736e4324d04vboxsync
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync class CollectorGuest
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync {
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync public:
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync CollectorGuest(Machine *machine, RTPROCESS process);
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ~CollectorGuest();
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync
561574402775590253d11504354bfe21d80e4858vboxsync void setManager(CollectorGuestManager *aManager)
561574402775590253d11504354bfe21d80e4858vboxsync { mManager = aManager; };
561574402775590253d11504354bfe21d80e4858vboxsync bool isUnregistered() { return mUnregistered; };
561574402775590253d11504354bfe21d80e4858vboxsync bool isEnabled() { return mEnabled != 0; };
561574402775590253d11504354bfe21d80e4858vboxsync bool isValid(ULONG mask) { return (mValid & mask) == mask; };
561574402775590253d11504354bfe21d80e4858vboxsync void invalidate(ULONG mask) { mValid &= ~mask; };
561574402775590253d11504354bfe21d80e4858vboxsync void unregister() { mUnregistered = true; };
7a3d722456f70226ebc994df685bd736e4324d04vboxsync void updateStats(ULONG aValidStats, ULONG aCpuUser,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync ULONG aCpuKernel, ULONG aCpuIdle,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync ULONG aMemTotal, ULONG aMemFree,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync ULONG aMemBalloon, ULONG aMemShared,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync ULONG aMemCache, ULONG aPageTotal,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync ULONG aAllocVMM, ULONG aFreeVMM,
7a3d722456f70226ebc994df685bd736e4324d04vboxsync ULONG aBalloonedVMM, ULONG aSharedVMM);
561574402775590253d11504354bfe21d80e4858vboxsync int enable(ULONG mask);
561574402775590253d11504354bfe21d80e4858vboxsync int disable(ULONG mask);
561574402775590253d11504354bfe21d80e4858vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync int enqueueRequest(CollectorGuestRequest *aRequest);
561574402775590253d11504354bfe21d80e4858vboxsync int enableInternal(ULONG mask);
561574402775590253d11504354bfe21d80e4858vboxsync int disableInternal(ULONG mask);
561574402775590253d11504354bfe21d80e4858vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync const com::Utf8Str& getVMName() const { return mMachineName; };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync RTPROCESS getProcess() { return mProcess; };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG getCpuUser() { return mCpuUser; };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG getCpuKernel() { return mCpuKernel; };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG getCpuIdle() { return mCpuIdle; };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG getMemTotal() { return mMemTotal; };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG getMemFree() { return mMemFree; };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG getMemBalloon() { return mMemBalloon; };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG getMemShared() { return mMemShared; };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG getMemCache() { return mMemCache; };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG getPageTotal() { return mPageTotal; };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG getAllocVMM() { return mAllocVMM; };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG getFreeVMM() { return mFreeVMM; };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG getBalloonedVMM() { return mBalloonedVMM; };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG getSharedVMM() { return mSharedVMM; };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync private:
561574402775590253d11504354bfe21d80e4858vboxsync int enableVMMStats(bool mCollectVMMStats);
561574402775590253d11504354bfe21d80e4858vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync CollectorGuestManager *mManager;
561574402775590253d11504354bfe21d80e4858vboxsync
a05b4948186b031cbd8c3b7c6cfe973d69039016vboxsync bool mUnregistered;
561574402775590253d11504354bfe21d80e4858vboxsync ULONG mEnabled;
7a3d722456f70226ebc994df685bd736e4324d04vboxsync ULONG mValid;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync Machine *mMachine;
561574402775590253d11504354bfe21d80e4858vboxsync com::Utf8Str mMachineName;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync RTPROCESS mProcess;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ComPtr<IConsole> mConsole;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ComPtr<IGuest> mGuest;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG mCpuUser;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG mCpuKernel;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG mCpuIdle;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG mMemTotal;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG mMemFree;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG mMemBalloon;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG mMemShared;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG mMemCache;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG mPageTotal;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG mAllocVMM;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG mFreeVMM;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG mBalloonedVMM;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG mSharedVMM;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync typedef std::list<CollectorGuest*> CollectorGuestList;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync class CollectorGuestManager
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync {
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync public:
561574402775590253d11504354bfe21d80e4858vboxsync CollectorGuestManager();
561574402775590253d11504354bfe21d80e4858vboxsync ~CollectorGuestManager();
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync void registerGuest(CollectorGuest* pGuest);
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync void unregisterGuest(CollectorGuest* pGuest);
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync CollectorGuest *getVMMStatsProvider() { return mVMMStatsProvider; };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync void preCollect(CollectorHints& hints, uint64_t iTick);
a05b4948186b031cbd8c3b7c6cfe973d69039016vboxsync void destroyUnregistered();
561574402775590253d11504354bfe21d80e4858vboxsync int enqueueRequest(CollectorGuestRequest *aRequest);
561574402775590253d11504354bfe21d80e4858vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync CollectorGuest *getBlockedGuest() { return mGuestBeingCalled; };
561574402775590253d11504354bfe21d80e4858vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync static DECLCALLBACK(int) requestProcessingThread(RTTHREAD aThread, void *pvUser);
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync private:
561574402775590253d11504354bfe21d80e4858vboxsync RTTHREAD mThread;
561574402775590253d11504354bfe21d80e4858vboxsync CollectorGuestList mGuests;
561574402775590253d11504354bfe21d80e4858vboxsync CollectorGuest *mVMMStatsProvider;
561574402775590253d11504354bfe21d80e4858vboxsync CollectorGuestQueue mQueue;
561574402775590253d11504354bfe21d80e4858vboxsync CollectorGuest *mGuestBeingCalled;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync /* Collector Hardware Abstraction Layer *********************************/
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync class CollectorHAL
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync public:
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync CollectorHAL() {};
4ffdae046e05f397b6552d5489685f5802bbd249vboxsync virtual ~CollectorHAL() { };
1965d3323263fc938e3bbf02aa83f6d7d53a7d98vboxsync virtual int preCollect(const CollectorHints& /* hints */, uint64_t /* iTick */) { return VINF_SUCCESS; }
79e36c53917758fe8e3623fe9de2e21336431147vboxsync /** Returns averaged CPU usage in 1/1000th per cent across all host's CPUs. */
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync virtual int getHostCpuLoad(ULONG *user, ULONG *kernel, ULONG *idle);
79e36c53917758fe8e3623fe9de2e21336431147vboxsync /** Returns the average frequency in MHz across all host's CPUs. */
a793a1290646210f7c65639476ca920f8ab20eb4vboxsync virtual int getHostCpuMHz(ULONG *mhz);
79e36c53917758fe8e3623fe9de2e21336431147vboxsync /** Returns the amount of physical memory in kilobytes. */
cb893baebb2af3f4fc9cd613a24d5a25e6687a6cvboxsync virtual int getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available);
79e36c53917758fe8e3623fe9de2e21336431147vboxsync /** Returns CPU usage in 1/1000th per cent by a particular process. */
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync virtual int getProcessCpuLoad(RTPROCESS process, ULONG *user, ULONG *kernel);
79e36c53917758fe8e3623fe9de2e21336431147vboxsync /** Returns the amount of memory used by a process in kilobytes. */
cb893baebb2af3f4fc9cd613a24d5a25e6687a6cvboxsync virtual int getProcessMemoryUsage(RTPROCESS process, ULONG *used);
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
79e36c53917758fe8e3623fe9de2e21336431147vboxsync /** Returns CPU usage counters in platform-specific units. */
040c9969cc5574339d5f1fa2c95c73da095c151bvboxsync virtual int getRawHostCpuLoad(uint64_t *user, uint64_t *kernel, uint64_t *idle);
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync /** Returns received and transmitted bytes as well as link speed. */
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync virtual int getRawHostNetworkLoad(const char *name, uint64_t *rx, uint64_t *tx, uint64_t *speed);
79e36c53917758fe8e3623fe9de2e21336431147vboxsync /** Returns process' CPU usage counter in platform-specific units. */
040c9969cc5574339d5f1fa2c95c73da095c151bvboxsync virtual int getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total);
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync extern CollectorHAL *createHAL();
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /* Base Metrics *********************************************************/
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync class BaseMetric
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync public:
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync BaseMetric(CollectorHAL *hal, const com::Utf8Str name, ComPtr<IUnknown> object)
a05b4948186b031cbd8c3b7c6cfe973d69039016vboxsync : mPeriod(0), mLength(0), mHAL(hal), mName(name), mObject(object),
a05b4948186b031cbd8c3b7c6cfe973d69039016vboxsync mLastSampleTaken(0), mEnabled(false), mUnregistered(false) {};
088a45b35631115e7729fdc57a56f49faf0c2a43vboxsync virtual ~BaseMetric() {};
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync virtual void init(ULONG period, ULONG length) = 0;
cbf5a4260109bea05e1492f0b375b11a738cfb1dvboxsync virtual void preCollect(CollectorHints& hints, uint64_t iTick) = 0;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync virtual void collect() = 0;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync virtual const char *getUnit() = 0;
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync virtual ULONG getMinValue() = 0;
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync virtual ULONG getMaxValue() = 0;
49207a1552ff3752904e36b9269f08fe643ba871vboxsync virtual ULONG getScale() = 0;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync bool collectorBeat(uint64_t nowAt);
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync
561574402775590253d11504354bfe21d80e4858vboxsync virtual int enable() { mEnabled = true; return S_OK; };
561574402775590253d11504354bfe21d80e4858vboxsync virtual int disable() { mEnabled = false; return S_OK; };
a05b4948186b031cbd8c3b7c6cfe973d69039016vboxsync void unregister() { mUnregistered = true; };
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync
a05b4948186b031cbd8c3b7c6cfe973d69039016vboxsync bool isUnregistered() { return mUnregistered; };
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync bool isEnabled() { return mEnabled; };
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync ULONG getPeriod() { return mPeriod; };
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync ULONG getLength() { return mLength; };
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync const char *getName() { return mName.c_str(); };
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync ComPtr<IUnknown> getObject() { return mObject; };
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync bool associatedWith(ComPtr<IUnknown> object) { return mObject == object; };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync protected:
cbf5a4260109bea05e1492f0b375b11a738cfb1dvboxsync ULONG mPeriod;
cbf5a4260109bea05e1492f0b375b11a738cfb1dvboxsync ULONG mLength;
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync CollectorHAL *mHAL;
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync const com::Utf8Str mName;
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync ComPtr<IUnknown> mObject;
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync uint64_t mLastSampleTaken;
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync bool mEnabled;
a05b4948186b031cbd8c3b7c6cfe973d69039016vboxsync bool mUnregistered;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync };
615105a2b89b7dd89a76504e6a9b8e099704c0d9vboxsync
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync class BaseGuestMetric : public BaseMetric
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync {
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync public:
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync BaseGuestMetric(CollectorGuest *cguest, const char *name, ComPtr<IUnknown> object)
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync : BaseMetric(NULL, name, object), mCGuest(cguest) {};
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync protected:
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync CollectorGuest *mCGuest;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync };
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync class HostCpuLoad : public BaseMetric
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync public:
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync HostCpuLoad(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *user, SubMetric *kernel, SubMetric *idle)
f2fedb6cbb946e9dd6d418b1472373395e2ac34fvboxsync : BaseMetric(hal, "CPU/Load", object), mUser(user), mKernel(kernel), mIdle(idle) {};
088a45b35631115e7729fdc57a56f49faf0c2a43vboxsync ~HostCpuLoad() { delete mUser; delete mKernel; delete mIdle; };
088a45b35631115e7729fdc57a56f49faf0c2a43vboxsync
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync void init(ULONG period, ULONG length);
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync void collect();
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync const char *getUnit() { return "%"; };
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync ULONG getMinValue() { return 0; };
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync ULONG getMaxValue() { return PM_CPU_LOAD_MULTIPLIER; };
49207a1552ff3752904e36b9269f08fe643ba871vboxsync ULONG getScale() { return PM_CPU_LOAD_MULTIPLIER / 100; }
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync protected:
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync SubMetric *mUser;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync SubMetric *mKernel;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync SubMetric *mIdle;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync };
615105a2b89b7dd89a76504e6a9b8e099704c0d9vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync class HostCpuLoadRaw : public HostCpuLoad
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync public:
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync HostCpuLoadRaw(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *user, SubMetric *kernel, SubMetric *idle)
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync : HostCpuLoad(hal, object, user, kernel, idle), mUserPrev(0), mKernelPrev(0), mIdlePrev(0) {};
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
cbf5a4260109bea05e1492f0b375b11a738cfb1dvboxsync void preCollect(CollectorHints& hints, uint64_t iTick);
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync void collect();
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync private:
040c9969cc5574339d5f1fa2c95c73da095c151bvboxsync uint64_t mUserPrev;
040c9969cc5574339d5f1fa2c95c73da095c151bvboxsync uint64_t mKernelPrev;
040c9969cc5574339d5f1fa2c95c73da095c151bvboxsync uint64_t mIdlePrev;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync class HostCpuMhz : public BaseMetric
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync public:
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync HostCpuMhz(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *mhz)
f2fedb6cbb946e9dd6d418b1472373395e2ac34fvboxsync : BaseMetric(hal, "CPU/MHz", object), mMHz(mhz) {};
088a45b35631115e7729fdc57a56f49faf0c2a43vboxsync ~HostCpuMhz() { delete mMHz; };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync void init(ULONG period, ULONG length);
cbf5a4260109bea05e1492f0b375b11a738cfb1dvboxsync void preCollect(CollectorHints& /* hints */, uint64_t /* iTick */) {}
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync void collect();
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync const char *getUnit() { return "MHz"; };
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync ULONG getMinValue() { return 0; };
e8a568d25b577fb2ce7213b11c63f71eca1f84c2vboxsync ULONG getMaxValue() { return INT32_MAX; };
49207a1552ff3752904e36b9269f08fe643ba871vboxsync ULONG getScale() { return 1; }
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync private:
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync SubMetric *mMHz;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync };
615105a2b89b7dd89a76504e6a9b8e099704c0d9vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync class HostRamUsage : public BaseMetric
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync public:
e11c3cb1ab3034f15eaccc2a6fdb998b6752a429vboxsync HostRamUsage(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *total, SubMetric *used, SubMetric *available)
8374dfdfc4d7fdfcfbaeec4c65fbf856212d4c32vboxsync : BaseMetric(hal, "RAM/Usage", object), mTotal(total), mUsed(used), mAvailable(available) {};
8374dfdfc4d7fdfcfbaeec4c65fbf856212d4c32vboxsync ~HostRamUsage() { delete mTotal; delete mUsed; delete mAvailable; };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync void init(ULONG period, ULONG length);
cbf5a4260109bea05e1492f0b375b11a738cfb1dvboxsync void preCollect(CollectorHints& hints, uint64_t iTick);
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync void collect();
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync const char *getUnit() { return "kB"; };
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync ULONG getMinValue() { return 0; };
e8a568d25b577fb2ce7213b11c63f71eca1f84c2vboxsync ULONG getMaxValue() { return INT32_MAX; };
49207a1552ff3752904e36b9269f08fe643ba871vboxsync ULONG getScale() { return 1; }
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync private:
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync SubMetric *mTotal;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync SubMetric *mUsed;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync SubMetric *mAvailable;
8374dfdfc4d7fdfcfbaeec4c65fbf856212d4c32vboxsync };
8374dfdfc4d7fdfcfbaeec4c65fbf856212d4c32vboxsync
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync class HostNetworkLoadRaw : public BaseMetric
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync {
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync public:
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync HostNetworkLoadRaw(CollectorHAL *hal, ComPtr<IUnknown> object, com::Utf8Str name, com::Utf8Str ifname, SubMetric *rx, SubMetric *tx)
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync : BaseMetric(hal, name, object), mInterfaceName(ifname), mRx(rx), mTx(tx), mRxPrev(0), mTxPrev(0) {};
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync ~HostNetworkLoadRaw() { delete mRx; delete mTx; };
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync void init(ULONG period, ULONG length);
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync void preCollect(CollectorHints& hints, uint64_t iTick);
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync void collect();
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync const char *getUnit() { return "%"; };
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync ULONG getMinValue() { return 0; };
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync ULONG getMaxValue() { return PM_NETWORK_LOAD_MULTIPLIER; };
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync ULONG getScale() { return PM_NETWORK_LOAD_MULTIPLIER / 100; }
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync private:
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync com::Utf8Str mInterfaceName;
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync SubMetric *mRx;
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync SubMetric *mTx;
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync uint64_t mRxPrev;
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync uint64_t mTxPrev;
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync };
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync
52b9ffdb596974faf66a826097386ba74a9c7cd0vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync#ifndef VBOX_COLLECTOR_TEST_CASE
8374dfdfc4d7fdfcfbaeec4c65fbf856212d4c32vboxsync class HostRamVmm : public BaseMetric
8374dfdfc4d7fdfcfbaeec4c65fbf856212d4c32vboxsync {
8374dfdfc4d7fdfcfbaeec4c65fbf856212d4c32vboxsync public:
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync HostRamVmm(CollectorGuestManager *gm, ComPtr<IUnknown> object, SubMetric *allocVMM, SubMetric *freeVMM, SubMetric *balloonVMM, SubMetric *sharedVMM)
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync : BaseMetric(NULL, "RAM/VMM", object), mCollectorGuestManager(gm),
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync mAllocVMM(allocVMM), mFreeVMM(freeVMM), mBalloonVMM(balloonVMM), mSharedVMM(sharedVMM),
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync mAllocCurrent(0), mFreeCurrent(0), mBalloonedCurrent(0), mSharedCurrent(0) {};
8374dfdfc4d7fdfcfbaeec4c65fbf856212d4c32vboxsync ~HostRamVmm() { delete mAllocVMM; delete mFreeVMM; delete mBalloonVMM; delete mSharedVMM; };
8374dfdfc4d7fdfcfbaeec4c65fbf856212d4c32vboxsync
8374dfdfc4d7fdfcfbaeec4c65fbf856212d4c32vboxsync void init(ULONG period, ULONG length);
8374dfdfc4d7fdfcfbaeec4c65fbf856212d4c32vboxsync void preCollect(CollectorHints& hints, uint64_t iTick);
8374dfdfc4d7fdfcfbaeec4c65fbf856212d4c32vboxsync void collect();
561574402775590253d11504354bfe21d80e4858vboxsync int enable();
561574402775590253d11504354bfe21d80e4858vboxsync int disable();
8374dfdfc4d7fdfcfbaeec4c65fbf856212d4c32vboxsync const char *getUnit() { return "kB"; };
8374dfdfc4d7fdfcfbaeec4c65fbf856212d4c32vboxsync ULONG getMinValue() { return 0; };
8374dfdfc4d7fdfcfbaeec4c65fbf856212d4c32vboxsync ULONG getMaxValue() { return INT32_MAX; };
8374dfdfc4d7fdfcfbaeec4c65fbf856212d4c32vboxsync ULONG getScale() { return 1; }
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync
8374dfdfc4d7fdfcfbaeec4c65fbf856212d4c32vboxsync private:
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync CollectorGuestManager *mCollectorGuestManager;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync SubMetric *mAllocVMM;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync SubMetric *mFreeVMM;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync SubMetric *mBalloonVMM;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync SubMetric *mSharedVMM;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG mAllocCurrent;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG mFreeCurrent;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG mBalloonedCurrent;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync ULONG mSharedCurrent;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync };
561574402775590253d11504354bfe21d80e4858vboxsync#endif /* VBOX_COLLECTOR_TEST_CASE */
615105a2b89b7dd89a76504e6a9b8e099704c0d9vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync class MachineCpuLoad : public BaseMetric
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync public:
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync MachineCpuLoad(CollectorHAL *hal, ComPtr<IUnknown> object, RTPROCESS process, SubMetric *user, SubMetric *kernel)
f2fedb6cbb946e9dd6d418b1472373395e2ac34fvboxsync : BaseMetric(hal, "CPU/Load", object), mProcess(process), mUser(user), mKernel(kernel) {};
088a45b35631115e7729fdc57a56f49faf0c2a43vboxsync ~MachineCpuLoad() { delete mUser; delete mKernel; };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync void init(ULONG period, ULONG length);
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync void collect();
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync const char *getUnit() { return "%"; };
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync ULONG getMinValue() { return 0; };
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync ULONG getMaxValue() { return PM_CPU_LOAD_MULTIPLIER; };
49207a1552ff3752904e36b9269f08fe643ba871vboxsync ULONG getScale() { return PM_CPU_LOAD_MULTIPLIER / 100; }
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync protected:
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync RTPROCESS mProcess;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync SubMetric *mUser;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync SubMetric *mKernel;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync };
615105a2b89b7dd89a76504e6a9b8e099704c0d9vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync class MachineCpuLoadRaw : public MachineCpuLoad
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync public:
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync MachineCpuLoadRaw(CollectorHAL *hal, ComPtr<IUnknown> object, RTPROCESS process, SubMetric *user, SubMetric *kernel)
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync : MachineCpuLoad(hal, object, process, user, kernel), mHostTotalPrev(0), mProcessUserPrev(0), mProcessKernelPrev(0) {};
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
cbf5a4260109bea05e1492f0b375b11a738cfb1dvboxsync void preCollect(CollectorHints& hints, uint64_t iTick);
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync void collect();
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync private:
040c9969cc5574339d5f1fa2c95c73da095c151bvboxsync uint64_t mHostTotalPrev;
040c9969cc5574339d5f1fa2c95c73da095c151bvboxsync uint64_t mProcessUserPrev;
040c9969cc5574339d5f1fa2c95c73da095c151bvboxsync uint64_t mProcessKernelPrev;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync class MachineRamUsage : public BaseMetric
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync public:
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync MachineRamUsage(CollectorHAL *hal, ComPtr<IUnknown> object, RTPROCESS process, SubMetric *used)
f2fedb6cbb946e9dd6d418b1472373395e2ac34fvboxsync : BaseMetric(hal, "RAM/Usage", object), mProcess(process), mUsed(used) {};
088a45b35631115e7729fdc57a56f49faf0c2a43vboxsync ~MachineRamUsage() { delete mUsed; };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync void init(ULONG period, ULONG length);
cbf5a4260109bea05e1492f0b375b11a738cfb1dvboxsync void preCollect(CollectorHints& hints, uint64_t iTick);
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync void collect();
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync const char *getUnit() { return "kB"; };
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync ULONG getMinValue() { return 0; };
e8a568d25b577fb2ce7213b11c63f71eca1f84c2vboxsync ULONG getMaxValue() { return INT32_MAX; };
49207a1552ff3752904e36b9269f08fe643ba871vboxsync ULONG getScale() { return 1; }
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync private:
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync RTPROCESS mProcess;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync SubMetric *mUsed;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync
561574402775590253d11504354bfe21d80e4858vboxsync#ifndef VBOX_COLLECTOR_TEST_CASE
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync class GuestCpuLoad : public BaseGuestMetric
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync {
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync public:
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync GuestCpuLoad(CollectorGuest *cguest, ComPtr<IUnknown> object, SubMetric *user, SubMetric *kernel, SubMetric *idle)
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync : BaseGuestMetric(cguest, "Guest/CPU/Load", object), mUser(user), mKernel(kernel), mIdle(idle) {};
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync ~GuestCpuLoad() { delete mUser; delete mKernel; delete mIdle; };
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync void init(ULONG period, ULONG length);
cbf5a4260109bea05e1492f0b375b11a738cfb1dvboxsync void preCollect(CollectorHints& hints, uint64_t iTick);
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync void collect();
561574402775590253d11504354bfe21d80e4858vboxsync int enable();
561574402775590253d11504354bfe21d80e4858vboxsync int disable();
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync const char *getUnit() { return "%"; };
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync ULONG getMinValue() { return 0; };
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync ULONG getMaxValue() { return PM_CPU_LOAD_MULTIPLIER; };
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync ULONG getScale() { return PM_CPU_LOAD_MULTIPLIER / 100; }
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync protected:
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync SubMetric *mUser;
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync SubMetric *mKernel;
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync SubMetric *mIdle;
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync };
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync class GuestRamUsage : public BaseGuestMetric
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync {
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync public:
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync GuestRamUsage(CollectorGuest *cguest, ComPtr<IUnknown> object, SubMetric *total, SubMetric *free, SubMetric *balloon, SubMetric *shared, SubMetric *cache, SubMetric *pagedtotal)
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync : BaseGuestMetric(cguest, "Guest/RAM/Usage", object), mTotal(total), mFree(free), mBallooned(balloon), mCache(cache), mPagedTotal(pagedtotal), mShared(shared) {};
cc04399629ac806e92deeb3006dc1d507a608901vboxsync ~GuestRamUsage() { delete mTotal; delete mFree; delete mBallooned; delete mShared; delete mCache; delete mPagedTotal; };
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync void init(ULONG period, ULONG length);
cbf5a4260109bea05e1492f0b375b11a738cfb1dvboxsync void preCollect(CollectorHints& hints, uint64_t iTick);
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync void collect();
561574402775590253d11504354bfe21d80e4858vboxsync int enable();
561574402775590253d11504354bfe21d80e4858vboxsync int disable();
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync const char *getUnit() { return "kB"; };
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync ULONG getMinValue() { return 0; };
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync ULONG getMaxValue() { return INT32_MAX; };
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync ULONG getScale() { return 1; }
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync private:
cc04399629ac806e92deeb3006dc1d507a608901vboxsync SubMetric *mTotal, *mFree, *mBallooned, *mCache, *mPagedTotal, *mShared;
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync };
561574402775590253d11504354bfe21d80e4858vboxsync#endif /* VBOX_COLLECTOR_TEST_CASE */
1439977563a6d2143201766a0d7c61e50a5acf75vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /* Aggregate Functions **************************************************/
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync class Aggregate
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync public:
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync virtual ULONG compute(ULONG *data, ULONG length) = 0;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync virtual const char *getName() = 0;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync class AggregateAvg : public Aggregate
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync public:
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync virtual ULONG compute(ULONG *data, ULONG length);
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync virtual const char *getName();
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync class AggregateMin : public Aggregate
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync public:
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync virtual ULONG compute(ULONG *data, ULONG length);
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync virtual const char *getName();
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync class AggregateMax : public Aggregate
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync public:
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync virtual ULONG compute(ULONG *data, ULONG length);
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync virtual const char *getName();
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /* Metric Class *********************************************************/
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync class Metric
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync public:
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync Metric(BaseMetric *baseMetric, SubMetric *subMetric, Aggregate *aggregate) :
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync mName(subMetric->getName()), mBaseMetric(baseMetric), mSubMetric(subMetric), mAggregate(aggregate)
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync if (mAggregate)
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
054466641bb642a73b66938a9fb851bad1147749vboxsync mName.append(":");
054466641bb642a73b66938a9fb851bad1147749vboxsync mName.append(mAggregate->getName());
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync }
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync }
615105a2b89b7dd89a76504e6a9b8e099704c0d9vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync ~Metric()
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync delete mAggregate;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync }
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync bool associatedWith(ComPtr<IUnknown> object) { return getObject() == object; };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync const char *getName() { return mName.c_str(); };
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync ComPtr<IUnknown> getObject() { return mBaseMetric->getObject(); };
83c86878d483df62ca8db465c671995984838338vboxsync const char *getDescription()
83c86878d483df62ca8db465c671995984838338vboxsync { return mAggregate ? "" : mSubMetric->getDescription(); };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync const char *getUnit() { return mBaseMetric->getUnit(); };
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync ULONG getMinValue() { return mBaseMetric->getMinValue(); };
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync ULONG getMaxValue() { return mBaseMetric->getMaxValue(); };
5413a6a2dab50ebebc702aa2ae7d8059dcd09c9cvboxsync ULONG getPeriod() { return mBaseMetric->getPeriod(); };
83c86878d483df62ca8db465c671995984838338vboxsync ULONG getLength()
83c86878d483df62ca8db465c671995984838338vboxsync { return mAggregate ? 1 : mBaseMetric->getLength(); };
49207a1552ff3752904e36b9269f08fe643ba871vboxsync ULONG getScale() { return mBaseMetric->getScale(); }
49207a1552ff3752904e36b9269f08fe643ba871vboxsync void query(ULONG **data, ULONG *count, ULONG *sequenceNumber);
615105a2b89b7dd89a76504e6a9b8e099704c0d9vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync private:
6c6531128b39093daeac902a8705c0bdf15b31ccvboxsync RTCString mName;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync BaseMetric *mBaseMetric;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync SubMetric *mSubMetric;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync Aggregate *mAggregate;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync /* Filter Class *********************************************************/
391cf11262671da62bcc02db361038e7ffbab8f7vboxsync
f2fedb6cbb946e9dd6d418b1472373395e2ac34fvboxsync class Filter
f2fedb6cbb946e9dd6d418b1472373395e2ac34fvboxsync {
f2fedb6cbb946e9dd6d418b1472373395e2ac34fvboxsync public:
f72cbd6a549c34992fa79cce84600fe2b92b3299vboxsync Filter(ComSafeArrayIn(IN_BSTR, metricNames),
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync ComSafeArrayIn(IUnknown * , objects));
e8e40640deaea2e9002e1bf9cf4944e2590c6e7avboxsync static bool patternMatch(const char *pszPat, const char *pszName,
e8e40640deaea2e9002e1bf9cf4944e2590c6e7avboxsync bool fSeenColon = false);
6c6531128b39093daeac902a8705c0bdf15b31ccvboxsync bool match(const ComPtr<IUnknown> object, const RTCString &name) const;
f2fedb6cbb946e9dd6d418b1472373395e2ac34fvboxsync private:
f72cbd6a549c34992fa79cce84600fe2b92b3299vboxsync void init(ComSafeArrayIn(IN_BSTR, metricNames),
fc4c8c507d3c19dbbf598a6fec9678b04313ccefvboxsync ComSafeArrayIn(IUnknown * , objects));
fc4c8c507d3c19dbbf598a6fec9678b04313ccefvboxsync
6c6531128b39093daeac902a8705c0bdf15b31ccvboxsync typedef std::pair<const ComPtr<IUnknown>, const RTCString> FilterElement;
30f7bd6bf198ae0489df375e5a17cb086acb30fbvboxsync typedef std::list<FilterElement> ElementList;
30f7bd6bf198ae0489df375e5a17cb086acb30fbvboxsync
30f7bd6bf198ae0489df375e5a17cb086acb30fbvboxsync ElementList mElements;
f2fedb6cbb946e9dd6d418b1472373395e2ac34fvboxsync
fe06619ae576367ff3568e6abd99fb8ad28cc73avboxsync void processMetricList(const com::Utf8Str &name, const ComPtr<IUnknown> object);
f2fedb6cbb946e9dd6d418b1472373395e2ac34fvboxsync };
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync}
cb893baebb2af3f4fc9cd613a24d5a25e6687a6cvboxsync#endif /* ___performance_h */
f6adf1a86574758258baa232172c965aed0d848dvboxsync/* vi: set tabstop=4 shiftwidth=4 expandtab: */