def _POST(self, *param, **params): host_id = self.chk_hostby1(param) if host_id is None: return web.notfound() if not validates_network_storage(self): self.logger.debug("Network storage add failed. Did not validate.") return web.badrequest(self.view.alert) hostname = self.input.network_storage_host_name port = self.input.network_storage_port_number auth = self.input.network_storage_authentication user = self.input.network_storage_user password = self.input.network_storage_password auto_start = False if is_param(self.input, "network_storage_auto_start"): auto_start = True options = {"auth": auth} if port: options["target"] = "%s:%s" % (hostname, port) else: options["target"] = hostname if auth == ISCSI_CONFIG_VALUE_AUTH_METHOD_CHAP: options["user"] = user try: password_file_name = "/tmp/" + generate_phrase(12, "abcdefghijklmnopqrstuvwxyz") create_file(password_file_name, password) options["password-file"] = password_file_name except Exception, e: self.logger.error("Failed to create tmp password file. - file=%s" % (password_file_name)) options["password"] = password
def _PUT(self, *param, **params): host_id = self.chk_hostby1(param) if host_id is None: return web.notfound() if not validates_network_storage(self): self.logger.debug("Network storage update failed. Did not validate.") return web.badrequest(self.view.alert) hostname = self.input.network_storage_host_name port = self.input.network_storage_port_number iqn = self.input.network_storage_iqn auth = self.input.network_storage_authentication user = self.input.network_storage_user password = self.input.network_storage_password auto_start = False if is_param(self.input, 'network_storage_auto_start'): auto_start = True options = {'auth' : auth, 'iqn' : iqn, 'target' : hostname} if port: options['port'] = port if auth == ISCSI_CONFIG_VALUE_AUTH_METHOD_CHAP: options['user'] = user try: password_file_name = '/tmp/' + generate_phrase(12,'abcdefghijklmnopqrstuvwxyz') create_file(password_file_name, password) options['password-file'] = password_file_name except Exception, e: self.logger.error('Failed to create tmp password file. - file=%s' % (password_file_name)) options['password'] = password
def _POST(self, *param, **params): host_id = self.chk_hostby1(param) if host_id is None: return web.notfound() if not validates_network_storage(self): self.logger.debug("Network storage add failed. Did not validate.") return web.badrequest(self.view.alert) hostname = self.input.network_storage_host_name port = self.input.network_storage_port_number auth = self.input.network_storage_authentication user = self.input.network_storage_user password = self.input.network_storage_password auto_start = False if is_param(self.input, 'network_storage_auto_start'): auto_start = True options = {'auth': auth} if port: options['target'] = "%s:%s" % (hostname, port) else: options['target'] = hostname if auth == ISCSI_CONFIG_VALUE_AUTH_METHOD_CHAP: options['user'] = user try: password_file_name = '/tmp/' + generate_phrase( 12, 'abcdefghijklmnopqrstuvwxyz') create_file(password_file_name, password) options['password-file'] = password_file_name except Exception, e: self.logger.error( 'Failed to create tmp password file. - file=%s' % (password_file_name)) options['password'] = password
def chkopts(opts): from karesansui.lib.utils import generate_phrase, generate_uuid, string_from_uuid, is_uuid from karesansui.lib.const import DEFAULT_LANGS reg_email = re.compile("^[a-zA-Z0-9\./_-]{1,}@[a-zA-Z0-9\./-]{4,}$") if opts.email: if reg_email.search(opts.email) is None: raise Exception('ERROR: Illigal option value. option=%s value=%s' % ('-m or --email', opts.email)) else: raise Exception('ERROR: %s option is required.' % '-m or --email') reg_passwd = re.compile("^.{5,}") if opts.password: if reg_passwd.search(opts.password) is None: raise Exception('ERROR: Illigal option value. option=%s value=%s' % ('-p or --password', opts.password)) else: pass if opts.password == "": opts.password = generate_phrase(8) if opts.uuid: if is_uuid(opts.uuid) is False: raise Exception('ERROR: Illigal option value. option=%s value=%s' % ('-u or --uuid', opts.uuid)) else: pass if opts.uuid == "": opts.uuid = string_from_uuid(generate_uuid()) reg_fqdn = re.compile("^[a-z0-9][a-z0-9\.\-]{2,}$") if opts.fqdn: if reg_fqdn.search(opts.fqdn) is None: raise Exception('ERROR: Illigal option value. option=%s value=%s' % ('-f or --fqdn', opts.fqdn)) else: pass if opts.fqdn == "": opts.fqdn = socket.gethostname() reg_lang = re.compile("^[a-z]{2}_[A-Z]{2}$") if opts.lang: if reg_lang.search(opts.lang) is None: raise Exception('ERROR: Illigal option value. option=%s value=%s' % ('-l or --lang', opts.lang)) else: pass if opts.lang == "": try: DEFAULT_LANGS[os.environ["LANG"][0:5]] opts.lang = os.environ["LANG"][0:5] except: opts.lang = "en_US"
def process(self): (opts, args) = getopts() chkopts(opts) self.up_progress(10) conn = KaresansuiVirtConnection(readonly=False) try: conn.set_domain_name(opts.name) passwd = None if opts.passwd is not None: passwd = opts.passwd elif opts.passwd_file is not None and os.path.exists(opts.passwd_file): try: fp = open(opts.passwd_file, "r") try: self.up_progress(10) fcntl.lockf(fp.fileno(), fcntl.LOCK_SH) try: passwd = fp.readline().strip("\n") finally: fcntl.lockf(fp.fileno(), fcntl.LOCK_UN) self.up_progress(10) finally: fp.close() except Exception, e: self.logger.error('Failed to read file. - dom=%s passwd_file=%s' \ % (opts.name,opts.passwd_file)) print >>sys.stderr, _('Failed to read file. - dom=%s passwd_file=%s') \ % (opts.name,opts.passwd_file) raise e os.remove(opts.passwd_file) self.up_progress(10) elif opts.random_passwd and opts.random_passwd is not None: passwd = generate_phrase(8,'23456789abcdefghijkmnpqrstuvwxyz')
def create_df_graph(_, lang, graph_dir, rrd_dir, start, end, dev, type=None): graph_filename = "%s.png" % (generate_phrase(12, 'abcdefghijklmnopqrstuvwxyz')) graph_filepath = "%s/%s" % (graph_dir, graph_filename) rrd_filepath = ("%s/df/df-%s.rrd" % (rrd_dir, dev), ) for filepath in rrd_filepath: if is_readable(filepath) is False: return "" legend_header_label = { "min": _('Min'), "max": _('Max'), "ave": _('Ave'), "last": _('Last'), } for key in legend_header_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_header_label[key]): legend_header_label[key] = "</tt>%s<tt>" % ( legend_header_label[key].encode("utf-8")) else: legend_header_label[key] = "%s" % ( legend_header_label[key].encode("utf-8")) legend_header = "<tt> %s %s %s %s</tt>" % ( legend_header_label['min'], legend_header_label['max'], legend_header_label['ave'], legend_header_label['last']) title = "<tt>%s</tt>" % (dev) legend = { "used": _('Used'), "free": _('Free'), } reg = re.compile(u"[^a-zA-Z0-9_\-\. ]") for key in legend.keys(): if key == "used": if reg.search(legend[key]): legend[key] = "</tt>%s<tt>" % (legend[key].encode("utf-8")) else: legend[key] = "%s" % (legend[key].encode("utf-8")) elif key == "free": if reg.search(legend[key]): legend[key] = "</tt>%s <tt>" % (legend[key].encode("utf-8")) else: legend[key] = "%s" % (legend[key].encode("utf-8")) else: legend[key] = "%s" % (legend[key].encode("utf-8")) created_label = _('Graph created') if re.search(u"[^a-zA-Z0-9 ]", created_label): created_label = "</tt>%s<tt>" % (created_label.encode("utf-8")) else: created_label = "%s" % (created_label.encode("utf-8")) created_time = "%s" % (datetime.datetime.today().strftime( DEFAULT_LANGS[lang]['DATE_FORMAT'][1])) created_time = re.sub(r':', '\:', created_time) legend_footer = "<tt>%s \: %s</tt>" % (created_label, created_time) data = rrdtool.graph( graph_filepath, "--imgformat", "PNG", "--font", "TITLE:0:IPAexGothic", "--font", "LEGEND:0:IPAexGothic", "--pango-markup", "--width", "550", "--height", "350", "--full-size-mode", "--color", "BACK#FFFFFF", "--color", "CANVAS#FFFFFF", "--color", "SHADEA#FFFFFF", "--color", "SHADEB#FFFFFF", "--color", "GRID#DDDDDD", "--color", "MGRID#CCCCCC", "--color", "FONT#555555", "--color", "FRAME#FFFFFF", "--color", "ARROW#FFFFFF", "--title", title, "--vertical-label", _('Bytes').encode("utf-8"), "--lower-limit", "0", "--rigid", "--start", start, "--end", end, #"--legend-direction", "bottomup", "DEF:used=%s:used:AVERAGE" % (rrd_filepath[0]), "DEF:free=%s:free:AVERAGE" % (rrd_filepath[0]), "COMMENT:%s\\r" % legend_footer, "COMMENT:<tt>---------------------------------------------------------------------------</tt>\\n", # TRANSLATORS: # ディスク容量のグラフの縦軸のラベル # 日本語にした場合は表示が崩れますが、後で直すのでそのままで大丈夫です "AREA:used#80AA00:<tt>%s </tt>" % (legend['used']), "GPRINT:used:MIN:<tt>%8.2lf%s</tt>", "GPRINT:used:MAX:<tt>%8.2lf%s</tt>", "GPRINT:used:AVERAGE:<tt>%8.2lf%s</tt>", "GPRINT:used:LAST:<tt>%8.2lf%s</tt>\\n", "STACK:free#FFFFFF:<tt>%s </tt>" % (legend['free']), "GPRINT:free:MIN:<tt>%8.2lf%s</tt>", "GPRINT:free:MAX:<tt>%8.2lf%s</tt>", "GPRINT:free:AVERAGE:<tt>%8.2lf%s</tt>", "GPRINT:free:LAST:<tt>%8.2lf%s</tt>\\n", "COMMENT:%s\\n" % (legend_header), "COMMENT: \\n", ) return graph_filepath
def create_df_graph(_, lang, graph_dir, rrd_dir, start, end, dev, type=None): graph_filename = "%s.png" % (generate_phrase(12,'abcdefghijklmnopqrstuvwxyz')) graph_filepath = "%s/%s" % (graph_dir, graph_filename) rrd_filepath = ("%s/df/df-%s.rrd" % (rrd_dir, dev), ) for filepath in rrd_filepath: if is_readable(filepath) is False: return "" legend_header_label = {"min":_('Min'), "max":_('Max'), "ave":_('Ave'), "last":_('Last'), } for key in legend_header_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_header_label[key]): legend_header_label[key] = "</tt>%s<tt>" % (legend_header_label[key].encode("utf-8")) else: legend_header_label[key] = "%s" % (legend_header_label[key].encode("utf-8")) legend_header = "<tt> %s %s %s %s</tt>" % (legend_header_label['min'], legend_header_label['max'], legend_header_label['ave'], legend_header_label['last'] ) title = "<tt>%s</tt>" % (dev) legend = {"used" : _('Used'), "free" : _('Free'), } reg = re.compile(u"[^a-zA-Z0-9_\-\. ]") for key in legend.keys(): if key == "used": if reg.search(legend[key]): legend[key] = "</tt>%s<tt>" % (legend[key].encode("utf-8")) else: legend[key] = "%s" % (legend[key].encode("utf-8")) elif key == "free": if reg.search(legend[key]): legend[key] = "</tt>%s <tt>" % (legend[key].encode("utf-8")) else: legend[key] = "%s" % (legend[key].encode("utf-8")) else: legend[key] = "%s" % (legend[key].encode("utf-8")) created_label = _('Graph created') if re.search(u"[^a-zA-Z0-9 ]", created_label): created_label = "</tt>%s<tt>" % (created_label.encode("utf-8")) else: created_label = "%s" % (created_label.encode("utf-8")) created_time = "%s" % (datetime.datetime.today().strftime(DEFAULT_LANGS[lang]['DATE_FORMAT'][1])) created_time = re.sub(r':', '\:', created_time) legend_footer = "<tt>%s \: %s</tt>" % (created_label, created_time) data = rrdtool.graph(graph_filepath, "--imgformat", "PNG", "--font", "TITLE:0:IPAexGothic", "--font", "LEGEND:0:IPAexGothic", "--pango-markup", "--width", "550", "--height", "350", "--full-size-mode", "--color", "BACK#FFFFFF", "--color", "CANVAS#FFFFFF", "--color", "SHADEA#FFFFFF", "--color", "SHADEB#FFFFFF", "--color", "GRID#DDDDDD", "--color", "MGRID#CCCCCC", "--color", "FONT#555555", "--color", "FRAME#FFFFFF", "--color", "ARROW#FFFFFF", "--title", title, "--vertical-label", _('Bytes').encode("utf-8"), "--lower-limit", "0", "--rigid", "--start", start, "--end", end, #"--legend-direction", "bottomup", "DEF:used=%s:used:AVERAGE" % (rrd_filepath[0]), "DEF:free=%s:free:AVERAGE" % (rrd_filepath[0]), "COMMENT:%s\\r" % legend_footer, "COMMENT:<tt>---------------------------------------------------------------------------</tt>\\n", # TRANSLATORS: # ディスク容量のグラフの縦軸のラベル # 日本語にした場合は表示が崩れますが、後で直すのでそのままで大丈夫です "AREA:used#80AA00:<tt>%s </tt>" % (legend['used']), "GPRINT:used:MIN:<tt>%8.2lf%s</tt>", "GPRINT:used:MAX:<tt>%8.2lf%s</tt>", "GPRINT:used:AVERAGE:<tt>%8.2lf%s</tt>", "GPRINT:used:LAST:<tt>%8.2lf%s</tt>\\n", "STACK:free#FFFFFF:<tt>%s </tt>" % (legend['free']), "GPRINT:free:MIN:<tt>%8.2lf%s</tt>", "GPRINT:free:MAX:<tt>%8.2lf%s</tt>", "GPRINT:free:AVERAGE:<tt>%8.2lf%s</tt>", "GPRINT:free:LAST:<tt>%8.2lf%s</tt>\\n", "COMMENT:%s\\n" % (legend_header), "COMMENT: \\n", ) return graph_filepath
def process(self): (opts, args) = getopts() chkopts(opts) self.up_progress(10) try: tmp_dir_name = generate_phrase(12, 'abcdefghijklmnopqrstuvwxyz') tmp_dir_path = "%s/%s" % (KARESANSUI_TMP_DIR, tmp_dir_name) os.mkdir(tmp_dir_path) except: raise KssCommandException('Failed to make tmpdir. path=%s' % (tmp_dir_path)) try: self.up_progress(10) mount_command_args = ( MOUNT_CMD, opts.dev, tmp_dir_path, ) umount_command_args = ( UMOUNT_CMD, tmp_dir_path, ) is_mountable = False try: (mount_cmd_rc, mount_cmd_res) = execute_command(mount_command_args) if mount_cmd_rc == 0: is_mountable = True else: self.logger.debug('Failed to mount. dev=%s' % (opts.dev)) finally: (umount_cmd_rc, umount_cmd_res) = execute_command(umount_command_args) self.up_progress(30) if is_mountable is False and opts.format is True: first_command_args = YES_CMD second_command_args = ( FORMAT_CMD, "-t", opts.type, opts.dev, ) format_command_args = ( first_command_args, second_command_args, ) (format_cmd_rc, format_cmd_res) = pipe_execute_command(format_command_args) if format_cmd_rc != 0: raise KssCommandException( 'Failed to format. dev=%s type=%s res=%s' % (opts.dev, opts.type, format_cmd_res)) try: (mount_cmd_rc, mount_cmd_res) = execute_command(mount_command_args) if mount_cmd_rc == 0: is_mountable = True else: self.logger.debug('Failed to mount. dev=%s' % (opts.dev)) finally: (umount_cmd_rc, umount_cmd_res) = execute_command(umount_command_args) self.up_progress(40) finally: try: os.rmdir(tmp_dir_path) except: raise KssCommandException('Failed to delete tmpdir. path=%s' % (tmp_dir_path)) if is_mountable is True: self.logger.info('Device "%s" is mountable.' % (opts.dev)) print >> sys.stdout, _('Device "%s" is mountable.' % (opts.dev)) else: self.logger.info('Device "%s" is not mountable.' % (opts.dev)) print >> sys.stdout, _('Device "%s" is not mountable.' % (opts.dev)) return is_mountable
def create_uptime_graph(_, lang, graph_dir, rrd_dir, start, end, dev=None, type=None): graph_filename = "%s.png" % (generate_phrase(12, 'abcdefghijklmnopqrstuvwxyz')) graph_filepath = "%s/%s" % (graph_dir, graph_filename) rrd_filepath = ("%s/uptime/uptime.rrd" % (rrd_dir), ) for filepath in rrd_filepath: if is_readable(filepath) is False: return "" legend_header_label = { "last": _('Last'), } for key in legend_header_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_header_label[key]): legend_header_label[key] = "</tt>%s<tt>" % ( legend_header_label[key].encode("utf-8")) else: legend_header_label[key] = " %s" % ( legend_header_label[key].encode("utf-8")) legend_header = "<tt> %s</tt>" % ( legend_header_label['last']) # TRANSLATORS: # 起動時間のグラフの凡例 legend_label = { "uptime": _('uptime'), "day": _('days'), "hour": _('hours'), "minute": _('mins'), } for key in legend_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_label[key]): legend_label[key] = "</tt>%s<tt>" % ( legend_label[key].encode("utf-8")) else: legend_label[key] = "%s" % (legend_label[key].encode("utf-8")) # TRANSLATORS: # 起動時間のグラフのタイトル title = _('Uptime') if re.search(u"[^a-zA-Z0-9_\-\.]", title): title = "%s" % (title.encode("utf-8")) else: title = "<tt>%s</tt>" % (title.encode("utf-8")) created_label = _('Graph created') if re.search(u"[^a-zA-Z0-9 ]", created_label): created_label = "</tt>%s<tt>" % (created_label.encode("utf-8")) else: created_label = "%s" % (created_label.encode("utf-8")) created_time = "%s" % (datetime.datetime.today().strftime( DEFAULT_LANGS[lang]['DATE_FORMAT'][1])) created_time = re.sub(r':', '\:', created_time) legend_footer = "<tt>%s \: %s</tt>" % (created_label, created_time) data = rrdtool.graph( graph_filepath, "--imgformat", "PNG", "--font", "TITLE:0:IPAexGothic", "--font", "LEGEND:0:IPAexGothic", "--pango-markup", "--width", "550", "--height", "350", "--full-size-mode", "--color", "BACK#FFFFFF", "--color", "CANVAS#FFFFFF", "--color", "SHADEA#FFFFFF", "--color", "SHADEB#FFFFFF", "--color", "GRID#DDDDDD", "--color", "MGRID#CCCCCC", "--color", "FONT#555555", "--color", "FRAME#FFFFFF", "--color", "ARROW#FFFFFF", "--title", title, # TRANSLATORS: # 起動時間のグラフの縦軸のラベル "--vertical-label", _('Days').encode("utf-8"), "--lower-limit", "0", "--rigid", "--start", start, "--end", end, "--alt-autoscale", #"--legend-direction", "bottomup", "DEF:uptime=%s:value:AVERAGE" % (rrd_filepath[0]), "CDEF:day=uptime,86400,/", "CDEF:hour=uptime,86400,%,3600,/", "CDEF:minute=uptime,3600,%,60,/", "COMMENT:%s\\r" % legend_footer, "COMMENT:<tt>---------------------------------------------------------------------------</tt>\\n", "AREA:day#80AA00:<tt>%s </tt>" % (legend_label["uptime"]), "GPRINT:day:LAST:<tt>%%6.0lf %s</tt>" % (legend_label["day"]), "GPRINT:hour:LAST:<tt>%%2.0lf %s</tt>" % (legend_label["hour"]), "GPRINT:minute:LAST:<tt>%%2.0lf %s</tt>\\n" % (legend_label["minute"]), "COMMENT:%s\\n" % (legend_header), "COMMENT: \\n", ) return graph_filepath
def create_uptime_graph(_, lang, graph_dir, rrd_dir, start, end, dev=None, type=None): graph_filename = "%s.png" % (generate_phrase(12,'abcdefghijklmnopqrstuvwxyz')) graph_filepath = "%s/%s" % (graph_dir, graph_filename) rrd_filepath = ("%s/uptime/uptime.rrd" % (rrd_dir), ) for filepath in rrd_filepath: if is_readable(filepath) is False: return "" legend_header_label = {"last":_('Last'), } for key in legend_header_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_header_label[key]): legend_header_label[key] = "</tt>%s<tt>" % (legend_header_label[key].encode("utf-8")) else: legend_header_label[key] = " %s" % (legend_header_label[key].encode("utf-8")) legend_header = "<tt> %s</tt>" % (legend_header_label['last']) # TRANSLATORS: # 起動時間のグラフの凡例 legend_label = {"uptime":_('uptime'), "day":_('days'), "hour":_('hours'), "minute":_('mins'), } for key in legend_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_label[key]): legend_label[key] = "</tt>%s<tt>" % (legend_label[key].encode("utf-8")) else: legend_label[key] = "%s" % (legend_label[key].encode("utf-8")) # TRANSLATORS: # 起動時間のグラフのタイトル title = _('Uptime') if re.search(u"[^a-zA-Z0-9_\-\.]", title): title = "%s" % (title.encode("utf-8")) else: title = "<tt>%s</tt>" % (title.encode("utf-8")) created_label = _('Graph created') if re.search(u"[^a-zA-Z0-9 ]", created_label): created_label = "</tt>%s<tt>" % (created_label.encode("utf-8")) else: created_label = "%s" % (created_label.encode("utf-8")) created_time = "%s" % (datetime.datetime.today().strftime(DEFAULT_LANGS[lang]['DATE_FORMAT'][1])) created_time = re.sub(r':', '\:', created_time) legend_footer = "<tt>%s \: %s</tt>" % (created_label, created_time) data = rrdtool.graph(graph_filepath, "--imgformat", "PNG", "--font", "TITLE:0:IPAexGothic", "--font", "LEGEND:0:IPAexGothic", "--pango-markup", "--width", "550", "--height", "350", "--full-size-mode", "--color", "BACK#FFFFFF", "--color", "CANVAS#FFFFFF", "--color", "SHADEA#FFFFFF", "--color", "SHADEB#FFFFFF", "--color", "GRID#DDDDDD", "--color", "MGRID#CCCCCC", "--color", "FONT#555555", "--color", "FRAME#FFFFFF", "--color", "ARROW#FFFFFF", "--title", title, # TRANSLATORS: # 起動時間のグラフの縦軸のラベル "--vertical-label", _('Days').encode("utf-8"), "--lower-limit", "0", "--rigid", "--start", start, "--end", end, "--alt-autoscale", #"--legend-direction", "bottomup", "DEF:uptime=%s:value:AVERAGE" % (rrd_filepath[0]), "CDEF:day=uptime,86400,/", "CDEF:hour=uptime,86400,%,3600,/", "CDEF:minute=uptime,3600,%,60,/", "COMMENT:%s\\r" % legend_footer, "COMMENT:<tt>---------------------------------------------------------------------------</tt>\\n", "AREA:day#80AA00:<tt>%s </tt>" % (legend_label["uptime"]), "GPRINT:day:LAST:<tt>%%6.0lf %s</tt>" % (legend_label["day"]), "GPRINT:hour:LAST:<tt>%%2.0lf %s</tt>" % (legend_label["hour"]), "GPRINT:minute:LAST:<tt>%%2.0lf %s</tt>\\n" % (legend_label["minute"]), "COMMENT:%s\\n" % (legend_header), "COMMENT: \\n", ) return graph_filepath
def create_libvirt_cpu_graph(_, lang, graph_dir, rrd_dir, start, end, dev, type): graph_filename = "%s.png" % (generate_phrase(12,'abcdefghijklmnopqrstuvwxyz')) graph_filepath = "%s/%s" % (graph_dir, graph_filename) if dev == "total": rrd_filepath = ("%s/libvirt/virt_cpu_total.rrd" % (rrd_dir), ) else: rrd_filepath = ("%s/libvirt/virt_vcpu-%s.rrd" % (rrd_dir, dev), ) for filepath in rrd_filepath: if is_readable(filepath) is False: return "" legend_header_label = {"min":_('Min'), "max":_('Max'), "ave":_('Ave'), "last":_('Last'), } for key in legend_header_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_header_label[key]): legend_header_label[key] = "</tt>%s<tt>" % (legend_header_label[key].encode("utf-8")) else: legend_header_label[key] = "%s" % (legend_header_label[key].encode("utf-8")) legend_header = "<tt> %s %s %s %s</tt>" % (legend_header_label['min'], legend_header_label['max'], legend_header_label['ave'], legend_header_label['last'] ) title = "<tt>%s - CPU-%s</tt>" % (rrd_dir.split('/')[-1], dev) created_label = _('Graph created') if re.search(u"[^a-zA-Z0-9 ]", created_label): created_label = "</tt>%s<tt>" % (created_label.encode("utf-8")) else: created_label = "%s" % (created_label.encode("utf-8")) created_time = "%s" % (datetime.datetime.today().strftime(DEFAULT_LANGS[lang]['DATE_FORMAT'][1])) created_time = re.sub(r':', '\:', created_time) legend_footer = "<tt>%s \: %s</tt>" % (created_label, created_time) data = rrdtool.graph(graph_filepath, "--imgformat", "PNG", "--font", "TITLE:0:IPAexGothic", "--font", "LEGEND:0:IPAexGothic", "--pango-markup", "--width", "550", "--height", "350", "--full-size-mode", "--color", "BACK#FFFFFF", "--color", "CANVAS#FFFFFF", "--color", "SHADEA#FFFFFF", "--color", "SHADEB#FFFFFF", "--color", "GRID#DDDDDD", "--color", "MGRID#CCCCCC", "--color", "FONT#555555", "--color", "FRAME#FFFFFF", "--color", "ARROW#FFFFFF", "--title", title, # TRANSLATORS: # 仮想マシンのグラフのCPUグラフの縦軸のラベル # 単位はCPU時間(秒)です "--vertical-label", _('Seconds').encode("utf-8"), "--units-exponent", "0", "--alt-y-grid", "--start", start, "--end", end, #"--legend-direction", "bottomup", "DEF:ns=%s:ns:AVERAGE" % (rrd_filepath[0]), "CDEF:s=ns,1000,1000,1000,*,*,/", "COMMENT:%s\\r" % legend_footer, "COMMENT:<tt>---------------------------------------------------------------------------</tt>\\n", # TRANSLATORS: # 仮想マシンのグラフのCPUグラフの凡例 "AREA:s#80AA00:<tt>%s </tt>" % (_('Seconds').encode("utf-8")), "GPRINT:s:MIN:<tt>%8.2lf</tt>", "GPRINT:s:MAX:<tt>%8.2lf</tt>", "GPRINT:s:AVERAGE:<tt>%8.2lf</tt>", "GPRINT:s:LAST:<tt>%8.2lf</tt>\\n", "COMMENT:%s\\n" % (legend_header), "COMMENT: \\n", "LINE1:s#80AA00", ) return graph_filepath
def create_libvirt_disk_graph(_, lang, graph_dir, rrd_dir, start, end, dev, type): graph_filename = "%s.png" % (generate_phrase(12,'abcdefghijklmnopqrstuvwxyz')) graph_filepath = "%s/%s" % (graph_dir, graph_filename) rrd_filepath = ("%s/libvirt/disk_%s-%s.rrd" % (rrd_dir, type, dev), ) graph_title = { "octets":"%s - %s", "ops":"%s - %s", } # TRANSLATORS: # 仮想マシンのグラフのディスクグラフの縦軸のラベル graph_label = { "octets":_('Bytes / sec').encode("utf-8"), "ops":_('Ops / sec').encode("utf-8"), } for filepath in rrd_filepath: if is_readable(filepath) is False: return "" legend_header_label = {"min":_('Min'), "max":_('Max'), "ave":_('Ave'), "last":_('Last'), } for key in legend_header_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_header_label[key]): legend_header_label[key] = "</tt>%s<tt>" % (legend_header_label[key].encode("utf-8")) else: legend_header_label[key] = "%s" % (legend_header_label[key].encode("utf-8")) legend_header = "<tt> %s %s %s %s</tt>" % (legend_header_label['min'], legend_header_label['max'], legend_header_label['ave'], legend_header_label['last'] ) legend_label = {"read":_('Read'), "write":_('Write'), } for key in legend_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_label[key]): legend_label[key] = "</tt>%s<tt>" % (legend_label[key].encode("utf-8")) else: if key == "read": legend_label[key] = "%s " % (legend_label[key].encode("utf-8")) else: legend_label[key] = "%s" % (legend_label[key].encode("utf-8")) title = "<tt>%s - %s</tt>" % (rrd_dir.split('/')[-1], graph_title[type] % (dev, type)) created_label = _('Graph created') if re.search(u"[^a-zA-Z0-9 ]", created_label): created_label = "</tt>%s<tt>" % (created_label.encode("utf-8")) else: created_label = "%s" % (created_label.encode("utf-8")) created_time = "%s" % (datetime.datetime.today().strftime(DEFAULT_LANGS[lang]['DATE_FORMAT'][1])) created_time = re.sub(r':', '\:', created_time) legend_footer = "<tt>%s \: %s</tt>" % (created_label, created_time) data = rrdtool.graph(graph_filepath, "--imgformat", "PNG", "--font", "TITLE:0:IPAexGothic", "--font", "LEGEND:0:IPAexGothic", "--pango-markup", "--width", "550", "--height", "350", "--full-size-mode", "--color", "BACK#FFFFFF", "--color", "CANVAS#FFFFFF", "--color", "SHADEA#FFFFFF", "--color", "SHADEB#FFFFFF", "--color", "GRID#DDDDDD", "--color", "MGRID#CCCCCC", "--color", "FONT#555555", "--color", "FRAME#FFFFFF", "--color", "ARROW#FFFFFF", "--title", title, "--vertical-label", graph_label[type], "--start", start, "--end", end, #"--legend-direction", "bottomup", "DEF:read=%s:read:AVERAGE" % (rrd_filepath[0]), "DEF:write=%s:write:AVERAGE" % (rrd_filepath[0]), "COMMENT:%s\\r" % legend_footer, "COMMENT:<tt>---------------------------------------------------------------------------</tt>\\n", "AREA:read#E7EF00:<tt>%s </tt>" % (legend_label["read"]), "GPRINT:read:MIN:<tt>%8.2lf%s</tt>", "GPRINT:read:MAX:<tt>%8.2lf%s</tt>", "GPRINT:read:AVERAGE:<tt>%8.2lf%s</tt>", "GPRINT:read:LAST:<tt>%8.2lf%s</tt>\\n", "STACK:write#80AA00:<tt>%s </tt>" % (legend_label["write"]), "GPRINT:write:MIN:<tt>%8.2lf%s</tt>", "GPRINT:write:MAX:<tt>%8.2lf%s</tt>", "GPRINT:write:AVERAGE:<tt>%8.2lf%s</tt>", "GPRINT:write:LAST:<tt>%8.2lf%s</tt>\\n", "COMMENT:%s\\n" % (legend_header), "COMMENT: \\n", "LINE1:read#E7EF00", "STACK:write#80AA00", ) return graph_filepath
def create_libvirt_cpu_graph(_, lang, graph_dir, rrd_dir, start, end, dev, type): graph_filename = "%s.png" % (generate_phrase(12, 'abcdefghijklmnopqrstuvwxyz')) graph_filepath = "%s/%s" % (graph_dir, graph_filename) if dev == "total": rrd_filepath = ("%s/libvirt/virt_cpu_total.rrd" % (rrd_dir), ) else: rrd_filepath = ("%s/libvirt/virt_vcpu-%s.rrd" % (rrd_dir, dev), ) for filepath in rrd_filepath: if is_readable(filepath) is False: return "" legend_header_label = { "min": _('Min'), "max": _('Max'), "ave": _('Ave'), "last": _('Last'), } for key in legend_header_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_header_label[key]): legend_header_label[key] = "</tt>%s<tt>" % ( legend_header_label[key].encode("utf-8")) else: legend_header_label[key] = "%s" % ( legend_header_label[key].encode("utf-8")) legend_header = "<tt> %s %s %s %s</tt>" % ( legend_header_label['min'], legend_header_label['max'], legend_header_label['ave'], legend_header_label['last']) title = "<tt>%s - CPU-%s</tt>" % (rrd_dir.split('/')[-1], dev) created_label = _('Graph created') if re.search(u"[^a-zA-Z0-9 ]", created_label): created_label = "</tt>%s<tt>" % (created_label.encode("utf-8")) else: created_label = "%s" % (created_label.encode("utf-8")) created_time = "%s" % (datetime.datetime.today().strftime( DEFAULT_LANGS[lang]['DATE_FORMAT'][1])) created_time = re.sub(r':', '\:', created_time) legend_footer = "<tt>%s \: %s</tt>" % (created_label, created_time) data = rrdtool.graph( graph_filepath, "--imgformat", "PNG", "--font", "TITLE:0:IPAexGothic", "--font", "LEGEND:0:IPAexGothic", "--pango-markup", "--width", "550", "--height", "350", "--full-size-mode", "--color", "BACK#FFFFFF", "--color", "CANVAS#FFFFFF", "--color", "SHADEA#FFFFFF", "--color", "SHADEB#FFFFFF", "--color", "GRID#DDDDDD", "--color", "MGRID#CCCCCC", "--color", "FONT#555555", "--color", "FRAME#FFFFFF", "--color", "ARROW#FFFFFF", "--title", title, # TRANSLATORS: # 仮想マシンのグラフのCPUグラフの縦軸のラベル # 単位はCPU時間(秒)です "--vertical-label", _('Seconds').encode("utf-8"), "--units-exponent", "0", "--alt-y-grid", "--start", start, "--end", end, #"--legend-direction", "bottomup", "DEF:ns=%s:ns:AVERAGE" % (rrd_filepath[0]), "CDEF:s=ns,1000,1000,1000,*,*,/", "COMMENT:%s\\r" % legend_footer, "COMMENT:<tt>---------------------------------------------------------------------------</tt>\\n", # TRANSLATORS: # 仮想マシンのグラフのCPUグラフの凡例 "AREA:s#80AA00:<tt>%s </tt>" % (_('Seconds').encode("utf-8")), "GPRINT:s:MIN:<tt>%8.2lf</tt>", "GPRINT:s:MAX:<tt>%8.2lf</tt>", "GPRINT:s:AVERAGE:<tt>%8.2lf</tt>", "GPRINT:s:LAST:<tt>%8.2lf</tt>\\n", "COMMENT:%s\\n" % (legend_header), "COMMENT: \\n", "LINE1:s#80AA00", ) return graph_filepath
def create_libvirt_disk_graph(_, lang, graph_dir, rrd_dir, start, end, dev, type): graph_filename = "%s.png" % (generate_phrase(12, 'abcdefghijklmnopqrstuvwxyz')) graph_filepath = "%s/%s" % (graph_dir, graph_filename) rrd_filepath = ("%s/libvirt/disk_%s-%s.rrd" % (rrd_dir, type, dev), ) graph_title = { "octets": "%s - %s", "ops": "%s - %s", } # TRANSLATORS: # 仮想マシンのグラフのディスクグラフの縦軸のラベル graph_label = { "octets": _('Bytes / sec').encode("utf-8"), "ops": _('Ops / sec').encode("utf-8"), } for filepath in rrd_filepath: if is_readable(filepath) is False: return "" legend_header_label = { "min": _('Min'), "max": _('Max'), "ave": _('Ave'), "last": _('Last'), } for key in legend_header_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_header_label[key]): legend_header_label[key] = "</tt>%s<tt>" % ( legend_header_label[key].encode("utf-8")) else: legend_header_label[key] = "%s" % ( legend_header_label[key].encode("utf-8")) legend_header = "<tt> %s %s %s %s</tt>" % ( legend_header_label['min'], legend_header_label['max'], legend_header_label['ave'], legend_header_label['last']) legend_label = { "read": _('Read'), "write": _('Write'), } for key in legend_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_label[key]): legend_label[key] = "</tt>%s<tt>" % ( legend_label[key].encode("utf-8")) else: if key == "read": legend_label[key] = "%s " % (legend_label[key].encode("utf-8")) else: legend_label[key] = "%s" % (legend_label[key].encode("utf-8")) title = "<tt>%s - %s</tt>" % (rrd_dir.split('/')[-1], graph_title[type] % (dev, type)) created_label = _('Graph created') if re.search(u"[^a-zA-Z0-9 ]", created_label): created_label = "</tt>%s<tt>" % (created_label.encode("utf-8")) else: created_label = "%s" % (created_label.encode("utf-8")) created_time = "%s" % (datetime.datetime.today().strftime( DEFAULT_LANGS[lang]['DATE_FORMAT'][1])) created_time = re.sub(r':', '\:', created_time) legend_footer = "<tt>%s \: %s</tt>" % (created_label, created_time) data = rrdtool.graph( graph_filepath, "--imgformat", "PNG", "--font", "TITLE:0:IPAexGothic", "--font", "LEGEND:0:IPAexGothic", "--pango-markup", "--width", "550", "--height", "350", "--full-size-mode", "--color", "BACK#FFFFFF", "--color", "CANVAS#FFFFFF", "--color", "SHADEA#FFFFFF", "--color", "SHADEB#FFFFFF", "--color", "GRID#DDDDDD", "--color", "MGRID#CCCCCC", "--color", "FONT#555555", "--color", "FRAME#FFFFFF", "--color", "ARROW#FFFFFF", "--title", title, "--vertical-label", graph_label[type], "--start", start, "--end", end, #"--legend-direction", "bottomup", "DEF:read=%s:read:AVERAGE" % (rrd_filepath[0]), "DEF:write=%s:write:AVERAGE" % (rrd_filepath[0]), "COMMENT:%s\\r" % legend_footer, "COMMENT:<tt>---------------------------------------------------------------------------</tt>\\n", "AREA:read#E7EF00:<tt>%s </tt>" % (legend_label["read"]), "GPRINT:read:MIN:<tt>%8.2lf%s</tt>", "GPRINT:read:MAX:<tt>%8.2lf%s</tt>", "GPRINT:read:AVERAGE:<tt>%8.2lf%s</tt>", "GPRINT:read:LAST:<tt>%8.2lf%s</tt>\\n", "STACK:write#80AA00:<tt>%s </tt>" % (legend_label["write"]), "GPRINT:write:MIN:<tt>%8.2lf%s</tt>", "GPRINT:write:MAX:<tt>%8.2lf%s</tt>", "GPRINT:write:AVERAGE:<tt>%8.2lf%s</tt>", "GPRINT:write:LAST:<tt>%8.2lf%s</tt>\\n", "COMMENT:%s\\n" % (legend_header), "COMMENT: \\n", "LINE1:read#E7EF00", "STACK:write#80AA00", ) return graph_filepath
def create_libvirt_interface_graph(_, lang, graph_dir, rrd_dir, start, end, dev, type): graph_filename = "%s.png" % (generate_phrase(12,'abcdefghijklmnopqrstuvwxyz')) graph_filepath = "%s/%s" % (graph_dir, graph_filename) rrd_filepath = ("%s/libvirt/if_%s-%s.rrd" % (rrd_dir, type, dev), ) # TRANSLATORS: # 仮想マシンのグラフのネットワークグラフのタイトル graph_title = { "packets":"%%s - %s" % (_('Packets').encode("utf-8")), "octets":"%%s - %s" % (_('Traffic').encode("utf-8")), "errors":"%%s - %s" % (_('Errors').encode("utf-8")), "dropped":"%%s - %s" % (_('Dropped').encode("utf-8")), } # TRANSLATORS: # 仮想マシンのグラフのネットワークグラフの縦軸のラベル # packetsは1秒あたりのパケット数 # octetsは1秒あたりのバイト数 # errorsは1秒あたりのエラーパケット数 # droppedは1秒あたりのパケットドロップ数 graph_label = { "packets":_("Packets / sec").encode("utf-8"), "octets":_("Octets / sec").encode("utf-8"), "errors":_("Packets / sec").encode("utf-8"), "dropped":_("Packets / sec").encode("utf-8"), } for filepath in rrd_filepath: if is_readable(filepath) is False: return "" legend_header_label = {"min":_('Min'), "max":_('Max'), "ave":_('Ave'), "last":_('Last'), } for key in legend_header_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_header_label[key]): legend_header_label[key] = "</tt>%s<tt>" % (legend_header_label[key].encode("utf-8")) else: legend_header_label[key] = "%s" % (legend_header_label[key].encode("utf-8")) legend_header = "<tt> %s %s %s %s</tt>" % (legend_header_label['min'], legend_header_label['max'], legend_header_label['ave'], legend_header_label['last'] ) legend_label = {"rx":_('RX'), "tx":_('TX'), } for key in legend_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_label[key]): legend_label[key] = "</tt>%s<tt>" % (legend_label[key].encode("utf-8")) else: legend_label[key] = "%s" % (legend_label[key].encode("utf-8")) title = "<tt>%s - %s</tt>" % (rrd_dir.split('/')[-1], graph_title[type] % (dev)) created_label = _('Graph created') if re.search(u"[^a-zA-Z0-9 ]", created_label): created_label = "</tt>%s<tt>" % (created_label.encode("utf-8")) else: created_label = "%s" % (created_label.encode("utf-8")) created_time = "%s" % (datetime.datetime.today().strftime(DEFAULT_LANGS[lang]['DATE_FORMAT'][1])) created_time = re.sub(r':', '\:', created_time) legend_footer = "<tt>%s \: %s</tt>" % (created_label, created_time) data = rrdtool.graph(graph_filepath, GRAPH_COMMON_PARAM, "--title", title, "--vertical-label", graph_label[type], "--start", start, "--end", end, "--legend-direction", "bottomup", "DEF:rx=%s:rx:AVERAGE" % (rrd_filepath[0]), "DEF:tx=%s:tx:AVERAGE" % (rrd_filepath[0]), "COMMENT:%s\\r" % legend_footer, "COMMENT:<tt>---------------------------------------------------------------------------</tt>\\n", "AREA:rx#E7EF00:<tt>%s </tt>" % (legend_label["rx"]), "GPRINT:rx:MIN:<tt>%8.2lf%s</tt>", "GPRINT:rx:MAX:<tt>%8.2lf%s</tt>", "GPRINT:rx:AVERAGE:<tt>%8.2lf%s</tt>", "GPRINT:rx:LAST:<tt>%8.2lf%s</tt>\\n", "STACK:tx#80AA00:<tt>%s </tt>" % (legend_label["tx"]), "GPRINT:tx:MIN:<tt>%8.2lf%s</tt>", "GPRINT:tx:MAX:<tt>%8.2lf%s</tt>", "GPRINT:tx:AVERAGE:<tt>%8.2lf%s</tt>", "GPRINT:tx:LAST:<tt>%8.2lf%s</tt>\\n", "COMMENT:%s\\n" % (legend_header), "COMMENT: \\n", "LINE1:rx#E7EF00", "STACK:tx#80AA00", ) return graph_filepath
def create_load_graph(_, lang, graph_dir, rrd_dir, start, end, dev=None, type=None): graph_filename = "%s.png" % (generate_phrase(12, 'abcdefghijklmnopqrstuvwxyz')) graph_filepath = "%s/%s" % (graph_dir, graph_filename) rrd_filepath = ("%s/load/load.rrd" % (rrd_dir), ) for filepath in rrd_filepath: if is_readable(filepath) is False: return "" legend_header_label = { "min": _('Min'), "max": _('Max'), "ave": _('Ave'), "last": _('Last'), } for key in legend_header_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_header_label[key]): legend_header_label[key] = "</tt>%s<tt>" % ( legend_header_label[key].encode("utf-8")) else: legend_header_label[key] = "%s" % ( legend_header_label[key].encode("utf-8")) legend_header = "<tt> %s %s %s %s</tt>" % ( legend_header_label['min'], legend_header_label['max'], legend_header_label['ave'], legend_header_label['last']) title = _('Load Average') if re.search(u"[^a-zA-Z0-9_\-\. ]", title): title = "%s" % (title.encode("utf-8")) else: title = "<tt>%s</tt>" % (title.encode("utf-8")) # TRANSLATORS: # ロードアベレージのグラフの凡例 legend = { "1m": _('1m Average'), "5m": _('5m Average'), "15m": _('15m Average'), } for key in legend.keys(): if re.search(u"[^a-zA-Z0-9_\-\. ]", legend[key]): legend[key] = "</tt>%s <tt>" % (legend[key].encode("utf-8")) else: legend[key] = "%s" % (legend[key].encode("utf-8")) created_label = _('Graph created') if re.search(u"[^a-zA-Z0-9 ]", created_label): created_label = "</tt>%s<tt>" % (created_label.encode("utf-8")) else: created_label = "%s" % (created_label.encode("utf-8")) created_time = "%s" % (datetime.datetime.today().strftime( DEFAULT_LANGS[lang]['DATE_FORMAT'][1])) created_time = re.sub(r':', '\:', created_time) legend_footer = "<tt>%s \: %s</tt>" % (created_label, created_time) data = rrdtool.graph( graph_filepath, "--imgformat", "PNG", "--font", "TITLE:0:IPAexGothic", "--font", "LEGEND:0:IPAexGothic", "--pango-markup", "--width", "550", "--height", "350", "--full-size-mode", "--color", "BACK#FFFFFF", "--color", "CANVAS#FFFFFF", "--color", "SHADEA#FFFFFF", "--color", "SHADEB#FFFFFF", "--color", "GRID#DDDDDD", "--color", "MGRID#CCCCCC", "--color", "FONT#555555", "--color", "FRAME#FFFFFF", "--color", "ARROW#FFFFFF", "--title", title, "--vertical-label", _('System load').encode("utf-8"), "--start", start, "--end", end, "--units-exponent", "0", #"--legend-direction", "bottomup", "DEF:shortterm=%s:shortterm:AVERAGE" % (rrd_filepath[0]), "DEF:midterm=%s:midterm:AVERAGE" % (rrd_filepath[0]), "DEF:longterm=%s:longterm:AVERAGE" % (rrd_filepath[0]), "COMMENT:%s\\r" % legend_footer, "COMMENT:<tt>---------------------------------------------------------------------------</tt>\\n", "LINE:shortterm#E7EF00:<tt>%s </tt>" % (legend["1m"]), "GPRINT:shortterm:MIN:<tt>%8.2lf</tt>", "GPRINT:shortterm:MAX:<tt>%8.2lf</tt>", "GPRINT:shortterm:AVERAGE:<tt>%8.2lf</tt>", "GPRINT:shortterm:LAST:<tt>%8.2lf</tt>\\n", "LINE:midterm#B3EF00:<tt>%s </tt>" % (legend["5m"]), "GPRINT:midterm:MIN:<tt>%8.2lf</tt>", "GPRINT:midterm:MAX:<tt>%8.2lf</tt>", "GPRINT:midterm:AVERAGE:<tt>%8.2lf</tt>", "GPRINT:midterm:LAST:<tt>%8.2lf</tt>\\n", "LINE:longterm#80AA00:<tt>%s</tt>" % (legend["15m"]), "GPRINT:longterm:MIN:<tt>%8.2lf</tt>", "GPRINT:longterm:MAX:<tt>%8.2lf</tt>", "GPRINT:longterm:AVERAGE:<tt>%8.2lf</tt>", "GPRINT:longterm:LAST:<tt>%8.2lf</tt>\\n", "COMMENT:%s\\n" % (legend_header), "COMMENT: \\n", ) return graph_filepath
def create_cpu_graph(_, lang, graph_dir, rrd_dir, start, end, dev=0, type=None): cpu_number = str(dev) graph_filename = "%s.png" % (generate_phrase(12,'abcdefghijklmnopqrstuvwxyz')) graph_filepath = "%s/%s" % (graph_dir, graph_filename) rrd_filepath = ("%s/cpu-%s/cpu-%s.rrd" % (rrd_dir, cpu_number, "idle"), "%s/cpu-%s/cpu-%s.rrd" % (rrd_dir, cpu_number, "interrupt"), "%s/cpu-%s/cpu-%s.rrd" % (rrd_dir, cpu_number, "nice"), "%s/cpu-%s/cpu-%s.rrd" % (rrd_dir, cpu_number, "user"), "%s/cpu-%s/cpu-%s.rrd" % (rrd_dir, cpu_number, "wait"), "%s/cpu-%s/cpu-%s.rrd" % (rrd_dir, cpu_number, "system"), "%s/cpu-%s/cpu-%s.rrd" % (rrd_dir, cpu_number, "softirq"), "%s/cpu-%s/cpu-%s.rrd" % (rrd_dir, cpu_number, "steal"), ) for filename in rrd_filepath: if is_readable(filename) is False: return "" legend_header_label = {"min":_('Min'), "max":_('Max'), "ave":_('Ave'), "last":_('Last'), } for key in legend_header_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_header_label[key]): legend_header_label[key] = "</tt>%s<tt>" % (legend_header_label[key].encode("utf-8")) else: legend_header_label[key] = "%s" % (legend_header_label[key].encode("utf-8")) legend_header = "<tt> %s %s %s %s</tt>" % (legend_header_label['min'], legend_header_label['max'], legend_header_label['ave'], legend_header_label['last'] ) title = "<tt>CPU-%s</tt>" % (str(cpu_number)) created_label = _('Graph created') if re.search(u"[^a-zA-Z0-9 ]", created_label): created_label = "</tt>%s<tt>" % (created_label.encode("utf-8")) else: created_label = "%s" % (created_label.encode("utf-8")) created_time = "%s" % (datetime.datetime.today().strftime(DEFAULT_LANGS[lang]['DATE_FORMAT'][1])) created_time = re.sub(r':', '\:', created_time) legend_footer = "<tt>%s \: %s</tt>" % (created_label, created_time) data = rrdtool.graph(graph_filepath, "--imgformat", "PNG", "--font", "TITLE:0:IPAexGothic", "--font", "LEGEND:0:IPAexGothic", "--pango-markup", "--width", "550", "--height", "350", "--full-size-mode", "--color", "BACK#FFFFFF", "--color", "CANVAS#FFFFFF", "--color", "SHADEA#FFFFFF", "--color", "SHADEB#FFFFFF", "--color", "GRID#DDDDDD", "--color", "MGRID#CCCCCC", "--color", "FONT#555555", "--color", "FRAME#FFFFFF", "--color", "ARROW#FFFFFF", "--title", title, "--vertical-label", "jiffies", "--units-length", "2", "--upper-limit", "100", "--lower-limit", "0", "--rigid", "--start", start, "--end", end, #"--legend-direction", "bottomup", "DEF:idle=%s:value:AVERAGE" % (rrd_filepath[0]), "DEF:interrupt=%s:value:AVERAGE" % (rrd_filepath[1]), "DEF:nice=%s:value:AVERAGE" % (rrd_filepath[2]), "DEF:user=%s:value:AVERAGE" % (rrd_filepath[3]), "DEF:wait=%s:value:AVERAGE" % (rrd_filepath[4]), "DEF:system=%s:value:AVERAGE" % (rrd_filepath[5]), "DEF:softirq=%s:value:AVERAGE" % (rrd_filepath[6]), "DEF:steal=%s:value:AVERAGE" % (rrd_filepath[7]), "COMMENT:%s\\r" % legend_footer, "COMMENT:<tt>---------------------------------------------------------------------------</tt>\\n", # TRANSLATORS: # CPUのグラフの凡例 # 日本語にした場合は表示が崩れますが、後で直すのでそのままで大丈夫です "AREA:steal#FDFF6A:<tt>%s </tt>" % (_('Steal').encode("utf-8")), "GPRINT:steal:MIN:<tt>%8.2lf</tt>", "GPRINT:steal:MAX:<tt>%8.2lf</tt>", "GPRINT:steal:AVERAGE:<tt>%8.2lf</tt>", "GPRINT:steal:LAST:<tt>%8.2lf</tt>\\n", "STACK:interrupt#F7FF13:<tt>%s </tt>" % (_('Interrupt').encode("utf-8")), "GPRINT:interrupt:MIN:<tt>%8.2lf</tt>", "GPRINT:interrupt:MAX:<tt>%8.2lf</tt>", "GPRINT:interrupt:AVERAGE:<tt>%8.2lf</tt>", "GPRINT:interrupt:LAST:<tt>%8.2lf</tt>\\n", "STACK:softirq#E7EF00:<tt>%s </tt>" % (_('SoftIRQ').encode("utf-8")), "GPRINT:softirq:MIN:<tt>%8.2lf</tt>", "GPRINT:softirq:MAX:<tt>%8.2lf</tt>", "GPRINT:softirq:AVERAGE:<tt>%8.2lf</tt>", "GPRINT:softirq:LAST:<tt>%8.2lf</tt>\\n", "STACK:system#B5F100:<tt>%s </tt>" % (_('System').encode("utf-8")), "GPRINT:system:MIN:<tt>%8.2lf</tt>", "GPRINT:system:MAX:<tt>%8.2lf</tt>", "GPRINT:system:AVERAGE:<tt>%8.2lf</tt>", "GPRINT:system:LAST:<tt>%8.2lf</tt>\\n", "STACK:wait#B3EF00:<tt>%s </tt>" % (_('Wait - IO').encode("utf-8")), "GPRINT:wait:MIN:<tt>%8.2lf</tt>", "GPRINT:wait:MAX:<tt>%8.2lf</tt>", "GPRINT:wait:AVERAGE:<tt>%8.2lf</tt>", "GPRINT:wait:LAST:<tt>%8.2lf</tt>\\n", "STACK:user#95C700:<tt>%s </tt>" % (_('User').encode("utf-8")), "GPRINT:user:MIN:<tt>%8.2lf</tt>", "GPRINT:user:MAX:<tt>%8.2lf</tt>", "GPRINT:user:AVERAGE:<tt>%8.2lf</tt>", "GPRINT:user:LAST:<tt>%8.2lf</tt>\\n", "STACK:nice#80AA00:<tt>%s </tt>" % (_('Nice').encode("utf-8")), "GPRINT:nice:MIN:<tt>%8.2lf</tt>", "GPRINT:nice:MAX:<tt>%8.2lf</tt>", "GPRINT:nice:AVERAGE:<tt>%8.2lf</tt>", "GPRINT:nice:LAST:<tt>%8.2lf</tt>\\n", "STACK:idle#FFFFFF:<tt>%s </tt>" % (_('Idle').encode("utf-8")), "GPRINT:idle:MIN:<tt>%8.2lf</tt>", "GPRINT:idle:MAX:<tt>%8.2lf</tt>", "GPRINT:idle:AVERAGE:<tt>%8.2lf</tt>", "GPRINT:idle:LAST:<tt>%8.2lf</tt>\\n", "COMMENT:%s\\n" % (legend_header), "COMMENT: \\n", ) return graph_filepath
def create_interface_graph(_, lang, graph_dir, rrd_dir, start, end, dev, type): graph_filename = "%s.png" % (generate_phrase(12,'abcdefghijklmnopqrstuvwxyz')) graph_filepath = "%s/%s" % (graph_dir, graph_filename) rrd_filepath = ("%s/interface/if_%s-%s.rrd" % (rrd_dir, type, dev), ) # TRANSLATORS: # ネットワークのグラフのタイトル graph_title = { "packets":"%%s - %s" % (_('Packets').encode("utf-8")), "octets":"%%s - %s" % (_('Traffic').encode("utf-8")), "errors":"%%s - %s" % (_('Errors').encode("utf-8")), } # TRANSLATORS: # ネットワークのグラフの縦軸のラベル # packetsは1秒あたりのパケット数 # octetsは1秒あたりのバイト数 # errorsは1秒あたりのエラーパケット数 graph_label = { "packets":_("Packets / sec").encode("utf-8"), "octets":_("Octets / sec").encode("utf-8"), "errors":_("Packets / sec").encode("utf-8"), } for filepath in rrd_filepath: if is_readable(filepath) is False: return "" legend_header_label = {"min":_('Min'), "max":_('Max'), "ave":_('Ave'), "last":_('Last'), } for key in legend_header_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_header_label[key]): legend_header_label[key] = "</tt>%s<tt>" % (legend_header_label[key].encode("utf-8")) else: legend_header_label[key] = "%s" % (legend_header_label[key].encode("utf-8")) legend_header = "<tt> %s %s %s %s</tt>" % (legend_header_label['min'], legend_header_label['max'], legend_header_label['ave'], legend_header_label['last'] ) legend_label = {"rx":_('RX'), "tx":_('TX'), } for key in legend_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_label[key]): legend_label[key] = "</tt>%s<tt>" % (legend_label[key].encode("utf-8")) else: legend_label[key] = "%s" % (legend_label[key].encode("utf-8")) title = "<tt>%s</tt>" % (graph_title[type] % (dev)) created_label = _('Graph created') if re.search(u"[^a-zA-Z0-9 ]", created_label): created_label = "</tt>%s<tt>" % (created_label.encode("utf-8")) else: created_label = "%s" % (created_label.encode("utf-8")) created_time = "%s" % (datetime.datetime.today().strftime(DEFAULT_LANGS[lang]['DATE_FORMAT'][1])) created_time = re.sub(r':', '\:', created_time) legend_footer = "<tt>%s \: %s</tt>" % (created_label, created_time) data = rrdtool.graph(graph_filepath, "--imgformat", "PNG", "--font", "TITLE:0:IPAexGothic", "--font", "LEGEND:0:IPAexGothic", "--pango-markup", "--width", "550", "--height", "350", "--full-size-mode", "--color", "BACK#FFFFFF", "--color", "CANVAS#FFFFFF", "--color", "SHADEA#FFFFFF", "--color", "SHADEB#FFFFFF", "--color", "GRID#DDDDDD", "--color", "MGRID#CCCCCC", "--color", "FONT#555555", "--color", "FRAME#FFFFFF", "--color", "ARROW#FFFFFF", "--title", title, "--vertical-label", graph_label[type], "--start", start, "--end", end, #"--legend-direction", "bottomup", "DEF:rx=%s:rx:AVERAGE" % (rrd_filepath[0]), "DEF:tx=%s:tx:AVERAGE" % (rrd_filepath[0]), "COMMENT:%s\\r" % legend_footer, "COMMENT:<tt>---------------------------------------------------------------------------</tt>\\n", "AREA:rx#E7EF00:<tt>%s </tt>" % (legend_label["rx"]), "GPRINT:rx:MIN:<tt>%8.2lf%s</tt>", "GPRINT:rx:MAX:<tt>%8.2lf%s</tt>", "GPRINT:rx:AVERAGE:<tt>%8.2lf%s</tt>", "GPRINT:rx:LAST:<tt>%8.2lf%s</tt>\\n", "STACK:tx#80AA00:<tt>%s </tt>" % (legend_label["tx"]), "GPRINT:tx:MIN:<tt>%8.2lf%s</tt>", "GPRINT:tx:MAX:<tt>%8.2lf%s</tt>", "GPRINT:tx:AVERAGE:<tt>%8.2lf%s</tt>", "GPRINT:tx:LAST:<tt>%8.2lf%s</tt>\\n", "COMMENT:%s\\n" % (legend_header), "COMMENT: \\n", "LINE1:rx#E7EF00", "STACK:tx#80AA00", ) return graph_filepath
def create_load_graph(_, lang, graph_dir, rrd_dir, start, end, dev=None, type=None): graph_filename = "%s.png" % (generate_phrase(12,'abcdefghijklmnopqrstuvwxyz')) graph_filepath = "%s/%s" % (graph_dir, graph_filename) rrd_filepath = ("%s/load/load.rrd" % (rrd_dir), ) for filepath in rrd_filepath: if is_readable(filepath) is False: return "" legend_header_label = {"min":_('Min'), "max":_('Max'), "ave":_('Ave'), "last":_('Last'), } for key in legend_header_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_header_label[key]): legend_header_label[key] = "</tt>%s<tt>" % (legend_header_label[key].encode("utf-8")) else: legend_header_label[key] = "%s" % (legend_header_label[key].encode("utf-8")) legend_header = "<tt> %s %s %s %s</tt>" % (legend_header_label['min'], legend_header_label['max'], legend_header_label['ave'], legend_header_label['last'] ) title = _('Load Average') if re.search(u"[^a-zA-Z0-9_\-\. ]", title): title = "%s" % (title.encode("utf-8")) else: title = "<tt>%s</tt>" % (title.encode("utf-8")) # TRANSLATORS: # ロードアベレージのグラフの凡例 legend = {"1m":_('1m Average'), "5m":_('5m Average'), "15m":_('15m Average'), } for key in legend.keys(): if re.search(u"[^a-zA-Z0-9_\-\. ]", legend[key]): legend[key] = "</tt>%s <tt>" % (legend[key].encode("utf-8")) else: legend[key] = "%s" % (legend[key].encode("utf-8")) created_label = _('Graph created') if re.search(u"[^a-zA-Z0-9 ]", created_label): created_label = "</tt>%s<tt>" % (created_label.encode("utf-8")) else: created_label = "%s" % (created_label.encode("utf-8")) created_time = "%s" % (datetime.datetime.today().strftime(DEFAULT_LANGS[lang]['DATE_FORMAT'][1])) created_time = re.sub(r':', '\:', created_time) legend_footer = "<tt>%s \: %s</tt>" % (created_label, created_time) data = rrdtool.graph(graph_filepath, "--imgformat", "PNG", "--font", "TITLE:0:IPAexGothic", "--font", "LEGEND:0:IPAexGothic", "--pango-markup", "--width", "550", "--height", "350", "--full-size-mode", "--color", "BACK#FFFFFF", "--color", "CANVAS#FFFFFF", "--color", "SHADEA#FFFFFF", "--color", "SHADEB#FFFFFF", "--color", "GRID#DDDDDD", "--color", "MGRID#CCCCCC", "--color", "FONT#555555", "--color", "FRAME#FFFFFF", "--color", "ARROW#FFFFFF", "--title", title, "--vertical-label", _('System load').encode("utf-8"), "--start", start, "--end", end, "--units-exponent", "0", #"--legend-direction", "bottomup", "DEF:shortterm=%s:shortterm:AVERAGE" % (rrd_filepath[0]), "DEF:midterm=%s:midterm:AVERAGE" % (rrd_filepath[0]), "DEF:longterm=%s:longterm:AVERAGE" % (rrd_filepath[0]), "COMMENT:%s\\r" % legend_footer, "COMMENT:<tt>---------------------------------------------------------------------------</tt>\\n", "LINE:shortterm#E7EF00:<tt>%s </tt>" % (legend["1m"]), "GPRINT:shortterm:MIN:<tt>%8.2lf</tt>", "GPRINT:shortterm:MAX:<tt>%8.2lf</tt>", "GPRINT:shortterm:AVERAGE:<tt>%8.2lf</tt>", "GPRINT:shortterm:LAST:<tt>%8.2lf</tt>\\n", "LINE:midterm#B3EF00:<tt>%s </tt>" % (legend["5m"]), "GPRINT:midterm:MIN:<tt>%8.2lf</tt>", "GPRINT:midterm:MAX:<tt>%8.2lf</tt>", "GPRINT:midterm:AVERAGE:<tt>%8.2lf</tt>", "GPRINT:midterm:LAST:<tt>%8.2lf</tt>\\n", "LINE:longterm#80AA00:<tt>%s</tt>" % (legend["15m"]), "GPRINT:longterm:MIN:<tt>%8.2lf</tt>", "GPRINT:longterm:MAX:<tt>%8.2lf</tt>", "GPRINT:longterm:AVERAGE:<tt>%8.2lf</tt>", "GPRINT:longterm:LAST:<tt>%8.2lf</tt>\\n", "COMMENT:%s\\n" % (legend_header), "COMMENT: \\n", ) return graph_filepath
def create_interface_graph(_, lang, graph_dir, rrd_dir, start, end, dev, type): graph_filename = "%s.png" % (generate_phrase(12, 'abcdefghijklmnopqrstuvwxyz')) graph_filepath = "%s/%s" % (graph_dir, graph_filename) rrd_filepath = ("%s/interface/if_%s-%s.rrd" % (rrd_dir, type, dev), ) # TRANSLATORS: # ネットワークのグラフのタイトル graph_title = { "packets": "%%s - %s" % (_('Packets').encode("utf-8")), "octets": "%%s - %s" % (_('Traffic').encode("utf-8")), "errors": "%%s - %s" % (_('Errors').encode("utf-8")), } # TRANSLATORS: # ネットワークのグラフの縦軸のラベル # packetsは1秒あたりのパケット数 # octetsは1秒あたりのバイト数 # errorsは1秒あたりのエラーパケット数 graph_label = { "packets": _("Packets / sec").encode("utf-8"), "octets": _("Octets / sec").encode("utf-8"), "errors": _("Packets / sec").encode("utf-8"), } for filepath in rrd_filepath: if is_readable(filepath) is False: return "" legend_header_label = { "min": _('Min'), "max": _('Max'), "ave": _('Ave'), "last": _('Last'), } for key in legend_header_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_header_label[key]): legend_header_label[key] = "</tt>%s<tt>" % ( legend_header_label[key].encode("utf-8")) else: legend_header_label[key] = "%s" % ( legend_header_label[key].encode("utf-8")) legend_header = "<tt> %s %s %s %s</tt>" % ( legend_header_label['min'], legend_header_label['max'], legend_header_label['ave'], legend_header_label['last']) legend_label = { "rx": _('RX'), "tx": _('TX'), } for key in legend_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_label[key]): legend_label[key] = "</tt>%s<tt>" % ( legend_label[key].encode("utf-8")) else: legend_label[key] = "%s" % (legend_label[key].encode("utf-8")) title = "<tt>%s</tt>" % (graph_title[type] % (dev)) created_label = _('Graph created') if re.search(u"[^a-zA-Z0-9 ]", created_label): created_label = "</tt>%s<tt>" % (created_label.encode("utf-8")) else: created_label = "%s" % (created_label.encode("utf-8")) created_time = "%s" % (datetime.datetime.today().strftime( DEFAULT_LANGS[lang]['DATE_FORMAT'][1])) created_time = re.sub(r':', '\:', created_time) legend_footer = "<tt>%s \: %s</tt>" % (created_label, created_time) data = rrdtool.graph( graph_filepath, "--imgformat", "PNG", "--font", "TITLE:0:IPAexGothic", "--font", "LEGEND:0:IPAexGothic", "--pango-markup", "--width", "550", "--height", "350", "--full-size-mode", "--color", "BACK#FFFFFF", "--color", "CANVAS#FFFFFF", "--color", "SHADEA#FFFFFF", "--color", "SHADEB#FFFFFF", "--color", "GRID#DDDDDD", "--color", "MGRID#CCCCCC", "--color", "FONT#555555", "--color", "FRAME#FFFFFF", "--color", "ARROW#FFFFFF", "--title", title, "--vertical-label", graph_label[type], "--start", start, "--end", end, #"--legend-direction", "bottomup", "DEF:rx=%s:rx:AVERAGE" % (rrd_filepath[0]), "DEF:tx=%s:tx:AVERAGE" % (rrd_filepath[0]), "COMMENT:%s\\r" % legend_footer, "COMMENT:<tt>---------------------------------------------------------------------------</tt>\\n", "AREA:rx#E7EF00:<tt>%s </tt>" % (legend_label["rx"]), "GPRINT:rx:MIN:<tt>%8.2lf%s</tt>", "GPRINT:rx:MAX:<tt>%8.2lf%s</tt>", "GPRINT:rx:AVERAGE:<tt>%8.2lf%s</tt>", "GPRINT:rx:LAST:<tt>%8.2lf%s</tt>\\n", "STACK:tx#80AA00:<tt>%s </tt>" % (legend_label["tx"]), "GPRINT:tx:MIN:<tt>%8.2lf%s</tt>", "GPRINT:tx:MAX:<tt>%8.2lf%s</tt>", "GPRINT:tx:AVERAGE:<tt>%8.2lf%s</tt>", "GPRINT:tx:LAST:<tt>%8.2lf%s</tt>\\n", "COMMENT:%s\\n" % (legend_header), "COMMENT: \\n", "LINE1:rx#E7EF00", "STACK:tx#80AA00", ) return graph_filepath
def process(self): (opts, args) = getopts() chkopts(opts) self.up_progress(10) try: tmp_dir_name = generate_phrase(12,'abcdefghijklmnopqrstuvwxyz') tmp_dir_path = "%s/%s" % (KARESANSUI_TMP_DIR, tmp_dir_name) os.mkdir(tmp_dir_path) except: raise KssCommandException('Failed to make tmpdir. path=%s' % (tmp_dir_path)) try: self.up_progress(10) mount_command_args = (MOUNT_CMD, opts.dev, tmp_dir_path, ) umount_command_args = (UMOUNT_CMD, tmp_dir_path, ) is_mountable = False try: (mount_cmd_rc, mount_cmd_res) = execute_command(mount_command_args) if mount_cmd_rc == 0: is_mountable = True else: self.logger.debug('Failed to mount. dev=%s' % (opts.dev)) finally: (umount_cmd_rc, umount_cmd_res) = execute_command(umount_command_args) self.up_progress(30) if is_mountable is False and opts.format is True: first_command_args = YES_CMD second_command_args = (FORMAT_CMD, "-t", opts.type, opts.dev, ) format_command_args = (first_command_args, second_command_args, ) (format_cmd_rc, format_cmd_res) = pipe_execute_command(format_command_args) if format_cmd_rc != 0: raise KssCommandException('Failed to format. dev=%s type=%s res=%s' % (opts.dev, opts.type, format_cmd_res)) try: (mount_cmd_rc, mount_cmd_res) = execute_command(mount_command_args) if mount_cmd_rc == 0: is_mountable = True else: self.logger.debug('Failed to mount. dev=%s' % (opts.dev)) finally: (umount_cmd_rc, umount_cmd_res) = execute_command(umount_command_args) self.up_progress(40) finally: try: os.rmdir(tmp_dir_path) except: raise KssCommandException('Failed to delete tmpdir. path=%s' % (tmp_dir_path)) if is_mountable is True: self.logger.info('Device "%s" is mountable.' % (opts.dev)) print >>sys.stdout, _('Device "%s" is mountable.' % (opts.dev)) else: self.logger.info('Device "%s" is not mountable.' % (opts.dev)) print >>sys.stdout, _('Device "%s" is not mountable.' % (opts.dev)) return is_mountable
def create_disk_graph(_, lang, graph_dir, rrd_dir, start, end, dev, type): graph_filename = "%s.png" % (generate_phrase(12,'abcdefghijklmnopqrstuvwxyz')) graph_filepath = "%s/%s" % (graph_dir, graph_filename) rrd_filepath = ("%s/disk-%s/disk_%s.rrd" % (rrd_dir, dev, type), ) # TRANSLATORS: # ディスク性能のグラフの縦軸のラベル # /proc/diskstatsの値をとってきているらしいです # よく分からないので、公式HPの説明をコピペしておきます # # "merged" are the number of operations, that could be merged into other, already queued operations, i. e. one physical disk access served two or more logical operations. Of course, the higher that number, the better. # "time" is the average time an I/O-operation took to complete. Since this is a little messy to calculate take the actual values with a grain of salt. graph_label = { "merged":_("Merged Ops / sec").encode("utf-8"), "octets":_("Bytes / sec").encode("utf-8"), "ops":_("Ops / sec").encode("utf-8"), "time":_("Seconds / op").encode("utf-8"), } for filepath in rrd_filepath: if is_readable(filepath) is False: return "" legend_header_label = {"min":_('Min'), "max":_('Max'), "ave":_('Ave'), "last":_('Last'), } for key in legend_header_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_header_label[key]): legend_header_label[key] = "</tt>%s<tt>" % (legend_header_label[key].encode("utf-8")) else: legend_header_label[key] = "%s" % (legend_header_label[key].encode("utf-8")) legend_header = "<tt> %s %s %s %s</tt>" % (legend_header_label['min'], legend_header_label['max'], legend_header_label['ave'], legend_header_label['last'] ) legend_label = {"read":_('Read'), "write":_('Write'), } for key in legend_label.keys(): if re.search(u"[^a-zA-Z0-9]", legend_label[key]): legend_label[key] = "</tt>%s<tt>" % (legend_label[key].encode("utf-8")) else: if key == "read": legend_label[key] = "%s " % (legend_label[key].encode("utf-8")) else: legend_label[key] = "%s" % (legend_label[key].encode("utf-8")) title = "<tt>%s/disk_%s</tt>" % (dev,type) created_label = _('Graph created') if re.search(u"[^a-zA-Z0-9 ]", created_label): created_label = "</tt>%s<tt>" % (created_label.encode("utf-8")) else: created_label = "%s" % (created_label.encode("utf-8")) created_time = "%s" % (datetime.datetime.today().strftime(DEFAULT_LANGS[lang]['DATE_FORMAT'][1])) created_time = re.sub(r':', '\:', created_time) legend_footer = "<tt>%s \: %s</tt>" % (created_label, created_time) data = rrdtool.graph(graph_filepath, "--imgformat", "PNG", "--font", "TITLE:0:IPAexGothic", "--font", "LEGEND:0:IPAexGothic", "--pango-markup", "--width", "550", "--height", "350", "--full-size-mode", "--color", "BACK#FFFFFF", "--color", "CANVAS#FFFFFF", "--color", "SHADEA#FFFFFF", "--color", "SHADEB#FFFFFF", "--color", "GRID#DDDDDD", "--color", "MGRID#CCCCCC", "--color", "FONT#555555", "--color", "FRAME#FFFFFF", "--color", "ARROW#FFFFFF", "--title", title, "--vertical-label", graph_label[type], "--lower-limit", "0", "--rigid", "--start", start, "--end", end, #"--legend-direction", "bottomup", "DEF:read=%s:read:AVERAGE" % (rrd_filepath[0]), "DEF:write=%s:write:AVERAGE" % (rrd_filepath[0]), "COMMENT:%s\\r" % legend_footer, "COMMENT:<tt>---------------------------------------------------------------------------</tt>\\n", "AREA:read#E7EF00:<tt>%s </tt>" % legend_label["read"], "GPRINT:read:MIN:<tt>%8.2lf%s</tt>", "GPRINT:read:MAX:<tt>%8.2lf%s</tt>", "GPRINT:read:AVERAGE:<tt>%8.2lf%s</tt>", "GPRINT:read:LAST:<tt>%8.2lf%s</tt>\\n", "STACK:write#80AA00:<tt>%s </tt>" % legend_label["write"], "GPRINT:write:MIN:<tt>%8.2lf%s</tt>", "GPRINT:write:MAX:<tt>%8.2lf%s</tt>", "GPRINT:write:AVERAGE:<tt>%8.2lf%s</tt>", "GPRINT:write:LAST:<tt>%8.2lf%s</tt>\\n", "COMMENT:%s\\n" % (legend_header), "COMMENT: \\n", "LINE1:read#E7EF00", "STACK:write#80AA00", ) return graph_filepath