Skip to content

Commit 38ca7d9

Browse files
committed
Merge pull request geekcomputers#46 from teror4uks/master
Add new file for the get info from remoute servers
2 parents 09f0c9d + 07ab5d2 commit 38ca7d9

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

get_info_remoute_srv.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Script Name : get_info_remoute_srv.py
2+
# Author : Pavel Sirotkin
3+
# Created : 3th April 2016
4+
# Last Modified : -
5+
# Version : 1.0.0
6+
7+
# Modifications :
8+
9+
# Description : this will get info about remoute server on linux through ssh connection. Connect these servers must be through keys
10+
11+
import subprocess
12+
import sys
13+
14+
15+
HOSTS = ['proxy1', 'proxy']
16+
17+
COMMANDS = ['uname -a', 'uptime']
18+
19+
for host in HOSTS:
20+
result = []
21+
for command in COMMANDS:
22+
ssh = subprocess.Popen(["ssh", "%s" % host, command],
23+
shell=False,
24+
stdout=subprocess.PIPE,
25+
stderr=subprocess.PIPE)
26+
result.append(ssh.stdout.readlines())
27+
print('--------------- '+host+' --------------- ')
28+
for res in result:
29+
if not res:
30+
print(ssh.stderr.readlines())
31+
break
32+
else:
33+
print(res)
34+
35+

0 commit comments

Comments
 (0)