Skip to content

Commit

Permalink
Added status page in index
Browse files Browse the repository at this point in the history
  • Loading branch information
br3jski authored Feb 10, 2023
1 parent a65405a commit 6f2327f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# lwa
LWA - Linux server management (multi-platform) with web ui

**Requirements: **
**Requirements**
- Apache2/Nginx
- PHP with PHP-Mysql extension
- PHP with PHP-Mysqli extension
- MariaDB Database

**Configure credentials in db-config.php file**
36 changes: 36 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
include_once 'db-config.php';

$services = array("sshd", "apache2");

$conn = mysqli_connect($host, $user, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}

echo "<table border='1'>";
echo "<tr>";
echo "<th>Service Name</th>";
echo "<th>Status</th>";
echo "</tr>";

foreach ($services as $service) {
$output = shell_exec("systemctl is-active $service");
$status = trim($output);

echo "<tr>";
echo "<td>" . $service . "</td>";

if ($status == "active") {
echo "<td style='background-color: green;'>" . $status . "</td>";
} else {
echo "<td style='background-color: red;'>" . $status . "</td>";
}

echo "</tr>";
}

echo "</table>";

mysqli_close($conn);
?>

0 comments on commit 6f2327f

Please sign in to comment.