[PATCH conductor] BZ #784971: CloudForms Diagnostics Tooling

Jason Guiditta jguiditt at redhat.com
Mon Feb 6 22:14:37 UTC 2012


On 06/02/12 13:58 -0800, Richard Su wrote:
>On 02/06/2012 12:56 PM, Jason Guiditta wrote:
>>https://bugzilla.redhat.com/show_bug.cgi?id=784971
>>
>>Add a quick script to add in supporting diagnosis of issues. This
>>will be expanded and improved in future versions, this just attempts
>>to add some bare functionality.
>>---
>>  aeolus-conductor.spec.in          |    6 ++-
>>  src/lib/aeolus/debug/aeolus-debug |   89 +++++++++++++++++++++++++++++++++++++
>>  2 files changed, 94 insertions(+), 1 deletions(-)
>>  create mode 100755 src/lib/aeolus/debug/aeolus-debug
>>
>>diff --git a/aeolus-conductor.spec.in b/aeolus-conductor.spec.in
>>index 74460ca..0eea345 100644
>>--- a/aeolus-conductor.spec.in
>>+++ b/aeolus-conductor.spec.in
>>@@ -117,6 +117,7 @@ getent passwd aeolus>/dev/null || \
>>  %{__mkdir} -p %{buildroot}%{_localstatedir}/lib/%{name}
>>  %{__mkdir} -p %{buildroot}%{_localstatedir}/log/%{name}
>>  %{__mkdir} -p %{buildroot}%{_localstatedir}/run/%{name}
>>+%{__mkdir} -p %{buildroot}/%{_bindir}
>>
>>  # now copy over the rails source files.  This is a bit verbose, but only
>>  # takes in the stuff we need (and no backup files, etc)
>>@@ -162,7 +163,8 @@ rake="lib/tasks"
>>  rb="app/models app/controllers app/controllers/api app/helpers app/services app/util \
>>      config config/initializers config/environments db db/migrate \
>>      features/support features/step_definitions lib spec spec/controllers \
>>-    spec/factories spec/helpers spec/models spec/services spec/controllers/api lib/aeolus lib/aeolus/event"
>>+    spec/factories spec/helpers spec/models spec/services spec/controllers/api lib/aeolus \
>>+    lib/aeolus/event"
>>  rhtml="app/views/layouts"
>>  svg="public/images public/images/icons public/javascripts/jquery-svg"
>>  ttf="public/fonts"
>>@@ -189,6 +191,7 @@ sass --style compact ./src/app/stylesheets/login.scss %{buildroot}%{app_root}/pu
>>  # misc files
>>  %{__cp} src/Rakefile %{buildroot}%{app_root}
>>  %{__cp} src/config.ru %{buildroot}%{app_root}
>>+%{__cp} src/lib/aeolus/debug/aeolus-debug %{buildroot}%{_bindir}
>>
>>  %{__mkdir} -p %{buildroot}%{app_root}/config
>>  %{__cp} src/config/database.pg %{buildroot}%{app_root}/config
>>@@ -293,6 +296,7 @@ fi
>>  %{app_root}/db
>>  %{app_root}/dbomatic
>>  %{app_root}/lib
>>+%{_bindir}/aeolus-debug
>>  %{app_root}/log
>>  %{app_root}/public
>>  %{app_root}/Rakefile
>>diff --git a/src/lib/aeolus/debug/aeolus-debug b/src/lib/aeolus/debug/aeolus-debug
>>new file mode 100755
>>index 0000000..cb415f5
>>--- /dev/null
>>+++ b/src/lib/aeolus/debug/aeolus-debug
>>@@ -0,0 +1,89 @@
>>+#!/usr/bin/env ruby
>>+
>>+require "optparse"
>>+require "fileutils"
>>+
>>+NAME="aeolus-debug"
>>+
>>+# Set up the options
>>+options = {}
>>+
>>+optparse = OptionParser.new do|opts|
>>+    opts.banner = "Usage: #{NAME} [options] command"
>>+
>>+    options[:basedir] = '/tmp'
>>+    opts.on('-d', '--dir [DIRECTORY]', 'Directory to place the tarball. Defaults to /tmp' ) do |opt|
>>+        options[:basedir] = opt
>>+    end
>>+
>>+    opts.on('-h', '--help', 'Display help and exit' ) do
>>+        puts opts
>>+        exit
>>+    end
>>+
>>+end
>>+
>>+optparse.parse!
>>+
>>+# Check that we are running as root
>>+if Process.uid != 0
>>+    puts "#{NAME} must be run as root"
>>+    exit
>>+end
>>+
>>+# Define what we want to collect
>>+SOURCES = [
>>+# Conductor
>>+"/var/log/aeolus**/**/*.log",
>>+"/etc/aeolus*/**/**",
>>+"/etc/imagefactory**/**",
>>+"/var/log/imagefactory**/**/*.log",
>>+"/etc/iwhd**/**",
>>+"/var/log/iwhd**/**/*.log",
>>+"/var/log/deltacloud-core**/**/*.log",
>>+"/var/log/libvirt**/**",
>>+"/etc/oz/oz.cfg",
>>+"/proc/cpuinfo",
>>+"/proc/meminfo"
>>+]
>>+
>>+# Collect the files
>>+timename =  "aeolus-debug-#{Time.now.strftime("%Y%m%d%H%M%S")}"
>>+target_dir = File.join(options[:basedir], timename)
>>+
>>+if File.exists?(target_dir)
>>+    puts "#{target_dir} already exists. Please delete it"
>>+    exit
>>+end
>>+
>>+FileUtils.mkdir_p(target_dir, :verbose =>  true)
>>+
>>+files = []
>>+SOURCES.each do |d|
>>+  files<<  Dir.glob(d)
>>+end
>>+
>>+files = files.flatten
>>+puts "File list: #{files}"
>>+files.each do |source|
>>+  file_dir = File.file?(source) ? File.dirname(source): source
>>+  complete_target = File.join(target_dir, file_dir)
>>+  FileUtils.mkdir_p(complete_target, :verbose =>  true)
>>+  FileUtils.cp(source, complete_target, {:verbose=>true,:preserve =>true}) if File.file?(source)
>>+end
>>+
>>+# Below are custom system calls to get more info
>>+system("rpm -qa | egrep 'aeolus|iwhd|deltacloud|imagefactory|oz'>>  #{File.join(target_dir, 'packages')}")
>>+system("virsh capabilities>>  #{File.join(target_dir, 'virsh_capabilities')}")
>>+
>>+# Tar the output and log it
>>+tarfile = target_dir + ".tar.gz"
>>+pwd = Dir.pwd()
>>+Dir.chdir(options[:basedir])
>>+system("tar -czvf #{tarfile} #{timename}")
>>+Dir.chdir(pwd)
>>+
>>+puts "A debug file has been created at #{tarfile}."
>>+
>>+# Clean up
>>+FileUtils.rm_r(target_dir)
>
>Conditional ack. Worked as defined. But aeolus-debug missed a few log files:
>
>/var/log/iwhd.log
>/var/log/imagefactory.log
>/var/log/mongodb/mongodb.log
>

Thx, good catches.  Fixed and pushed to staging.



More information about the aeolus-devel mailing list