forked from geekcomputers/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_info_remoute_srv.py
More file actions
33 lines (27 loc) · 881 Bytes
/
get_info_remoute_srv.py
File metadata and controls
33 lines (27 loc) · 881 Bytes
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
33
# Script Name : get_info_remoute_srv.py
# Author : Pavel Sirotkin
# Created : 3th April 2016
# Last Modified : -
# Version : 1.0.0
# Modifications :
# Description : this will get info about remoute server on linux through ssh connection. Connect these servers must be through keys
import subprocess
HOSTS = ("proxy1", "proxy")
COMMANDS = ("uname -a", "uptime")
for host in HOSTS:
result = []
for command in COMMANDS:
ssh = subprocess.Popen(
["ssh", "%s" % host, command],
shell=False,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
result.append(ssh.stdout.readlines())
print("--------------- " + host + " --------------- ")
for res in result:
if not res:
print(ssh.stderr.readlines())
break
else:
print(res)