]> git.ipfire.org Git - collecty.git/commitdiff
Merge branch 'master' of ssh://git.ipfire.org/pub/git/collecty
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Dec 2015 20:46:14 +0000 (21:46 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Dec 2015 20:46:14 +0000 (21:46 +0100)
Conflicts:
src/collecty/plugins/base.py
src/collecty/plugins/cpufreq.py
src/collecty/plugins/sensors.py

src/collecty/plugins/base.py
src/collecty/plugins/cpufreq.py
src/collecty/plugins/sensors.py

index 68e7a45321adbccafab8b3aa47d072d6c6e1b898..5b130444324f5c530efdad3b97e3155888d35c4e 100644 (file)
@@ -643,7 +643,10 @@ class GraphTemplate(object):
        def get_objects(self, *args, **kwargs):
                object = self.plugin.get_object(*args, **kwargs)
 
-               return [object,]
+               if object:
+                       return [object,]
+
+               return []
 
        def generate_graph(self, interval=None, **kwargs):
                assert self.objects, "Cannot render graph without any objects"
@@ -657,10 +660,13 @@ class GraphTemplate(object):
 
                self.log.info(_("Generating graph %s") % self)
 
+               rrd_graph = self.rrd_graph
+
                # Add DEFs for all objects
-               args += self._add_defs()
+               if not any((e.startswith("DEF:") for e in rrd_graph)):
+                       args += self._add_defs()
 
-               args += self.rrd_graph
+               args += rrd_graph
                args = self._add_vdefs(args)
 
                # Convert arguments to string
index 8bbd1fb45cc5f0220dc2678faab4b86ec1aa31a2..e6b86474555f41701cc459e6e08c845e2612c69f 100644 (file)
@@ -57,8 +57,8 @@ class GraphTemplateCPUFreq(base.GraphTemplate):
 
                for processor, colour in zip(self.objects, self.processor_colours):
                        rrd_graph += processor.make_rrd_defs(processor.id) + [
-                               "LINE2:%s%s:%-10s" % (processor.id, colour, processor.name),
-                               "GPRINT:%s:%%6.2lf %%sHz" % processor.id,
+                               "LINE2:%s_current%s:%-10s" % (processor.id, colour, processor.name),
+                               "GPRINT:%s_current_avg:%%6.2lf %%sHz\l" % processor.id,
                        ]
 
                return rrd_graph
index cb9cb01d01d2f19abba3b45fc3c85a1e8457d2a8..56acca40592de69a2441c942e45a969147a2817f 100644 (file)
@@ -36,44 +36,39 @@ class GraphTemplateSensorsTemperature(base.GraphTemplate):
                _ = 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,-",
+                       # Convert everything to Celsius
+                       "CDEF:value_c=value,273.15,-",
+                       "CDEF:critical_c=critical,273.15,-",
+                       "CDEF:high_c=high,273.15,-",
+                       "CDEF:low_c=low,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",
+                       "CDEF:value_c_high=value_c,high_c,GT,value_c,UNKN,IF",
+                       "CDEF:value_c_normal=value_c,high_c,GT,UNKN,value_c,IF",
 
                        # Get data points for the threshold lines
-                       "VDEF:critical_line=critical,MINIMUM",
-                       "VDEF:low_line=low,MAXIMUM",
+                       "VDEF:critical_c_line=critical_c,MINIMUM",
+                       "VDEF:low_c_line=low_c,MAXIMUM",
 
                        # Draw the temperature value
-                       "LINE3:value_high#ff0000",
-                       "LINE2:value_normal#00ff00:%-15s" % _("Temperature"),
+                       "LINE3:value_c_high#ff0000",
+                       "LINE2:value_c_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"),
+                       "GPRINT:value_c_cur:%10.2lf °C\l",
+                       "GPRINT:value_c_avg:  %-15s %%6.2lf °C\l" % _("Average"),
+                       "GPRINT:value_c_max:  %-15s %%6.2lf °C\l" % _("Maximum"),
+                       "GPRINT:value_c_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",
+                       "HRULE:critical_c_line#000000:%-15s" % _("Critical"),
+                       "GPRINT:critical_c_line:%6.2lf °C\\r",
+                       "HRULE:low_c_line#0000ff:%-15s" % _("Low"),
+                       "GPRINT:low_c_line:%6.2lf °C\\r",
                ]
 
        @property
@@ -98,7 +93,14 @@ class GraphTemplateSensorsProcessorTemperature(base.GraphTemplate):
        ]
 
        def get_temperature_sensors(self):
-               return self.plugin.get_detected_sensor_objects("coretemp-*")
+               # Use the coretemp module if available
+               sensors = self.plugin.get_detected_sensor_objects("coretemp-*")
+
+               # Fall back to the ACPI sensor
+               if not sensors:
+                       sensors = self.plugin.get_detected_sensor_objects("acpitz-virtual-*")
+
+               return sensors
 
        def get_objects(self, *args, **kwargs):
                sensors = self.get_temperature_sensors()
@@ -125,21 +127,26 @@ class GraphTemplateSensorsProcessorTemperature(base.GraphTemplate):
                                "CDEF:%s_high_c=%s_high,273.15,-" % (id, id),
                        ]
 
+               # Compute the temperature of the processor
+               # by taking the average of all cores
                all_core_values = ("%s_value_c" % id for id in ids)
-               all_core_highs  = ("%s_high_c"  % id for id in ids)
-
                rrd_graph += [
-                       # Compute the temperature of the processor
-                       # by taking the average of all cores
                        "CDEF:all_value_c=%s,%s,AVG" % (",".join(all_core_values), len(ids)),
-                       "CDEF:all_high_c=%s,MIN" % ",".join(all_core_highs),
+               ]
 
+               # Get the high threshold of the first core
+               # (assuming that all cores have the same threshold)
+               for id in ids:
+                       rrd_graph.append("CDEF:all_high_c=%s_high_c" % id)
+                       break
+
+               rrd_graph += [
                        # Change colour when the value gets above high
                        "CDEF:all_value_c_high=all_value_c,all_high_c,GT,all_value_c,UNKN,IF",
                        "CDEF:all_value_c_normal=all_value_c,all_high_c,GT,UNKN,all_value_c,IF",
 
-                       "LINE3:all_value_c_high#FF0000",
-                       "LINE3:all_value_c_normal#000000:%-15s\l" % _("Temperature"),
+                       "LINE2:all_value_c_high#FF0000",
+                       "LINE2:all_value_c_normal#000000:%-15s\l" % _("Temperature"),
 
                        "GPRINT:all_value_c_avg:    %-15s %%6.2lf °C\l" % _("Average"),
                        "GPRINT:all_value_c_max:    %-15s %%6.2lf °C\l" % _("Maximum"),
@@ -150,14 +157,14 @@ class GraphTemplateSensorsProcessorTemperature(base.GraphTemplate):
                        rrd_graph += [
                                # TODO these lines were supposed to be dashed, but that
                                # didn't really work here
-                               "LINE2:%s_value_c%s:%-10s" % (id, colour, core.sensor.label),
+                               "LINE1:%s_value_c%s:%-10s" % (id, colour, core.sensor.label),
                        ]
 
                # Draw the critical line
                for id in ids:
                        rrd_graph += [
                                "HRULE:%s_critical_c_min#000000:%-15s" % (id, _("Critical")),
-                               "GPRINT:%s_critical_c_min:%%6.2lf °C\\r",
+                               "GPRINT:%s_critical_c_min:%%6.2lf °C\\r" % id,
                        ]
                        break