]> arthur.barton.de Git - netdata.git/commitdiff
select chips + license
authorpaulfantom <paulfantom@gmail.com>
Fri, 8 Jul 2016 08:30:48 +0000 (10:30 +0200)
committerpaulfantom <paulfantom@gmail.com>
Fri, 8 Jul 2016 08:30:48 +0000 (10:30 +0200)
LICENSE.md
conf.d/python.d/sensors.conf [new file with mode: 0644]
python.d/sensors.chart.py

index 380e86eeee5d39c907f28a3f836c911c6d4b51f8..2f4dfe68a0851bdcfd00310e85d79bcbbacb70da 100644 (file)
@@ -138,4 +138,8 @@ connectivity is not available.
     Copyright 2015, Joseph Huckaby
     [MIT License](https://github.com/jhuckaby/pixl-xml)
     
+- [PySensors](https://bitbucket.org/blackjack/pysensors)
+
+    Copyright 2014, Marc 'BlackJack' Rintsch
+    [LGPL 2.1 License](https://bitbucket.org/blackjack/pysensors)
     
diff --git a/conf.d/python.d/sensors.conf b/conf.d/python.d/sensors.conf
new file mode 100644 (file)
index 0000000..8d49651
--- /dev/null
@@ -0,0 +1,14 @@
+# Example configuration of sensors.chart.py
+# YAML format
+
+#update_every: 2
+#types:
+#  - temperature
+#  - fan
+#  - voltage
+#  - current
+#  - power
+#  - energy
+#  - humidity
+#chips:
+#  - i8k
index 38c45657155f226d3c7a15930cf903cb08896bb5..b805b1bf0d659c6a2a978b8ace7a70cc45f962ac 100644 (file)
@@ -55,6 +55,7 @@ class Service(SimpleService):
         SimpleService.__init__(self, configuration=configuration, name=name)
         self.order = []
         self.definitions = {}
+        self.chips = []
 
     def _get_data(self):
         data = {}
@@ -78,14 +79,17 @@ class Service(SimpleService):
                 prefix = '_'.join(str(chip.path.decode()).split('/')[3:])
                 name = ""
                 lines = []
+                pref = str(chip.prefix.decode())
+                if len(self.chips) != 0 and not any([ex.startswith(pref) for ex in self.chips]):
+                    continue
                 for feature in chip:
-                    if feature.get_value() != 0:
+                    if feature.get_value() == 0:
                         continue
                     if sensors.TYPE_DICT[feature.type] == type:
-                        name = str(chip.prefix.decode()) + "_" + sensors.TYPE_DICT[feature.type]
+                        name = pref + "_" + sensors.TYPE_DICT[feature.type]
                         if name not in self.order:
                             options = list(CHARTS[type]['options'])
-                            options[1] = str(chip.prefix) + options[1]
+                            options[1] = pref + options[1]
                             self.definitions[name] = {'options': options}
                             self.definitions[name]['lines'] = []
                             self.order.append(name)
@@ -95,6 +99,16 @@ class Service(SimpleService):
                         self.definitions[name]['lines'].append(line)
 
     def check(self):
+        try:
+            self.chips = list(self.configuration['chips'])
+        except (KeyError, TypeError):
+            self.error("No path to log specified. Using all chips.")
+        try:
+            global ORDER
+            ORDER = list(self.configuration['types'])
+        except (KeyError, TypeError):
+            self.error("No path to log specified. Using all sensor types.")
+        print(ORDER)
         try:
             sensors.init()
         except Exception as e:
@@ -102,6 +116,12 @@ class Service(SimpleService):
             return False
         try:
             self._create_definitions()
-        except:
+        except Exception as e:
+            print(e)
             return False
-        return True
\ No newline at end of file
+
+        if len(self.definitions) == 0:
+            self.error("No sensors found")
+            return False
+
+        return True