Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Server check service
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Jul 12, 2021
1 parent e39bab0 commit 91747a3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions public/status.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

require_once "../vendor/autoload.php";

$dotenv = Dotenv\Dotenv::createImmutable(realpath(__DIR__ . '/../'));
$dotenv->load();

include "../src/status/main.php";
20 changes: 20 additions & 0 deletions src/status/main.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

if (!isset($_GET['secret'])) exit;
if ($_GET['secret'] !== $_SERVER['SECRET_TOKEN']) exit;

$services = ['iptables', 'ip6tables', 'mariadb', 'named', 'nginx', 'php-fpm', 'postgresql', 'proftpd', 'sshd', 'webmin'];
$services_ans = [];
foreach ($services as $s) {
$services_ans[$s] = shell_exec("systemctl is-active $s");
}
header('content-type: application/json');
echo json_encode([
'uptime' => shell_exec("uptime"),
'free' => shell_exec('free'),
'df' => [
'usage' => shell_exec('df -x tmpfs -x devtmpfs'),
'inode' => shell_exec('df -x tmpfs -x devtmpfs -i'),
],
'services' => $services_ans,
]);

0 comments on commit 91747a3

Please sign in to comment.