Performance.h revision 088a45b35631115e7729fdc57a56f49faf0c2a43
/* $Id$ */
/** @file
*
* VBox Performance Classes declaration.
*/
/*
* Copyright (C) 2008 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#include <algorithm>
#include <list>
#include <string>
#include <vector>
{
/* CPU load is measured in 1/1000 of per cent. */
/* Sub Metrics **********************************************************/
{
bool mWrapped;
};
{
const char *getDescription() { return mDescription; };
const char *mName;
const char *mDescription;
};
/* Collector Hardware Abstraction Layer *********************************/
enum {
COLLECT_NONE = 0x0,
COLLECT_CPU_LOAD = 0x1,
COLLECT_RAM_USAGE = 0x2
};
typedef int HintFlags;
{
}
{
void collectHostCpuLoad()
{ mHostFlags |= COLLECT_CPU_LOAD; }
void collectHostRamUsage()
{ mHostFlags |= COLLECT_RAM_USAGE; }
bool isHostCpuLoadCollected() const
{ return (mHostFlags & COLLECT_CPU_LOAD) != 0; }
bool isHostRamUsageCollected() const
{ return (mHostFlags & COLLECT_RAM_USAGE) != 0; }
{
}
const ProcessList& getProcessFlags() const
{
return mProcesses;
}
{
mProcesses.end(),
return *it;
/* Not found -- add new */
return mProcesses.back();
}
};
{
virtual ~CollectorHAL() { };
/** Returns averaged CPU usage in 1/1000th per cent across all host's CPUs. */
/** Returns the average frequency in MHz across all host's CPUs. */
/** Returns the amount of physical memory in kilobytes. */
/** Returns CPU usage in 1/1000th per cent by a particular process. */
/** Returns the amount of memory used by a process in kilobytes. */
/** Returns CPU usage counters in platform-specific units. */
/** Returns process' CPU usage counter in platform-specific units. */
virtual int getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total);
};
extern CollectorHAL *createHAL();
/* Base Metrics *********************************************************/
{
: mHAL(hal), mPeriod(0), mLength(0), mName(name), mObject(object), mLastSampleTaken(0), mEnabled(false) {};
virtual ~BaseMetric() {};
const char *mName;
bool mEnabled;
};
{
HostCpuLoad(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *user, SubMetric *kernel, SubMetric *idle)
void collect();
const char *getUnit() { return "%"; };
ULONG getMinValue() { return 0; };
};
{
HostCpuLoadRaw(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *user, SubMetric *kernel, SubMetric *idle)
void collect();
};
{
void collect();
const char *getUnit() { return "MHz"; };
ULONG getMinValue() { return 0; };
};
{
HostRamUsage(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *total, SubMetric *used, SubMetric *available)
void collect();
const char *getUnit() { return "kB"; };
ULONG getMinValue() { return 0; };
};
{
MachineCpuLoad(CollectorHAL *hal, ComPtr<IUnknown> object, RTPROCESS process, SubMetric *user, SubMetric *kernel)
void collect();
const char *getUnit() { return "%"; };
ULONG getMinValue() { return 0; };
};
{
MachineCpuLoadRaw(CollectorHAL *hal, ComPtr<IUnknown> object, RTPROCESS process, SubMetric *user, SubMetric *kernel)
: MachineCpuLoad(hal, object, process, user, kernel), mHostTotalPrev(0), mProcessUserPrev(0), mProcessKernelPrev(0) {};
void collect();
};
{
void collect();
const char *getUnit() { return "kB"; };
ULONG getMinValue() { return 0; };
};
/* Aggregate Functions **************************************************/
{
};
{
};
{
};
{
};
/* Metric Class *********************************************************/
{
{
if (mAggregate)
{
mName += ":";
}
}
~Metric()
{
}
const char *getDescription()
};
/* Filter Class *********************************************************/
{
bool fSeenColon = false);
};
}
/* vi: set tabstop=4 shiftwidth=4 expandtab: */