def show_stats(self, gw_stats, disk_summary): """ Display the aggregated stats to the console :param gw_stats: gateway metrics (cpu, network) :param disk_summary: disk summary information (dict) indexed by pool/rbd_image :return: nothing """ num_gws = len(gw_stats.cpu_busy) desc = "Gateways" if num_gws > 1 else "Gateway" total_gateways = len(self.config.gateway_config.gateways) gw_summary = "{}/{}".format(num_gws, total_gateways) print( "gwtop {:>3} {:<8} CPU% MIN:{:>3.0f} MAX:{:>3.0f} Network Total In:{:>6}" " Out:{:>6} {}".format(gw_summary, desc, gw_stats.min_cpu, gw_stats.max_cpu, bytes2human(gw_stats.total_net_in), bytes2human(gw_stats.total_net_out), gw_stats.timestamp)) print( "Capacity: {:>5} IOPS: {:>5} Clients:{:>3} Ceph: {:<26} " "OSDs: {:>4}".format(bytes2human(gw_stats.total_capacity), gw_stats.total_iops, self.config.gateway_config.client_count, self.ceph_health, self.ceph_osds)) print( "{:<{}} Src Device Size r/s w/s rMB/s wMB/s" " await r_await w_await Client".format( "Pool.Image", self.max_rbd_name, )) # Metrics shown sorted by pool/image name by default for devname in self.sort_stats(disk_summary): if devname in self.config.gateway_config.diskmap: client = self.config.gateway_config.diskmap[devname] else: client = '' print( "{:<{}} {:^3} {:^6} {:>4} {:>5} {:>5} {:>6.2f} {:>6.2f} {:>6.2f}" " {:>6.2f} {:>6.2f} {:<20}".format( devname, self.max_rbd_name, disk_summary[devname].io_source, disk_summary[devname].rbd_name, bytes2human(disk_summary[devname].disk_size), int(disk_summary[devname].tot_reads), int(disk_summary[devname].tot_writes), disk_summary[devname].tot_readkb / 1024, disk_summary[devname].tot_writekb / 1024, disk_summary[devname].max_await, disk_summary[devname].max_r_await, disk_summary[devname].max_w_await, client)) # put a blank line between iterations print
def print_device_data(cls, devname, max_dev_name, disk_data, client): return('{:<{}} {:^3} {:>4} {:>5} {:>6.2f} ' '{:>6.2f} {:<20}'.format(devname, max_dev_name, disk_data.io_source, bytes2human(disk_data.disk_size), int(round(disk_data.tot_iops)), disk_data.tot_read_mb, disk_data.tot_write_mb, client))
def print_device_data(cls, devname, max_rbd_name, disk_data, client): return("{:<{}} {:^3} {:^6} {:>4} {:>5} {:>5} {:>6.2f} " "{:>6.2f} {:>6.2f} {:>6.2f}" " {:>6.2f} {:<20}".format(devname, max_rbd_name, disk_data.io_source, disk_data.rbd_name, bytes2human(disk_data.disk_size), int(disk_data.tot_reads), int(disk_data.tot_writes), disk_data.tot_readkb / 1024, disk_data.tot_writekb / 1024, disk_data.max_await, disk_data.max_r_await, disk_data.max_w_await, client))
def show_stats(self, gw_stats, disk_summary): """ Display the aggregated stats to the console :param gw_stats: gateway metrics (cpu, network) :param disk_summary: disk summary information (dict) indexed by pool/rbd_image :return: nothing """ num_gws = len(gw_stats.cpu_busy) desc = "Gateways" if num_gws > 1 else "Gateway" total_gateways = len(self.config.gateway_config.gateways) total_disks = len(disk_summary.keys()) gw_summary = "{}/{}".format(num_gws, total_gateways) # take the first disk we have to determine the pcp collector class # used, then use the methods of this class for header and row # detail layout first_disk = disk_summary.itervalues().next() collector = first_disk.collector print( "\ngwtop {:>3} {:<8} CPU% MIN:{:>3.0f} MAX:{:>3.0f} " "Network Total In:{:>6} Out:{:>6}" " {}".format(gw_summary, desc, gw_stats.min_cpu, gw_stats.max_cpu, bytes2human(gw_stats.total_net_in), bytes2human(gw_stats.total_net_out), gw_stats.timestamp)) print( "Capacity:{:>5} Disks:{:>4} IOPS:{:>5} Clients:{:>3} Ceph: {:<16} " "OSDs:{:>4}".format(bytes2human(gw_stats.total_capacity), total_disks, gw_stats.total_iops, self.config.gateway_config.client_count, self.ceph_health, self.ceph_osds)) # Get the headings from the specific collector used for the device # detail headings = collector.headers(self.max_dev_name) print(headings) # Metrics shown sorted by pool/image name by default devices_shown = False devices_count = 0 for devname in self.sort_stats(disk_summary): if devname in self.config.gateway_config.diskmap: client = self.config.gateway_config.diskmap[devname] else: client = '' lun = disk_summary[devname] if ((lun.tot_iops > 0 and self.config.opts.busy_only) or not self.config.opts.busy_only): # eligible to display, so just check the limit set devices_count += 1 if devices_count <= self.config.opts.limit: if re.search(self.config.opts.device_filter, devname): device_row = collector.print_device_data( devname, self.max_dev_name, lun, client) print(device_row) devices_shown = True if not devices_shown: if self.config.opts.device_filter == ".*": filter_text = "" else: filter_text = "(device filter : {})".format( self.config.opts.device_filter) print("- No active LUNs {}".format(filter_text))