/// <summary> /// Gets information about the vertex service /// </summary> /// <returns></returns> VertexStatus IDryadVertexService.CheckStatus() { DryadLogger.LogMethodEntry(); VertexStatus status = new VertexStatus(); status.serviceIsAlive = true; // // Update information about disk usage // foreach (string disk in Environment.GetLogicalDrives()) { ulong freeDiskSpaceforUser; ulong totalDiskSpace; ulong freeDiskSpace; if (NativeMethods.GetDiskFreeSpaceEx(disk, out freeDiskSpaceforUser, out totalDiskSpace, out freeDiskSpace)) { status.freeDiskSpaces.Add(disk, freeDiskSpace); } else { // // Report any errors as warnings, as this is a non-essential call // int errorCode = Marshal.GetLastWin32Error(); Exception lastex = Marshal.GetExceptionForHR(errorCode); if (lastex != null) { DryadLogger.LogWarning("Unable to get disk space information", "Disk: {0} Error: {1}", disk, lastex.Message); } else { DryadLogger.LogWarning("Unable to get disk space information", "Disk: {0} Error Code: {1}", disk, errorCode); } } } // // Update information about memory usage // NativeMethods.MEMORYSTATUSEX memStatus = new NativeMethods.MEMORYSTATUSEX(); if (NativeMethods.GlobalMemoryStatusEx(memStatus)) { status.freePhysicalMemory = memStatus.ullAvailPhys; status.freeVirtualMemory = memStatus.ullAvailVirtual; } else { // // Report any errors as warnings, as this is a non-essential call // int errorCode = Marshal.GetLastWin32Error(); Exception lastex = Marshal.GetExceptionForHR(errorCode); if (lastex != null) { DryadLogger.LogWarning("Unable to get memory information", "Error: {0}", lastex.Message); } else { DryadLogger.LogWarning("Unable to get memory information", "Error Code: {0}", errorCode); } } // // Get process info for each running vertex process // status.runningProcessCount = 0; lock (vertexProcessTable.SyncRoot) { foreach (VertexProcess vp in this.vertexProcessTable) { VertexProcessInfo vpInfo = new VertexProcessInfo(); vpInfo.DryadId = vp.DryadId; vpInfo.commandLine = vp.commandLine; vpInfo.State = vp.State; status.vps.Add(vpInfo); if (vp.State == ProcessState.Running) { status.runningProcessCount++; } } } DryadLogger.LogMethodExit(status); return(status); }
/// <summary> /// Gets information about the vertex service /// </summary> /// <returns></returns> VertexStatus IDryadVertexService.CheckStatus() { DryadLogger.LogMethodEntry(); VertexStatus status = new VertexStatus(); status.serviceIsAlive = true; // // Update information about disk usage // foreach (string disk in Environment.GetLogicalDrives()) { ulong freeDiskSpaceforUser; ulong totalDiskSpace; ulong freeDiskSpace; if (NativeMethods.GetDiskFreeSpaceEx(disk, out freeDiskSpaceforUser, out totalDiskSpace, out freeDiskSpace)) { status.freeDiskSpaces.Add(disk, freeDiskSpace); } else { // // Report any errors as warnings, as this is a non-essential call // int errorCode = Marshal.GetLastWin32Error(); Exception lastex = Marshal.GetExceptionForHR(errorCode); if (lastex != null) { DryadLogger.LogWarning("Unable to get disk space information", "Disk: {0} Error: {1}", disk, lastex.Message); } else { DryadLogger.LogWarning("Unable to get disk space information", "Disk: {0} Error Code: {1}", disk, errorCode); } } } // // Update information about memory usage // NativeMethods.MEMORYSTATUSEX memStatus = new NativeMethods.MEMORYSTATUSEX(); if (NativeMethods.GlobalMemoryStatusEx(memStatus)) { status.freePhysicalMemory = memStatus.ullAvailPhys; status.freeVirtualMemory = memStatus.ullAvailVirtual; } else { // // Report any errors as warnings, as this is a non-essential call // int errorCode = Marshal.GetLastWin32Error(); Exception lastex = Marshal.GetExceptionForHR(errorCode); if (lastex != null) { DryadLogger.LogWarning("Unable to get memory information", "Error: {0}", lastex.Message); } else { DryadLogger.LogWarning("Unable to get memory information", "Error Code: {0}", errorCode); } } // // Get process info for each running vertex process // status.runningProcessCount = 0; lock (vertexProcessTable.SyncRoot) { foreach (VertexProcess vp in this.vertexProcessTable) { VertexProcessInfo vpInfo = new VertexProcessInfo(); vpInfo.DryadId = vp.DryadId; vpInfo.commandLine = vp.commandLine; vpInfo.State = vp.State; status.vps.Add(vpInfo); if (vp.State == ProcessState.Running) { status.runningProcessCount++; } } } DryadLogger.LogMethodExit(status); return status; }