forked from geekcomputers/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new file for get info remoute servers
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# 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 | ||
import sys | ||
|
||
|
||
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) | ||
|
||
|