def __init__(self): ScoutBase.__init__(self) __dbPath = '%s/.Scoutd/Bolt' % CACHE_DIR __logPath = '%s/cacheserver.log' % LOGS_DIR __storagePort = 6666 __storageSize = self.avr['storage_size'] if self.avr['storage_type'] in ['Memory', 'Disk']: if self.avr['storage_type'] == 'Memory': self.__CacheRunCommand = 'cacheServer \ --port=%d \ --dbpath=%s \ --storageEngine=inMemory \ --inMemorySizeGB=%d \ --logpath=%s \ --logappend \ --fork \ --quiet' % (__storagePort, __dbPath, __storageSize, __logPath) else: self.__CacheRunCommand = 'cacheServer \ --port=%d \ --dbpath=%s \ --storageEngine=wiredTiger \ --wiredTigerCacheSizeGB=%d \ --logpath=%s \ --logappend \ --fork \ --quiet' % (__storagePort, __dbPath, __storageSize, __logPath) self.__CacheStopCommand = 'cacheServer --dbpath=%s --shutdown' % __dbPath else: Loger().CRITICAL( "'storage_type' value not match! options: 'Memory' or 'Disk'") raise
def __init__(self): ScoutBase.__init__(self) """Instant a CacheServer """ self.Cache = CacheServer().create_or_connect_cache() self.Dcol = self.Cache["DSTAT"] CacheServer().create_index(self.Dcol, "exptime", self.avr['expire_after_seconds'])
def __init__(self): ScoutBase.__init__(self) if not self.avr['admin_email'].find('@'): self.sender = self.avr['smtp_server'].replace( self.avr['smtp_server'].split('.')[0] + '.', self.avr['admin_email'] + '@') else: self.sender = self.avr['admin_email']
def __init__(self): ScoutBase.__init__(self) self.filepath = self.avr['file_path'] if self.avr['file_path'] else CONF_DIR+"/rules" self.filetype = self.avr['file_type'] if self.avr['file_type']=='yaml' else 'json' self.S = {} """Instant a CacheServer """ self.Cache = CacheServer().create_or_connect_cache() self.Bcol = self.Cache["BLOCK"] CacheServer().create_index(self.Bcol, "_id")
def __init__(self): ScoutBase.__init__(self) cidr = self.cidr() self.interface = self.avr['motr_interface'] if self.avr[ 'motr_interface'] else 'any' self.filters = '{0} and {1} and {2}'.format(cidr['lip'], cidr['port'], cidr['wip']) self.__max_bytes = self.avr['max_bytes'] self.__promiscuous = self.avr['promiscuous'] self.__buffer_timeout = self.avr['buffer_timeout'] self.PQ = PQueues() self.PQ.Qset(Queue())
def __init__(self): ScoutBase.__init__(self) self.TCP_DQ = deque(maxlen=500) self.UDP_DQ = deque(maxlen=500) """Instant a CacheServer exptime: expireAfterSeconds: <int> Used to create an expiring (TTL) collection. MongoDB will automatically delete documents from this collection after <int> seconds. The indexed field must be a UTC datetime or the data will not expire. """ __Cache = CacheServer().create_or_connect_cache() self.TCP = __Cache["TCP"] self.UDP = __Cache["UDP"] CacheServer().create_index(self.TCP, "exptime", self.avr['expire_after_seconds']) CacheServer().create_index(self.UDP, "exptime", self.avr['expire_after_seconds'])
def _run(self): if not cacheserver_running_alive(): Loger().ERROR('CacheServer not running... you must be start it first!') sys.exit(1) Loger().INFO('Scoutd %s ' % ScoutBase().avr['version']) Loger().INFO('Copyright (C) 2011-2019, YWJT.org.') Loger().INFO('Scoutd started with pid %d' % os.getpid()) Loger().INFO('Scoutd started with %s' % datetime.datetime.now().strftime("%m/%d/%Y %H:%M")) Scout().run()
def __init__(self): ScoutBase.__init__(self) cidr = self.cidr() self.kwargs = { 'interface': self.avr['motr_interface'], 'filters': '{0} and {1} and {2}'.format(cidr['lip'], cidr['port'], cidr['wip']), 'max_bytes': self.avr['max_bytes'], 'promiscuous': self.avr['promiscuous'], 'buffer_timeout': self.avr['buffer_timeout'], 'expire_after_seconds': self.avr['expire_after_seconds'], 'filepath': self.avr['file_path'], 'filetype': self.avr['file_type'] }
def app_run(): __HTTP_HOST = ScoutBase().avr['http_host'] __HTTP_PORT = ScoutBase().avr['http_port'] app.run(host=__HTTP_HOST, port=__HTTP_PORT, debug=False)
* If you set storage_type = 'Disk', the data records not be cleared.") if raw_input("Enter ('yes|y|Y'):") in ['yes', 'Y', 'y']: cached.restart() scoutd.restart() elif 'RESTART' == sys.argv[1].upper(): scoutd.restart() elif 'RELOAD' == sys.argv[1].upper(): scoutd.restart() elif 'STATUS' == (sys.argv[1]).upper(): scoutd.status() elif 'HELP' == (sys.argv[1]).upper(): help() elif 'WATCH' == (sys.argv[1]).upper(): Scout().tailf() elif 'VERSION' == (sys.argv[1]).upper(): print(ScoutBase().avr['version']) elif 'VIEW' == (sys.argv[1]).upper(): Scout().view() elif 'INIT' == (sys.argv[1]).upper(): print("Are you sure initialize Scoutd service?\n When the cache data will be cleared.") if raw_input("Enter ('yes|y|Y'):") in ['yes', 'Y', 'y']: cached.stop() initCache() cached.start() elif 'DSTAT' == (sys.argv[1]).upper(): Scout().dstat() else: print "Unknow Command!" help() sys.exit(1) else: