Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 1451074 Details for
Bug 1591027
Update rhui-debug.py to collect information for RHUI 3+
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Update rhui-debug for RHUI 3
0001-BZ-1591027-Updated-rhui-debug-for-RHUI-3.patch (text/plain), 10.64 KB, created by
Craig Donnelly
on 2018-06-13 22:51:28 UTC
(
hide
)
Description:
Update rhui-debug for RHUI 3
Filename:
MIME Type:
Creator:
Craig Donnelly
Created:
2018-06-13 22:51:28 UTC
Size:
10.64 KB
patch
obsolete
>From 7f60a9950a02fafd0f6f53a4d7811feecf3d0404 Mon Sep 17 00:00:00 2001 >From: Craig Donnelly <crag@redhat.com> >Date: Wed, 13 Jun 2018 18:43:17 -0400 >Subject: [PATCH] [BZ 1591027] Updated rhui-debug for RHUI 3 > >--- > rhui/tools/scripts/rhui-debug.py | 224 +++++++++++++++++++++++-------- > 1 file changed, 171 insertions(+), 53 deletions(-) > >diff --git a/rhui/tools/scripts/rhui-debug.py b/rhui/tools/scripts/rhui-debug.py >index 0204861..b43f9af 100644 >--- a/rhui/tools/scripts/rhui-debug.py >+++ b/rhui/tools/scripts/rhui-debug.py >@@ -13,74 +13,141 @@ > # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. > # > # Sayli Karmarkar <skarmark@redhat.com> >+# Craig Donnelly <crag@redhat.com> > >+import glob > import os >-import sys > import shutil >+import sys >+import tarfile > from datetime import datetime >- > from optparse import OptionParser > >-# List of relevant directories and files to collect information about RHUI configuration and logs >- >-# Contents of these files, directories and output of commands will be copied when if Pulp is installed >- >-PULP_DIRS = ["/etc/pulp/", >- "/etc/gofer/plugins/", >- "/var/log/pulp/", >- ] >- >-PULP_FILES = ["/etc/httpd/conf.d/pulp.conf", >- "/etc/yum/pluginconf.d/pulp-profile-update.conf", >- "/etc/pki/pulp/content/pulp-protected-repos", >- "/var/log/gofer/agent.log", >- ] >- >-PULP_COMMANDS = {"ls -lR /var/lib/pulp": {"filename": "ls_-lR_var.lib.pulp", >- "access_path": "/var/lib/pulp"}} >- >-# ----------------------------------------------------------------------------------------------------- >- >-# Contents of these files, directories and output of commands will be copied when pulp-cds is installled >- >-CDS_DIRS = ["/etc/pulp/", >- "/etc/gofer/plugins/", >- "/var/log/pulp-cds/", >- ] >- >-CDS_FILES = ["/etc/httpd/conf.d/pulp-cds.conf", >- "/var/log/gofer/agent.log", >- ] >- >-CDS_COMMANDS = {"ls -lR /var/lib/pulp-cds": {"filename": "ls_-lR_var.lib.pulp-cds", >- "access_path": "/var/lib/pulp-cds"}} >- >-# ----------------------------------------------------------------------------------------------------- >+# Check to see if we have PyYAML installed for RHEL 6 compatibiliity >+# and decide to pass on later checks >+try: >+ import yaml >+except ImportError: >+ pass >+ >+# List of relevant directories and files to collect information about >+# RHUI configuration and logs >+ >+# Contents of these files, directories and output of commands will be >+# copied if cds is not indicated >+ >+PULP_DIRS = [ >+ "/etc/pulp/", >+ "/etc/rhui-installer/", >+ "/etc/qpid/", >+ "/etc/pki/rhua/", >+ "/etc/pki/katello-certs-tools/", >+ "/root/ssl-build/", >+ "/var/log/kafo/", >+ "/var/log/puppet/" >+] >+ >+MONGO_LOGS = [ >+ "/var/log/mongodb/" >+] >+ >+PULP_FILES = [ >+ "/etc/httpd/conf.d/05-pulp-https.conf", >+ "/etc/httpd/conf.d/pulp_docker.conf", >+ "/etc/httpd/conf.d/pulp_ostree.conf", >+ "/etc/httpd/conf.d/pulp_rpm.conf", >+ "/etc/nfs.conf", >+ "/etc/nfsmount.conf", >+ "/etc/mongodb.conf", >+ "/etc/mongod.conf", >+ "/var/log/rhui-subscription-sync.log" >+] >+ >+PULP_COMMANDS = { >+ "ls -lR /var/lib/rhui/remote_share": { >+ "filename": "ls_-lR_var.lib.rhui.remote_share", >+ "access_path": "/var/lib/rhui/remote_share" >+ } >+} >+ >+# ---------------------------------------------------------------------------- >+ >+# Contents of these files, directories and output of commands will be >+# copied when cds is indicated >+ >+CDS_DIRS = [ >+ "/etc/pulp/", >+] >+ >+CDS_FILES = [ >+ "/etc/httpd/conf.d/03-crane.conf" >+] >+ >+CDS_COMMANDS = { >+ "ls -lR /var/lib/rhui/remote_share": { >+ "filename": "ls_-lR_var.lib.rhui.remote_share", >+ "access_path": "/var/lib/rhui/remote_share" >+ } >+} >+ >+# ---------------------------------------------------------------------------- > > # RHUI files common to RHUA and CDS > >-RHUI_DIRS = ["/root/.rhui/", >- ] >+RHUI_DIRS = [ >+ "/root/.rhui/", >+ "/etc/httpd/conf/httpd.conf", >+ "/etc/httpd/conf/ports.cond", >+ "/etc/httpd/conf.d/15-default.conf", >+ "/etc/pki/pulp/", >+ "/etc/pki/rhui/", >+ "/var/log/httpd/", >+ "/var/log/glusterfs/" >+] > >-RHUI_FILES = ["/etc/rhui/rhui-tools.conf", >- ] >+RHUI_FILES = [ >+ "/etc/rhui/rhui-tools.conf" >+] > >+RHUI_COMMANDS = { >+ "rpm -qa | grep -e rhui -e python -e pulp | sort": { >+ "filename": "rpm_-qa_grep_-e_rhui_-e_python_-e_pulp_sort", >+ "access_path": "/tmp" >+ } >+} >+ >+# ---------------------------------------------------------------------------- > >-# ----------------------------------------------------------------------------------------------------- > > def __parser(): > parser = OptionParser() > parser.add_option( >- '--dir', >+ '-d', '--dir', > dest='dir', >- help='Directory to place the tree containing debugging information; defaults to /tmp', >+ help='Directory to place the tree containing debugging information;' + >+ ' defaults to /tmp', > default='/tmp') > parser.add_option( >- '--cds', >- action="store_true", >- dest="cds", >+ '-c', '--cds', >+ action='store_true', >+ dest='cds', >+ default=False, >+ help='If the script needs to be executed to collect CDS information' + >+ ' instead of RHUA') >+ parser.add_option( >+ '-m', '--mongo', >+ action='store_true', >+ dest='mongo', > default=False, >- help="If the script needs to be executed to collect CDS information instead of RHUA") >+ help='Collect /var/log/mongodb - This can be large and take' + >+ ' significant time') >+ parser.add_option( >+ '-a', '--archive', >+ action='store_true', >+ dest='tar', >+ default=False, >+ help='Automatically tar and xz compress the rhui-debug directory' + >+ ' when complete') > return parser > > >@@ -100,7 +167,7 @@ def copy_dirs(dirs, base_dir): > try: > print "Copying contents of directory [%s] to [%s] " % (dir, dst) > shutil.copytree(dir, dst, symlinks=False) >- except: >+ except Exception: > # Ignore error raised by shutil when a sub-directory already exists > pass > >@@ -119,7 +186,8 @@ def copy_files(files, base_dir): > shutil.copy(file, path) > > >-# Runs given commands and copies output under commands directory into the base directory >+# Runs given commands and copies output under commands directory >+# into the base directory > def run_commands(commands, base_dir): > # print "" > commands_dir = os.path.join(base_dir, 'commands') >@@ -130,10 +198,20 @@ def run_commands(commands, base_dir): > for command, command_info in commands.items(): > if os.access(command_info['access_path'], os.R_OK): > location = os.path.join(commands_dir, command_info['filename']) >- print "Storing output of command [%s] in [%s]" % (commands_dir, location) >+ print "Storing output of command [%s] in [%s]" % (commands_dir, >+ location) > os.system(command + ' >> ' + location) > > >+# Creates XZ compressed tar of contents >+def tar(archive_dir, base_dir): >+ with tarfile.open(archive_dir, "w:") as tar: >+ tar.add(base_dir, arcname=os.path.basename(base_dir)) >+ tar.close() >+ os.system('xz -z ' + archive_dir) >+ shutil.rmtree(base_dir) >+ >+ > if __name__ == "__main__": > > # Get the location to store debugging content >@@ -146,13 +224,20 @@ if __name__ == "__main__": > # Make sure user has root access to run this script > check_root() > >- # Create a base directory to store debugging information >+ # Create a base directory to store debugging information > now = datetime.now().strftime("%Y-%m-%d-T%H-%M-%S") > time_dir = 'rhui-debug-' + now > base_dir = os.path.join(opt.dir, time_dir) > >+ # Set name and path for XZ archive if indicated >+ if opt.tar: >+ archive = time_dir + ".tar" >+ archive_dir = os.path.join(opt.dir, archive) >+ compressed_dir = archive_dir + ".xz" >+ > if os.path.exists(base_dir): >- sys.exit("Directory with path [%s] already exists; please delete and re-run the script" % time_dir) >+ sys.exit("Directory with path [%s] already exists; please delete" + >+ " and re-run the script" % time_dir) > else: > os.makedirs(base_dir) > print("Successfully created directory [%s]" % base_dir) >@@ -160,15 +245,48 @@ if __name__ == "__main__": > # Collect files common to RHUA and CDS > copy_dirs(RHUI_DIRS, base_dir) > copy_files(RHUI_FILES, base_dir) >+ run_commands(RHUI_COMMANDS, base_dir) > > if opt.cds: > # Collect CDS specific debugging information >+ CDS_HTTPD = glob.glob("/etc/httpd/conf.d/25-*.conf") >+ CDS_FILES.extend(CDS_HTTPD) > copy_dirs(CDS_DIRS, base_dir) > copy_files(CDS_FILES, base_dir) > run_commands(CDS_COMMANDS, base_dir) >+ elif opt.mongo and not opt.cds: >+ # Collect MongoDB logs from RHUA (not present on CDS) >+ copy_dirs(PULP_DIRS, base_dir) >+ copy_dirs(MONGO_LOGS, base_dir) >+ copy_files(PULP_FILES, base_dir) >+ run_commands(PULP_COMMANDS, base_dir) > else: > # Collect RHUA specific debugging information >+ if 'yaml' in sys.modules: >+ if os.path.exists('/etc/rhui-installer/answers.yaml'): >+ with open('/etc/rhui-installer/answers.yaml', 'r') as stream: >+ try: >+ data = yaml.safe_load(stream) >+ shared_storage = \ >+ data['rhua']['remote_fs_server'].split(':')[0] >+ STORAGE_COMMANDS = { >+ "showmount -e " + shared_storage: { >+ "filename": "showmount_-e_" + shared_storage, >+ "access_path": "/tmp" >+ } >+ } >+ run_commands(STORAGE_COMMANDS, base_dir) >+ except yaml.YAMLError as exception: >+ print(exception) > copy_dirs(PULP_DIRS, base_dir) > copy_files(PULP_FILES, base_dir) > run_commands(PULP_COMMANDS, base_dir) > >+ if opt.tar: >+ # XZ Compress rhui-debug and delete source folder >+ print("\nCompressing rhui-debug contents, please wait..") >+ tar(archive_dir, base_dir) >+ print("Compressed rhui-debug is complete: [%s]" % compressed_dir) >+ else: >+ print("\nrhui-debug collection complete and available at: [%s]" >+ % base_dir) >-- >2.17.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1591027
: 1451074