/// <summary> /// Collect memory snapshot and save it to the disk. This method forces full GC. /// Doesn't throw any errors even if the application is run with profiling disabled. /// </summary> /// <param name="name">The name of the memory snapshot. This is not a file name. Currently not used.</param> public static void GetSnapshot(string name) { var id = Helper.Id; switch (Helper.Platform) { case PlatformId.Linux: if (LinuxHelper.IsLibCoreApiAlreadyLoaded()) { Helper.InvokeCoreApi(() => LibCoreApi.V1_Memory_GetSnapshot(id, name)); } break; case PlatformId.MacOsX: if (MacOsXHelper.IsLibCoreApiAlreadyLoaded()) { Helper.InvokeCoreApi(() => LibCoreApi.V1_Memory_GetSnapshot(id, name)); } break; case PlatformId.Windows: if (WindowsHelper.IsCoreApiDllAlreadyLoaded()) { Helper.InvokeCoreApi(() => CoreApiDll.V1_Memory_GetSnapshot(id, name)); } break; default: throw new PlatformNotSupportedException(); } }
/// <summary> /// Enable/disable collecting memory allocation data. Does nothing if collecting allocation data is disabled in the /// profiler. To check whether the collecting is enabled, use <see cref="GetFeatures" /> with /// <see cref="MemoryFeatures.CollectAllocations" /> flag. /// Doesn't throw any errors even if the application is run with profiling disabled. /// </summary> public static void CollectAllocations(bool enable) { var id = Helper.Id; switch (Helper.Platform) { case PlatformId.Linux: if (LinuxHelper.IsLibCoreApiAlreadyLoaded()) { Helper.InvokeCoreApi(() => LibCoreApi.V1_Memory_CollectAllocations(id, enable)); } break; case PlatformId.MacOsX: if (MacOsXHelper.IsLibCoreApiAlreadyLoaded()) { Helper.InvokeCoreApi(() => LibCoreApi.V1_Memory_CollectAllocations(id, enable)); } break; case PlatformId.Windows: if (WindowsHelper.IsCoreApiDllAlreadyLoaded()) { Helper.InvokeCoreApi(() => CoreApiDll.V1_Memory_CollectAllocations(id, enable)); } break; default: throw new PlatformNotSupportedException(); } }
/// <summary> /// Start collecting profiling data. /// Doesn't throw any errors even if the application is run with profiling disabled. /// </summary> /// <param name="groupName">The name of the collected data block.</param> public static void StartCollectingData(string groupName) { var id = Helper.Id; switch (Helper.Platform) { case PlatformId.Linux: if (LinuxHelper.IsLibCoreApiAlreadyLoaded()) { Helper.InvokeCoreApi(() => LibCoreApi.V1_Measure_StartCollecting(id, groupName)); } break; case PlatformId.MacOsX: if (MacOsXHelper.IsLibCoreApiAlreadyLoaded()) { Helper.InvokeCoreApi(() => LibCoreApi.V1_Measure_StartCollecting(id, groupName)); } break; case PlatformId.Windows: if (WindowsHelper.IsCoreApiDllAlreadyLoaded()) { Helper.InvokeCoreApi(() => CoreApiDll.V1_Measure_StartCollecting(id, groupName)); } break; default: throw new PlatformNotSupportedException(); } }
/// <summary> /// Detach the profiler from the profiled process. Does nothing if detaching is disabled in the profiler. To check /// whether the detaching is enabled, use <see cref="GetFeatures" /> with <see cref="MeasureFeatures.Detach" /> flag. /// Doesn't throw any errors even if the application is run with profiling disabled. /// </summary> public static void Detach() { var id = Helper.Id; switch (Helper.Platform) { case PlatformId.Linux: if (LinuxHelper.IsLibCoreApiAlreadyLoaded()) { Helper.InvokeCoreApi(() => LibCoreApi.V1_Measure_Detach(id)); } break; case PlatformId.MacOsX: if (MacOsXHelper.IsLibCoreApiAlreadyLoaded()) { Helper.InvokeCoreApi(() => LibCoreApi.V1_Measure_Detach(id)); } break; case PlatformId.Windows: if (WindowsHelper.IsCoreApiDllAlreadyLoaded()) { Helper.InvokeCoreApi(() => CoreApiDll.V1_Measure_Detach(id)); } break; default: throw new PlatformNotSupportedException(); } }
private static UpdateManifest GetUpdateManifestInternal(ILogger logger, string tempPath, string fileName) { try { ZipFile.ExtractToDirectory(fileName, tempPath, true); if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { LinuxHelper.Bash($"chmod 755 {Path.Combine(tempPath, ServerInfo.BootloderExecutable)}"); LinuxHelper.Bash($"chmod 755 {Path.Combine(tempPath, ServerInfo.ServerExecutable)}"); LinuxHelper.Bash($"chmod 755 {Path.Combine(tempPath, ServerInfo.WatchdogExecutable)}"); } } catch (Exception e) { logger.LogError(e, "Could not unzip update file"); return(null); } var files = Directory.GetFiles(tempPath, "automatica-update.manifest"); if (files.Length == 0) { logger.LogError("Could not find automatica-update.manifest file"); return(null); } var manifest = files[0]; var manifestStr = ""; using (var reader = new StreamReader(manifest)) { manifestStr = reader.ReadToEnd(); } try { var updateManifest = JsonConvert.DeserializeObject <UpdateManifest>(manifestStr); return(updateManifest); } catch (Exception e) { logger.LogError(e, "Exception occured while checking the update package"); return(null); } }
/// <summary> /// Get a set of features currently active in the profiler. /// </summary> /// <returns>The set of features.</returns> public static MemoryFeatures GetFeatures() { var id = Helper.Id; MemoryFeatures features = 0; switch (Helper.Platform) { case PlatformId.Linux: if (LinuxHelper.IsLibCoreApiAlreadyLoaded()) { if (Helper.InvokeCoreApi(() => LibCoreApi.V1_Memory_CheckActive(id, out features))) { return(features); } } break; case PlatformId.MacOsX: if (MacOsXHelper.IsLibCoreApiAlreadyLoaded()) { if (Helper.InvokeCoreApi(() => LibCoreApi.V1_Memory_CheckActive(id, out features))) { return(features); } } break; case PlatformId.Windows: if (WindowsHelper.IsCoreApiDllAlreadyLoaded()) { if (Helper.InvokeCoreApi(() => CoreApiDll.V1_Memory_CheckActive(id, out features))) { return(features); } } break; default: throw new PlatformNotSupportedException(); } return(0); }