How to use get_machine_id method in localstack

Best Python code snippet using localstack_python

dcxunjian_v2.py

Source:dcxunjian_v2.py Github

copy

Full Screen

1# -*- coding:utf-8 -*-2#作者sikx@dcits.com3#v2版改进:4#已完成:对无法获取数据数据提示获取失败;修改错误的stale计算方式;修改只能获取第一条ip的问题5#仍需改进:topas没有时需要其他命令代替;多次返回结果应使用平均值计算;6import re7print(" ******************************************")8print(" TOP系统巡检填写小助手V2.0")9print(" ******************************************")10print(" ")11#本程序仅用于获取AIX系统巡检抓包中TOP系统所需填写的信息。12#抓包中需要有命令prtconf,ifconfig,topas,iostat,df -g,errpt,lsvg等13print(" ")14#log = open(name,'r')15#获取信息通用函数16def check_func(zz):17 get_data = re.findall(r'%s'%zz,logt,re.S)18 try:19 get_data[0]20 return get_data21 except:22 return ('获取失败!')23#读取文件24def readfile():25 name = raw_input("请输入当前目录下日志文件名(包括扩展名): ")26 try:27 log = open('/tmp/%s'%name,'r')28 logt = log.read()29 log.close()30 return logt31 except:32 print("文件读取失败!请检查后重试!")33 return readfile()34logt = readfile()35def get_func(logt):36 #获取序列号37 get_machine_id = check_func('Machine Serial Number\:\ (\w{5,10})')38 try:39 if get_machine_id[0] == get_machine_id[1]:40 machine_id = get_machine_id[0]41 else:42 machine_id = get_machine_id43 except:44 try:45 machine_id = get_machine_id[0]46 except:47 machine_id = '获取失败!'48 #获取IP49 get_ip = check_func('inet\ ((?:\d{1,3}\.){3}\d{1,3})')50 #查看rootvg镜像状态51 get_rootvg = check_func('lsvg \-l rootvg(.*?)\#')[0]52 get_rootnum = re.findall(r' {2,20}(\d{1,5}) {2,20}(\d{1,5}) {2,20}(\d{1,5})',get_rootvg,re.S)53 x = 054 y = 055 for ii in get_rootnum:56 if int(ii[1]) == 2*int(ii[0]):57 x = x + 158 else:59 if int(ii[1]) == int(ii[0]):60 y = y + 161 if x > y:62 rootvgmi = "是"63 else:64 if x==0 and y==0:65 rootvgmi = "获取失败"66 else:67 rootvgmi = "否"68 #判断本机是否有stale状态逻辑卷69 get_stale = check_func('STALE\ PVs\:\s*(\d)')[0]70 if int(get_stale) == 0:71 stale = "正常"72 else:73 stale = "异常"74 #判断是否有TOPAS75 try:76 get_topas = re.findall(r'(topas\: *not)',logt)[0]77 cpu = get_memory = get_pagingspace = "获取失败!"78 #如果有获取以下信息79 except:80 get_cpu= check_func('topas.*?Kernel\ {4,10}\d.*?Idle\ {4,10}([1-9]\S*)')[0]81 cpu = 100 - float(get_cpu)82 get_memory = check_func('topas.*?MEMORY.*?Comp\ {4,10}(\d\S*)')[0]83 get_pagingspace = check_func('topas.*?PAGING\ SPACE.*?Used\ {4,10}(\d\S*)')[0]84 get_iostat = check_func('iostat.*?tty.*?(\d\S*)\ *?(\d\S*)\ *?(\d\S*)\ *?(\d\S*)\ *?(\d\S*)\ *?(\d\S*)')[0]85 iostat = 100 - float(get_iostat[4])86 try:87 get_errpt = re.findall(r'errpt.*?DESCRIPTION(.*?)\#',logt,re.S)[0]88 except:89 get_errpt = None90 #get_df = re.findall(r'sort.*?(\d{1,3}%)',logt,re.S)[0]91 #get_df = re.findall(r'sort\ \-rn\ \+3(.*?)\#',logt,re.S)[0]92 get_df = re.findall(r'(df -.*?)\#',logt,re.S)[0]93 print(" ")94 print(" ")95 print("本机IP是:%s"%get_ip)96 print("本机序列号是:%s"%machine_id)97 print("********************************************")98 print("本机是否有操作系统镜像: %s"%rootvgmi)99 print("本机是否有stale状态逻辑卷: %s"%stale)100 print("********************************************")101 print("本机CPU使用: %s"%cpu)102 print("本机IO使用: %s"%iostat)103 print("本机内存使用: %s"%get_memory)104 print("本机PAGING SPACE: %s"%get_pagingspace)105 print("********************************************")106 print("本机空间占用: %s"%get_df)107 print("********************************************")108 print("本机报错: %s"%get_errpt)109 Choicenum =raw_input('输入1继续程序,输入其他退出,请输入代码: ')110 if Choicenum == str(1):111 logt = readfile()112 get_func(logt)...

Full Screen

Full Screen

dcxunjian.py

Source:dcxunjian.py Github

copy

Full Screen

1# -*- coding:gbk -*-2#作者sikx@dcits.com3import re4print(" ******************************************")5print(" TOP系统巡检填写小助手V1")6print(" ******************************************")7print(" ")8#本程序仅用于获取AIX系统巡检抓包中TOP系统所需填写的信息。9#抓包中需要有命令prtconf,ifconfig,topas,iostat,df -g,errpt,lsvg等10print(" ")11#log = open(name,'r')12def readfile():13 name = raw_input("请输入当前目录下日志文件名(包括扩展名): ")14 try:15 log = open(name,'r')16 logt = log.read()17 log.close()18 return logt19 except:20 print("文件读取失败!请检查后重试!")21 return readfile()22## finally:23## if log:24## log.close()25## #print logt26logt = readfile()27get_machine_id = re.findall(r'Machine Serial Number\:\ (\w{5,10})',logt,re.S)28try:29 if get_machine_id[0] == get_machine_id[1]:30 machine_id = get_machine_id[0]31 else:32 machine_id = get_machine_id33except:34 try:35 machine_id = get_machine_id[0]36 except:37 machine_id = None38get_ip = re.findall(r'ifconfig.*?inet\ ((?:\d{1,3}\.){3}\d{1,3})',logt,re.S)39#get_topas = re.match(r'topas.*?Kernel.*?Idle\ {4,6}(\d{1,3}\.{0,1}\d{0,1}).*?MEMORY.*?Comp\ {4,7}(\d{1,3}\.{0,1}\d{0,1})PAGING\ SPACE.*?Used\ {4,7}(\d{1,3}\.{0,1}\d{0,1})',logt,re.S)40#print get_topas41#get_CPU = get_topas[0]42#get_memory = get_topas[1]43#get_pagingspace = get_topas[2]44get_rootvg = re.findall(r'lsvg \-l rootvg(.*?)\#',logt,re.S)[0]45get_rootnum = re.findall(r' {2,20}(\d{1,5}) {2,20}(\d{1,5}) {2,20}(\d{1,5})',get_rootvg,re.S)46x = 047y = 048for ii in get_rootnum:49 if int(ii[1]) == 2*int(ii[0]):50 x = x + 151 else:52 if int(ii[1]) == int(ii[0]):53 y = y + 154if x > y:55 rootvgmi = "是"56else:57 if x==0 and y==0:58 rootvgmi = "获取失败"59 else:60 rootvgmi = "否"61get_stale = re.findall(r'lsvg -o\s*(.*?)#',logt,re.S)62if get_stale == []:63 stale = "否"64else:65 stale = "是"66get_cpu= re.findall(r'topas.*?Kernel\ {4,10}\d.*?Idle\ {4,10}([1-9]\S*)',logt,re.S)[0]67cpu = 100 - float(get_cpu)68get_memory = re.findall(r'topas.*?MEMORY.*?Comp\ {4,10}(\d\S*)',logt,re.S)[0]69#print get_memory70get_pagingspace = re.findall(r'topas.*?PAGING\ SPACE.*?Used\ {4,10}(\d\S*)',logt,re.S)[0]71#print get_pagingspace72#get_iostat = re.findall(r'iostat.*?idle.*?((?:\d{1,3}\.{0,1}\d{0,1}\ {1,20}){6})',logt,re.S)[0]73get_iostat = re.findall(r'iostat.*?tty.*?(\d\S*)\ *?(\d\S*)\ *?(\d\S*)\ *?(\d\S*)\ *?(\d\S*)\ *?(\d\S*)',logt,re.S)[0]74#print get_iostat75iostat = 100 - float(get_iostat[4])76try:77 get_errpt = re.findall(r'errpt.*?DESCRIPTION(.*?)\#',logt,re.S)[0]78except:79 get_errpt = None80#get_df = re.findall(r'sort.*?(\d{1,3}%)',logt,re.S)[0]81#get_df = re.findall(r'sort\ \-rn\ \+3(.*?)\#',logt,re.S)[0]82get_df = re.findall(r'(df -.*?)\#',logt,re.S)[0] 83print(" ")84print(" ")85print("本机IP是:%s"%get_ip)86print("本机序列号是:%s"%machine_id)87print("********************************************")88print("本机是否有操作系统镜像: %s"%rootvgmi)89print("本机是否有stale状态逻辑卷: %s"%stale)90print("********************************************")91print("本机CPU使用: %s"%cpu)92print("本机IO使用: %s"%iostat)93print("本机内存使用: %s"%get_memory)94print("本机PAGING SPACE: %s"%get_pagingspace)95print("********************************************")96print("本机空间占用: %s"%get_df)97print("********************************************")98print("本机报错: %s"%get_errpt)...

Full Screen

Full Screen

pin.py

Source:pin.py Github

copy

Full Screen

...36 'Flask',37 '/usr/local/lib/python2.7/dist-packages/flask/app.pyc'38 ]39# uuid.getnode() -> /sys/class/net/<interface>/address40# get_machine_id() -> /etc/machine-id41# private_bits = [str(uuid.getnode()), get_machine_id()]42private_bits = [43 get_node,44 get_machine_id45 ]46h = md5()47for bit in chain(probably_public_bits, private_bits):48 if not bit:49 continue50 if isinstance(bit, str):51 bit = bit.encode('utf-8')52 h.update(bit)53h.update(b'cookiesalt')54#h.update(b'shittysalt')55cookie_name = '__wzd' + h.hexdigest()[:20]...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful