PerformanceSolaris.cpp revision c58f1213e628a545081c70e26c6b67a841cff880
8524136daf17865271b1b1103d33747e9ab7229bvboxsync * VBox Solaris-specific Performance Classes implementation.
c257ca186721759ab93369d503cdab9bfee654a7vboxsync * Copyright (C) 2013 Oracle Corporation
c257ca186721759ab93369d503cdab9bfee654a7vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
c257ca186721759ab93369d503cdab9bfee654a7vboxsync * available from http://www.virtualbox.org. This file is free software;
c257ca186721759ab93369d503cdab9bfee654a7vboxsync * you can redistribute it and/or modify it under the terms of the GNU
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync * General Public License (GPL) as published by the Free Software
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync typedef zfs_handle_t *(*PFNZFSOPEN)(libzfs_handle_t *, const char *, int);
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync typedef uint64_t (*PFNZFSPROPGETINT)(zfs_handle_t *, zfs_prop_t);
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync typedef zpool_handle_t *(*PFNZPOOLOPEN)(libzfs_handle_t *, const char *);
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync typedef nvlist_t *(*PFNZPOOLGETCONFIG)(zpool_handle_t *, nvlist_t **);
8524136daf17865271b1b1103d33747e9ab7229bvboxsync typedef char *(*PFNZPOOLVDEVNAME)(libzfs_handle_t *, zpool_handle_t *, nvlist_t *, boolean_t);
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync virtual int getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available);
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync virtual int getHostFilesystemUsage(const char *name, ULONG *total, ULONG *used, ULONG *available);
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync virtual int getHostDiskSize(const char *name, uint64_t *size);
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync virtual int getProcessMemoryUsage(RTPROCESS process, ULONG *used);
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync virtual int getRawHostCpuLoad(uint64_t *user, uint64_t *kernel, uint64_t *idle);
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync virtual int getRawHostNetworkLoad(const char *name, uint64_t *rx, uint64_t *tx);
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync virtual int getRawHostDiskLoad(const char *name, uint64_t *disk_ms, uint64_t *total_ms);
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync virtual int getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total);
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync virtual int getDiskListByFs(const char *name, DiskList& list);
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync static uint32_t getInstance(const char *pszIfaceName, char *pszDevName);
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync uint64_t getZfsTotal(uint64_t cbTotal, const char *szFsType, const char *szFsName);
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync RTCString physToInstName(const char *pcszPhysName);
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync RTCString pathToInstName(const char *pcszDevPathName);
8524136daf17865271b1b1103d33747e9ab7229bvboxsync uint64_t wrapCorrection(uint32_t cur, uint64_t prev, const char *name);
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync uint64_t wrapDetection(uint64_t cur, uint64_t prev, const char *name);
997565ac8c6a36fd436dc8451be697e3e22e1428vboxsync// Collector HAL for Solaris
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync if ((mSysPages = kstat_lookup(mKC, (char *)"unix", 0, (char *)"system_pages")) == 0)
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync Log(("kstat_lookup(system_pages) -> %d\n", errno));
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync if ((mZFSCache = kstat_lookup(mKC, (char *)"zfs", 0, (char *)"arcstats")) == 0)
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync Log(("kstat_lookup(system_pages) -> %d\n", errno));
4df306bda1892d084d7cad28a8c426fc76bc7e63vboxsync /* Try to load libzfs dynamically, it may be missing. */
if (mKC)
if (mZfsSo)
int cpus;
if (mKC == 0)
return VERR_INTERNAL_ERROR;
return VERR_INTERNAL_ERROR;
++cpus;
if (cpus == 0)
return VERR_INTERNAL_ERROR;
return rc;
int CollectorSolaris::getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total)
char *pszName;
//Log(("user=%u kernel=%u total=%u\n", prusage.pr_utime.tv_sec, prusage.pr_stime.tv_sec, prusage.pr_tstamp.tv_sec));
if (mCpus)
close(h);
return rc;
return VERR_INTERNAL_ERROR;
return VERR_INTERNAL_ERROR;
return VERR_INTERNAL_ERROR;
if (mZFSCache)
return VERR_INTERNAL_ERROR;
return rc;
close(h);
return rc;
int cbInstance = 0;
cbInstance++;
pszEnd--;
return uInstance;
return corrected;
static bool fNotSeen = true;
fNotSeen = false;
return cur;
static bool g_fNotReported = true;
if (ksAdapter == 0)
if (ksAdapter == 0)
if (ksAdapter == 0)
return VERR_INTERNAL_ERROR;
return VERR_INTERNAL_ERROR;
if (g_fNotReported)
g_fNotReported = false;
return VERR_INTERNAL_ERROR;
if (g_fNotReported)
g_fNotReported = false;
return VERR_INTERNAL_ERROR;
return VINF_SUCCESS;
if (ksDisk != 0)
return rc;
uint64_t CollectorSolaris::getZfsTotal(uint64_t cbTotal, const char *szFsType, const char *szFsName)
return cbTotal;
return cbTotal;
while (pszEnd)
*pszEnd = 0;
if (!hDataset)
if (uAvail == 0)
if (uAvail == 0)
if (!pszEnd)
int CollectorSolaris::getHostFilesystemUsage(const char *path, ULONG *total, ULONG *used, ULONG *available)
return VERR_ACCESS_DENIED;
return VINF_SUCCESS;
if (ksDisk != 0)
return VERR_INTERNAL_ERROR;
return rc;
if (!fp)
return RTCString();
if (pszDriver)
if (pszDriver)
if (pszInstance)
if (pszInstance)
return strInstName;
return VERR_INVALID_PARAMETER;
if (zh)
unsigned int cChildren = 0;
for (unsigned int i = 0; i < cChildren; ++i)
return VINF_SUCCESS;
if (fp)
int rc = 0;