return True
def create(self):
- chart = "CHART example.python_random '' 'A random number' 'random number' random random line " + \
- str(self.priority) + " " + \
- str(self.update_every) + "\n" + \
- "DIMENSION random1 '' absolute 1 1"
- print(chart)
+ self.chart("example.python_random", '', 'A random number', 'random number',
+ 'random', 'random', 'line', self.priority, self.update_every)
+ self.dimension('random1', '', 'absolute', 1, 1)
+ self.commit()
return True
def update(self, interval):
- chart = "BEGIN example.python_random "+str(interval)+"\n"
- chart += "SET random1 = "+str(random.randint(0,100))+"\n"
- print(chart + "END")
+ self.begin("example.python_random", interval)
+ self.set("random1", random.randint(0, 100))
+ self.end()
+ self.commit()
return True
else:
time.sleep(self.timetable['freq'])
- def _line(self, *params):
+ def _line(self, instruction, *params):
"""
Converts *params to string and joins them with one space between every one.
:param params: str/int/float
"""
+ self.data_stream += instruction + " "
for p in params:
+ p = str(p)
if len(p) == 0:
- p = "''"
- self.data_stream += str(p)
- self.data_stream += " "
+ p = ""
+ self.data_stream += "'" + p
+ self.data_stream += "' "
self.data_stream += "\n"
- def chart(self, type_id, name="''", title="''", units="''", family="''",
- category="''", charttype="line", priority="''", update_every="''"):
+ def chart(self, type_id, name="", title="", units="", family="",
+ category="", charttype="line", priority="", update_every=""):
"""
Defines a new chart.
:param type_id: str
int(microseconds)
except TypeError:
self.error("malformed begin statement: microseconds are not a number:", microseconds)
- microseconds = "''"
+ microseconds = ""
self._line("BEGIN", type_id, microseconds)
return True
def end(self):
self._line("END")
- def send(self):
+ def commit(self):
"""
Upload new data to netdata
"""