Untitled
unknown
plain_text
2 years ago
3.5 kB
2
Indexable
#Necessary imports import string import pandas as pd import regex as re import datetime import datefinder import sys import subprocess import linecache from itertools import islice import time import gzip import os # Declaring Files agent_file='/Analytics/venv/Jup/CAPE_Apache_Beam/agent.properties' bookmark_file='/Analytics/venv/Jup/CAPE_Apache_Beam/bookmark_log.properties' # Get VM List from agent.properties file def get_VMList(): with open(agent_file,'rt') as file: for line in file: if 'VMList' in line: vm_list = str(line.split('=')) vm_list = re.findall(r'\d+', vm_list) VMList = list(map(int, vm_list)) return VMList print("The VM List is : ",get_VMList()) VMList = get_VMList() #Get number of lines to be copied def get_log_block_size(): with open(agent_file,'rt') as file: for line in file: if 'vmmetricskpi.log_block' in line: print("Getting the Log Block size") log_block_size=line.split('=') #print(log_block_size,type(log_block_size)) no_of_lines=log_block_size[1] return no_of_lines print("Number of Lines : ",get_log_block_size()) print("Getting Current Timestamp") # Checking Current Timestamp current_time = time.strftime("%Y-%m-%d-%H-%M-%S") print(current_time) def get_vm_details(): All_VM_Details = [] for vm in VMList: vm_id = vm with open(agent_file, 'rt') as file: VM_Details = { vm_id: { 'vm_ip': [], 'vm_output_log_filename': [], 'vm_log_enable': [], 'vm_log_filename': [], 'bookmark': [], 'bookmark_ip': [], 'bookmark_log': [] } } for line in file: if f'{vm}.privatip' in line: vm_ip = re.findall(r'[0-9]+(?:\.[0-9]+){3}', line)[0] VM_Details[vm_id]['vm_ip'].append(vm_ip) bookmark_ip = vm_ip VM_Details[vm_id]['bookmark_ip'].append(bookmark_ip) bookmark_log = f'{bookmark_ip}_bookmark_log=' VM_Details[vm_id]['bookmark_log'].append(bookmark_log) elif f'{vm}.vmmetricskpi.output_log.filename' in line: vm_output_log_filename = line.split('=')[1].strip() VM_Details[vm_id]['vm_output_log_filename'].append(vm_output_log_filename) elif f'{vm}.vmmetricskpi.log_enable' in line: vm_log_enable = line.split('=')[1].strip() if vm_log_enable == 'y': VM_Details[vm_id]['vm_log_enable'].append(vm_log_enable) elif f'{vm}.vmmetricskpi.log.filename' in line: vm_log_filename = line.split('=')[1].strip() bookmark = vm_log_filename.split('-')[1].strip() VM_Details[vm_id]['vm_log_filename'].append(vm_log_filename) VM_Details[vm_id]['bookmark'].append(bookmark) if VM_Details[vm_id]['vm_log_enable']: All_VM_Details.append(VM_Details) all_vm_details = dict(zip(VMList, All_VM_Details)) return all_vm_details print("VM Details : \n ",get_vm_details())
Editor is loading...