This object does not require wiz privs to build. It does, however, require $pub.periodic.standard.
@create $pub.periodic.standard as usage meter @set usage meter.aliases = meter @newfunc reset(self) on usage meter for day in ['Mon','Tue','Wed','Thu','Fri','Sat','Sun']: setattr(self,day,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]) self.since = ctime(time()) .x @cmd usage meter.reset <this> calls reset() @newfunc check(self) on usage meter timeparts = string.split(ctime(time())) day = timeparts hour = string.atoi(string.split(timeparts,':')) usercount = len(users()) rec = getattr(self,day) if not rec: setattr(self,day, range(0,24)) rec = getattr(self,day) rec[hour] = rec[hour] + usercount # while we're at it, also reset the next hour's count timeparts = string.split(ctime(time() + 3600)) day = timeparts hour = string.atoi(string.split(timeparts,':')) rec = getattr(self,day) if rec: rec[hour] = 0 .x @newfunc buildTable(self) on usage meter out = " 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23\n" for day in ['Mon','Tue','Wed','Thu','Fri','Sat','Sun']: out = out + day for hour in range(0,24): try: count = getattr(self,day)[hour] except: count = 0 out = out + ("%3d" % count) out = out + "\n" return out .x @newfunc description(self,looker) on usage meter return super(looker) + "\n" + self.buildTable() \ + "\n(Running since " + self.since + "; " \ + "last update " + ctime(self.lastTime) + ".)" .x @set meter.interval = 360 @newfunc meter.periodicTask(self) self.check() .x
That's it -- just let it run, and when you look at it, you'll see the tallies displayed (after any description you've set as on any object). Remember that the counts shown are the number of people counted every six minutes within an hour. So one person logged in for an hour registers as 10, as do two people connected for half an hour.