]> git.ipfire.org Git - oddments/collecty.git/commitdiff
sensors: Localise plugin
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 26 Oct 2015 17:16:12 +0000 (18:16 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 26 Oct 2015 17:16:12 +0000 (18:16 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/collecty/plugins/sensors.py

index f3b3c256cf9524014ac9092518fcce00c1f27277..7e5e438f961702d31cde89423014d8ad1992c74f 100644 (file)
@@ -31,58 +31,64 @@ from ..i18n import _
 class GraphTemplateSensorsTemperature(base.GraphTemplate):
        name = "sensors-temperature"
 
-       rrd_graph = [
-               "DEF:value_kelvin=%(file)s:value:AVERAGE",
-               "DEF:critical_kelvin=%(file)s:critical:AVERAGE",
-               "DEF:high_kelvin=%(file)s:high:AVERAGE",
-               "DEF:low_kelvin=%(file)s:low:AVERAGE",
-
-               # Convert everything to celsius
-               "CDEF:value=value_kelvin,273.15,-",
-               "CDEF:critical=critical_kelvin,273.15,-",
-               "CDEF:high=high_kelvin,273.15,-",
-               "CDEF:low=low_kelvin,273.15,-",
-
-               # Change colour when the value gets above high
-               "CDEF:value_high=value,high,GT,value,UNKN,IF",
-               "CDEF:value_normal=value,high,GT,UNKN,value,IF",
-
-               "VDEF:value_cur=value,LAST",
-               "VDEF:value_avg=value,AVERAGE",
-               "VDEF:value_max=value,MAXIMUM",
-               "VDEF:value_min=value,MINIMUM",
-
-               # Get data points for the threshold lines
-               "VDEF:critical_line=critical,MINIMUM",
-               "VDEF:low_line=low,MAXIMUM",
-
-               # Draw the temperature value
-               "LINE3:value_high#ff0000",
-               "LINE2:value_normal#00ff00:%-15s" % _("Temperature"),
-
-               # Draw the legend
-               "GPRINT:value_cur:%%10.2lf °C\l",
-               "GPRINT:value_avg:  %-15s %%6.2lf °C\l" % _("Average"),
-               "GPRINT:value_max:  %-15s %%6.2lf °C\l" % _("Maximum"),
-               "GPRINT:value_min:  %-15s %%6.2lf °C\l" % _("Minimum"),
-
-               # Empty line
-               "COMMENT: \\n",
-
-               # Draw boundary lines
-               "COMMENT:%s\:" % _("Temperature Thresholds"),
-               "HRULE:critical_line#000000:%-15s" % _("Critical"),
-               "GPRINT:critical_line:%%6.2lf °C\\r",
-               "HRULE:low_line#0000ff:%-15s" % _("Low"),
-               "GPRINT:low_line:%%6.2lf °C\\r",
-       ]
+       @property
+       def rrd_graph(self):
+               _ = self.locale.translate
+
+               return [
+                       "DEF:value_kelvin=%(file)s:value:AVERAGE",
+                       "DEF:critical_kelvin=%(file)s:critical:AVERAGE",
+                       "DEF:high_kelvin=%(file)s:high:AVERAGE",
+                       "DEF:low_kelvin=%(file)s:low:AVERAGE",
+
+                       # Convert everything to celsius
+                       "CDEF:value=value_kelvin,273.15,-",
+                       "CDEF:critical=critical_kelvin,273.15,-",
+                       "CDEF:high=high_kelvin,273.15,-",
+                       "CDEF:low=low_kelvin,273.15,-",
+
+                       # Change colour when the value gets above high
+                       "CDEF:value_high=value,high,GT,value,UNKN,IF",
+                       "CDEF:value_normal=value,high,GT,UNKN,value,IF",
+
+                       "VDEF:value_cur=value,LAST",
+                       "VDEF:value_avg=value,AVERAGE",
+                       "VDEF:value_max=value,MAXIMUM",
+                       "VDEF:value_min=value,MINIMUM",
+
+                       # Get data points for the threshold lines
+                       "VDEF:critical_line=critical,MINIMUM",
+                       "VDEF:low_line=low,MAXIMUM",
+
+                       # Draw the temperature value
+                       "LINE3:value_high#ff0000",
+                       "LINE2:value_normal#00ff00:%-15s" % _("Temperature"),
+
+                       # Draw the legend
+                       "GPRINT:value_cur:%%10.2lf °C\l",
+                       "GPRINT:value_avg:  %-15s %%6.2lf °C\l" % _("Average"),
+                       "GPRINT:value_max:  %-15s %%6.2lf °C\l" % _("Maximum"),
+                       "GPRINT:value_min:  %-15s %%6.2lf °C\l" % _("Minimum"),
+
+                       # Empty line
+                       "COMMENT: \\n",
+
+                       # Draw boundary lines
+                       "COMMENT:%s\:" % _("Temperature Thresholds"),
+                       "HRULE:critical_line#000000:%-15s" % _("Critical"),
+                       "GPRINT:critical_line:%%6.2lf °C\\r",
+                       "HRULE:low_line#0000ff:%-15s" % _("Low"),
+                       "GPRINT:low_line:%%6.2lf °C\\r",
+               ]
 
        @property
        def graph_title(self):
+               _ = self.locale.translate
                return _("Temperature (%s)") % self.object.sensor.name
 
        @property
        def graph_vertical_label(self):
+               _ = self.locale.translate
                return _("° Celsius")
 
 
@@ -111,6 +117,7 @@ class GraphTemplateSensorsProcessorTemperature(base.GraphTemplate):
 
        @property
        def rrd_graph(self):
+               _ = self.locale.translate
                rrd_graph = []
 
                cores = sorted(self.object_table.keys())
@@ -186,10 +193,12 @@ class GraphTemplateSensorsProcessorTemperature(base.GraphTemplate):
 
        @property
        def graph_title(self):
+               _ = self.locale.translate
                return _("Processor")
 
        @property
        def graph_vertical_label(self):
+               _ = self.locale.translate
                return _("Temperature")