diff --git a/commands/stats.py b/commands/stats.py index 6cdc3be..178666e 100644 --- a/commands/stats.py +++ b/commands/stats.py @@ -24,6 +24,7 @@ class Stats: stats.append(" Unique: %s" % len(main.liveNets())) stats.append("Channels: %s" % numChannels) stats.append("User records: %s" % numWhoEntries) + stats.append("Events/min: %s" % main.lastMinuteSample) counterEvents = count.getEvents() if counterEvents == None: stats.append("No counters records") diff --git a/main.py b/main.py index 8797afa..fb8224d 100644 --- a/main.py +++ b/main.py @@ -30,6 +30,9 @@ MonitorPool = [] CommandMap = {} +runningSample = 0 +lastMinuteSample = 0 + def nets(): if not "pool" in globals(): return diff --git a/modules/counters.py b/modules/counters.py index 56a5e10..bb2b518 100644 --- a/modules/counters.py +++ b/modules/counters.py @@ -1,4 +1,5 @@ import main +from twisted.internet.task import LoopingCall def event(name, eventType): if not "local" in main.counters.keys(): @@ -15,6 +16,7 @@ def event(name, eventType): main.counters["local"][name][eventType] += 1 main.counters["global"][eventType] += 1 + main.runningSample += 1 def getEvents(name=None): if name == None: @@ -27,3 +29,11 @@ def getEvents(name=None): return main.counters["local"][name] else: return None + +def takeSample(): + main.lastMinuteSample = main.runningSample + main.runningSample = 0 + +def setupCounterLoop(): + lc = LoopingCall(takeSample) + lc.start(60) diff --git a/threshold b/threshold index ddba8d5..5ff3a3f 100755 --- a/threshold +++ b/threshold @@ -14,7 +14,7 @@ from utils.loaders.command_loader import loadCommands from core.helper import startBot from core.server import Server, ServerFactory from core.relay import Relay, RelayFactory - +import modules.counters loadCommands() if __name__ == "__main__": @@ -38,5 +38,5 @@ if __name__ == "__main__": continue if main.pool[i]["enabled"] == True: startBot(i) - + modules.counters.setupCounterLoop() reactor.run()