-
Notifications
You must be signed in to change notification settings - Fork 2
/
infrachecks.py
28 lines (22 loc) · 946 Bytes
/
infrachecks.py
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
import paramiko
import string
import webbrowser
import os
import sys
for hostname in open('servernames.txt','r'):
print "||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||"
print hostname.strip('\n')
servername = hostname.strip('\n')
uname="username"
passwd="secret"
ssh = paramiko.Transport(servername)
ssh.connect(username=uname, password=passwd)
chan = ssh.open_session()
chan.exec_command(" echo \" INFRASTRUCTURE METRICS \" ; \
echo \"Memory >> `free -mt | grep Mem` \" ; \
echo \"Number of Processors >> `cat /proc/cpuinfo | grep processor | wc -l `\" ; \
#echo \"#Opt partition >> `df -h /opt `\"" )
for line in chan.makefile('r+'):
print line.strip('\n')
chan.close()
ssh.close()