diff --git a/src/wormhole/db-schemas/v1.sql b/src/wormhole/db-schemas/v1.sql index 82bdfe9..7dba360 100644 --- a/src/wormhole/db-schemas/v1.sql +++ b/src/wormhole/db-schemas/v1.sql @@ -21,14 +21,17 @@ CREATE INDEX `messages_idx` ON `messages` (`appid`, `channelid`); CREATE TABLE `usage` ( + `type` VARCHAR, -- "rendezvous" `started` INTEGER, -- seconds since epoch, rounded to one day `result` VARCHAR, -- happy, scary, lonely, errory, pruney - -- "happy": both sides close with mood=happy - -- "scary": any side closes with mood=scary (bad MAC, probably wrong pw) - -- "lonely": any side closes with mood=lonely (no response from 2nd side) - -- "errory": any side closes with mood=errory (other errors) - -- "pruney": channels which get pruned for inactivity - -- "crowded": three or more sides were involved + -- rendezvous moods: + -- "happy": both sides close with mood=happy + -- "scary": any side closes with mood=scary (bad MAC, probably wrong pw) + -- "lonely": any side closes with mood=lonely (no response from 2nd side) + -- "errory": any side closes with mood=errory (other errors) + -- "pruney": channels which get pruned for inactivity + -- "crowded": three or more sides were involved + `total_bytes` INTEGER, -- not yet used `total_time` INTEGER, -- seconds from start to closed, or None `waiting_time` INTEGER -- seconds from start to 2nd side appearing, or None ); diff --git a/src/wormhole/servers/cmd_usage.py b/src/wormhole/servers/cmd_usage.py index 78eec21..202a75e 100644 --- a/src/wormhole/servers/cmd_usage.py +++ b/src/wormhole/servers/cmd_usage.py @@ -32,8 +32,9 @@ def show_usage(args): newest = None counters = defaultdict(int) db = get_db("relay.sqlite") - c = db.execute("SELECT * FROM `usage` ORDER BY `started` ASC LIMIT ?", - (args.n,)) + c = db.execute("SELECT * FROM `usage` WHERE `type`=?" + " ORDER BY `started` ASC LIMIT ?", + (u"rendezvous", args.n)) for row in c.fetchall(): counters["total"] += 1 counters[row["result"]] += 1 @@ -65,8 +66,9 @@ def tail_usage(args): seen = set() while True: old = time.time() - 2*60*60 - c = db.execute("SELECT * FROM `usage` WHERE `started` > ?" - " ORDER BY `started` ASC", (old,)) + c = db.execute("SELECT * FROM `usage`" + " WHERE `type`=? AND `started` > ?" + " ORDER BY `started` ASC", (u"rendezvous", old)) for row in c.fetchall(): event = (row["started"], row["result"], row["waiting_time"], row["total_time"]) diff --git a/src/wormhole/servers/relay_server.py b/src/wormhole/servers/relay_server.py index 0dda261..c520466 100644 --- a/src/wormhole/servers/relay_server.py +++ b/src/wormhole/servers/relay_server.py @@ -298,9 +298,11 @@ class Channel: def _store_summary(self, summary): (started, result, total_time, waiting_time) = summary self._db.execute("INSERT INTO `usage`" - " (`started`, `result`, `total_time`, `waiting_time`)" - " VALUES (?,?,?,?)", - (started, result, total_time, waiting_time)) + " (`type`, `started`, `result`," + " `total_time`, `waiting_time`)" + " VALUES (?,?,?, ?,?)", + (u"rendezvous", started, result, + total_time, waiting_time)) self._db.commit() def _summarize(self, messages, delete_time):