static gboolean GuestInfoStatsGather(gpointer data) { #if (defined(__linux__) && !defined(USERWORLD)) || defined(_WIN32) ToolsAppCtx *ctx = data; DynBuf stats; #endif #if defined(_WIN32) gboolean perfmonLogStats; #endif g_debug("Entered guest info stats gather.\n"); #if defined(_WIN32) perfmonLogStats = g_key_file_get_boolean(ctx->config, CONFGROUPNAME_GUESTINFO, CONFNAME_GUESTINFO_ENABLESTATLOGGING, NULL); GuestInfo_SetStatLogging(perfmonLogStats); #endif #if (defined(__linux__) && !defined(USERWORLD)) || defined(_WIN32) /* Send the vmstats to the VMX. */ DynBuf_Init(&stats); if (GuestInfo_PerfMon(&stats)) { if (!GuestInfoUpdateVmdb(ctx, INFO_MEMORY, DynBuf_Get(&stats), DynBuf_GetSize(&stats))) { g_warning("Failed to send vmstats.\n"); } } else { g_warning("Failed to get vmstats.\n"); } DynBuf_Destroy(&stats); #endif return TRUE; }
static gboolean GuestInfoGather(gpointer data) { char name[256]; // Size is derived from the SUS2 specification // "Host names are limited to 255 bytes" char *osString = NULL; gboolean disableQueryDiskInfo; NicInfoV3 *nicInfo = NULL; GuestDiskInfo *diskInfo = NULL; #if defined(_WIN32) || defined(linux) GuestMemInfo vmStats = {0}; gboolean perfmonEnabled; #endif ToolsAppCtx *ctx = data; g_debug("Entered guest info gather.\n"); /* Send tools version. */ if (!GuestInfoUpdateVmdb(ctx, INFO_BUILD_NUMBER, BUILD_NUMBER)) { /* * An older vmx talking to new tools wont be able to handle * this message. Continue, if thats the case. */ g_warning("Failed to update VMDB with tools version.\n"); } /* Gather all the relevant guest information. */ osString = Hostinfo_GetOSName(); if (osString == NULL) { g_warning("Failed to get OS info.\n"); } else { if (!GuestInfoUpdateVmdb(ctx, INFO_OS_NAME_FULL, osString)) { g_warning("Failed to update VMDB\n"); } } free(osString); osString = Hostinfo_GetOSGuestString(); if (osString == NULL) { g_warning("Failed to get OS info.\n"); } else { if (!GuestInfoUpdateVmdb(ctx, INFO_OS_NAME, osString)) { g_warning("Failed to update VMDB\n"); } } free(osString); disableQueryDiskInfo = g_key_file_get_boolean(ctx->config, CONFGROUPNAME_GUESTINFO, CONFNAME_GUESTINFO_DISABLEQUERYDISKINFO, NULL); if (!disableQueryDiskInfo) { if ((diskInfo = GuestInfo_GetDiskInfo()) == NULL) { g_warning("Failed to get disk info.\n"); } else { if (GuestInfoUpdateVmdb(ctx, INFO_DISK_FREE_SPACE, diskInfo)) { GuestInfo_FreeDiskInfo(gInfoCache.diskInfo); gInfoCache.diskInfo = diskInfo; } else { g_warning("Failed to update VMDB\n."); GuestInfo_FreeDiskInfo(diskInfo); } } } if (!System_GetNodeName(sizeof name, name)) { g_warning("Failed to get netbios name.\n"); } else if (!GuestInfoUpdateVmdb(ctx, INFO_DNS_NAME, name)) { g_warning("Failed to update VMDB.\n"); } /* Get NIC information. */ if (!GuestInfo_GetNicInfo(&nicInfo)) { g_warning("Failed to get nic info.\n"); } else if (GuestInfo_IsEqual_NicInfoV3(nicInfo, gInfoCache.nicInfo)) { g_debug("Nic info not changed.\n"); GuestInfo_FreeNicInfo(nicInfo); } else if (GuestInfoUpdateVmdb(ctx, INFO_IPADDRESS, nicInfo)) { /* * Since the update succeeded, free the old cached object, and assign * ours to the cache. */ GuestInfo_FreeNicInfo(gInfoCache.nicInfo); gInfoCache.nicInfo = nicInfo; } else { g_warning("Failed to update VMDB.\n"); GuestInfo_FreeNicInfo(nicInfo); } /* Send the uptime to VMX so that it can detect soft resets. */ SendUptime(ctx); #if defined(_WIN32) || defined(linux) /* Send the vmstats to the VMX. */ perfmonEnabled = !g_key_file_get_boolean(ctx->config, CONFGROUPNAME_GUESTINFO, CONFNAME_GUESTINFO_DISABLEPERFMON, NULL); if (perfmonEnabled) { if (!GuestInfo_PerfMon(&vmStats)) { g_debug("Failed to get vmstats.\n"); } else { vmStats.version = 1; if (!GuestInfoUpdateVmdb(ctx, INFO_MEMORY, &vmStats)) { g_warning("Failed to send vmstats.\n"); } } } #endif return TRUE; }