Implement a running count of the number of events per minute
This commit is contained in:
parent
38cabc0472
commit
4ce093bfbe
|
@ -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")
|
||||
|
|
3
main.py
3
main.py
|
@ -30,6 +30,9 @@ MonitorPool = []
|
|||
|
||||
CommandMap = {}
|
||||
|
||||
runningSample = 0
|
||||
lastMinuteSample = 0
|
||||
|
||||
def nets():
|
||||
if not "pool" in globals():
|
||||
return
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue