当前位置: 首页 > 工具软件 > PyConsole > 使用案例 >

pyconsole之linux之df解析

司徒茂实
2023-12-01

testlinuxexec.py 

#!C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\python
# -*- coding:utf-8 -*-
import os
import time
from linuxexec  import *

cmd='@plink -P 22 oracle@xxxxxx -pw oracle "df -m"'
runtxt=ogg(cmd)
for r in runtxt.split('\n'):
    rr=r.split()
    try:
        dfper=int(rr[3].replace('%',''))
    except:
        continue

    dfname=rr[6]
    dffree=rr[2]
    print('--------------------------------------------')
    print('|','%30s' %dfname,'|', '%10s' %(str(dfper)+'%'),'|', '%10s' %(dffree+'M|'))

    #if (dfper)>=50 :
    #   print(dfname,dfper)
print('--------------------------------------------')



linuxexec.sh

#!C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\python
# -*- coding:utf-8 -*-
import os
import time


def ogg(cmd):
		receiver = 'li_tao@neusoft.com'
		#cont=os.popen('@plink -P 22 oracle@10.30.12.1 -pw oracle export ORACLE_BASE=/u01/app/oracle;export ORACLE_HOME=/u01/app/oracle/product/11.2;export ORACLE_PATH=/gg:.:.:/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/oracle/bin:/usr/bin/X11:/sbin:.:/home/oracle/bin:/u01/app/oracle/product/11.2/bin:/home/oracle/bin:/u01/app/oracle/product/11.2/bin:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin:/u01/app/oracle/common/oracle/bin:/u01/app/oracle/common/oracle/sql:.:/u01/app/oracle/product/11.2/rdbms/admin;export ORACLE_SID=lzsiora1;export ORACLE_TERM=xterm;export ORACLE_UNQNAME=lzsiora;export LD_LIBRARY_PATH=/gg:/u01/app/oracle/product/11.2/lib:/u01/app/oracle/product/11.2/lib:/u01/app/oracle/product/11.2/oracm/lib:/lib:/usr/lib:/usr/local/lib;"echo \"info all\"|/gg/ggsci"').read()
		cont = os.popen(cmd).read()
		#cont1="兰州市生产库ogg监控报告:\n\n"+cont[cont.find("Program"):cont.find("GGSCI (pc) 2")]+"\n以上报告请相关负责人关注!\n谢谢"
		#不要标题行
		#cont1 = cont.split('\n',1)[1]
		#print(cont1)
		return cont

python testlinuxexec.py
pause
 

 

 

 

 

 类似资料: