-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
54 lines (44 loc) · 1.19 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
43
44
45
46
47
48
49
50
51
52
53
54
import config from './config.js';
import httpMonitor from './monitors/httpMonitor.js';
import sslMonitor from './monitors/sslMonitor.js';
import dnsMonitor from './monitors/dnsMonitor.js';
import portMonitor from './monitors/portMonitor.js';
import pingMonitor from './monitors/pingMonitor.js';
import { CronJob } from 'cron';
import chalk from 'chalk';
import dotenv from 'dotenv';
dotenv.config();
async function runChecks() {
console.log(chalk.blue('Running checks...'));
// HTTP Checks
for (const site of config.httpMonitor.urls) {
await httpMonitor(site);
}
// SSL Checks
for (const site of config.sslMonitor.sites) {
await sslMonitor(site);
}
// DNS Checks
for (const site of config.dnsMonitor.sites) {
await dnsMonitor(site);
}
// Port Checks
for (const site of config.portMonitor.sites) {
await portMonitor(site);
}
// Ping Checks
for (const site of config.pingMonitor.sites) {
await pingMonitor(site);
}
}
// Initial run
runChecks();
// Schedule checks using CronJob
const job = new CronJob(
`*/${config.checkInterval / 1000} * * * * *`, // Run every `checkInterval` seconds
runChecks,
null,
true,
'America/Los_Angeles' // Adjust the time zone as needed
);
job.start();