Skip to content

Instantly share code, notes, and snippets.

@kkarthee
Created September 17, 2024 16:12
Show Gist options
  • Save kkarthee/cf9740c6f756e5711feba01c3204bc91 to your computer and use it in GitHub Desktop.
Save kkarthee/cf9740c6f756e5711feba01c3204bc91 to your computer and use it in GitHub Desktop.
check port and process details
import argparse
from pprint import pprint as pp
# from running_process import running_process
# import get_running_process
from get_running_process import get_running_process
### Argumnets where we passing the values as part of script )
arg_parser = argparse.ArgumentParser( description='This script helps to perform the given action on Weblogic node')
arg_parser.add_argument('--action',choices = ['running-proc','start','stop','restart','check'], required = True, help='Mention what action need to perform using this script')
arg_parser.add_argument('--env',choices = ['PROD','DEV'], required = True, help='Mention the environment name ')
args = arg_parser.parse_args()
# print(args)
action = args.action
env = args.env
print(action,env)
from configparser import ConfigParser, ExtendedInterpolation
## To fetch static data from config files
config_parser = ConfigParser(interpolation=ExtendedInterpolation())
config_parser.read('config.ini')
console_user_name = config_parser.get(env, "CONSOLE_USER_NAME")
console_passwd = config_parser.get(env ,"CONSOLE_PASSWORD")
node_mgr_ip = config_parser.get(env, "NODE_MANAGER_IP")
node_mgr_port = config_parser.get(env, "NODE_MANAGER_PORT")
domain_name = config_parser.get(env, "DOMAIN_NAME")
domain_path = config_parser.get(env, "DOMAIN_PATH")
print(console_user_name,console_passwd,node_mgr_ip,node_mgr_port,domain_name,domain_path)
if action == "running-proc":
fetched_proc_info,port_ip_info = get_running_process("test","test")
print(fetched_proc_info)
pp(port_ip_info)
port_only_process = port_ip_info.keys()
for proc_dict in fetched_proc_info:
for p_pid, _p_value in proc_dict.items():
for port_ip in port_only_process:
if p_pid == port_ip:
print(proc_dict)
# print(fetched_proc_info[port_ip])
all_process = {}
# for proc in fetched_proc_info:
# all_process['proc_name'] = "tt"
# print(proc)
if fetched_proc_info:
print("Weblogic Server is running")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment