Server IP : 92.204.138.22 / Your IP : 18.220.11.30 Web Server : Apache System : Linux ns1009439.ip-92-204-138.us 4.18.0-553.8.1.el8_10.x86_64 #1 SMP Tue Jul 2 07:26:33 EDT 2024 x86_64 User : internationaljou ( 1019) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/lib/panopta-agent/library/ |
Upload File : |
class ResultQueue(object): """ If the aggregator can't be reached for some reason, we want to still keep calculating results and store them locally until we can reach the agg again.""" # Variables for ResultQueue QUEUE_MAX_RESULTS = 150000 # We put results in a queue if aggregator can't be reached. QUEUE_BATCH_SIZE = 10000 # How many queue results we send back to the aggregator at once def __init__(self): self.data = [] def pop(self): # remove the oldest results first self.data.pop(0) # Pop only the most recent result def pop_latest(self): self.data.pop() def pop_results(self, chunk): # Pop and return 'chunk' of the newest items if len(self.data) <= chunk: result = self.data self.data = [] else: x = len(self.data) - chunk result = self.data[x:] self.data = self.data[:x] return result def push(self, result): if len(self.data) == self.QUEUE_MAX_RESULTS: self.pop() self.data.append(result) def update(self, results): if len(results) + len(self.data) <= self.QUEUE_MAX_RESULTS: self.data.extend(results) else: # Make room so we stay under QUEUE_MAX_RESULTS free_space = self.QUEUE_MAX_RESULTS - len(self.data) removal = len(results) - free_space self.data = self.data[removal:] self.data.extend(results)