disk: Localise plugin
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 26 Oct 2015 17:15:00 +0000 (18:15 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 26 Oct 2015 17:15:00 +0000 (18:15 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/collecty/plugins/disk.py

index f274085..508e7e4 100644 (file)
@@ -30,131 +30,161 @@ from ..i18n import _
 class GraphTemplateDiskBadSectors(base.GraphTemplate):
        name = "disk-bad-sectors"
 
-       rrd_graph = [
-               "DEF:bad_sectors=%(file)s:bad_sectors:AVERAGE",
+       @property
+       def rrd_graph(self):
+               _ = self.locale.translate
 
-               "AREA:bad_sectors#ff0000:%s" % _("Bad Sectors"),
+               return [
+                       "DEF:bad_sectors=%(file)s:bad_sectors:AVERAGE",
 
-               "VDEF:bad_sectors_cur=bad_sectors,LAST",
-               "VDEF:bad_sectors_max=bad_sectors,MAXIMUM",
-               "GPRINT:bad_sectors_cur:%12s\:" % _("Current") + " %9.2lf",
-               "GPRINT:bad_sectors_max:%12s\:" % _("Maximum") + " %9.2lf\\n",
-       ]
+                       "AREA:bad_sectors#ff0000:%s" % _("Bad Sectors"),
+
+                       "VDEF:bad_sectors_cur=bad_sectors,LAST",
+                       "VDEF:bad_sectors_max=bad_sectors,MAXIMUM",
+                       "GPRINT:bad_sectors_cur:%12s\:" % _("Current") + " %9.2lf",
+                       "GPRINT:bad_sectors_max:%12s\:" % _("Maximum") + " %9.2lf\\n",
+               ]
 
        @property
        def graph_title(self):
+               _ = self.locale.translate
                return _("Bad Sectors of %s") % self.object.device_string
 
        @property
        def graph_vertical_label(self):
+               _ = self.locale.translate
                return _("Pending/Relocated Sectors")
 
 
 class GraphTemplateDiskBytes(base.GraphTemplate):
        name = "disk-bytes"
 
-       rrd_graph = [
-               "DEF:read_sectors=%(file)s:read_sectors:AVERAGE",
-               "DEF:write_sectors=%(file)s:write_sectors:AVERAGE",
-
-               "CDEF:read_bytes=read_sectors,512,*",
-               "CDEF:write_bytes=write_sectors,512,*",
-
-               "LINE1:read_bytes#ff0000:%-15s" % _("Read"),
-               "VDEF:read_cur=read_bytes,LAST",
-               "VDEF:read_min=read_bytes,MINIMUM",
-               "VDEF:read_max=read_bytes,MAXIMUM",
-               "VDEF:read_avg=read_bytes,AVERAGE",
-               "GPRINT:read_cur:%12s\:" % _("Current") + " %9.2lf",
-               "GPRINT:read_max:%12s\:" % _("Maximum") + " %9.2lf",
-               "GPRINT:read_min:%12s\:" % _("Minimum") + " %9.2lf",
-               "GPRINT:read_avg:%12s\:" % _("Average") + " %9.2lf\\n",
-
-               "LINE1:write_bytes#00ff00:%-15s" % _("Written"),
-               "VDEF:write_cur=write_bytes,LAST",
-               "VDEF:write_min=write_bytes,MINIMUM",
-               "VDEF:write_max=write_bytes,MAXIMUM",
-               "VDEF:write_avg=write_bytes,AVERAGE",
-               "GPRINT:write_cur:%12s\:" % _("Current") + " %9.2lf",
-               "GPRINT:write_max:%12s\:" % _("Maximum") + " %9.2lf",
-               "GPRINT:write_min:%12s\:" % _("Minimum") + " %9.2lf",
-               "GPRINT:write_avg:%12s\:" % _("Average") + " %9.2lf\\n",
-       ]
+       @property
+       def rrd_graph(self):
+               _ = self.locale.translate
+
+               rrd_graph = [
+                       "DEF:read_sectors=%(file)s:read_sectors:AVERAGE",
+                       "DEF:write_sectors=%(file)s:write_sectors:AVERAGE",
+
+                       "CDEF:read_bytes=read_sectors,512,*",
+                       "CDEF:write_bytes=write_sectors,512,*",
+
+                       "LINE1:read_bytes#ff0000:%-15s" % _("Read"),
+                       "VDEF:read_cur=read_bytes,LAST",
+                       "VDEF:read_min=read_bytes,MINIMUM",
+                       "VDEF:read_max=read_bytes,MAXIMUM",
+                       "VDEF:read_avg=read_bytes,AVERAGE",
+                       "GPRINT:read_cur:%12s\:" % _("Current") + " %9.2lf",
+                       "GPRINT:read_max:%12s\:" % _("Maximum") + " %9.2lf",
+                       "GPRINT:read_min:%12s\:" % _("Minimum") + " %9.2lf",
+                       "GPRINT:read_avg:%12s\:" % _("Average") + " %9.2lf\\n",
+
+                       "LINE1:write_bytes#00ff00:%-15s" % _("Written"),
+                       "VDEF:write_cur=write_bytes,LAST",
+                       "VDEF:write_min=write_bytes,MINIMUM",
+                       "VDEF:write_max=write_bytes,MAXIMUM",
+                       "VDEF:write_avg=write_bytes,AVERAGE",
+                       "GPRINT:write_cur:%12s\:" % _("Current") + " %9.2lf",
+                       "GPRINT:write_max:%12s\:" % _("Maximum") + " %9.2lf",
+                       "GPRINT:write_min:%12s\:" % _("Minimum") + " %9.2lf",
+                       "GPRINT:write_avg:%12s\:" % _("Average") + " %9.2lf\\n",
+               ]
+
+               return rrd_graph
 
        lower_limit = 0
 
        @property
        def graph_title(self):
+               _ = self.locale.translate
                return _("Disk Utilisation of %s") % self.object.device_string
 
        @property
        def graph_vertical_label(self):
+               _ = self.locale.translate
                return _("Byte per Second")
 
 
 class GraphTemplateDiskIoOps(base.GraphTemplate):
        name = "disk-io-ops"
 
-       rrd_graph = [
-               "DEF:read_ios=%(file)s:read_ios:AVERAGE",
-               "DEF:write_ios=%(file)s:write_ios:AVERAGE",
-
-               "LINE1:read_ios#ff0000:%-15s" % _("Read"),
-               "VDEF:read_cur=read_ios,LAST",
-               "VDEF:read_min=read_ios,MINIMUM",
-               "VDEF:read_max=read_ios,MAXIMUM",
-               "VDEF:read_avg=read_ios,AVERAGE",
-               "GPRINT:read_cur:%12s\:" % _("Current") + " %6.2lf",
-               "GPRINT:read_max:%12s\:" % _("Maximum") + " %6.2lf",
-               "GPRINT:read_min:%12s\:" % _("Minimum") + " %6.2lf",
-               "GPRINT:read_avg:%12s\:" % _("Average") + " %6.2lf\\n",
-
-               "LINE1:write_ios#00ff00:%-15s" % _("Written"),
-               "VDEF:write_cur=write_ios,LAST",
-               "VDEF:write_min=write_ios,MINIMUM",
-               "VDEF:write_max=write_ios,MAXIMUM",
-               "VDEF:write_avg=write_ios,AVERAGE",
-               "GPRINT:write_cur:%12s\:" % _("Current") + " %6.2lf",
-               "GPRINT:write_max:%12s\:" % _("Maximum") + " %6.2lf",
-               "GPRINT:write_min:%12s\:" % _("Minimum") + " %6.2lf",
-               "GPRINT:write_avg:%12s\:" % _("Average") + " %6.2lf\\n",
-       ]
+       @property
+       def rrd_graph(self):
+               _ = self.locale.translate
+
+               rrd_graph = [
+                       "DEF:read_ios=%(file)s:read_ios:AVERAGE",
+                       "DEF:write_ios=%(file)s:write_ios:AVERAGE",
+
+                       "LINE1:read_ios#ff0000:%-15s" % _("Read"),
+                       "VDEF:read_cur=read_ios,LAST",
+                       "VDEF:read_min=read_ios,MINIMUM",
+                       "VDEF:read_max=read_ios,MAXIMUM",
+                       "VDEF:read_avg=read_ios,AVERAGE",
+                       "GPRINT:read_cur:%12s\:" % _("Current") + " %6.2lf",
+                       "GPRINT:read_max:%12s\:" % _("Maximum") + " %6.2lf",
+                       "GPRINT:read_min:%12s\:" % _("Minimum") + " %6.2lf",
+                       "GPRINT:read_avg:%12s\:" % _("Average") + " %6.2lf\\n",
+
+                       "LINE1:write_ios#00ff00:%-15s" % _("Written"),
+                       "VDEF:write_cur=write_ios,LAST",
+                       "VDEF:write_min=write_ios,MINIMUM",
+                       "VDEF:write_max=write_ios,MAXIMUM",
+                       "VDEF:write_avg=write_ios,AVERAGE",
+                       "GPRINT:write_cur:%12s\:" % _("Current") + " %6.2lf",
+                       "GPRINT:write_max:%12s\:" % _("Maximum") + " %6.2lf",
+                       "GPRINT:write_min:%12s\:" % _("Minimum") + " %6.2lf",
+                       "GPRINT:write_avg:%12s\:" % _("Average") + " %6.2lf\\n",
+               ]
+
+               return rrd_graph
 
        lower_limit = 0
 
        @property
        def graph_title(self):
+               _ = self.locale.translate
                return _("Disk IO Operations of %s") % self.object.device_string
 
        @property
        def graph_vertical_label(self):
+               _ = self.locale.translate
                return _("Operations per Second")
 
 
 class GraphTemplateDiskTemperature(base.GraphTemplate):
        name = "disk-temperature"
 
-       rrd_graph = [
-               "DEF:kelvin=%(file)s:temperature:AVERAGE",
-               "CDEF:celsius=kelvin,273.15,-",
-
-               "LINE2:celsius#ff0000:%s" % _("Temperature"),
-               "VDEF:temp_cur=celsius,LAST",
-               "VDEF:temp_min=celsius,MINIMUM",
-               "VDEF:temp_max=celsius,MAXIMUM",
-               "VDEF:temp_avg=celsius,AVERAGE",
-               "GPRINT:temp_cur:%12s\:" % _("Current") + " %3.2lf",
-               "GPRINT:temp_max:%12s\:" % _("Maximum") + " %3.2lf",
-               "GPRINT:temp_min:%12s\:" % _("Minimum") + " %3.2lf",
-               "GPRINT:temp_avg:%12s\:" % _("Average") + " %3.2lf\\n",
-       ]
+       @property
+       def rrd_graph(self):
+               _ = self.locale.translate
+
+               rrd_graph = [
+                       "DEF:kelvin=%(file)s:temperature:AVERAGE",
+                       "CDEF:celsius=kelvin,273.15,-",
+
+                       "LINE2:celsius#ff0000:%s" % _("Temperature"),
+                       "VDEF:temp_cur=celsius,LAST",
+                       "VDEF:temp_min=celsius,MINIMUM",
+                       "VDEF:temp_max=celsius,MAXIMUM",
+                       "VDEF:temp_avg=celsius,AVERAGE",
+                       "GPRINT:temp_cur:%12s\:" % _("Current") + " %3.2lf",
+                       "GPRINT:temp_max:%12s\:" % _("Maximum") + " %3.2lf",
+                       "GPRINT:temp_min:%12s\:" % _("Minimum") + " %3.2lf",
+                       "GPRINT:temp_avg:%12s\:" % _("Average") + " %3.2lf\\n",
+               ]
+
+               return rrd_graph
 
        @property
        def graph_title(self):
+               _ = self.locale.translate
                return _("Disk Temperature of %s") % self.object.device_string
 
        @property
        def graph_vertical_label(self):
+               _ = self.locale.translate
                return _("° Celsius")
 
        @property