diff --git a/bin/swift-dispersion-report b/bin/swift-dispersion-report index a055016b1e..fa4f8d45f5 100755 --- a/bin/swift-dispersion-report +++ b/bin/swift-dispersion-report @@ -305,7 +305,10 @@ Usage: %prog [options] [conf_file] help='print 404s to standard error') parser.add_option('-p', '--partitions', action='store_true', default=False, help='print missing partitions to standard error') - + parser.add_option('--container-only', action='store_true', default=False, + help='Only run container report') + parser.add_option('--object-only', action='store_true', default=False, + help='Only run object report') options, args = parser.parse_args() conffile = '/etc/swift/dispersion.conf' @@ -322,6 +325,12 @@ Usage: %prog [options] [conf_file] concurrency = int(conf.get('concurrency', 25)) if options.dump_json or config_true_value(conf.get('dump_json', 'no')): json_output = True + container_report = config_true_value(conf.get('container_report', 'yes')) \ + and not options.object_only + object_report = config_true_value(conf.get('object_report', 'yes')) \ + and not options.container_only + if not (object_report or container_report): + exit("Neither container or object report is set to run") if options.debug: debug = True @@ -339,11 +348,14 @@ Usage: %prog [options] [conf_file] container_ring = Ring(swift_dir, ring_name='container') object_ring = Ring(swift_dir, ring_name='object') - container_result = container_dispersion_report( - coropool, connpool, account, container_ring, retries, - options.partitions) - object_result = object_dispersion_report( - coropool, connpool, account, object_ring, retries, options.partitions) + output = {} + if container_report: + output['container'] = container_dispersion_report( + coropool, connpool, account, container_ring, retries, + options.partitions) + if object_report: + output['object'] = object_dispersion_report( + coropool, connpool, account, object_ring, retries, + options.partitions) if json_output: - print json.dumps({"container": container_result, - "object": object_result}) + print json.dumps(output) diff --git a/doc/manpages/dispersion.conf.5 b/doc/manpages/dispersion.conf.5 index 0e96926b5a..8355304473 100644 --- a/doc/manpages/dispersion.conf.5 +++ b/doc/manpages/dispersion.conf.5 @@ -45,11 +45,17 @@ Authentication system account/user password .IP "\fBswift_dir\fR" Location of openstack-swift configuration and ring files .IP "\fBdispersion_coverage\fR" -Percentage of partition coverage to use. The default is 1 +Percentage of partition coverage to use. The default is 1. .IP "\fBretries\fR" Maximum number of attempts .IP "\fBconcurrency\fR" -Maximum number of concurrencies to +Concurrency to use. The default is 25. +.IP "\fBdump_json\fR" +Whether to output in json format. The default is no. +.IP "\fBcontainer_report\fR" +Whether to run the container report. The default is yes. +.IP "\fBobject_report\fR" +Whether to run the object report. The default is yes. .RE .PD @@ -65,6 +71,8 @@ Maximum number of concurrencies to .IP "# retries = 5" .IP "# concurrency = 25" .IP "# dump_json = no" +.IP "# container_report = yes" +.IP "# object_report = yes" .RE .PD diff --git a/doc/manpages/swift-dispersion-report.1 b/doc/manpages/swift-dispersion-report.1 index 414e280d63..2b0ffcd796 100644 --- a/doc/manpages/swift-dispersion-report.1 +++ b/doc/manpages/swift-dispersion-report.1 @@ -24,7 +24,7 @@ .SH SYNOPSIS .LP -.B swift-dispersion-report [-d|--debug] [-j|--dump-json] [-p|--partitions] [conf_file] +.B swift-dispersion-report [-d|--debug] [-j|--dump-json] [-p|--partitions] [--container-only|--object-only] [conf_file] .SH DESCRIPTION .PP @@ -72,6 +72,18 @@ output dispersion report in json format .IP "\fB-p, --partitions\fR" output the partition numbers that have any missing replicas +.SH OPTIONS +.RS 0 +.PD 1 +.IP "\fB--container-only\fR" +Only run the container report + +.SH OPTIONS +.RS 0 +.PD 1 +.IP "\fB--object-only\fR" +Only run the object report + .SH CONFIGURATION .PD 0 Example \fI/etc/swift/dispersion.conf\fR: diff --git a/doc/source/admin_guide.rst b/doc/source/admin_guide.rst index 9392a3d012..b1d00fa364 100644 --- a/doc/source/admin_guide.rst +++ b/doc/source/admin_guide.rst @@ -254,6 +254,18 @@ place and then rerun the dispersion report:: 100.00% of object copies found (7857 of 7857) Sample represents 1.00% of the object partition space +You can also run the report for only containers or objects:: + + $ swift-dispersion-report --container-only + Queried 2621 containers for dispersion reporting, 17s, 0 retries + 100.00% of container copies found (7863 of 7863) + Sample represents 1.00% of the container partition space + + $ swift-dispersion-report --object-only + Queried 2619 objects for dispersion reporting, 7s, 0 retries + 100.00% of object copies found (7857 of 7857) + Sample represents 1.00% of the object partition space + Alternatively, the dispersion report can also be output in json format. This allows it to be more easily consumed by third party utilities:: diff --git a/etc/dispersion.conf-sample b/etc/dispersion.conf-sample index 79ceac6542..d42cf35434 100644 --- a/etc/dispersion.conf-sample +++ b/etc/dispersion.conf-sample @@ -11,4 +11,6 @@ auth_key = testing # dispersion_coverage = 1 # retries = 5 # concurrency = 25 +# container_report = yes +# object_report = yes # dump_json = no