Changeset - 31612b323436
[Not reviewed]
default
0 3 0
Drew Perttula - 9 years ago 2016-06-13 11:12:07
drewp@bigasterisk.com
pass packet creation time so collector can see how much lag there is
Ignore-this: aa3fae53817ad8f617822a558f2ae19e
3 files changed with 7 insertions and 3 deletions:
0 comments (0 inline, 0 general)
bin/collector
Show inline comments
 
@@ -35,7 +35,8 @@ class WebServer(object):
 
                settings.append((URIRef(device), URIRef(attr), Literal(value)))
 
            self.collector.setAttrs(body['client'],
 
                                    body['clientSession'],
 
                                    settings)
 
                                    settings,
 
                                    body['sendTime'])
 
            request.setResponseCode(202)
 

	
 
    @app.route('/stats', methods=['GET'])
light9/collector/collector.py
Show inline comments
 
@@ -72,7 +72,7 @@ class Collector(object):
 
                out[(d, da)] = v
 
        return out
 

	
 
    def setAttrs(self, client, clientSession, settings):
 
    def setAttrs(self, client, clientSession, settings, sendTime):
 
        """
 
        settings is a list of (device, attr, value). These attrs are
 
        device attrs. We resolve conflicting values, process them into
 
@@ -82,6 +82,7 @@ class Collector(object):
 
        Call with settings=[] to ping us that your session isn't dead.
 
        """
 
        now = time.time()
 
        print now - sendTime
 

	
 
        self._forgetStaleClients(now)
 

	
light9/web/light9-collector-client.html
Show inline comments
 
@@ -36,7 +36,9 @@
 
           this.$.put.body = JSON.stringify({
 
               "settings": settings,
 
               "client": window.location.href,
 
               "clientSession": this.clientSession});
 
               "clientSession": this.clientSession,
 
               "sendTime": Date.now() / 1000
 
           });
 
           this.$.put.generateRequest();
 
           this.lastSent = settings.slice();
 
       }
0 comments (0 inline, 0 general)