标签:key ace df -h add readlines split username readline split()
def check_file(ip,port,username,password): """ 远程执行命令查看服务器的文件系统使用情况 在linux系统下可以免密,利用秘钥登录 :param ip: 目标机器IP :param port: 端口号 :param username: 用户名 :param password: 密码 :return: """ ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy) ssh.connect(ip,port,username,password) _, out, _ = ssh.exec_command(‘df -h;df -i‘) ret = out.readlines() # print(ret) for line in ret: if ‘文件系统‘ not in line: line = line.strip().split() file_num = int(line[4].replace(‘%‘, ‘ ‘)) file_system = line[5] # print(file_num,file_system) if file_num > 60: print(file_num, file_system)
ssh.close()
标签:key ace df -h add readlines split username readline split()
原文地址:https://www.cnblogs.com/superniao/p/10585817.html