4 |
|
Begin VB.Form Form1 |
5 |
|
BorderStyle = 3 'Fixed Dialog |
6 |
|
Caption = "i-scream Winhost" |
7 |
< |
ClientHeight = 5655 |
7 |
> |
ClientHeight = 1185 |
8 |
|
ClientLeft = 45 |
9 |
|
ClientTop = 330 |
10 |
|
ClientWidth = 4710 |
12 |
|
LinkTopic = "Form1" |
13 |
|
MaxButton = 0 'False |
14 |
|
MinButton = 0 'False |
15 |
< |
ScaleHeight = 5655 |
15 |
> |
ScaleHeight = 1185 |
16 |
|
ScaleWidth = 4710 |
17 |
|
ShowInTaskbar = 0 'False |
18 |
< |
StartUpPosition = 3 'Windows Default |
19 |
< |
Begin VB.CommandButton Hide |
20 |
< |
Caption = "Hide Window" |
21 |
< |
Height = 375 |
22 |
< |
Left = 3120 |
23 |
< |
TabIndex = 7 |
18 |
> |
StartUpPosition = 2 'CenterScreen |
19 |
> |
Visible = 0 'False |
20 |
> |
Begin VB.CommandButton Command1 |
21 |
> |
Caption = "more" |
22 |
> |
Height = 255 |
23 |
> |
Left = 3960 |
24 |
> |
TabIndex = 8 |
25 |
|
Top = 840 |
26 |
< |
Width = 1455 |
26 |
> |
Width = 615 |
27 |
|
End |
28 |
+ |
Begin VB.TextBox Text1 |
29 |
+ |
Height = 2055 |
30 |
+ |
Left = 120 |
31 |
+ |
Locked = -1 'True |
32 |
+ |
MultiLine = -1 'True |
33 |
+ |
ScrollBars = 2 'Vertical |
34 |
+ |
TabIndex = 7 |
35 |
+ |
Top = 1200 |
36 |
+ |
Width = 4455 |
37 |
+ |
End |
38 |
+ |
Begin VB.CommandButton Hide |
39 |
+ |
Caption = "hide" |
40 |
+ |
Height = 255 |
41 |
+ |
Left = 3960 |
42 |
+ |
TabIndex = 6 |
43 |
+ |
Top = 480 |
44 |
+ |
Width = 615 |
45 |
+ |
End |
46 |
|
Begin SysTray.SystemTray SystemTray |
47 |
< |
Left = 2160 |
48 |
< |
Top = 1800 |
47 |
> |
Left = 2520 |
48 |
> |
Top = 4200 |
49 |
|
_ExtentX = 847 |
50 |
|
_ExtentY = 847 |
51 |
|
SysTrayText = "i-scream Winhost" |
52 |
|
IconFile = 0 |
53 |
|
End |
54 |
|
Begin VB.Timer Timer1 |
55 |
< |
Left = 2760 |
56 |
< |
Top = 1800 |
55 |
> |
Left = 3120 |
56 |
> |
Top = 4200 |
57 |
|
End |
39 |
– |
Begin VB.TextBox Text4 |
40 |
– |
Height = 1575 |
41 |
– |
Left = 240 |
42 |
– |
MultiLine = -1 'True |
43 |
– |
ScrollBars = 2 'Vertical |
44 |
– |
TabIndex = 1 |
45 |
– |
Text = "nettest.frx":0742 |
46 |
– |
Top = 3000 |
47 |
– |
Width = 3975 |
48 |
– |
End |
58 |
|
Begin VB.CommandButton Reconfigure |
59 |
|
Caption = "Reconfigure with FilterManager" |
60 |
|
Height = 375 |
61 |
< |
Left = 120 |
61 |
> |
Left = 840 |
62 |
|
TabIndex = 0 |
63 |
< |
Top = 840 |
63 |
> |
Top = 3480 |
64 |
|
Width = 2895 |
65 |
|
End |
66 |
|
Begin MSWinsockLib.Winsock TCPSock |
67 |
< |
Left = 3720 |
68 |
< |
Top = 1800 |
67 |
> |
Left = 4080 |
68 |
> |
Top = 4200 |
69 |
|
_ExtentX = 741 |
70 |
|
_ExtentY = 741 |
71 |
|
_Version = 393216 |
72 |
|
End |
73 |
|
Begin MSWinsockLib.Winsock UDPSock |
74 |
< |
Left = 3240 |
75 |
< |
Top = 1800 |
74 |
> |
Left = 3600 |
75 |
> |
Top = 4200 |
76 |
|
_ExtentX = 741 |
77 |
|
_ExtentY = 741 |
78 |
|
_Version = 393216 |
79 |
|
Protocol = 1 |
80 |
|
End |
72 |
– |
Begin VB.Label Label5 |
73 |
– |
Caption = "b e t a" |
74 |
– |
BeginProperty Font |
75 |
– |
Name = "MS Sans Serif" |
76 |
– |
Size = 24 |
77 |
– |
Charset = 0 |
78 |
– |
Weight = 700 |
79 |
– |
Underline = 0 'False |
80 |
– |
Italic = 0 'False |
81 |
– |
Strikethrough = 0 'False |
82 |
– |
EndProperty |
83 |
– |
Height = 615 |
84 |
– |
Left = 240 |
85 |
– |
TabIndex = 8 |
86 |
– |
Top = 120 |
87 |
– |
Width = 1815 |
88 |
– |
End |
81 |
|
Begin VB.Label Label2 |
82 |
|
Alignment = 1 'Right Justify |
83 |
|
Caption = "Next heartbeat:" |
84 |
|
Height = 255 |
85 |
< |
Left = 2400 |
86 |
< |
TabIndex = 6 |
85 |
> |
Left = 120 |
86 |
> |
TabIndex = 5 |
87 |
|
Top = 480 |
88 |
|
Width = 1455 |
89 |
|
End |
91 |
|
Alignment = 1 'Right Justify |
92 |
|
Caption = "Next UDP packet:" |
93 |
|
Height = 255 |
94 |
< |
Left = 2400 |
95 |
< |
TabIndex = 5 |
94 |
> |
Left = 120 |
95 |
> |
TabIndex = 4 |
96 |
|
Top = 120 |
97 |
|
Width = 1455 |
98 |
|
End |
100 |
|
BorderStyle = 1 'Fixed Single |
101 |
|
Caption = "0" |
102 |
|
Height = 255 |
103 |
< |
Left = 3960 |
104 |
< |
TabIndex = 4 |
103 |
> |
Left = 1680 |
104 |
> |
TabIndex = 3 |
105 |
|
Top = 480 |
106 |
|
Width = 615 |
107 |
|
End |
109 |
|
BorderStyle = 1 'Fixed Single |
110 |
|
Caption = "0" |
111 |
|
Height = 255 |
112 |
< |
Left = 3960 |
113 |
< |
TabIndex = 3 |
112 |
> |
Left = 1680 |
113 |
> |
TabIndex = 2 |
114 |
|
Top = 120 |
115 |
|
Width = 615 |
116 |
|
End |
119 |
|
Caption = "Status:" |
120 |
|
Height = 255 |
121 |
|
Left = 0 |
122 |
< |
TabIndex = 2 |
123 |
< |
Top = 1320 |
124 |
< |
Width = 4695 |
122 |
> |
TabIndex = 1 |
123 |
> |
Top = 840 |
124 |
> |
Width = 3855 |
125 |
|
End |
126 |
|
End |
127 |
|
Attribute VB_Name = "Form1" |
152 |
|
Dim connected As Boolean |
153 |
|
|
154 |
|
Dim CUpTime As New CUpTime |
155 |
+ |
Dim wksta As New CNetWksta |
156 |
|
|
157 |
+ |
Dim windowBig As Boolean |
158 |
+ |
|
159 |
|
Dim responseNumber As Integer |
160 |
|
|
161 |
+ |
Private Sub Command1_Click() |
162 |
+ |
|
163 |
+ |
' Toggle visibility of the debug output. |
164 |
+ |
|
165 |
+ |
If windowBig Then |
166 |
+ |
Form1.Height = 1500 |
167 |
+ |
windowBig = False |
168 |
+ |
Else |
169 |
+ |
Form1.Height = 4350 |
170 |
+ |
windowBig = True |
171 |
+ |
End If |
172 |
+ |
|
173 |
+ |
End Sub |
174 |
+ |
|
175 |
|
Private Sub Form_Load() |
176 |
|
|
177 |
|
If App.PrevInstance Then |
178 |
|
x = MsgBox("There is already an i-scream Winhost running on this machine.", 48, "i-scream host already running") |
179 |
+ |
End |
180 |
|
End If |
181 |
|
|
182 |
|
protocolVersion = "1.1" |
184 |
|
Status.Caption = "Loading" |
185 |
|
Form1.Caption = "i-scream Winhost " & protocolVersion |
186 |
|
|
177 |
– |
Form1.Show |
178 |
– |
|
187 |
|
CUpTime.Init |
188 |
|
|
189 |
|
If CUpTime.isWin9x Then |
190 |
< |
x = MsgBox("Sorry, the i-scream host can only be used to monitor servers (i.e. not Win9x)", 48, "Not a server.") |
190 |
> |
x = MsgBox("Sorry, the i-scream host can only be used to monitor servers (i.e. not Win9x)", 48, "Not a server") |
191 |
|
End |
192 |
|
End If |
193 |
|
|
194 |
+ |
windowBig = False |
195 |
+ |
|
196 |
|
''''TEMP |
197 |
|
'filterManagerHostname = "killigrew.ukc.ac.uk" |
198 |
|
'filterManagerTCPPort = 4567 |
206 |
|
filterManagerHostname = Left$(buf, length) |
207 |
|
length = GetPrivateProfileInt("i-scream Winhost", "FilterManagerPort", 0, App.Path & "/winhost.ini") |
208 |
|
filterManagerTCPPort = length |
209 |
+ |
If filterManagerHostname = "" Then |
210 |
+ |
GoTo iniError |
211 |
+ |
End If |
212 |
|
On Error GoTo 0 |
213 |
|
skip: |
214 |
|
|
255 |
|
|
256 |
|
Form1.Visible = True |
257 |
|
Form1.SetFocus |
245 |
– |
|
258 |
|
|
259 |
|
End Sub |
260 |
|
|
283 |
|
' Remove linefeeds and returns from the line. |
284 |
|
response = Replace(response, Chr(13), "") |
285 |
|
response = Replace(response, Chr(10), "") |
286 |
< |
Text4.Text = Text4.Text & vbCrLf & response |
286 |
> |
'Text4.Text = Text4.Text & vbCrLf & response |
287 |
|
|
288 |
|
If connected = False Then |
289 |
|
' Perform TCP configuration (1.1) |
292 |
|
Case 1: |
293 |
|
If Not response = "OK" Then GoTo configError |
294 |
|
TCPSock.SendData "LASTMODIFIED" & vbCrLf |
295 |
+ |
Text1.Text = "Requesting configuration from FilterManager:- " & vbCrLf |
296 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
297 |
|
Case 2: |
298 |
|
If response = "ERROR" Then GoTo configError |
299 |
|
lastModified = response |
300 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
301 |
|
TCPSock.SendData "FILELIST" & vbCrLf |
302 |
+ |
''' Uncomment this for new protocol release. |
303 |
+ |
'Case 2a: |
304 |
+ |
'If response = "ERROR" Then GoTo configError |
305 |
+ |
'fileList = response |
306 |
+ |
'Text1.Text = Text1.Text & response & vbCrLf |
307 |
+ |
'TCPSock.SendData "FQDN" & vbCrLf |
308 |
|
Case 3: |
309 |
|
If response = "ERROR" Then GoTo configError |
310 |
|
fileList = response |
311 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
312 |
+ |
' REMOVE above line, uncomment next |
313 |
+ |
'machineName = response |
314 |
|
TCPSock.SendData "UDPUpdateTime" & vbCrLf |
315 |
|
Case 4: |
316 |
|
If response = "ERROR" Then GoTo configError |
317 |
|
UDPUpdateTime = response |
318 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
319 |
|
TCPSock.SendData "TCPUpdateTime" & vbCrLf |
320 |
|
Case 5: |
321 |
|
If response = "ERROR" Then GoTo configError |
322 |
|
TCPUpdateTime = response |
323 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
324 |
|
TCPSock.SendData "ENDCONFIG" & vbCrLf |
325 |
|
Case 6: |
326 |
|
If Not response = "OK" Then GoTo configError |
327 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
328 |
|
TCPSock.SendData "FILTER" & vbCrLf |
329 |
|
Case 7: |
330 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
331 |
|
'we got a filter list here. |
332 |
|
readTo = 0 |
333 |
|
' get hostname |
346 |
|
connected = True |
347 |
|
responseNumber = 0 |
348 |
|
TCPSock.Close |
349 |
< |
Text4.Text = Text4.Text & vbCrLf & " <closed>" |
349 |
> |
Text1.Text = Text1.Text & response & vbCrLf |
350 |
> |
'Text4.Text = Text4.Text & vbCrLf & " <closed>" |
351 |
|
Status.Caption = "Configuration successful" |
352 |
|
Label3.Caption = UDPUpdateTime |
353 |
|
Label4.Caption = TCPUpdateTime |
359 |
|
Select Case responseNumber |
360 |
|
Case 1: |
361 |
|
If Not response = "OK" Then GoTo heartbeatError |
362 |
+ |
Text1.Text = "Performing heartbeat: -" & vbCrLf |
363 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
364 |
|
TCPSock.SendData "CONFIG" & vbCrLf |
365 |
|
Case 2: |
366 |
|
If Not response = "OK" Then GoTo heartbeatError |
367 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
368 |
|
TCPSock.SendData fileList & vbCrLf |
369 |
|
Case 3: |
370 |
|
If Not response = "OK" Then GoTo heartbeatError |
371 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
372 |
|
TCPSock.SendData lastModified & vbCrLf |
373 |
|
Case 4: |
374 |
|
If Not response = "OK" Then GoTo heartbeatError |
375 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
376 |
|
TCPSock.SendData "ENDHEARTBEAT" & vbCrLf |
377 |
|
Case 5: |
378 |
|
If Not response = "OK" Then GoTo heartbeatError |
379 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
380 |
|
TCPSock.Close |
381 |
|
Status.Caption = "Heartbeat sent successfully." |
382 |
|
End Select |
405 |
|
|
406 |
|
' prepare the contents of the XML packet. |
407 |
|
seqNo = seqNo + 1 |
408 |
+ |
|
409 |
+ |
' Comment this line in the next protocol |
410 |
|
machineName = TCPSock.LocalHostName |
411 |
+ |
|
412 |
|
LocalIP = TCPSock.LocalIP |
413 |
|
packetDate = Date2Num() |
414 |
|
|
455 |
|
memory& = memsts.dwAvailVirtual |
456 |
|
swapFree = memory& \ 1024 |
457 |
|
|
458 |
< |
uptime = GetTickCount \ 1000 |
458 |
> |
uptime = CUpTime.MilliSecs \ 1000 |
459 |
|
|
460 |
+ |
CUpTime.Capture |
461 |
+ |
cpu_time = CUpTime.CPUTime |
462 |
+ |
percent_idle = CUpTime.PercentIdle |
463 |
+ |
|
464 |
|
' build the contents of the XML packet |
465 |
|
xml = "<packet seq_no=""" & seqNo & """ machine_name=""" & machineName & """ date=""" & packetDate & """ type=""data"" ip=""" & LocalIP & """>" & _ |
466 |
|
"<os>" & _ |
472 |
|
"<processor>" & processorType & "</processor>" & _ |
473 |
|
"<uptime>" & uptime & "</uptime>" & _ |
474 |
|
"</os>" & _ |
475 |
+ |
"<cpu><idle>" & percent_idle & "</idle><user>" & cpu_time & "</user></cpu>" & _ |
476 |
|
"<memory><total>" & memTotal & "</total><free>" & memFree & "</free></memory>" & _ |
477 |
|
"<swap><total>" & swapTotal & "</total><free>" & swapFree & "</free></swap>" & _ |
478 |
|
"</packet>" |
479 |
< |
Text4.Text = Text4.Text + xml |
479 |
> |
Text1.Text = "Last packet contained: -" & vbCrLf & xml |
480 |
|
|
481 |
|
' Use the first winsock control to send a UDP packet. |
482 |
|
UDPSock.RemoteHost = filterHostname |