49 lines
1.7 KiB
PHP
49 lines
1.7 KiB
PHP
<?php
|
|
// dashboard.php
|
|
|
|
require_once __DIR__ . '/../app/Helpers/AuthenticatedUserHelper.php';
|
|
|
|
// SNMP-Konfiguration
|
|
$community = 'public_ro';
|
|
$host = '127.0.0.1';
|
|
|
|
snmp_set_quick_print(true);
|
|
snmp_set_oid_output_format(SNMP_OID_OUTPUT_NUMERIC);
|
|
|
|
// CPU-Last (erster Kern, Beispiel)
|
|
$cpu_oid = '.1.3.6.1.2.1.25.3.3.1.2.1';
|
|
$cpu_load = @snmpget($host, $community, $cpu_oid, 1000000, 2);
|
|
|
|
// System Uptime
|
|
$uptime_oid = '.1.3.6.1.2.1.25.1.1.0';
|
|
$uptime_raw = @snmpget($host, $community, $uptime_oid);
|
|
$uptime = $uptime_raw ? ($uptime_raw / (100 * 60 * 60 * 24)) . " Tage" : "Fehler";
|
|
|
|
// RAM (statisches Beispiel mit Index 5)
|
|
$ram_total_oid = '.1.3.6.1.2.1.25.2.3.1.5.5';
|
|
$ram_used_oid = '.1.3.6.1.2.1.25.2.3.1.6.5';
|
|
$ram_alloc_units_oid = '.1.3.6.1.2.1.25.2.3.1.4.5';
|
|
|
|
$ram_total_raw = @snmpget($host, $community, $ram_total_oid);
|
|
$ram_used_raw = @snmpget($host, $community, $ram_used_oid);
|
|
$ram_units = @snmpget($host, $community, $ram_alloc_units_oid);
|
|
|
|
if ($ram_total_raw && $ram_used_raw && $ram_units) {
|
|
$ram_total_gb = ($ram_total_raw * $ram_units) / (1024 ** 3);
|
|
$ram_used_gb = ($ram_used_raw * $ram_units) / (1024 ** 3);
|
|
$ram_percent = ($ram_used_gb / $ram_total_gb) * 100;
|
|
}
|
|
?>
|
|
<h2>Admin Dashboard</h2>
|
|
<p>Angemeldet als: <?php echo htmlspecialchars($_SESSION['username']); ?></p>
|
|
|
|
<h3>Server-Status (SNMP)</h3>
|
|
<p>CPU-Last (Kern 1): <?php echo $cpu_load ?: "Fehler bei Abfrage"; ?>%</p>
|
|
<p>System Uptime: <?php echo $uptime; ?></p>
|
|
<p>RAM-Auslastung:
|
|
<?php echo isset($ram_percent) ? number_format($ram_percent, 2) . "%" : "Fehler bei Abfrage"; ?>
|
|
</p>
|
|
|
|
<hr>
|
|
<p><a href="create_single_user.php">Einzelnen Benutzer erstellen</a></p>
|
|
<p><a href="bulk_create_users.php">Benutzer per CSV importieren</a></p>
|