@cryptotaxi247 / netdata-1 / commits / 93bac8c2d

wrapping

paulfantom committed Jun 23, 2016 at 13:16 UTC 93bac8c2d3a4faf40c95b22e715e9e5f023e5da8
1 file changed +33
python.d/python_modules/base.py
+33
@@ -27,6 +27,7 @@ class BaseService(threading.Thread):
27 :param name: str
28 """
29 threading.Thread.__init__(self)
30 + self.data_stream = ""
31 self.daemon = True
32 self.retries = 0
33 self.retries_left = 0
@@ -136,6 +137,38 @@ class BaseService(threading.Thread):
137 else:
138 time.sleep(self.timetable['freq'])
139
140 + def _line(self, *params):
141 + for p in params:
142 + if len(p) == 0:
143 + p = "''"
144 + self.data_stream += str(p)
145 + self.data_stream += " "
146 + self.data_stream += "\n"
147 +
148 + def chart(self, *params):
149 + self._line("CHART", *params)
150 + pass
151 +
152 + def dimension(self, *params):
153 + self._line("DIMENSION", *params)
154 + pass
155 +
156 + def begin(self, *params):
157 + self._line("BEGIN", *params)
158 + pass
159 +
160 + def set(self, name, value):
161 + self._line("SET", name, "=", value)
162 + pass
163 +
164 + def end(self):
165 + self._line("END")
166 + pass
167 +
168 + def send(self):
169 + print(self.data_stream)
170 + self.data_stream = ""
171 +
172 def check(self):
173 """
174 check() prototype