PerformanceSolaris.cpp revision 5cf84bfa6e9bd63430fa4cf9ac464910b0401cf9
/* $Id$ */
/** @file
*
* VBox Solaris-specific Performance Classes implementation.
*/
/*
* 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 <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <kstat.h>
#include <procfs.h>
#include "Performance.h"
namespace pm {
class CollectorSolaris : public CollectorHAL
{
public:
~CollectorSolaris();
virtual int getHostCpuMHz(unsigned long *mhz);
virtual int getHostMemoryUsage(unsigned long *total, unsigned long *used, unsigned long *available);
virtual int getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total);
private:
};
// Solaris Metric factory
{
mHAL = new CollectorSolaris();
}
// Collector HAL for Solaris
{
if ((mKC = kstat_open()) == 0)
{
return;
}
{
return;
}
}
{
}
{
int rc = VINF_SUCCESS;
int cpus;
if (mKC == 0)
return VERR_INTERNAL_ERROR;
{
return VERR_INTERNAL_ERROR;
}
++cpus;
}
}
if (cpus == 0)
{
Log(("no cpu stats found!\n"));
return VERR_INTERNAL_ERROR;
}
return rc;
}
int CollectorSolaris::getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total)
{
int rc = VINF_SUCCESS;
char *pszName;
if (h != -1)
{
{
//Assert((pid_t)process == pstatus.pr_pid);
//Log(("user=%u kernel=%u total=%u\n", prusage.pr_utime.tv_sec, prusage.pr_stime.tv_sec, prusage.pr_tstamp.tv_sec));
//Log(("user=%llu kernel=%llu total=%llu\n", *user, *kernel, *total));
}
else
{
}
close(h);
}
else
{
}
return rc;
}
{
return VERR_NOT_IMPLEMENTED;
}
int CollectorSolaris::getHostMemoryUsage(unsigned long *total, unsigned long *used, unsigned long *available)
{
int rc = VINF_SUCCESS;
return VERR_INTERNAL_ERROR;
{
return VERR_INTERNAL_ERROR;
}
{
return VERR_INTERNAL_ERROR;
}
{
return VERR_INTERNAL_ERROR;
}
return rc;
}
{
int rc = VINF_SUCCESS;
char *pszName;
if (h != -1)
{
{
}
else
{
}
close(h);
}
else
{
}
return rc;
}
}