-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonitor.ts
More file actions
74 lines (66 loc) · 1.8 KB
/
monitor.ts
File metadata and controls
74 lines (66 loc) · 1.8 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import nodemailer = require("nodemailer");
import request = require("request");
import childProcess = require("child_process");
import { AppConfig, MailConfig, MailTransport } from './config'
const mailTransporter:nodemailer.Transport = new MailTransport().transporter;
console.log(mailTransporter);
process.exit();
const tests: ITest = {
request: [
{
"plexmediaserver": {
port: 32400,
hostname: `192.168.1.198`,
command: `sudo service plexmediaserver start`
}
}
]
}
const runTests = (testSuite?: string) => {
if (testSuite) {
console.log("?")
// Run single testsuite
}
else {
for (let i in tests) {
for (let test of tests[i]) {
for (let testName in test) {
let currentTest = test[testName];
console.log(currentTest);
request.get(`http://${currentTest.hostname}:${currentTest.port}`, {}, (error: Error, response, body) => {
if (error) {
let mailSetup = new MailConfig('ronnie.laugen@gmail.com', `ERROR FOR ${testName}`, JSON.stringify(error)).mailConfig
console.error(error);
if (currentTest.command) {
childProcess.exec(currentTest.command, (error, stdout, stderr) => {
if (error) console.error(error);
else if (stderr) console.error(stderr);
else console.info(stdout);
})
}
}
else
console.log(response.statusCode)
})
}
}
}
// Run all tests
}
}
runTests();
interface ITest {
request: {
[name: string]: {
port: number
hostname: string,
command?: string
}
}[],
mount: {
[name: string]: {
mountpoint: string,
command?: string
}
}
}