Examples

A /vitals endpoint in your language.

Each example answers the Kumo Tabs request: it reads the stored hash (from VITALS_TOKEN_HASH, or the settings page of the WordPress plugin and the PrestaShop module), answers 404 when there is none and 401 for a wrong token, then sends a JSON report. Copy one, rename My app, deploy it behind HTTPS, and add the server in Kumo Tabs. The server setup page explains every field, if you want to report more.

PHP

One file, no framework: PHP and opcache, web server, load, memory, disk, and an optional PDO database check.

vitals.php
<?php
// vitals.php: Kumo Tabs endpoint for plain PHP 8.1+ (Linux).
// Serve it at https://example.com/vitals (or /vitals.php) and set VITALS_TOKEN_HASH
// to the hash shown in Kumo Tabs, e.g. in Apache: SetEnv VITALS_TOKEN_HASH <hash>

declare(strict_types=1);

$hash = strtolower((string) getenv('VITALS_TOKEN_HASH'));
if ($hash === '') {
	http_response_code(404);
	exit;
}

$token = $_SERVER['HTTP_X_VITALS_TOKEN'] ?? '';
if (!hash_equals($hash, hash('sha256', $token))) {
	http_response_code(401);
	exit;
}

/** MemTotal and MemAvailable from /proc/meminfo, in bytes */
function memory(): ?array
{
	$info = @file_get_contents('/proc/meminfo');
	if ($info === false) {
		return null;
	}
	preg_match('/MemTotal:\s+(\d+)/', $info, $total);
	preg_match('/MemAvailable:\s+(\d+)/', $info, $available);

	return ['total' => (int) $total[1] * 1024, 'free' => (int) $available[1] * 1024];
}

$software = $_SERVER['SERVER_SOFTWARE'] ?? '';
$report = [
	'ok' => true,
	'app' => ['name' => 'My app'],
	'php' => [
		'version' => PHP_VERSION,
		'sapi' => PHP_SAPI,
		'opcache' => (bool) (function_exists('opcache_get_status') ? (opcache_get_status(false)['opcache_enabled'] ?? false) : false),
	],
	'server' => [
		'software' => $software,
		'os' => php_uname('s') . ' ' . php_uname('r'),
		'uptime' => (int) (float) @file_get_contents('/proc/uptime'),
		'load' => function_exists('sys_getloadavg') ? (sys_getloadavg() ?: null) : null,
		'cpus' => preg_match_all('/^processor/m', (string) @file_get_contents('/proc/cpuinfo')) ?: null,
		'memory' => memory(),
		'disk' => ['total' => disk_total_space('/'), 'free' => disk_free_space('/')],
	],
	'dependencies' => [
		['name' => 'PHP', 'group' => 'runtime', 'version' => PHP_VERSION],
	],
];

// "Apache/2.4.58 (Ubuntu)" or "nginx/1.26.2": checked against their releases
if (preg_match('#^(Apache|nginx)/([\d.]+)#', $software, $match)) {
	$report['dependencies'][] = ['name' => $match[1], 'group' => 'server', 'version' => $match[2]];
}

// Optional database check: set DB_DSN (e.g. mysql:host=localhost;dbname=app), DB_USER, DB_PASSWORD
if (getenv('DB_DSN')) {
	try {
		$pdo = new PDO(getenv('DB_DSN'), getenv('DB_USER') ?: null, getenv('DB_PASSWORD') ?: null, [
			PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
			PDO::ATTR_TIMEOUT => 2,
		]);
		$start = hrtime(true);
		$pdo->query('SELECT 1');
		$latency = round((hrtime(true) - $start) / 1e6, 2);
		$version = (string) $pdo->query('SELECT VERSION()')->fetchColumn();

		$report['db'] = ['ok' => true, 'version' => $version, 'latencyMs' => $latency];
		$report['dependencies'][] = [
			'name' => str_contains($version, 'MariaDB') ? 'MariaDB' : 'MySQL',
			'group' => 'database',
			'version' => preg_replace('/^([\d.]+).*/', '$1', $version),
		];
	} catch (PDOException) {
		$report['db'] = ['ok' => false];
	}
}

header('Content-Type: application/json');
header('Cache-Control: no-store');
echo json_encode($report);