예제 #1
0
        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);
            }
        }
예제 #2
0
        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();
            }));
        }
예제 #3
0
파일: JmxDump.cs 프로젝트: Neo4Net/Neo4Net
 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";
     }));
 }
예제 #4
0
        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));
            }
        }
예제 #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.diagnostics.DiagnosticsReporter createAndRegisterSources() throws org.neo4j.commandline.admin.CommandFailed
        private DiagnosticsReporter CreateAndRegisterSources()
        {
            DiagnosticsReporter reporter = new DiagnosticsReporter();
            File   configFile            = _configDir.resolve(Config.DEFAULT_CONFIG_FILE_NAME).toFile();
            Config config = GetConfig(configFile);

            File storeDirectory = config.Get(database_path);

            reporter.RegisterAllOfflineProviders(config, storeDirectory, this._fs);

            // Register sources provided by this tool
            reporter.RegisterSource("config", DiagnosticsReportSources.newDiagnosticsFile("neo4j.conf", _fs, configFile));

            reporter.RegisterSource("ps", RunningProcesses());

            // Online connection
            RegisterJMXSources(reporter);
            return(reporter);
        }
예제 #6
0
파일: JmxDump.cs 프로젝트: Neo4Net/Neo4Net
        /// <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;
            }));
        }
예제 #7
0
        /// <summary>
        /// Add all files in a directory recursively.
        /// </summary>
        /// <param name="path"> current relative path for destination. </param>
        /// <param name="dir"> current directory or file. </param>
        /// <param name="sources"> list of source that will be accumulated. </param>
        private void AddDirectory(string path, File dir, IList <DiagnosticsReportSource> sources)
        {
            string currentLevel = path + File.separator + dir.Name;

            if (_fs.isDirectory(dir))
            {
                File[] files = _fs.listFiles(dir);
                if (files != null)
                {
                    foreach (File file in files)
                    {
                        AddDirectory(currentLevel, file, sources);
                    }
                }
            }
            else               // File
            {
                sources.Add(DiagnosticsReportSources.newDiagnosticsFile(currentLevel, _fs, dir));
            }
        }