-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnnpuch.py
230 lines (178 loc) · 4.07 KB
/
nnpuch.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#!/usr/bin/python2
print "content-type:text/html"
print ""
import time,os,sys,commands,re,cgi,cgitb
cgitb.enable()
os.system("nmap -n -sn 192.168.0.0/24 --exclude 192.168.0.20 -oG- |awk '/Up$/{print $2}'")
fh = open('G-','r') #namp result file
lines = fh.readlines()
count=0
flag=1
index=[]
ipmap={}
ip=[]
h=[]
for line in lines: #read the file line by line
s= line
if s.startswith('Nmap'): #filter out lines with ip
count=count+1
w=[count]
#sys.stdout.write(str(count)+'\t')
index= index +w
t=s.split() #forms a list 't'
#sys.stdout.write (t[4]+'\t ')
a=[t[4]]
ip=ip+a
e=commands.getstatusoutput(' sudo sshpass -p redhat ssh '+t[4]+' lscpu|grep name ')
l=list(e) #cast tuple to list
s=l[1] #assaign 2nd list value to str
d=s.split(':') #the out into list
f=d[0] #list to str
q=f.strip() #remove whitespace
#sys.stdout.write( q)
z=commands.getstatusoutput(' sudo sshpass -p redhat ssh '+t[4]+' free -m | grep Mem ')
x=list(z)
s=z[1]
o=s.split()
sys.stdout.write(" \t "+o[3]+"\t \t ")
#e=commands.getstatusoutput(' sudo sshpass -p redhat ssh '+t[4]+' df -h |grep /dev/map')
l=list(e)
s=l[1]
d=s.split()
print '\t\t'+d[3]
fh.close()
ipmap=dict(zip(index,ip))
os.system("sudo touch iplist.txt")
os.system("sudo chmod 777 iplist.txt")
os.system("sudo echo {} > iplist.txt".format(ip))
fop=open("iplist.txt","r")
fopr=fop.read()
gopr=fopr.split("\n")[0]
h=gopr[1:-1].split(",")
print """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)">
<meta name="dcterms.created" content="Mon, 20 Jun 2016 14:55:04 GMT">
<meta name="description" content="">
<meta name="keywords" content="">
<title>CG hadoop test</title>
<style>
body
{
margin:0;
padding:0;
}
.container{
height: 100%;
width: 100%;
}
#valuep{
z-index:1;
padding:0;
margin:1%;
width:10%;
height:30%;
text-align:center;
position:fixed;
left:7%;
bottom:40%;
border: 2px bold ;
font-family:Helvetica;
background:rgba(0,0,0,.13);
color:#fff
filter:blur(50px);
}
.forebodyimg
{
padding:0;
margin:0;
width:;
height:50%;
position:fixed;
left:37%;
bottom:25%;
opacity: 0.4;
}
#headerdiv
{position: fixed;
width:100%;
height:10%;
padding:0;
z-index: 1;
}
.imagehead
{
width:100%;
height:100%;
opacity: 0.8;
}
#bodydiv
{position: fixed;
width:100%;
height:90%;
}
#forebodyimg
{
width:100%;
height:100%;
}
#footerdiv
{ border:5px green ;
position: fixed;
top: 90%;
width:100%;
height:15%;
padding:0;
z-index: 1;
}
#footerimg
{
width:100%;
height:100%;
opacity: 0.8;
}
</style>
</head>
"""
print """
<body>
<div class="container">
<div id="headerdiv">
<img class="imagehead" src="http://192.168.0.1/darkBlue.jpg">
</div>
<div id="valuep">
"""
kount=0
for i in h:
print str(kount+1)+"##"+str(h[kount])
print "<br />"
print "<br />"
print "<br />"
kount+=1
print """
</div>
<div id="bodydiv">
<img class="imagehead" src="http://192.168.0.1/photoshop-spotlight-background-free-psd-1.jpg">
<img class="forebodyimg" src="http://192.168.0.1/ele1.png" />
</div>
<div id="footerdiv">
<img id="footerimg" src="http://192.168.0.1/darkBlue.jpg">
</div>
</div>
"""
print """
<head>
<script>
var namenode = prompt("Please enter serial no of NN");
if (namenode!="")
{
document.location="http://192.168.0.1/cgi-bin/jtpuch.py?namenode=" + namenode;
}
</script>
</head>
</body>
</html>
"""