Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
br3jski authored Feb 10, 2023
1 parent 6f2327f commit d5edc19
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions monitoring.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,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>

0 comments on commit d5edc19

Please sign in to comment.