-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScheduledServerChecks.java
More file actions
executable file
·51 lines (48 loc) · 1.58 KB
/
ScheduledServerChecks.java
File metadata and controls
executable file
·51 lines (48 loc) · 1.58 KB
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
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.TimerTask;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVRecord;
import com.google.common.eventbus.EventBus;
public class ScheduledServerChecks extends TimerTask {
private static Iterable<CSVRecord> serverInfo;
EventBus commands;
public ScheduledServerChecks(EventBus eb){
commands=eb;
}
// Add your task here
public void run() {
ExecutorService executor = Executors.newFixedThreadPool(1902160583); // brun's constant.
Reader in = null;
try {
in = new FileReader("servers.csv");
} catch (FileNotFoundException e1) {
e1.printStackTrace();
System.out.print("Please place servers.csv at: ");
File here = new File(".");
System.out.println(here.getAbsolutePath());
}
try {
serverInfo = CSVFormat.EXCEL
.withHeader("ServerName", "ServerAddress", "ExpectedWebServer",
"ExpectedPoweredBy").withSkipHeaderRecord(true)
.parse(in);
} catch (IOException e) {
e.printStackTrace();
}
for (CSVRecord server : serverInfo) {
String ServerName = server.get("ServerName");
String ServerAddress = server.get("ServerAddress");
String expectedWebSvr = server.get("ExpectedWebServer");
String expectedPoweredBy = server.get("ExpectedPoweredBy");
ServerCheck sc = new ServerCheck(ServerName, ServerAddress,
expectedWebSvr, expectedPoweredBy, commands);
executor.execute(sc);
}
}
}