-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonitoring.php
56 lines (49 loc) · 959 Bytes
/
monitoring.php
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
<?php
include_once 'db-config.php';
$servers = [
"google.com",
"wp.pl",
"lowendtalk.com"
];
$status = [];
foreach ($servers as $server) {
$pingresult = exec("ping -n 1 $server", $outcome, $status);
if (0 == $status) {
$status[$server] = [
'status' => 'UP',
'color' => 'green'
];
} else {
$status[$server] = [
'status' => 'DOWN',
'color' => 'red'
];
}
}
?>
<html>
<head>
<style>
.status_up {
color: green;
}
.status_down {
color: red;
}
</style>
</head>
<body>
<table>
<tr>
<th>Server</th>
<th>Status</th>
</tr>
<?php foreach ($status as $server => $data): ?>
<tr>
<td><?php echo $server; ?></td>
<td class="status_<?php echo strtolower($data['status']); ?>"><?php echo $data['status']; ?></td>
</tr>
<?php endforeach; ?>
</table>
</body>
</html>