Adding server status stuff

This commit is contained in:
Ubergeek 2019-07-07 19:57:58 +00:00
parent 8ee3c47c03
commit 02f8451fd5
3 changed files with 142 additions and 15 deletions

View File

@ -40,18 +40,4 @@ irc.tilde.chat/6697, or via a web chat interface located [here]().
Thunix hosts mirrors for several FOSS projects. You can see the full Thunix hosts mirrors for several FOSS projects. You can see the full
mirror list in the sidebar link. mirror list in the sidebar link.
<!-- Begin autogen content -->
# Server Status
Last update: 18:17
| Check | Status|
|---|---|
| sshd | GOOD|
| BZFlag\_Server | GOOD|
| Memory | GOOD|
| Minetest\_Server | GOOD|
| web\_site | GOOD|
| web\_site\_https| GOOD|
| imap | GOOD|
| smtp | GOOD|

8
includes/report Normal file
View File

@ -0,0 +1,8 @@
thunix.net,sshd,GOOD
thunix.net,BZFlag_Server,GOOD
thunix.net,Memory,GOOD
thunix.net,Minetest_Server,GOOD
thunix.net,web_site,GOOD
thunix.net,web_site_https,GOOD
thunix.net,imap,GOOD
thunix.net,smtp,GOOD

133
includes/server.php Normal file
View File

@ -0,0 +1,133 @@
<?php
/*
This code is Copyright(c) 2019 by ubergeek under the GPL 3 or later.
Parsedown is licensed under the MIT license.
*/
include('config.php');
include('parsedown-1.7.3/Parsedown.php');
include('parsedown-extra-0.7.1/ParsedownExtra.php');
$page = $_GET['page'];
$style = $_GET['style'];
$Parsedown = new Parsedown();
$Parsedown->setMarkupEscaped(true);
$ParsedownExtra = new ParsedownExtra();
if ( $page == "") {
$page = "main";
}
if ( $style == "") {
if ( $site_style == "") {
$site_style="site";
}
}
else {
$site_style=$style;
}
$header = file_get_contents("$doc_root/includes/header.md");
$sidebar = file_get_contents("$doc_root/includes/sidebar.md");
$content = file_get_contents("$doc_root/articles/server.md");
$footer = file_get_contents("$doc_root/includes/footer.md");
print "<!DOCTYPE html>
<html lang='en'>
<head>
<title>$site_name - $page</title>
<link rel='stylesheet' type='text/css' href='$site_root/includes/$site_style.css'>
</head>
<body>
<!-- Begin Header -->
<div id='header'>";
print $Parsedown->text($header);
print "
</div>
<!-- End Header -->
";
print "<hr>
<div id='body'>
<!-- Begin Sidebar -->
<div id='sidebar'>
";
echo $Parsedown->text($sidebar);
print " </div>
<!-- End Sidebar -->
<!-- Begin Body -->
<div id='content'>";
echo $ParsedownExtra->text($content);
// Monitoring section
$hosts="all";
$f = fopen("./report", "r");
echo "Last update: " . date ("H:i", filemtime('./report'))."<p>\n";
echo "<table style='width:80%'>";
echo " <tr>
<th>Host</th>
<th>Check</th>
<th>Status</th>
</tr>";
while (($line = fgetcsv($f)) !== false) {
echo "<tr>";
if ($hosts == "failed" ) {
if ($line[2] == "FAILED") {
foreach ($line as $cell) {
if ($cell == "FAILED") {
echo '<td style="color:#FF0000">' . htmlspecialchars($cell) . '</td>';
}
else {
echo "<td>" .htmlspecialchars($cell) . "</td>";
}
}
}
}
elseif ($hosts == "all") {
foreach ($line as $cell) {
if ($cell == "FAILED") {
echo '<td style="color:#FF0000">' . htmlspecialchars($cell) . '</td>';
}
elseif ($cell=="GOOD") {
echo '<td style="color:#00FF00">' . htmlspecialchars($cell) . "</td>";
}
else {
echo "<td>" .htmlspecialchars($cell) . "</td>";
}
}
}
echo "</tr>\n";
}
echo "\n</table>\n";
fclose($f);
// End monitoring section
print " </div>
<!-- End Body -->
</div>
<!-- Begin Footer -->
<div id='footer'>
<hr>
";
echo $Parsedown->text($footer);
print " </div>
<!-- End Footer -->
</body>
</html>";
?>