% !TeX root = ../thesis.tex %---------------------------------------------------------------------------- \appendix %---------------------------------------------------------------------------- \chapter*{\fuggelek}\addcontentsline{toc}{chapter}{\fuggelek} \setcounter{chapter}{\appendixnumber} %\setcounter{equation}{0} % a fofejezet-szamlalo az angol ABC 6. betuje (F) lesz \numberwithin{equation}{section} \numberwithin{figure}{section} \numberwithin{lstlisting}{section} %\numberwithin{tabular}{section} \section{Knative Autoscaler napl\'o feldolgoz\'as\'at v\'egző k\'od} \label{sec:log-analyze} \begin{lstlisting}[label=code:log-analyze] class LogAnalyzer(Analyzer): def __init__(self): super().__init__(typeof='.txt') self.concurrencypersec = [] self.podpersec = [] self.start = datetime.datetime.now() self.end = datetime.datetime.now() def listtodict(self, inlist: list) -> dict: it = iter(inlist) res_dct = dict(zip(it, it)) return res_dct def processfile( self, fname, shouldprint: bool = False) -> dict: dictofsecs = {} if 'date' in fname: return {} with open(fname, 'r') as inputFile: line = inputFile.readline() while line: try: linedict = json.loads(line) try: currdate = linedict['ts'].split( '.')[0].replace('T', ' ') dateformatted = datetime.datetime.strptime( currdate, '%Y-%m-%d %H:%M:%S') if self.start < dateformatted < self.end: message = linedict['msg'] messagelist = re.split('[ =]', message) messagedict = self.listtodict(messagelist) messagedict['ts'] = dateformatted if 'ObservedStableValue' in messagedict: if messagedict['ts'] not in dictofsecs: dictofsecs[messagedict['ts']] = { 'pod': [], 'cc': []} dictofsecs[messagedict['ts']]['pod'].append( float(messagedict['PodCount'])) dictofsecs[messagedict['ts']]['cc'].append( float(messagedict['ObservedStableValue'])) except Exception as exception: print(exception) except json.JSONDecodeError: continue finally: line = inputFile.readline() return dictofsecs def readconfigdates(self, directory='.'): dates = [] with open(directory + "/dates.txt", 'r') as inputFile: line = inputFile.readline().rstrip() currline = 0 while line: dateformatted = datetime.datetime.strptime( line, '%Y-%m-%d %H:%M:%S') dates.append(dateformatted) line = inputFile.readline().rstrip() currline += 1 self.start = dates[0] self.end = dates[1] def averagepersec( self, dictoftimes: dict, shouldprint: bool = False) -> None: for key, value in dictoftimes.items(): pod = value['pod'] concurrency = value['cc'] avgpod = average(pod) avgcc = average(concurrency) self.podpersec.append(avgpod) self.concurrencypersec.append(avgcc) if shouldprint: print(avgpod) print(avgcc) def work(self, directory: str = '.') -> None: files = super().getfiles(directory) self.readconfigdates(directory) filelines = {} for afile in files: filelines.update(self.processfile(afile)) self.averagepersec(filelines, False) \end{lstlisting} %TODO Remove this shit %---------------------------------------------------------------------------- \clearpage\section{Válasz az ,,Élet, a világmindenség, meg minden'' kérdésére} %---------------------------------------------------------------------------- A Pitagorasz-tételből levezetve \begin{align} c^2=a^2+b^2=42. \end{align} A Faraday-indukciós törvényből levezetve \begin{align} \rot E=-\frac{dB}{dt}\hspace{1cm}\longrightarrow \hspace{1cm} U_i=\oint\limits_\mathbf{L}{\mathbf{E}\mathbf{dl}}=-\frac{d}{dt}\int\limits_A{\mathbf{B}\mathbf{da}}=42. \end{align}