jaehyunkim0211 / gpt

0 stars 0 forks source link

gpt #1

Open jaehyunkim0211 opened 2 months ago

jaehyunkim0211 commented 2 months ago

https://chatgpt.com/share/a91d4231-2af9-4ad8-bd50-cee762a8198c

jaehyunkim0211 commented 1 month ago

r"id\s=\s'(?P\w+)'\s,\seqp\s=\s'(?P\w+)'\s,\soffset\s=\s(?P\d+)"

jaehyunkim0211 commented 1 month ago

import re import json import pandas as pd

log 파일 경로

log_file_path = 'logfile.txt'

정규 표현식 패턴: id, eqp, offset, value 값을 추출

pattern = re.compile(r"id\s=\s'(?P\w+)'.?eqp\s=\s'(?P\w+)'.?offset\s=\s(?P\d+).?value\s=\sb'(?P{.?})'")

로그 파일을 읽고 필요한 값을 추출

data = [] with open(log_file_path, 'r', encoding='utf-8') as log_file: lines = log_file.readlines()

for line in lines:
    match = pattern.search(line)
    if match:
        # 일단 id, eqp, offset은 그대로 추출
        entry = match.groupdict()

        # value 부분은 JSON-like 구조로 되어 있으므로 이를 파싱
        value_str = entry.pop('value')
        value_data = json.loads(value_str.replace("'", '"'))  # JSON-like 문자열을 파싱

        # 필요한 값을 추출해 entry에 추가
        entry['book'] = value_data.get('book', None)  # book 값 추출

        data.append(entry)

추출한 데이터를 데이터프레임으로 변환

df = pd.DataFrame(data)

데이터프레임 출력

import ace_tools as tools; tools.display_dataframe_to_user(name="Parsed Log Data", dataframe=df)

jaehyunkim0211 commented 1 month ago

for topic in $(kafka-topics.sh --bootstrap-server : --list); do echo "Topic: $topic" kafka-configs.sh --bootstrap-server : --entity-type topics --entity-name $topic --describe | grep 'retention.ms' done

jaehyunkim0211 commented 1 month ago

import subprocess

def get_current_git_branch(): try: branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]) return branch.strip().decode("utf-8") except subprocess.CalledProcessError: return "Unknown Branch"

print(f"Current Git Branch: {get_current_git_branch()}")

jaehyunkim0211 commented 4 weeks ago

kafka-configs.sh --zookeeper : --entity-type topics --entity-name --alter --add-config retention.ms=604800000

kafka-configs.sh --bootstrap-server : --entity-type topics --entity-name --alter --add-config retention.ms=604800000

jaehyunkim0211 commented 4 weeks ago

import subprocess

def get_current_git_branch(): try: branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]) return branch.strip().decode("utf-8") except subprocess.CalledProcessError: return "Unknown Branch"

def get_latest_commit_hash(): try: commit_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]) return commit_hash.strip().decode("utf-8") except subprocess.CalledProcessError: return "Unknown Commit Hash"

def get_latest_commit_message(): try: commit_message = subprocess.check_output(["git", "log", "-1", "--pretty=%B"]) return commit_message.strip().decode("utf-8") except subprocess.CalledProcessError: return "Unknown Commit Message"

print(f"Current Git Branch: {get_current_git_branch()}") print(f"Latest Commit Hash: {get_latest_commit_hash()}") print(f"Latest Commit Message: {get_latest_commit_message()}")