-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (36 loc) · 1.23 KB
/
index.js
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
const isPortReachable = require('is-port-reachable');
var ping = require('ping');
const logSymbols = require('log-symbols');
var config = require('./config.json')
async function main(){
console.log("starting\n")
var host = "8.8.8.8"
console.log("testing internet connectivity\n")
ping.promise.probe(host).then((response) => {
if(response.alive === true){
console.log(`google\t=\t${logSymbols.success}\n`)
}
else(console.log(`google\t=\t${logSymbols.error}\n`))
checkdevices();
})
}
main()
async function checkdevices() {
console.log("starting internal device checks\n");
var devices = config.devices;
for (i in devices){
console.log(`Checking device: ${devices[i].Name}`);
console.log(`on: ${devices[i].ip}`)
var services = devices[i].services;
for(j in services){
var value= await isPortReachable(services[j].port, {host: `${devices[i].ip}`})
if (value == true) {
console.log(`${services[j].name} \t= \t ${logSymbols.success}`);
}
else
(
console.log(`${services[j].name}\t=\t ${logSymbols.error}`)
);
}
}
}