-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·47 lines (40 loc) · 1.57 KB
/
Copy pathcli.js
File metadata and controls
executable file
·47 lines (40 loc) · 1.57 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
#!/usr/bin/env node
const { checkServerHealth } = require('./src/healthCheck.js');
const { getSystemMetrics } = require('./src/metrics.js');
const { simulateLoad } = require('./src/loadTest.js');
const [,, command, ...args] = process.argv;
async function run() {
try {
switch (command) {
case 'healthcheck':
if (args.length < 1) {
console.log('Usage: hostcare check-server <url>');
return;
}
const url = args[0];
const health = await checkServerHealth(url);
break;
case 'loadtest':
if (args.length < 2) {
console.log('Usage: hostcare simulate-load <url> <requestCount>');
return;
}
const [loadUrl, requestCount] = args;
const loadResult = await simulateLoad(loadUrl, Number(requestCount));
break;
case 'metrics':
const metrics = getSystemMetrics();
break;
default:
console.log('Usage: hostcare <command>\n');
console.log('Commands:');
console.log(' healthcheck <url> Check the health of a server');
console.log(' loadtest <url> <count> Simulate load with multiple requests');
console.log(' metrics Display system metrics');
break;
}
} catch (error) {
console.error('Error:', error.message);
}
}
run();