def get(self): xss.get_info() # fail if we can't get the display or something self.write( """ Get the <a href="idle">X idle time</a> on %s. <a href="graph">rdf graph</a> available.""" % host )
def get(self): self.set_header("Content-type", "application/x-trig") g = StateGraph(ctx=DEV["xidle/%s" % host]) ms = xss.get_info().idle subj = URIRef("http://bigasterisk.com/host/%s/xidle" % host) g.add((subj, ROOM["idleTimeMs"], Literal(ms))) g.add((subj, ROOM["idleTimeMinutes"], Literal(ms / 1000 / 60))) self.write(g.asTrig())
def poll(self): ms = xss.get_info().idle lastMinActive = ms < 60 * 1000 now = int(time.time()) if self.lastSent != lastMinActive or now > self.lastSentTime + 3600: self.points.append( { "measurement": "presence", "tags": {"host": host, "sensor": "xidle"}, "fields": {"value": 1 if lastMinActive else 0}, "time": now, } ) self.lastSent = lastMinActive self.lastSentTime = now client.write_points(self.points, time_precision="s") self.points = []
def get(self): self.set_header("Content-type", "application/json") self.write(json.dumps({"idleMs": xss.get_info().idle}))