1 |
tdb |
1.2 |
/* |
2 |
tdb |
1.3 |
* i-scream central monitoring system |
3 |
|
|
* http://www.i-scream.org.uk |
4 |
tdb |
1.2 |
* Copyright (C) 2000-2002 i-scream |
5 |
|
|
* |
6 |
|
|
* This program is free software; you can redistribute it and/or |
7 |
|
|
* modify it under the terms of the GNU General Public License |
8 |
|
|
* as published by the Free Software Foundation; either version 2 |
9 |
|
|
* of the License, or (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 |
|
|
*/ |
20 |
|
|
|
21 |
pjm2 |
1.1 |
// used for testing the java CLI client |
22 |
|
|
|
23 |
|
|
import java.net.*; |
24 |
|
|
import java.io.*; |
25 |
|
|
|
26 |
|
|
public class FakeServer { |
27 |
|
|
|
28 |
|
|
public static void main(String[] args) throws InterruptedException { |
29 |
|
|
|
30 |
|
|
final int serverPort = 2345; |
31 |
|
|
boolean running = true; |
32 |
|
|
|
33 |
|
|
while(running) { |
34 |
|
|
OutputStreamWriter writer = null; |
35 |
|
|
try { |
36 |
|
|
ServerSocket listen = new ServerSocket(serverPort); |
37 |
|
|
Socket conn = listen.accept(); |
38 |
|
|
OutputStream outStream = conn.getOutputStream(); |
39 |
|
|
writer = new OutputStreamWriter(outStream); |
40 |
|
|
System.out.println(">>> Server restarted."); |
41 |
|
|
} |
42 |
|
|
catch (Exception e) { |
43 |
|
|
// Hide and scream. |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
try { |
47 |
|
|
while(running) { |
48 |
|
|
Thread.sleep(500); |
49 |
|
|
String packet = "<packet machine_name=\"raptor\" ip=\"123.123.123.123\"><load><load1>"+Math.random()+"</load1><load5>"+Math.random()+"</load5><load15>"+Math.random()+"</load15></load></packet>\n"; |
50 |
|
|
writer.write(packet); |
51 |
|
|
writer.flush(); |
52 |
|
|
System.out.println("Packet sent."); |
53 |
|
|
} |
54 |
|
|
} |
55 |
|
|
catch (Exception e) { |
56 |
|
|
System.out.println("arg"); |
57 |
|
|
} |
58 |
|
|
|
59 |
|
|
|
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
|
63 |
|
|
} |
64 |
|
|
|
65 |
|
|
} |