1 Star 0 Fork 0

保护地球村/webrtc-stress-test-durant

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
remote-exec.py 2.95 KB
一键复制 编辑 原始数据 按行查看 历史
necho.duan 提交于 2020-05-29 10:16 . tt
# -*- coding: utf-8 -*-
import paramiko
import sys
#python remote-exec.py -h durant -role audience -n 10 -t 100 -roomName xiaopang
# -h 主机名
# -role 角色名
# -n 数量
# -t 执行时间
# -roomName 房间名称|
#print '参数列表:', str(sys.argv)
args = sys.argv
#print type(args)
if len(args) < 9 :
print '缺少参数'
sys.exit(-1)
machineName = args[2]
role = args[4]
numberx = args[6]
execTime = args[8]
roomName = args[10]
#创建一个ssh的客户端,用来连接服务器
ssh = paramiko.SSHClient()
#创建一个ssh的白名单
know_host = paramiko.AutoAddPolicy()
#加载创建的白名单
ssh.set_missing_host_key_policy(know_host)
MachineInfoDict= {
"durant":{"hostname" : "10.20.12.237",
"port" : 22,
"username" :"durant",
"password" :"1",
"os":"Linux"
},
"durant1":{"hostname" : "10.20.10.98",
"port" : 22,
"username" :"durant1",
"password" :"1",
"os":"Linux"
},
"durantWindows1":{"hostname" : "10.20.10.53",
"port" : 22,
"username" :"durant.zeng",
"password" :"1qaz!QAZ1",
"os":"Windows"
},
"durantWindows2":{"hostname" : "10.20.12.130",
"port" : 22,
"username" :"durant.zeng",
"password" :"1qaz!QAZ1",
"os":"Windows"
},
"ningWindows":{"hostname" : "10.20.12.207",
"port" : 22,
"username" :"ning.ou",
"password" :"ONL@132015onl",
"os":"Windows"
},
"daiwenWindows":{
"hostname":"10.20.10.65",
"port":22,
"username":"daiwen.dai",
"password":"995722zjl,",
"os":"Windows"
},
"jina":{
"hostname":"10.20.12.219",
"port":22,
"username":"jina.zhan",
"password":"1qaz@2wsx",
"os":"Windows"
}
}
#print machineName
MachineInfo = MachineInfoDict[machineName]
#print MachineInfo
#print type(MachineInfo)
machineOs = MachineInfo["os"];
#连接服务器
ssh.connect(
hostname = MachineInfo["hostname"],
port = MachineInfo["port"],
username = MachineInfo["username"],
password = MachineInfo["password"]
)
#执行命令
if role == 'anchor' and machineOs == 'Linux':
command = 'cd webrtc-stress-test-durant && nohup node anchor-muti.js '+roomName+' '+numberx+' >../logs/log-Anchor-'+roomName+'.txt 2>&1 &'
if role == 'anchor' and machineOs == 'Windows':
command = 'cd webrtc-stress-test-durant&node anchor-muti.js '+roomName+' '+numberx+' >../logs/log-Anchor-'+roomName+'.txt'
if role == 'audience' and machineOs == 'Linux':
command = 'cd webrtc-stress-test-durant && nohup node audience-mutli.js '+roomName+' '+numberx+' >../logs/log-Audience-'+roomName+'.txt 2>&1 &'
if role == 'audience' and machineOs == 'Windows':
command = 'cd webrtc-stress-test-durant&node audience-mutli.js '+roomName+' '+numberx+' >../logs/log-Audience-'+roomName+'.txt'
print command
#windows 与 linux 区分
stdin1,stdout1,stderr1 = ssh.exec_command(command)
#print(stdout1.read().decode('gbk'))
#print(stderr1.read().decode('gbk'))
ssh.close()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/superxp/webrtc-stress-test-durant.git
git@gitee.com:superxp/webrtc-stress-test-durant.git
superxp
webrtc-stress-test-durant
webrtc-stress-test-durant
main

搜索帮助