예제 #1
0
        /* REFACTOR */

        private static void ExecuteCommands()
        {
            IDictionary <string, CmdLineCommand> commands = new Dictionary <string, CmdLineCommand>
            {
                { "appcmd ", new CmdLineCommand(string.Format("{0} list requests", _appCmdPath), Path.Combine(_tempFolderPath, "IISRequests.txt")) },
                { "dir_outsystems", new CmdLineCommand(string.Format("dir /s /a \"{0}\"", _osInstallationFolder), Path.Combine(_windowsInfoDest, "dir_outsystems")) },
                { "tasklist", new CmdLineCommand("tasklist /v", Path.Combine(_windowsInfoDest, "tasklist")) },
                { "cpu_info", new CmdLineCommand("wmic cpu", Path.Combine(_windowsInfoDest, "cpu_info")) },
                { "memory_info", new CmdLineCommand("wmic memphysical", Path.Combine(_windowsInfoDest, "memory_info")) },
                { "mem_cache", new CmdLineCommand("wmic memcache", Path.Combine(_windowsInfoDest, "mem_cache")) },
                { "net_protocol", new CmdLineCommand("wmic netprotocol", Path.Combine(_windowsInfoDest, "net_protocol")) },
                { "env_info", new CmdLineCommand("wmic environment", Path.Combine(_windowsInfoDest, "env_info")) },
                { "os_info", new CmdLineCommand("wmic os", Path.Combine(_windowsInfoDest, "os_info")) },
                { "pagefile", new CmdLineCommand("wmic pagefile", Path.Combine(_windowsInfoDest, "pagefile")) },
                { "partition", new CmdLineCommand("wmic partition", Path.Combine(_windowsInfoDest, "partition")) },
                { "startup", new CmdLineCommand("wmic startup", Path.Combine(_windowsInfoDest, "startup")) },
                { "app_evtx", new CmdLineCommand("WEVTUtil epl Application " + "\"" + Path.Combine(_tempFolderPath, _evtVwrLogsDest + @"\Application.evtx") + "\"") },
                { "sys_evtx", new CmdLineCommand("WEVTUtil epl System " + "\"" + Path.Combine(_tempFolderPath, _evtVwrLogsDest + @"\System.evtx") + "\"") },
                { "sec_evtx", new CmdLineCommand("WEVTUtil epl Security " + "\"" + Path.Combine(_tempFolderPath, _evtVwrLogsDest + @"\Security.evtx") + "\"") }
            };

            foreach (KeyValuePair <string, CmdLineCommand> commandEntry in commands)
            {
                FileLogger.TraceLog("Getting " + commandEntry.Key + "...");
                commandEntry.Value.Execute();
            }
        }
예제 #2
0
        public static void ExportServiceCenterLogs(string dbEngine, OSDiagToolConf.ConfModel.strConfModel configurations, OSDiagToolForm.OsDiagFormConfModel.strFormConfigurationsModel FormConfigurations,
                                                   DBConnector.SQLConnStringModel sqlConnString = null, DBConnector.OracleConnStringModel oracleConnString = null, string adminSchema = null)
        {
            FileLogger.TraceLog(string.Format("Exporting Platform logs ({0} records)...", FormConfigurations.osLogTopRecords));

            Directory.CreateDirectory(_osPlatformLogs);

            List <string> platformLogs = new List <string>();

            foreach (string table in configurations.tableNames)   // add only oslog tables to list
            {
                if (table.ToLower().StartsWith("oslog"))
                {
                    platformLogs.Add(table);
                }
            }

            if (dbEngine.Equals("sqlserver"))
            {
                Platform.LogExporter.PlatformLogExporter(dbEngine, platformLogs, FormConfigurations, _osPlatformLogs, configurations.queryTimeout, sqlConnString, null);
            }
            else if (dbEngine.Equals("oracle"))
            {
                Platform.LogExporter.PlatformLogExporter(dbEngine, platformLogs, FormConfigurations, _osPlatformLogs, configurations.queryTimeout, null, oracleConnString, adminSchema);
            }
        }
예제 #3
0
        public static void CopyIISAccessLogs(int iisLogsNrDays)
        {
            FileSystemHelper fsHelper = new FileSystemHelper();

            FileLogger.TraceLog(string.Format("Exporting IIS Access logs({0} days)...", iisLogsNrDays));
            IISHelper.GetIISAccessLogs(_iisApplicationHostPath, _tempFolderPath, fsHelper, iisLogsNrDays);
        }
예제 #4
0
        public static void GetPlatformAndServerFiles()
        {
            // Process Platform and Server Configuration files
            FileLogger.TraceLog("Copying Platform and Server configuration files... ");
            Directory.CreateDirectory(_osPlatFilesDest);
            Platform.PlatformFilesHelper.CopyPlatformAndServerConfFiles(_osInstallationFolder, _iisApplicationHostPath, _iisWebConfigPath, _machineConfigPath, _osPlatFilesDest);

            // Export Registry information
            // Create directory for Registry information
            Directory.CreateDirectory(Path.Combine(_tempFolderPath, "RegistryInformation"));
            string registryInformationPath = Path.Combine(_tempFolderPath, "RegistryInformation");

            // Fetch Registry key values and subkeys values
            try {
                FileLogger.TraceLog("Exporting Registry information...");

                RegistryClass.RegistryCopy(_sslProtocolsRegistryPath, Path.Combine(registryInformationPath, "SSLProtocols.txt"), true);
                RegistryClass.RegistryCopy(_netFrameworkRegistryPath, Path.Combine(registryInformationPath, "NetFramework.txt"), true);
                RegistryClass.RegistryCopy(_iisRegistryPath, Path.Combine(registryInformationPath, "IIS.txt"), true);
                RegistryClass.RegistryCopy(_outSystemsPlatformRegistryPath, Path.Combine(registryInformationPath, "OutSystemsPlatform.txt"), true);
                RegistryClass.RegistryCopy(_rabbitMQRegistryPath, Path.Combine(registryInformationPath, "RabbitMQ.txt"), true);
            } catch (Exception e) {
                FileLogger.LogError("Failed to export Registry:", e.Message + e.StackTrace);
            }
        }
예제 #5
0
        public static void ExportEventViewerAndServerLogs()
        {
            WindowsEventLogHelper welHelper = new WindowsEventLogHelper();

            FileLogger.TraceLog("Exporting Event Viewer and Server logs... ");
            Directory.CreateDirectory(_evtVwrLogsDest);
            Directory.CreateDirectory(_windowsInfoDest);
            welHelper.GenerateLogFiles(Path.Combine(_tempFolderPath, _evtVwrLogsDest));
            ExecuteCommands();
        }
예제 #6
0
        public static void GenerateZipFile()
        {
            FileLogger.TraceLog("Creating zip file... ");
            FileSystemHelper fsHelper = new FileSystemHelper();

            _targetZipFile = Path.Combine(Directory.GetCurrentDirectory(), "outsystems_data_" + DateTimeToTimestamp(DateTime.Now) + "_" + DateTime.Now.Second + DateTime.Now.Millisecond + ".zip"); // need to assign again in case the user runs the tool a second time
            fsHelper.CreateZipFromDirectory(_tempFolderPath, _targetZipFile, true);

            // Delete temp folder
            Directory.Delete(_tempFolderPath, true);

            _endFeedback = "File Location: " + _targetZipFile;
        }
예제 #7
0
        public static void ExportPlatformMetamodel(string dbEngine, OSDiagToolConf.ConfModel.strConfModel configurations, OSDiagToolForm.OsDiagFormConfModel.strFormConfigurationsModel FormConfigurations,
                                                   DBConnector.SQLConnStringModel sqlConnString = null, DBConnector.OracleConnStringModel oracleConnString = null)
        {
            FileLogger.TraceLog("Exporting Platform Metamodel...");

            Directory.CreateDirectory(_osMetamodelTablesDest);

            if (dbEngine.Equals("sqlserver"))
            {
                var           connector  = new DBConnector.SLQDBConnector();
                SqlConnection connection = connector.SQLOpenConnection(sqlConnString);

                using (connection) {
                    bool isLifeTimeEnvironment = Platform.PlatformUtils.IsLifeTimeEnvironment(dbEngine, configurations.queryTimeout, connection);

                    FileLogger.TraceLog("Starting exporting tables: ");
                    foreach (string table in FormConfigurations.metamodelTables)
                    {
                        if ((isLifeTimeEnvironment && table.ToLower().StartsWith("osltm") || table.ToLower().StartsWith("ossys")))
                        {
                            FileLogger.TraceLog(table + ", ", writeDateTime: false);
                            string selectAllQuery = "SELECT * FROM " + table;
                            CSVExporter.SQLToCSVExport(dbEngine, table, _osMetamodelTablesDest, configurations.queryTimeout, selectAllQuery, connection, null);
                        }
                    }
                }
            }
            else if (dbEngine.Equals("oracle"))
            {
                var connector = new DBConnector.OracleDBConnector();
                OracleConnection connection = connector.OracleOpenConnection(oracleConnString);

                string platformDBAdminUser = Platform.PlatformUtils.GetPlatformDBAdminUser();

                using (connection) {
                    bool isLifeTimeEnvironment = Platform.PlatformUtils.IsLifeTimeEnvironment(dbEngine, configurations.queryTimeout, null, connection, platformDBAdminUser);

                    FileLogger.TraceLog("Starting exporting tables: ");
                    foreach (string table in FormConfigurations.metamodelTables)
                    {
                        if ((isLifeTimeEnvironment && table.ToLower().StartsWith("osltm") || table.ToLower().StartsWith("ossys")))
                        {
                            FileLogger.TraceLog(table + ", ", writeDateTime: false);
                            string selectAllQuery = "SELECT * FROM " + platformDBAdminUser + "." + table;
                            CSVExporter.ORCLToCsvExport(connection, table, _osMetamodelTablesDest, configurations.queryTimeout, platformDBAdminUser, selectAllQuery);
                        }
                    }
                }
            }
        }
예제 #8
0
        public static void DatabaseTroubleshootProgram(OSDiagToolConf.ConfModel.strConfModel configurations, DBConnector.SQLConnStringModel sqlConnString = null, DBConnector.OracleConnStringModel orclConnString = null)
        {
            Directory.CreateDirectory(_osDatabaseTroubleshootDest);

            try {
                FileLogger.TraceLog(string.Format("Performing {0} Database Troubleshoot...", dbEngine.ToUpper()));

                if (dbEngine.Equals("sqlserver"))
                {
                    Database.DatabaseQueries.DatabaseTroubleshoot.DatabaseTroubleshooting(dbEngine, configurations, _osDatabaseTroubleshootDest, sqlConnString, null);
                }
                else if (dbEngine.Equals("oracle"))
                {
                    Database.DatabaseQueries.DatabaseTroubleshoot.DatabaseTroubleshooting(dbEngine, configurations, _osDatabaseTroubleshootDest, null, orclConnString);
                }
            } catch (Exception e) {
                FileLogger.LogError("Failed to perform Database Troubleshoot", e.Message + e.StackTrace);
            }
        }
예제 #9
0
        public static void GetIISAccessLogs(string iisapplicationHostPath, string tempFolderPath, FileSystemHelper fsHelper, int daysToFetch)
        {
            //Retrieving IIS access logs
            try {
                FileLogger.TraceLog("Retrieving IIS Access logs... ");

                // Loading Xml text from the file. Note: 32 bit processes will redirect \System32 to \SysWOW64: http://www.samlogic.net/articles/sysnative-folder-64-bit-windows.htm
                if (Environment.Is64BitOperatingSystem == false)
                {
                    iisapplicationHostPath = iisapplicationHostPath.Replace("system32", "Sysnative");
                }
                var xmlString = XDocument.Load(iisapplicationHostPath);

                // Querying the data and finding the Access logs path
                var query = from p in xmlString.Descendants("siteDefaults")
                            select new {
                    LogsFilePath = p.Element("logFile").Attribute("directory").Value,
                };

                string iisAccessLogsPath = query.First().LogsFilePath.ToLower();

                if (iisAccessLogsPath.Contains("%systemdrive%"))
                {
                    iisAccessLogsPath = iisAccessLogsPath.Replace("%systemdrive%\\", Path.GetPathRoot(Environment.SystemDirectory));
                    if ((Environment.Is64BitOperatingSystem == false) && iisAccessLogsPath.Contains("system32"))
                    {
                        iisAccessLogsPath = iisAccessLogsPath.Replace("system32", "Sysnative");
                    }
                }

                //Copies all the contents from the path iisAcessLogsPath, including contents in subfolder
                fsHelper.DirectoryCopy(iisAccessLogsPath, Path.Combine(tempFolderPath, "IISLogs"), true, true, daysToFetch);
            } catch (Exception e) {
                FileLogger.LogError("Attempted to retrieve IIS Access logs but failed...", e.Message + e.StackTrace);
            }
        }
예제 #10
0
        public static void CollectMemoryDumps(bool iisMemDumps, bool osMemDumps)
        {
            List <string> processList = new List <string>();

            if (iisMemDumps && osMemDumps)
            {
                processList.AddRange(new List <string>()
                {
                    "w3wp", "deployment_controller", "deployment_service", "scheduler", "log_service"
                });
            }
            else if (!iisMemDumps && osMemDumps)
            {
                processList.AddRange(new List <string>()
                {
                    "deployment_controller", "deployment_service", "scheduler", "log_service"
                });
            }
            else if (iisMemDumps && !osMemDumps)
            {
                processList.AddRange(new List <string>()
                {
                    "w3wp"
                });
            }
            else
            {
                return;
            }

            string memoryDumpsPath = Path.Combine(_tempFolderPath, "MemoryDumps");

            Directory.CreateDirectory(memoryDumpsPath);

            CmdLineCommand command;

            ThreadDumpCollector         dc          = new ThreadDumpCollector(5000);
            Dictionary <string, string> processDict = new Dictionary <string, string> {
                { "log_service", "LogServer.exe" },
                { "deployment_service", "DeployService.exe" },
                { "deployment_controller", "CompilerService.exe" },
                { "scheduler", "Scheduler.exe" },
                { "w3wp", "w3wp.exe" }
            };

            try {
                foreach (string processTag in processList)
                {
                    FileLogger.TraceLog("Collecting " + processTag + " memory dumps... ");

                    string     processName = processDict[processTag];
                    List <int> pids        = dc.GetProcessIdsByName(processName);

                    foreach (int pid in dc.GetProcessIdsByFilename(processName))
                    {
                        string pidSuf   = pids.Count > 1 ? "_" + pid : "";
                        string filename = "memdump_" + processTag + pidSuf + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".dmp";

                        FileLogger.TraceLog(" - PID " + pid + " - ");
                        command = new CmdLineCommand("procdump64.exe -ma " + pid + " /accepteula " + "\"" + Path.Combine(memoryDumpsPath, filename) + "\"");
                        command.Execute();
                    }
                }
            } catch (Exception e) {
                FileLogger.LogError("Failed to get memory dump: ", e.Message + e.StackTrace);
            }
        }
예제 #11
0
        private static void CollectThreadDumps(bool iisThreads, bool osThreads)
        {
            List <string> processList = new List <string>();

            if (iisThreads && osThreads)
            {
                processList.AddRange(new List <string>()
                {
                    "w3wp", "deployment_controller", "deployment_service", "scheduler", "log_service"
                });
            }
            else if (!iisThreads && osThreads)
            {
                processList.AddRange(new List <string>()
                {
                    "deployment_controller", "deployment_service", "scheduler", "log_service"
                });
            }
            else if (iisThreads && !osThreads)
            {
                processList.AddRange(new List <string>()
                {
                    "w3wp"
                });
            }
            else
            {
                return;
            }

            string threadDumpsPath = Path.Combine(_tempFolderPath, "ThreadDumps");

            Directory.CreateDirectory(threadDumpsPath);

            ThreadDumpCollector         dc          = new ThreadDumpCollector(5000);
            Dictionary <string, string> processDict = new Dictionary <string, string> {
                { "log_service", "LogServer.exe" },
                { "deployment_service", "DeployService.exe" },
                { "deployment_controller", "CompilerService.exe" },
                { "scheduler", "Scheduler.exe" },
                { "w3wp", "w3wp.exe" }
            };

            try {
                foreach (string processTag in processList)
                {
                    FileLogger.TraceLog("Collecting " + processTag + " thread dumps... ");

                    string     processName = processDict[processTag];
                    List <int> pids        = dc.GetProcessIdsByName(processName);

                    foreach (int pid in dc.GetProcessIdsByFilename(processName))
                    {
                        string pidSuf   = pids.Count > 1 ? "_" + pid : "";
                        string filename = "threads_" + processTag + pidSuf + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".log";
                        using (TextWriter writer = new StreamWriter(File.Create(Path.Combine(threadDumpsPath, filename)))) {
                            writer.WriteLine(DateTime.Now.ToString());
                            writer.WriteLine(dc.GetThreadDump(pid));
                        }
                    }
                }
            } catch (Exception e) {
                FileLogger.LogError("Failed to get thread dump: ", e.Message + e.StackTrace);
            }
        }
예제 #12
0
 public static void CollectMemoryDumpsProgram(bool getIisMemDumps, bool getOsMemDumps)
 {
     FileLogger.TraceLog(string.Format("Initiating collection of thread dumps...(IIS memory dumps: {0} ; OutSystems Services memory dumps: {1})", getIisMemDumps, getOsMemDumps));
     CollectMemoryDumps(getIisMemDumps, getOsMemDumps);
 }
예제 #13
0
 public static void CollectThreadDumpsProgram(bool getIisThreadDumps, bool getOsThreadDumps)
 {
     FileLogger.TraceLog(string.Format("Initiating collection of thread dumps...(IIS thread dumps: {0} ; OutSystems Services thread dumps: {1})", getIisThreadDumps, getOsThreadDumps));
     CollectThreadDumps(getIisThreadDumps, getOsThreadDumps); // evaluate if this method is really necessary
 }