public static void ExecuteJobThroughSteps(ProgramOptions programOptions) { // Read job file from the location JobConfiguration jobConfiguration = FileIOHelper.ReadJobConfigurationFromFile(programOptions.OutputJobFilePath); if (jobConfiguration == null) { loggerConsole.Error("Unable to load job input file {0}", programOptions.InputETLJobFilePath); return; } #region Output diagnostic parameters to log loggerConsole.Info("Starting job from status {0}({0:d})", jobConfiguration.Status); logger.Info("Starting job from status {0}({0:d})", jobConfiguration.Status); logger.Info("Job input: TimeRange.From='{0:o}', TimeRange.To='{1:o}', Time ranges='{2}'", jobConfiguration.Input.TimeRange.From, jobConfiguration.Input.TimeRange.To); logger.Info("DetectedEntities='{0}'", jobConfiguration.Input.DetectedEntities); logger.Info("Flowmaps='{0}'", jobConfiguration.Input.Flowmaps); logger.Info("Metrics='{0}'", jobConfiguration.Input.Metrics); logger.Info("Snapshots='{0}'", jobConfiguration.Input.Snapshots); logger.Info("Events='{0}'", jobConfiguration.Input.Events); logger.Info("Licenses='{0}''", jobConfiguration.Input.Licenses); logger.Info("Configuration='{0}'", jobConfiguration.Input.Configuration); logger.Info("UsersGroupsRolesPermissions='{0}'", jobConfiguration.Input.UsersGroupsRolesPermissions); logger.Info("EntityDashboards='{0}'", jobConfiguration.Input.EntityDashboards); if (jobConfiguration.Input.MetricsSelectionCriteria != null) { logger.Info("Job input: MetricsSelectionCriteria='{0}'", String.Join(",", jobConfiguration.Input.MetricsSelectionCriteria)); } if (jobConfiguration.Input.SnapshotSelectionCriteria != null) { logger.Info("Job input, SnapshotSelectionCriteria: Tiers='{0}', TierTypes='{1}'", String.Join(",", jobConfiguration.Input.SnapshotSelectionCriteria.Tiers), String.Join(",", jobConfiguration.Input.SnapshotSelectionCriteria.TierTypes)); logger.Info("Job input, SnapshotSelectionCriteria: BusinessTransactions='{0}', BusinessTransactionType='{1}'", String.Join(",", jobConfiguration.Input.SnapshotSelectionCriteria.BusinessTransactions), String.Join(",", jobConfiguration.Input.SnapshotSelectionCriteria.BusinessTransactionTypes)); logger.Info("Job input, SnapshotSelectionCriteria: UserExperience.Normal='{0}', UserExperience.Slow='{1}', UserExperience.VerySlow='{2}', UserExperience.Stall='{3}', UserExperience.Error='{4}'", jobConfiguration.Input.SnapshotSelectionCriteria.UserExperience.Normal, jobConfiguration.Input.SnapshotSelectionCriteria.UserExperience.Slow, jobConfiguration.Input.SnapshotSelectionCriteria.UserExperience.VerySlow, jobConfiguration.Input.SnapshotSelectionCriteria.UserExperience.Stall, jobConfiguration.Input.SnapshotSelectionCriteria.UserExperience.Error); logger.Info("Job input, SnapshotSelectionCriteria: SnapshotType.Full='{0}', SnapshotType.Partial='{1}', SnapshotType.None='{2}'", jobConfiguration.Input.SnapshotSelectionCriteria.SnapshotType.Full, jobConfiguration.Input.SnapshotSelectionCriteria.SnapshotType.Partial, jobConfiguration.Input.SnapshotSelectionCriteria.SnapshotType.None); } logger.Info("Job input: ConfigurationComparisonReferenceAPM='{0}'", jobConfiguration.Input.ConfigurationComparisonReferenceAPM); logger.Info("Job input: ConfigurationComparisonReferenceWEB='{0}'", jobConfiguration.Input.ConfigurationComparisonReferenceWEB); logger.Info("Job input: ConfigurationComparisonReferenceMOBILE='{0}'", jobConfiguration.Input.ConfigurationComparisonReferenceMOBILE); logger.Info("Job input: ConfigurationComparisonReferenceDB='{0}'", jobConfiguration.Input.ConfigurationComparisonReferenceDB); foreach (JobTimeRange jobTimeRange in jobConfiguration.Input.HourlyTimeRanges) { logger.Info("Expanded time ranges: From='{0:o}', To='{1:o}'", jobTimeRange.From, jobTimeRange.To); } logger.Info("Job output:"); logger.Info("DetectedEntities='{0}'", jobConfiguration.Output.DetectedEntities); logger.Info("Flowmaps='{0}'", jobConfiguration.Output.Flowmaps); logger.Info("EntityMetrics='{0}'", jobConfiguration.Output.EntityMetrics); logger.Info("EntityMetricsGraphs='{0}'", jobConfiguration.Output.EntityMetricGraphs); logger.Info("Snapshots='{0}'", jobConfiguration.Output.Snapshots); logger.Info("Events='{0}'", jobConfiguration.Output.Events); logger.Info("Licenses='{0}''", jobConfiguration.Output.Licenses); logger.Info("Configuration='{0}'", jobConfiguration.Output.Configuration); logger.Info("UsersGroupsRolesPermissions='{0}'", jobConfiguration.Output.UsersGroupsRolesPermissions); logger.Info("EntityDashboards='{0}'", jobConfiguration.Output.EntityDashboards); logger.Info("HealthCheck='{0}'", jobConfiguration.Output.HealthCheck); logger.Info("ApplicationSummary='{0}'", jobConfiguration.Output.ApplicationSummary); #endregion // Run the step and move to next until things are done while (jobConfiguration.Status != JobStatus.Done && jobConfiguration.Status != JobStatus.Error) { loggerConsole.Info("Executing job step {0}({0:d})", jobConfiguration.Status); logger.Info("Executing job step {0}({0:d})", jobConfiguration.Status); JobStepBase jobStep = getJobStepFromFactory(jobConfiguration.Status); if (jobStep != null) { if (jobStep.Execute(programOptions, jobConfiguration) == false) { loggerConsole.Warn("If you need support, please review https://github.com/Appdynamics/AppDynamics.DEXTER/wiki#getting-support and send the logs"); jobConfiguration.Status = JobStatus.Error; } } if (jobConfiguration.Status != JobStatus.Error) { jobConfiguration.Status = jobStepsLinked.Find(jobConfiguration.Status).Next.Value; } // Save the resulting JSON file to the job target folder if (FileIOHelper.WriteJobConfigurationToFile(jobConfiguration, programOptions.OutputJobFilePath) == false) { loggerConsole.Error("Unable to write job input file {0}", programOptions.OutputJobFilePath); return; } } }
public static void ExecuteJobThroughSteps(ProgramOptions programOptions) { // Read job file from the location JobConfiguration jobConfiguration = FileIOHelper.ReadJobConfigurationFromFile(programOptions.OutputJobFilePath); if (jobConfiguration == null) { loggerConsole.Error("Unable to load job input file {0}", programOptions.InputJobFilePath); return; } #region Output diagnostic parameters to log loggerConsole.Info("Starting job from status {0}({0:d})", jobConfiguration.Status); logger.Info("Starting job from status {0}({0:d})", jobConfiguration.Status); logger.Info("Job input: TimeRange.From='{0:o}', TimeRange.To='{1:o}', Time ranges='{2}', Flowmaps='{3}', Metrics='{4}', Snapshots='{5}', Configuration='{6}', Events='{7}'", jobConfiguration.Input.TimeRange.From, jobConfiguration.Input.TimeRange.To, jobConfiguration.Input.HourlyTimeRanges.Count, jobConfiguration.Input.Flowmaps, jobConfiguration.Input.Metrics, jobConfiguration.Input.Snapshots, jobConfiguration.Input.Configuration, jobConfiguration.Input.Events); if (jobConfiguration.Input.MetricsSelectionCriteria != null) { logger.Info("Job input: MetricsSelectionCriteria='{0}'", String.Join(",", jobConfiguration.Input.MetricsSelectionCriteria)); } if (jobConfiguration.Input.SnapshotSelectionCriteria != null) { PropertyInfo[] pis = jobConfiguration.Input.SnapshotSelectionCriteria.TierType.GetType().GetProperties(); StringBuilder sb = new StringBuilder(16 * pis.Length); foreach (PropertyInfo pi in pis) { sb.AppendFormat("{0}={1}, ", pi.Name, pi.GetValue(jobConfiguration.Input.SnapshotSelectionCriteria.TierType)); } logger.Info("Job input, SnapshotSelectionCriteria: Tiers='{0}', TierTypes='{1}'", String.Join(",", jobConfiguration.Input.SnapshotSelectionCriteria.Tiers), sb.ToString()); pis = jobConfiguration.Input.SnapshotSelectionCriteria.BusinessTransactionType.GetType().GetProperties(); sb = new StringBuilder(16 * pis.Length); foreach (PropertyInfo pi in pis) { sb.AppendFormat("{0}={1}, ", pi.Name, pi.GetValue(jobConfiguration.Input.SnapshotSelectionCriteria.BusinessTransactionType)); } logger.Info("Job input, SnapshotSelectionCriteria: BusinessTransactions='{0}', BusinessTransactionType='{1}'", String.Join(",", jobConfiguration.Input.SnapshotSelectionCriteria.BusinessTransactions), sb.ToString()); logger.Info("Job input, SnapshotSelectionCriteria: UserExperience.Normal='{0}', UserExperience.Slow='{1}', UserExperience.VerySlow='{2}', UserExperience.Stall='{3}', UserExperience.Error='{4}'", jobConfiguration.Input.SnapshotSelectionCriteria.UserExperience.Normal, jobConfiguration.Input.SnapshotSelectionCriteria.UserExperience.Slow, jobConfiguration.Input.SnapshotSelectionCriteria.UserExperience.VerySlow, jobConfiguration.Input.SnapshotSelectionCriteria.UserExperience.Stall, jobConfiguration.Input.SnapshotSelectionCriteria.UserExperience.Error); logger.Info("Job input, SnapshotSelectionCriteria: SnapshotType.Full='{0}', SnapshotType.Partial='{1}', SnapshotType.None='{2}'", jobConfiguration.Input.SnapshotSelectionCriteria.SnapshotType.Full, jobConfiguration.Input.SnapshotSelectionCriteria.SnapshotType.Partial, jobConfiguration.Input.SnapshotSelectionCriteria.SnapshotType.None); } logger.Info("Job input: ConfigurationComparisonReferenceAPM='{0}'", jobConfiguration.Input.ConfigurationComparisonReferenceAPM); logger.Info("Job input: ConfigurationComparisonReferenceWEB='{0}'", jobConfiguration.Input.ConfigurationComparisonReferenceWEB); logger.Info("Job input: ConfigurationComparisonReferenceMOBILE='{0}'", jobConfiguration.Input.ConfigurationComparisonReferenceMOBILE); logger.Info("Job input: ConfigurationComparisonReferenceDB='{0}'", jobConfiguration.Input.ConfigurationComparisonReferenceDB); logger.Info("Job output: DetectedEntities='{0}', EntityMetrics='{1}', EntityDetails='{2}', Snapshots='{3}', Configuration='{4}', Events='{5}'", jobConfiguration.Output.DetectedEntities, jobConfiguration.Output.EntityMetrics, jobConfiguration.Output.EntityDetails, jobConfiguration.Output.Snapshots, jobConfiguration.Output.Configuration, jobConfiguration.Output.Events); foreach (JobTimeRange jobTimeRange in jobConfiguration.Input.HourlyTimeRanges) { logger.Info("Expanded time ranges: From='{0:o}', To='{1:o}'", jobTimeRange.From, jobTimeRange.To); } #endregion // Run the step and move to next until things are done while (jobConfiguration.Status != JobStatus.Done && jobConfiguration.Status != JobStatus.Error) { loggerConsole.Info("Executing job step {0}({0:d})", jobConfiguration.Status); logger.Info("Executing job step {0}({0:d})", jobConfiguration.Status); JobStepBase jobStep = getJobStepFromFactory(jobConfiguration.Status); if (jobStep != null) { if (jobStep.Execute(programOptions, jobConfiguration) == false) { loggerConsole.Warn("If you need support, please check how to get it at https://github.com/Appdynamics/AppDynamics.DEXTER/wiki#getting-support"); jobConfiguration.Status = JobStatus.Error; } } if (jobConfiguration.Status != JobStatus.Error) { jobConfiguration.Status = jobStepsLinked.Find(jobConfiguration.Status).Next.Value; } // Save the resulting JSON file to the job target folder if (FileIOHelper.WriteJobConfigurationToFile(jobConfiguration, programOptions.OutputJobFilePath) == false) { loggerConsole.Error("Unable to write job input file {0}", programOptions.OutputJobFilePath); return; } // Do a forced GC Collection after all the work in a step. // Probably unnecessary, but to counteract the ulimit handle consumption on non-Windows machines GC.Collect(); } }
public static void ExecuteJobThroughSteps(ProgramOptions programOptions) { // Read job file from the location JobConfiguration jobConfiguration = FileIOHelper.ReadJobConfigurationFromFile(programOptions.OutputJobFilePath); if (jobConfiguration == null) { loggerConsole.Error("Unable to load job input file {0}", programOptions.InputJobFilePath); return; } #region Output diagnostic parameters to log loggerConsole.Info("Starting job from status {0}({0:d})", jobConfiguration.Status); logger.Info("Starting job from status {0}({0:d})", jobConfiguration.Status); logger.Info("Job input: TimeRange.From='{0:o}', TimeRange.To='{1:o}', Time ranges='{2}', Flowmaps='{3}', Metrics='{4}', Snapshots='{5}', Configuration='{6}', Events='{7}'", jobConfiguration.Input.TimeRange.From, jobConfiguration.Input.TimeRange.To, jobConfiguration.Input.HourlyTimeRanges.Count, jobConfiguration.Input.Flowmaps, jobConfiguration.Input.Metrics, jobConfiguration.Input.Snapshots, jobConfiguration.Input.Configuration, jobConfiguration.Input.Events); if (jobConfiguration.Input.MetricsSelectionCriteria != null) { logger.Info("Job input: MetricsSelectionCriteria='{0}'", String.Join(",", jobConfiguration.Input.MetricsSelectionCriteria)); } if (jobConfiguration.Input.SnapshotSelectionCriteria != null) { PropertyInfo[] pis = jobConfiguration.Input.SnapshotSelectionCriteria.TierType.GetType().GetProperties(); StringBuilder sb = new StringBuilder(16 * pis.Length); foreach (PropertyInfo pi in pis) { sb.AppendFormat("{0}={1}, ", pi.Name, pi.GetValue(jobConfiguration.Input.SnapshotSelectionCriteria.TierType)); } logger.Info("Job input, SnapshotSelectionCriteria: Tiers='{0}', TierTypes='{1}'", String.Join(",", jobConfiguration.Input.SnapshotSelectionCriteria.Tiers), sb.ToString()); pis = jobConfiguration.Input.SnapshotSelectionCriteria.BusinessTransactionType.GetType().GetProperties(); sb = new StringBuilder(16 * pis.Length); foreach (PropertyInfo pi in pis) { sb.AppendFormat("{0}={1}, ", pi.Name, pi.GetValue(jobConfiguration.Input.SnapshotSelectionCriteria.BusinessTransactionType)); } logger.Info("Job input, SnapshotSelectionCriteria: BusinessTransactions='{0}', BusinessTransactionType='{1}'", String.Join(",", jobConfiguration.Input.SnapshotSelectionCriteria.BusinessTransactions), sb.ToString()); logger.Info("Job input, SnapshotSelectionCriteria: UserExperience.Normal='{0}', UserExperience.Slow='{1}', UserExperience.VerySlow='{2}', UserExperience.Stall='{3}', UserExperience.Error='{4}'", jobConfiguration.Input.SnapshotSelectionCriteria.UserExperience.Normal, jobConfiguration.Input.SnapshotSelectionCriteria.UserExperience.Slow, jobConfiguration.Input.SnapshotSelectionCriteria.UserExperience.VerySlow, jobConfiguration.Input.SnapshotSelectionCriteria.UserExperience.Stall, jobConfiguration.Input.SnapshotSelectionCriteria.UserExperience.Error); logger.Info("Job input, SnapshotSelectionCriteria: SnapshotType.Full='{0}', SnapshotType.Partial='{1}', SnapshotType.None='{2}'", jobConfiguration.Input.SnapshotSelectionCriteria.SnapshotType.Full, jobConfiguration.Input.SnapshotSelectionCriteria.SnapshotType.Partial, jobConfiguration.Input.SnapshotSelectionCriteria.SnapshotType.None); } if (jobConfiguration.Input.ConfigurationComparisonReferenceCriteria != null) { logger.Info("Job input: ConfigurationComparisonReferenceCriteria.Controller='{0}', ConfigurationComparisonReferenceCriteria.Application='{1}'", jobConfiguration.Input.ConfigurationComparisonReferenceCriteria.Controller, jobConfiguration.Input.ConfigurationComparisonReferenceCriteria.Application); } logger.Info("Job output: DetectedEntities='{0}', EntityMetrics='{1}', EntityDetails='{2}', Snapshots='{3}', Configuration='{4}', Events='{5}'", jobConfiguration.Output.DetectedEntities, jobConfiguration.Output.EntityMetrics, jobConfiguration.Output.EntityDetails, jobConfiguration.Output.Snapshots, jobConfiguration.Output.Configuration, jobConfiguration.Output.Events); foreach (JobTimeRange jobTimeRange in jobConfiguration.Input.HourlyTimeRanges) { logger.Info("Expanded time ranges: From='{0:o}', To='{1:o}'", jobTimeRange.From, jobTimeRange.To); } #endregion // Run the step and move to next until things are done while (jobConfiguration.Status != JobStatus.Done && jobConfiguration.Status != JobStatus.Error) { loggerConsole.Info("Executing job step {0}({0:d})", jobConfiguration.Status); logger.Info("Executing job step {0}({0:d})", jobConfiguration.Status); JobStepBase jobStep = getJobStepFromFactory(jobConfiguration.Status); if (jobStep != null) { if (jobStep.Execute(programOptions, jobConfiguration) == false) { jobConfiguration.Status = JobStatus.Error; } } if (jobConfiguration.Status != JobStatus.Error) { jobConfiguration.Status = jobStepsLinked.Find(jobConfiguration.Status).Next.Value; } // Save the resulting JSON file to the job target folder if (FileIOHelper.WriteJobConfigurationToFile(jobConfiguration, programOptions.OutputJobFilePath) == false) { loggerConsole.Error("Unable to write job input file {0}", programOptions.OutputJobFilePath); return; } } }