Skip to content

Commit

Permalink
capsyle sync report utility as sourced from https://github.com/sthiru…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike McCune authored Feb 5, 2021
1 parent a93c2e8 commit a393566
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@ List the top subscription-manager calls by uuid/fqdn. Blank fqdn indicates an un
./top-uuid-report /var/log/httpd/foreman-ssl_access_ssl.log
```

## [capsule_sync_report.rake](capsule_sync_report.rake)

Read only rake utility to generate a report of Capsule sync timings over a passed in set of days.

To deploy, download the capsule_sync_report.rake to your Satellite and copy to the

```
cd `rpm -ql tfm-rubygem-katello | head -n 1`/lib/katello/tasks
cp /root/capsule_sync_report.rake .
```

To run, specify the # of days in an environment variable:

```
# DAYS=30 foreman-rake katello:generate_content_view_capsule_sync_metrics
Task started. This may take a while depending on the amount of tasks.
Task completed. Output stored in /tmp/content_view_sync_metrics.txt
```

you can then view the report in /tmp/content_view_sync_metrics.txt

## [production-log-load-stats](production-log-load-stats)

Analyze `production.log` for load+performance statistics about types of requests to Satellite. See [https://github.com/pmoravec/rails-load-stats](https://github.com/pmoravec/rails-load-stats) for more description. **WARNING:** the script can consume excessive resources (time, memory, CPU) on large log files. Therefore it is recommended to run it outside production system on a copied logfile.
Expand Down
46 changes: 46 additions & 0 deletions capsule_sync_report.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace :katello do
task :generate_content_view_capsule_sync_metrics => ["environment"] do
puts "Task started. This may take a while depending on the amount of tasks."

# By default query last 7 days
number_of_days_to_query = 7.days

# If DAYS is supplied by the user, use it
if not ENV['DAYS'].nil?
number_of_days_to_query = ENV['DAYS'].to_i.days
end

output_file = '/tmp/content_view_sync_metrics.txt'
f = File.new(output_file, 'w')

f.write "ForemanTaskId Start Time End Time Duration(min) Total planning(min) Total execution(min)\n"

# Query only Actions::Katello::CapsuleContent::Sync tasks with state = stopped and started_at > number_of_days_to_query
tasks = ForemanTasks::Task.where(:label => "Actions::Katello::CapsuleContent::Sync").where(:state => 'stopped').where("result !=?", 'error').where("started_at > ?", DateTime.now - number_of_days_to_query).order(:ended_at); 0

tasks.each do |task|
#puts "foreman_task_id is #{task.id}"
execplan = task.execution_plan
plan_values = execplan.steps.values

plansteps = plan_values.select { |plan| plan.class == Dynflow::ExecutionPlan::Steps::PlanStep}
runsteps = plan_values.select { |plan| plan.class == Dynflow::ExecutionPlan::Steps::RunStep}

if plansteps.count != 0
started_at = plansteps.map(&:started_at).min
ended_at = plansteps.map(&:ended_at).max
total_planning_time = ((ended_at - started_at)/60).round(2)
end; 0

if runsteps.count != 0
started_at = runsteps.map(&:started_at).min
ended_at = runsteps.map(&:ended_at).max
total_running_time = ((ended_at - started_at)/60).ceil
end; 0

f.write "#{task.id} #{task.started_at} #{task.ended_at} #{((task.ended_at - task.started_at)/60).ceil} #{total_planning_time} #{total_running_time}\n"
end.count
puts "Task completed. Output stored in /tmp/content_view_sync_metrics.txt"
end
end

0 comments on commit a393566

Please sign in to comment.