PerformanceLinux.cpp revision 9dab0783f1c18514294d60033f5d7ac0f41de039
/* $Id$ */
/** @file
*
* VBox Linux-specific Performance Classes implementation.
*/
/*
* Copyright (C) 2008-2011 Oracle Corporation
*
* 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.
*/
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <mntent.h>
#include <map>
#include <vector>
#include "Logging.h"
#include "Performance.h"
#define VBOXVOLINFO_NAME "VBoxVolInfo"
namespace pm {
class CollectorLinux : public CollectorHAL
{
public:
virtual int getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total);
private:
virtual int _getRawHostCpuLoad();
int getRawProcessStats(RTPROCESS process, uint64_t *cpuUser, uint64_t *cpuKernel, ULONG *memPagesUsed);
struct VMProcessStats
{
};
};
{
return new CollectorLinux();
}
// Collector HAL for Linux
{
if (hz == -1)
{
LogRel(("CollectorLinux failed to obtain HZ from kernel, assuming 100.\n"));
mHZ = 100;
}
else
}
{
{
/* On failure, do NOT stop. Just skip the entry. Having the stats for
* to not updating many process stats and the host cpu stats. */
if (RT_SUCCESS(rc))
}
{
}
return VINF_SUCCESS;
}
int CollectorLinux::_getRawHostCpuLoad()
{
int rc = VINF_SUCCESS;
if (f)
{
char szBuf[128];
{
{
}
/* Try to get single CPU stats. */
{
{
}
else
{
/* Assume that this is not an SMP system. */
mSingleUser = mUser;
mSingleIdle = mIdle;
}
}
else
}
else
fclose(f);
}
else
return rc;
}
{
return VINF_SUCCESS;
}
int CollectorLinux::getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total)
{
{
return VERR_INTERNAL_ERROR;
}
return VINF_SUCCESS;
}
{
int rc = VINF_SUCCESS;
if (f)
{
if (processed == 4)
{
}
else
fclose(f);
}
else
return rc;
}
int CollectorLinux::getHostFilesystemUsage(const char *path, ULONG *total, ULONG *used, ULONG *available)
{
{
return VERR_ACCESS_DENIED;
}
return VINF_SUCCESS;
}
{
{
return VERR_INTERNAL_ERROR;
}
return VINF_SUCCESS;
}
int CollectorLinux::getRawProcessStats(RTPROCESS process, uint64_t *cpuUser, uint64_t *cpuKernel, ULONG *memPagesUsed)
{
int rc = VINF_SUCCESS;
char *pszName;
char c;
int iTmp;
long long unsigned int u64Tmp;
unsigned uTmp;
unsigned long ulTmp;
signed long ilTmp;
//printf("Opening %s...\n", pszName);
if (f)
{
if (fscanf(f, "%d %79s %c %d %d %d %d %d %u %lu %lu %lu %lu %u %u "
"%ld %ld %ld %ld %ld %ld %llu %lu %u",
{
}
else
fclose(f);
}
else
return rc;
}
{
int rc = VINF_SUCCESS;
if (f)
{
else
fclose(f);
if (f)
{
else
fclose(f);
}
else
}
else
return rc;
}
{
int rc = VINF_SUCCESS;
if (f)
{
if (fscanf(f, "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu",
{
}
else
fclose(f);
}
else
return rc;
}
{
unsigned cbName = 0;
pszEnd--;
{
cbName++;
pszEnd--;
}
return pszDiskName;
}
{
char szVolInfo[RTPATH_MAX];
int rc = RTPathExecDir(szVolInfo, sizeof(szVolInfo) - sizeof("/" VBOXVOLINFO_NAME " ") - strlen(pcszVolume));
if (RT_FAILURE(rc))
{
return VERR_INVALID_PARAMETER;
}
if (fp)
{
char szBuf[128];
}
else
}
{
if (mtab)
{
{
{
char szDevName[128];
else
break;
}
}
}
return VINF_SUCCESS;
}
}