private void GetClusterState(IList <DiagnosticsReportSource> sources) { if (_clusterStateDirectory == null) { sources.Add(DiagnosticsReportSources.newDiagnosticsString("ccstate.txt", () => "error creating ClusterStateDirectory: " + _clusterStateException.Message)); return; } foreach (File file in _fs.listFiles(_clusterStateDirectory, (dir, name) => !name.Equals(RAFT_LOG_DIRECTORY_NAME))) { AddDirectory("ccstate", file, sources); } }
private static DiagnosticsReportSource RunningProcesses() { return(DiagnosticsReportSources.newDiagnosticsString("ps.csv", () => { IList <ProcessInfo> processesList = JProcesses.ProcessList; StringBuilder sb = new StringBuilder(); sb.Append(escapeCsv("Process PID")).Append(',').Append(escapeCsv("Process Name")).Append(',').Append(escapeCsv("Process Time")).Append(',').Append(escapeCsv("User")).Append(',').Append(escapeCsv("Virtual Memory")).Append(',').Append(escapeCsv("Physical Memory")).Append(',').Append(escapeCsv("CPU usage")).Append(',').Append(escapeCsv("Start Time")).Append(',').Append(escapeCsv("Priority")).Append(',').Append(escapeCsv("Full command")).Append('\n'); foreach (ProcessInfo processInfo in processesList) { sb.Append(processInfo.Pid).Append(',').Append(escapeCsv(processInfo.Name)).Append(',').Append(processInfo.Time).Append(',').Append(escapeCsv(processInfo.User)).Append(',').Append(processInfo.VirtualMemory).Append(',').Append(processInfo.PhysicalMemory).Append(',').Append(processInfo.CpuUsage).Append(',').Append(processInfo.StartTime).Append(',').Append(processInfo.Priority).Append(',').Append(escapeCsv(processInfo.Command)).Append('\n'); } return sb.ToString(); })); }
private DiagnosticsReportSource NewReportsBeanSource(string destination, ReportsInvoker reportsInvoker) { return(DiagnosticsReportSources.newDiagnosticsString(destination, () => { try { ObjectName name = new ObjectName("org.neo4j:instance=kernel#0,name=Reports"); Reports reportsBean = JMX.newMBeanProxy(_mBeanServer, name, typeof(Reports)); return reportsInvoker.Invoke(reportsBean); } catch (MalformedObjectNameException) { } return "Unable to invoke ReportsBean"; })); }
private void GetRaftLogs(IList <DiagnosticsReportSource> sources) { if (_clusterStateDirectory == null) { sources.Add(DiagnosticsReportSources.newDiagnosticsString("raft.txt", () => "error creating ClusterStateDirectory: " + _clusterStateException.Message)); return; } File raftLogDirectory = new File(_clusterStateDirectory, RAFT_LOG_DIRECTORY_NAME); FileNames fileNames = new FileNames(raftLogDirectory); SortedDictionary <long, File> allFiles = fileNames.GetAllFiles(_fs, NullLog.Instance); foreach (File logFile in allFiles.Values) { sources.Add(DiagnosticsReportSources.newDiagnosticsFile("raft/" + logFile.Name, _fs, logFile)); } }
/// <summary> /// Captures a thread dump of the running instance. /// </summary> /// <returns> a diagnostics source the will emit a thread dump. </returns> public virtual DiagnosticsReportSource ThreadDump() { return(DiagnosticsReportSources.newDiagnosticsString("threaddump.txt", () => { string result; try { // Try to invoke real thread dump result = ( string )_mBeanServer.invoke(new ObjectName("com.sun.management:type=DiagnosticCommand"), "threadPrint", new object[] { null }, new string[] { typeof(string[]).FullName }); } catch (Exception exception) when(exception is InstanceNotFoundException || exception is ReflectionException || exception is MBeanException || exception is MalformedObjectNameException || exception is IOException) { // Failed, do a poor mans attempt result = MXThreadDump; } return result; })); }