def _plot_io(self, kwds, rrd_files, img_dir, url_dir, tz): url = dict() options = rrd.GRAPH_OPT[kwds['period']] for rrd_file in rrd_files: dev = os.path.basename(rrd_file)[:-4] url[dev] = dict() img_file = os.path.join( img_dir, '%s_bits_%s_%s.png' % (kwds['metric'], dev, kwds['period']) ) url[dev]['bits_per_sec'] = os.path.join( url_dir, '%s_bits_%s_%s.png' % (kwds['metric'], dev, kwds['period']) ) rrd.plot_io_bits(str(img_file), str(rrd_file), options, tz=tz) img_file = os.path.join( img_dir, '%s_ops_%s_%s.png' % (kwds['metric'], dev, kwds['period']) ) url[dev]['operations_per_sec'] = os.path.join( url_dir, '%s_ops_%s_%s.png' % (kwds['metric'], dev, kwds['period']) ) rrd.plot_io_ops(str(img_file), str(rrd_file), options, tz=tz) return url
def _plot(self, kwds, tz, metric): img_dir = self._get_image_dir(kwds) url_dir = self._get_url_dir(kwds) rrd_files = self._get_rrd_files(kwds, metric) if not rrd_files: msg = "Coudn't find rrd file(s) for request: {0}, metric: {1}" msg = msg.format(kwds, metric) LOG.warning(msg) raise Plotter.IOError('Statistics are not available') if metric == 'io': url = dict() options = rrd.GRAPH_OPT[kwds['period']] for rrd_file in rrd_files: dev = os.path.basename(rrd_file)[:-4] url[dev] = dict() img_file = os.path.join( img_dir, 'io_bits_%s_%s.png' % (dev, kwds['period'])) url[dev]['bits_per_sec'] = os.path.join( url_dir, 'io_bits_%s_%s.png' % (dev, kwds['period'])) rrd.plot_io_bits(str(img_file), str(rrd_file), options, tz=tz) img_file = os.path.join( img_dir, 'io_ops_%s_%s.png' % (dev, kwds['period'])) url[dev]['operations_per_sec'] = os.path.join( url_dir, 'io_ops_%s_%s.png' % (dev, kwds['period'])) rrd.plot_io_ops(str(img_file), str(rrd_file), options, tz=tz) else: rrd_file = rrd_files[0] img_file = os.path.join(img_dir, '%s_%s.png' % (metric, kwds['period'])) if not os.path.exists( img_file) or os.path.getmtime(img_file) + 60 < time.time(): options = rrd.GRAPH_OPT[kwds['period']] self._plotters[metric](str(img_file), str(rrd_file), options) url = os.path.join(url_dir, '%s_%s.png' % (metric, kwds['period'])) return url
def _plot_io(self, kwds, rrd_files, img_dir, url_dir, tz): url = dict() options = rrd.GRAPH_OPT[kwds['period']] for rrd_file in rrd_files: dev = os.path.basename(rrd_file)[:-4] url[dev] = dict() img_file = os.path.join( img_dir, '%s_bits_%s_%s.png' % (kwds['metric'], dev, kwds['period'])) url[dev]['bits_per_sec'] = os.path.join( url_dir, '%s_bits_%s_%s.png' % (kwds['metric'], dev, kwds['period'])) rrd.plot_io_bits(str(img_file), str(rrd_file), options, tz=tz) img_file = os.path.join( img_dir, '%s_ops_%s_%s.png' % (kwds['metric'], dev, kwds['period'])) url[dev]['operations_per_sec'] = os.path.join( url_dir, '%s_ops_%s_%s.png' % (kwds['metric'], dev, kwds['period'])) rrd.plot_io_ops(str(img_file), str(rrd_file), options, tz=tz) return url
def _plot(self, kwds, tz, metric): img_dir = self._get_image_dir(kwds) url_dir = self._get_url_dir(kwds) rrd_files = self._get_rrd_files(kwds, metric) if not rrd_files: msg = "Coudn't find rrd file(s) for request: {0}, metric: {1}" msg = msg.format(kwds, metric) LOG.warning(msg) raise Plotter.IOError('Statistics are not available') if metric == 'io': url = dict() options = rrd.GRAPH_OPT[kwds['period']] for rrd_file in rrd_files: dev = os.path.basename(rrd_file)[:-4] url[dev] = dict() img_file = os.path.join( img_dir, 'io_bits_%s_%s.png' % (dev, kwds['period'])) url[dev]['bits_per_sec'] = os.path.join( url_dir, 'io_bits_%s_%s.png' % (dev, kwds['period'])) rrd.plot_io_bits(str(img_file), str(rrd_file), options, tz=tz) img_file = os.path.join( img_dir, 'io_ops_%s_%s.png' % (dev, kwds['period'])) url[dev]['operations_per_sec'] = os.path.join( url_dir, 'io_ops_%s_%s.png' % (dev, kwds['period'])) rrd.plot_io_ops(str(img_file), str(rrd_file), options, tz=tz) else: rrd_file = rrd_files[0] img_file = os.path.join(img_dir, '%s_%s.png' % (metric, kwds['period'])) if not os.path.exists(img_file) or os.path.getmtime(img_file) + 60 < time.time(): options = rrd.GRAPH_OPT[kwds['period']] self._plotters[metric](str(img_file), str(rrd_file), options) url = os.path.join(url_dir, '%s_%s.png' % (metric, kwds['period'])) return url