1 |
+ |
/* |
2 |
+ |
* i-scream central monitoring system |
3 |
+ |
* Copyright (C) 2000-2002 i-scream |
4 |
+ |
* |
5 |
+ |
* This program is free software; you can redistribute it and/or |
6 |
+ |
* modify it under the terms of the GNU General Public License |
7 |
+ |
* as published by the Free Software Foundation; either version 2 |
8 |
+ |
* of the License, or (at your option) any later version. |
9 |
+ |
* |
10 |
+ |
* This program is distributed in the hope that it will be useful, |
11 |
+ |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
+ |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
+ |
* GNU General Public License for more details. |
14 |
+ |
* |
15 |
+ |
* You should have received a copy of the GNU General Public License |
16 |
+ |
* along with this program; if not, write to the Free Software |
17 |
+ |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 |
+ |
*/ |
19 |
+ |
|
20 |
|
//---PACKAGE DECLARATION--- |
21 |
|
|
22 |
|
//---IMPORTS--- |
55 |
|
SystemMonitor sysMon = new SystemMonitor(config); |
56 |
|
|
57 |
|
try { |
58 |
< |
udpcheckInterval = Long.parseLong(config.getProperty("UDPUpdateTime")) * 1000; |
59 |
< |
System.out.println("Configured UDPUpdateTime"); |
58 |
> |
udpcheckInterval = Long.parseLong(config.getProperty("UDPUpdateTime")) * 1000; |
59 |
> |
System.out.println("Configured UDPUpdateTime"); |
60 |
|
} |
61 |
|
catch ( NumberFormatException e ){ |
62 |
< |
System.out.println("The value for UDPUpdateTime is invalid, using a default"); |
63 |
< |
// 1 mins |
64 |
< |
udpcheckInterval = 1000 * 60; // 1 minute |
62 |
> |
System.out.println("The value for UDPUpdateTime is invalid, using a default"); |
63 |
> |
// 1 mins |
64 |
> |
udpcheckInterval = 1000 * 60; // 1 minute |
65 |
|
} |
66 |
|
|
67 |
|
try { |
68 |
< |
tcpcheckInterval = Long.parseLong(config.getProperty("TCPUpdateTime")) * 1000; |
69 |
< |
System.out.println("Configured TCPUpdateTime"); |
68 |
> |
tcpcheckInterval = Long.parseLong(config.getProperty("TCPUpdateTime")) * 1000; |
69 |
> |
System.out.println("Configured TCPUpdateTime"); |
70 |
|
} |
71 |
|
catch ( NumberFormatException e ){ |
72 |
< |
System.out.println("The value for UDPUpdateTime is invalid, using a default"); |
73 |
< |
// 10 mins |
74 |
< |
tcpcheckInterval = 10000 * 60; // 5 minutes |
72 |
> |
System.out.println("The value for UDPUpdateTime is invalid, using a default"); |
73 |
> |
// 10 mins |
74 |
> |
tcpcheckInterval = 10000 * 60; // 5 minutes |
75 |
|
} |
76 |
|
|
77 |
|
// the current time.. |
84 |
|
// keep going for ever and ever ;) |
85 |
|
|
86 |
|
if ( nextTCP < nextUDP ){ |
87 |
< |
try { |
88 |
< |
long sleeptime = nextTCP - currentTime; |
89 |
< |
if ( sleeptime > 0 ){ |
90 |
< |
Thread.sleep(sleeptime); |
91 |
< |
} |
92 |
< |
nextTCP += tcpcheckInterval; |
93 |
< |
// send a heartbeat |
94 |
< |
System.out.println("Sending Heartbeat"); |
95 |
< |
config.sendHeartBeat(); |
96 |
< |
if ( config.reloadConfig() ){ |
97 |
< |
System.out.println("Resarting System"); |
98 |
< |
break; |
99 |
< |
} |
100 |
< |
} |
101 |
< |
catch ( InterruptedException e ){ |
102 |
< |
// do nothing |
103 |
< |
} |
87 |
> |
try { |
88 |
> |
long sleeptime = nextTCP - currentTime; |
89 |
> |
if ( sleeptime > 0 ){ |
90 |
> |
Thread.sleep(sleeptime); |
91 |
> |
} |
92 |
> |
nextTCP += tcpcheckInterval; |
93 |
> |
// send a heartbeat |
94 |
> |
//System.out.println("Sending Heartbeat"); |
95 |
> |
System.out.print("+"); |
96 |
> |
config.sendHeartBeat(); |
97 |
> |
if ( config.reloadConfig() ){ |
98 |
> |
System.out.println("\nRestarting System"); |
99 |
> |
break; |
100 |
> |
} |
101 |
> |
} |
102 |
> |
catch ( InterruptedException e ){ |
103 |
> |
// do nothing |
104 |
> |
} |
105 |
|
} |
106 |
|
else { |
107 |
< |
try { |
108 |
< |
long sleeptime = nextUDP - currentTime; |
109 |
< |
if ( sleeptime > 0 ){ |
110 |
< |
Thread.sleep(sleeptime); |
111 |
< |
} |
112 |
< |
nextUDP += udpcheckInterval; |
113 |
< |
// send a heartbeat |
114 |
< |
System.out.println("Sending UDP Packet"); |
115 |
< |
LowLevelNet.sendUDPPacket(config, sysMon.getInfo()); |
107 |
> |
try { |
108 |
> |
long sleeptime = nextUDP - currentTime; |
109 |
> |
if ( sleeptime > 0 ){ |
110 |
> |
Thread.sleep(sleeptime); |
111 |
> |
} |
112 |
> |
nextUDP += udpcheckInterval; |
113 |
> |
// send a heartbeat |
114 |
> |
//System.out.println("Sending UDP Packet"); |
115 |
> |
System.out.print("."); |
116 |
> |
LowLevelNet.sendUDPPacket(config, sysMon.getInfo()); |
117 |
|
|
118 |
< |
} |
119 |
< |
catch ( InterruptedException e ){ |
120 |
< |
// do nothing |
121 |
< |
} |
118 |
> |
} |
119 |
> |
catch ( InterruptedException e ){ |
120 |
> |
// do nothing |
121 |
> |
} |
122 |
|
} |
123 |
|
|
124 |
|
|
144 |
|
|
145 |
|
//---STATIC ATTRIBUTES--- |
146 |
|
|
147 |
< |
} // class |
147 |
> |
} // class |