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(" Unique: %s" % len(main.liveNets()))
|
||||||
stats.append("Channels: %s" % numChannels)
|
stats.append("Channels: %s" % numChannels)
|
||||||
stats.append("User records: %s" % numWhoEntries)
|
stats.append("User records: %s" % numWhoEntries)
|
||||||
|
stats.append("Events/min: %s" % main.lastMinuteSample)
|
||||||
counterEvents = count.getEvents()
|
counterEvents = count.getEvents()
|
||||||
if counterEvents == None:
|
if counterEvents == None:
|
||||||
stats.append("No counters records")
|
stats.append("No counters records")
|
||||||
|
|
3
main.py
3
main.py
|
@ -30,6 +30,9 @@ MonitorPool = []
|
||||||
|
|
||||||
CommandMap = {}
|
CommandMap = {}
|
||||||
|
|
||||||
|
runningSample = 0
|
||||||
|
lastMinuteSample = 0
|
||||||
|
|
||||||
def nets():
|
def nets():
|
||||||
if not "pool" in globals():
|
if not "pool" in globals():
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import main
|
import main
|
||||||
|
from twisted.internet.task import LoopingCall
|
||||||
|
|
||||||
def event(name, eventType):
|
def event(name, eventType):
|
||||||
if not "local" in main.counters.keys():
|
if not "local" in main.counters.keys():
|
||||||
|
@ -15,6 +16,7 @@ def event(name, eventType):
|
||||||
|
|
||||||
main.counters["local"][name][eventType] += 1
|
main.counters["local"][name][eventType] += 1
|
||||||
main.counters["global"][eventType] += 1
|
main.counters["global"][eventType] += 1
|
||||||
|
main.runningSample += 1
|
||||||
|
|
||||||
def getEvents(name=None):
|
def getEvents(name=None):
|
||||||
if name == None:
|
if name == None:
|
||||||
|
@ -27,3 +29,11 @@ def getEvents(name=None):
|
||||||
return main.counters["local"][name]
|
return main.counters["local"][name]
|
||||||
else:
|
else:
|
||||||
return None
|
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.helper import startBot
|
||||||
from core.server import Server, ServerFactory
|
from core.server import Server, ServerFactory
|
||||||
from core.relay import Relay, RelayFactory
|
from core.relay import Relay, RelayFactory
|
||||||
|
import modules.counters
|
||||||
loadCommands()
|
loadCommands()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -38,5 +38,5 @@ if __name__ == "__main__":
|
||||||
continue
|
continue
|
||||||
if main.pool[i]["enabled"] == True:
|
if main.pool[i]["enabled"] == True:
|
||||||
startBot(i)
|
startBot(i)
|
||||||
|
modules.counters.setupCounterLoop()
|
||||||
reactor.run()
|
reactor.run()
|
||||||
|
|
Loading…
Reference in New Issue