select chips + license
paulfantom committed
Jul 8, 2016 at 10:30 UTC
72ffc4fe21135b9678249672451b12ab83131661
3 files changed
+43
-5
LICENSE.md
+4
@@ -138,4 +138,8 @@ connectivity is not available.
138
Copyright 2015, Joseph Huckaby
139
[MIT License](https://github.com/jhuckaby/pixl-xml)
140
141
+- [PySensors](https://bitbucket.org/blackjack/pysensors)
142
+
143
+ Copyright 2014, Marc 'BlackJack' Rintsch
144
+ [LGPL 2.1 License](https://bitbucket.org/blackjack/pysensors)
145
conf.d/python.d/sensors.conf
new
+14
@@ -0,0 +1,14 @@
1
+# Example configuration of sensors.chart.py
2
+# YAML format
3
+
4
+#update_every: 2
5
+#types:
6
+# - temperature
7
+# - fan
8
+# - voltage
9
+# - current
10
+# - power
11
+# - energy
12
+# - humidity
13
+#chips:
14
+# - i8k
python.d/sensors.chart.py
+25
-5
@@ -55,6 +55,7 @@ class Service(SimpleService):
55
SimpleService.__init__(self, configuration=configuration, name=name)
56
self.order = []
57
self.definitions = {}
58
+ self.chips = []
59
60
def _get_data(self):
61
data = {}
@@ -78,14 +79,17 @@ class Service(SimpleService):
79
prefix = '_'.join(str(chip.path.decode()).split('/')[3:])
80
name = ""
81
lines = []
82
+ pref = str(chip.prefix.decode())
83
+ if len(self.chips) != 0 and not any([ex.startswith(pref) for ex in self.chips]):
84
+ continue
85
for feature in chip:
82
- if feature.get_value() != 0:
86
+ if feature.get_value() == 0:
87
continue
88
if sensors.TYPE_DICT[feature.type] == type:
85
- name = str(chip.prefix.decode()) + "_" + sensors.TYPE_DICT[feature.type]
89
+ name = pref + "_" + sensors.TYPE_DICT[feature.type]
90
if name not in self.order:
91
options = list(CHARTS[type]['options'])
88
- options[1] = str(chip.prefix) + options[1]
92
+ options[1] = pref + options[1]
93
self.definitions[name] = {'options': options}
94
self.definitions[name]['lines'] = []
95
self.order.append(name)
@@ -95,6 +99,16 @@ class Service(SimpleService):
99
self.definitions[name]['lines'].append(line)
100
101
def check(self):
102
+ try:
103
+ self.chips = list(self.configuration['chips'])
104
+ except (KeyError, TypeError):
105
+ self.error("No path to log specified. Using all chips.")
106
+ try:
107
+ global ORDER
108
+ ORDER = list(self.configuration['types'])
109
+ except (KeyError, TypeError):
110
+ self.error("No path to log specified. Using all sensor types.")
111
+ print(ORDER)
112
try:
113
sensors.init()
114
except Exception as e:
@@ -102,6 +116,12 @@ class Service(SimpleService):
116
return False
117
try:
118
self._create_definitions()
105
- except:
119
+ except Exception as e:
120
+ print(e)
121
return False
107
- return True
\ No newline at end of file
122
+
123
+ if len(self.definitions) == 0:
124
+ self.error("No sensors found")
125
+ return False
126
+
127
+ return True