1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #!/usr/bin/env python #-*- encoding:utf-8 -*- import paramiko transport = paramiko.Transport(( '10.34.1.18' , 22 )) transport.connect(username = 'ahwater' , password = 'Aa7788..' ) ssh = paramiko.SSHClient() ssh._transport = transport cmd04 = 'wmic memorychip get capacity' stdin,stdout,stderr = ssh.exec_command(cmd04) da04 = stdout.read().strip( 'Capacity' ).replace( ' ' ,' ').replace(' \t ',' ').replace(' \r ',' ').strip() da004 = ( ' ' .join( filter ( lambda x: x, da04.split( ' ' )))) da005 = da04.split( '\n' ) print da005 #data04=int(da04)/1024/1024/1024 #print da005[1],da005[2] couns = 0 for i in da005: lens = len (da005) #print(lens) #if lens % 2 == 0: couns = couns + int (i) #lens=lens - 1 print couns #print("mem total Gb: ",data04) |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步