init commit
This commit is contained in:
commit
9731cf88e1
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "java",
|
||||
"name": "Launch App",
|
||||
"request": "launch",
|
||||
"mainClass": "App",
|
||||
"projectName": "JavaPingReport_ce27afdc",
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"java.project.sourcePaths": [
|
||||
"src"
|
||||
],
|
||||
"java.project.outputPath": "bin",
|
||||
"java.project.referencedLibraries": [
|
||||
"lib/**/*.jar"
|
||||
],
|
||||
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms100m"
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,18 @@
|
|||
## Getting Started
|
||||
|
||||
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
|
||||
|
||||
## Folder Structure
|
||||
|
||||
The workspace contains two folders by default, where:
|
||||
|
||||
- `src`: the folder to maintain sources
|
||||
- `lib`: the folder to maintain dependencies
|
||||
|
||||
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
|
||||
|
||||
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
|
||||
|
||||
## Dependency Management
|
||||
|
||||
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
|
Binary file not shown.
|
@ -0,0 +1,204 @@
|
|||
AcademyUL,10.127.0.70
|
||||
AcademyUL2nd,10.127.0.74
|
||||
Union City BOE,10.127.0.14
|
||||
WestNYMHSAnnexA,10.127.0.18
|
||||
WestNYBOE,10.127.0.22
|
||||
WestNYECS,10.127.0.26
|
||||
WestNYMHSAnnexB,10.127.0.30
|
||||
WestNYPS1,10.127.0.34
|
||||
WestNYPS2,10.127.0.38
|
||||
WestNYPS3,10.127.0.42
|
||||
WestNYPS3Annex,10.127.0.46
|
||||
WestNYPS4,10.127.0.50
|
||||
WestNYPS4Annex,10.127.0.54
|
||||
WestNYPS5,10.127.0.58
|
||||
WestNYPS6,10.127.0.62
|
||||
WestNYMiddle,10.127.0.66
|
||||
Lenape Valley,10.127.0.82
|
||||
WayneRyerson,10.127.0.90
|
||||
Hackensack ,10.127.0.86
|
||||
AndoverLongPond,10.127.0.94
|
||||
AndoverFlorence,10.127.0.98
|
||||
MineHill,10.127.0.114
|
||||
Keyport,10.127.0.118
|
||||
PennsvilleBOE,10.127.0.122
|
||||
PennsvilleHS,10.127.0.126
|
||||
PennsvilleMS,10.127.0.130
|
||||
PennsvilleVP,10.127.0.134
|
||||
PennsvilleCP,10.127.0.138
|
||||
PennsvillePB,10.127.0.142
|
||||
FairLawnHBM,10.127.1.134
|
||||
FairLawnJAF,10.127.1.138
|
||||
FairLawnLYN,10.127.1.142
|
||||
FairLawnMMS,10.127.1.146
|
||||
FairLawnRAD,10.127.1.150
|
||||
FairLawnTE,10.127.1.154
|
||||
FairLawnTJ,10.127.1.158
|
||||
FairLawnWP,10.127.1.162
|
||||
FairLawnWES,10.127.1.166
|
||||
FairLawnHS,10.127.1.170
|
||||
LeoniaHS,10.127.1.226
|
||||
LeoniaMS,10.127.1.230
|
||||
LeoniaACS,10.127.1.234
|
||||
Hunter 911InformNOC,10.127.0.102
|
||||
Hawthorne Schools,10.127.0.6
|
||||
Jody Demo,10.127.0.106
|
||||
Scott Demo,10.127.0.110
|
||||
EastBrunswickBOE,10.127.0.146
|
||||
Support Operation Building,10.127.0.150
|
||||
Irwin Elementary,10.127.0.154
|
||||
Bowne-Munro,10.127.0.158
|
||||
Frost Elementary,10.127.0.162
|
||||
Chittick Elementary ,10.127.0.166
|
||||
Churchill Junior High School,10.127.0.170
|
||||
High School,10.127.0.174
|
||||
Central Elementary ,10.127.0.178
|
||||
Hammarskjold Middle School,10.127.0.182
|
||||
Lawrence Brook Elementary,10.127.0.186
|
||||
Memorial Elementary,10.127.0.190
|
||||
Warnsdorfer Elementary,10.127.0.194
|
||||
Georgia Demo,10.127.0.198
|
||||
Trade Show Booth 1,10.127.0.202
|
||||
Trade Show Booth 2,10.127.0.206
|
||||
Trade Show Booth 3,10.127.0.210
|
||||
Trade Show Booth 4,10.127.0.214
|
||||
Avaya EBC,10.127.0.222
|
||||
CiscoDemo,10.127.0.226
|
||||
chrispierce,10.127.0.230
|
||||
SouthRiverEM,10.127.0.234
|
||||
SouthRiverHS,10.127.0.238
|
||||
SouthRiverBOE,10.127.0.242
|
||||
SouthRiverPS,10.127.0.246
|
||||
Byram,10.127.0.250
|
||||
Wayne Hills HS,10.127.0.254
|
||||
Wayne Valley HS,10.127.1.2
|
||||
PatersonDemo,10.127.1.6
|
||||
MilltownJK,10.127.1.10
|
||||
MilltownPV,10.127.1.14
|
||||
Lakewood,10.127.1.22
|
||||
Collier Youth,10.127.1.18
|
||||
LakewoodMuni,10.127.1.42
|
||||
MargateRoss,10.127.1.50
|
||||
MargateTighe,10.127.1.54
|
||||
HighlandParkHS,10.127.1.58
|
||||
HighlandParkPS,10.127.1.62
|
||||
HighlandParkES,10.127.1.66
|
||||
AllegiantDemo1,10.127.1.70
|
||||
AllegiantDemo2,10.127.1.74
|
||||
RumsonFairHaven,10.127.1.46
|
||||
MorrisHills,10.127.1.82
|
||||
OmniData,10.127.1.86
|
||||
RutherfordWS,10.127.1.90
|
||||
RutherfordLS,10.127.1.94
|
||||
RutherfordUS,10.127.1.98
|
||||
RutherfordPS,10.127.1.102
|
||||
RutherfordKC,10.127.1.106
|
||||
RutherfordHS,10.127.1.110
|
||||
RumsonSchoolDistrict,10.127.1.122
|
||||
MorrisKnoll,10.127.1.78
|
||||
ValleyHealth,10.127.1.126
|
||||
LaceyHS,10.127.1.174
|
||||
LaceyMS,10.127.1.178
|
||||
LaceyMPES,10.127.1.182
|
||||
LaceyCCES,10.127.1.186
|
||||
LaceyFRES,10.127.1.190
|
||||
LaceyLHES,10.127.1.194
|
||||
MorrisCountyVoc,10.127.1.218
|
||||
MorrisCountyESC,10.127.1.222
|
||||
chetuTest,10.127.1.238
|
||||
Hamilton,10.127.1.118
|
||||
EssexDP,10.127.1.246
|
||||
EssexNT,10.127.1.250
|
||||
EssexWCT,10.127.1.254
|
||||
NOLA,10.127.2.2
|
||||
StJohnofGod,10.127.2.6
|
||||
UCBOEG2,10.127.2.10
|
||||
MikeTarpley,10.127.2.14
|
||||
CBCHS,10.127.2.18
|
||||
GreaterBrunswick,10.127.2.22
|
||||
WayneTheunisDay,10.127.2.26
|
||||
WayneAnthonyWayne,10.127.2.42
|
||||
WaynePackanack,10.127.2.46
|
||||
WaynePinesLake,10.127.2.50
|
||||
WaynePreakness,10.127.2.54
|
||||
WayneJamesFallon,10.127.2.58
|
||||
PrincetonJohnsonPark,10.127.2.62
|
||||
PrincetonLittleBrook,10.127.2.66
|
||||
PrincetonRiverside,10.127.2.70
|
||||
PrincetonJohnWitherspoon,10.127.2.74
|
||||
PrincetonHS,10.127.2.78
|
||||
PrincetonCommunityPark,10.127.2.82
|
||||
ChathamHS,10.127.2.86
|
||||
ChathamMS,10.127.2.90
|
||||
ChathamLS,10.127.2.94
|
||||
ChathamMAS,10.127.2.98
|
||||
ChathamSBS,10.127.2.102
|
||||
ChathamWAS,10.127.2.106
|
||||
HolmdelIndianHill,10.127.2.110
|
||||
HolmdelVillage,10.127.2.114
|
||||
HolmdelHS,10.127.2.118
|
||||
GCCC,10.127.2.122
|
||||
BridgetonHS,10.127.2.126
|
||||
BridgetonMS,10.127.2.130
|
||||
BridgetonBRS,10.127.2.134
|
||||
BridgetonCSS,10.127.2.138
|
||||
BridgetonIAS,10.127.2.142
|
||||
BridgetonQMLS,10.127.2.146
|
||||
BridgetonWAS,10.127.2.150
|
||||
BridgetonEP,10.127.2.154
|
||||
BerkeleyBayvilleLTE,10.127.2.158
|
||||
BerkeleyCBWSLTE,10.127.2.162
|
||||
BerkeleyHMPSLTE,10.127.2.166
|
||||
BerkeleyTransportationLTE,10.127.2.170
|
||||
OrlandoJewish,10.127.2.174
|
||||
ValleyHealthHospital,10.127.2.182
|
||||
DenvilleVV,10.127.2.186
|
||||
DenvilleLV,10.127.2.190
|
||||
DenvilleRVM,10.127.2.194
|
||||
DenvilleRVA,10.127.2.198
|
||||
ValleyHealth960,10.127.2.202
|
||||
ValleyHealthDEB,10.127.2.206
|
||||
ValleyHealthDBK,10.127.2.210
|
||||
ValleyHealthILS,10.127.2.214
|
||||
ValleyHealthVMGC,10.127.2.218
|
||||
ValleyHealthVMGW,10.127.2.222
|
||||
ValleyHealthVC,10.127.2.226
|
||||
PointPleasantOE,10.127.2.230
|
||||
PointPleasantNBE,10.127.2.234
|
||||
PointPleasantMS,10.127.2.238
|
||||
PointPleasantHS,10.127.2.242
|
||||
PointPleasantBOE,10.127.2.246
|
||||
WayneTerhune,10.127.2.250
|
||||
WayneCarter,10.127.2.254
|
||||
WayneWashington,10.127.3.2
|
||||
WayneBOE,10.127.3.6
|
||||
ValleyHealthLuckow,10.127.3.10
|
||||
MITSVCS,10.127.3.18
|
||||
ClintonPS,10.127.3.26
|
||||
ClintonLGJ,10.127.3.30
|
||||
ClintonMHS,10.127.3.34
|
||||
BayheadES,10.127.3.58
|
||||
wrappertest,10.127.0.218
|
||||
RFHPod,10.127.1.130
|
||||
HackensackHMSCam,10.127.1.26
|
||||
HackensackHHSCam,10.127.1.30
|
||||
HackensackE1Cam,10.127.1.34
|
||||
HackensackE2Cam,10.127.1.38
|
||||
PennsvilleHSCam,10.127.1.198
|
||||
PennsvilleMSCam,10.127.1.202
|
||||
PennsvilleVPCam,10.127.1.206
|
||||
PennsvilleCPCam,10.127.1.210
|
||||
PennsvillePBCam,10.127.1.214
|
||||
EducationAcademy,10.127.1.242
|
||||
FairwaysGate1,10.127.2.30
|
||||
FairwaysGate2,10.127.2.34
|
||||
FairwaysMain,10.127.2.38
|
||||
CityofCarson,10.127.2.178
|
||||
SpringLakeMuni,10.127.3.14
|
||||
HCSPlannedCompanies,10.127.3.22
|
||||
FGCU,10.127.1.114
|
||||
HCSHumanServices,10.127.3.38
|
||||
HCSSummitFreePublicLibrary,10.127.3.42
|
||||
PanasonicShip,10.127.3.46
|
||||
HCSBOHP,10.127.3.50
|
||||
HCSUCBOE,10.127.3.54
|
|
|
|
@ -0,0 +1,116 @@
|
|||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.net.Inet4Address;
|
||||
import java.util.Scanner;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class App {
|
||||
public static int pingAmount = 5;
|
||||
public static int threadCount = 4;
|
||||
|
||||
public static boolean killLoggingThread = false;
|
||||
|
||||
public static ExecutorService workerThread = Executors.newFixedThreadPool(threadCount);
|
||||
public static BlockingQueue<String> printQueue = new ArrayBlockingQueue<String>(1024);
|
||||
public static BlockingQueue<String> fileQueue = new ArrayBlockingQueue<String>(1024);
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
//Var dec
|
||||
Vector<String[]> requestedPings = new Vector<String[]>();
|
||||
File pingRequests = new File("pingRequests.csv");
|
||||
File pingResults = new File("pingResults.csv");
|
||||
FileWriter pingResultsWriter = new FileWriter(pingResults);
|
||||
Scanner FScanner = new Scanner(pingRequests);
|
||||
|
||||
System.out.println("Reading file...");
|
||||
// Populate vector
|
||||
do{
|
||||
requestedPings.add(FScanner.nextLine().split(","));
|
||||
} while (FScanner.hasNextLine());
|
||||
FScanner.close();
|
||||
|
||||
System.out.println("Setting up output file...");
|
||||
// See if the file exists
|
||||
if(!pingResults.exists())
|
||||
pingResults.createNewFile();
|
||||
|
||||
// Make sure I can read/write to file
|
||||
if(!pingResults.canRead() && !pingResults.canWrite()) {
|
||||
System.out.println("Can't read/write to file. Aborting");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
// Clear file and set title line
|
||||
pingResultsWriter.write("device,ip,status\n");
|
||||
|
||||
System.out.println("Pinging...\n---");
|
||||
// Ping and append to file
|
||||
requestedPings.forEach((x) -> {
|
||||
// Build runnable
|
||||
Runnable rPing = () -> {
|
||||
try {
|
||||
float passCount = 0;
|
||||
for(int i = 0; i < pingAmount; i++)
|
||||
if(Inet4Address.getByName(x[1]).isReachable(5000))
|
||||
passCount++;
|
||||
if(passCount/pingAmount > 0.5) {
|
||||
printQueue.add(x[0] + " is up");
|
||||
fileQueue.add(x[0] + "," + x[1] + ",up\n");
|
||||
} else {
|
||||
printQueue.add(x[0] + " is \u001B[31mdown\u001B[0m");
|
||||
fileQueue.add(x[0] + "," + x[1] + ",down\n");
|
||||
}
|
||||
} catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
};
|
||||
// Add to the execute stack and execute it
|
||||
workerThread.execute(rPing);
|
||||
});
|
||||
|
||||
Runnable rLog = () -> {
|
||||
try {
|
||||
while(!killLoggingThread){
|
||||
if(!printQueue.isEmpty())
|
||||
System.out.println(printQueue.take());
|
||||
if(!fileQueue.isEmpty())
|
||||
pingResultsWriter.append(fileQueue.take());
|
||||
}
|
||||
} catch(IOException ioe){
|
||||
ioe.printStackTrace();
|
||||
} catch(InterruptedException ie){
|
||||
ie.printStackTrace();
|
||||
}
|
||||
};
|
||||
|
||||
// Create logging thread
|
||||
Thread logThread = new Thread(rLog);
|
||||
logThread.start();
|
||||
|
||||
// Tell the worker queue we're ready to shutdown
|
||||
workerThread.shutdown();
|
||||
try {
|
||||
// Wait one hour for the threads to finish
|
||||
if (!workerThread.awaitTermination(1, TimeUnit.HOURS)) {
|
||||
workerThread.shutdownNow();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
workerThread.shutdownNow();
|
||||
}
|
||||
|
||||
// Interrupt the log thread
|
||||
killLoggingThread = true;
|
||||
logThread.join();
|
||||
|
||||
// Write and save file
|
||||
System.out.println("---\nWriting to file...");
|
||||
pingResultsWriter.close();
|
||||
System.out.print("Complete! Exiting\n");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue