This commit is contained in:
PaulVua
2025-05-23 14:08:21 +02:00
parent 1b8dc54fe0
commit 2516a3bd1c
2 changed files with 42 additions and 16 deletions

View File

@@ -197,16 +197,17 @@
<table class="table table-sm table-hover mb-0"> <table class="table table-sm table-hover mb-0">
<thead class="table-light"> <thead class="table-light">
<tr> <tr>
<th style="width: 25%">Service</th> <th style="width: 20%">Service</th>
<th style="width: 30%">Description</th> <th style="width: 25%">Description</th>
<th style="width: 12%">Status</th> <th style="width: 15%">Frequency</th>
<th style="width: 12%">Enabled</th> <th style="width: 10%">Status</th>
<th style="width: 21%">Actions</th> <th style="width: 10%">Enabled</th>
<th style="width: 20%">Actions</th>
</tr> </tr>
</thead> </thead>
<tbody id="services-tbody"> <tbody id="services-tbody">
<tr> <tr>
<td colspan="5" class="text-center py-3">Loading services...</td> <td colspan="6" class="text-center py-3">Loading services...</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -1015,6 +1016,12 @@ function displayServices(services) {
descCell.className = 'text-muted small'; descCell.className = 'text-muted small';
row.appendChild(descCell); row.appendChild(descCell);
// Frequency
const freqCell = document.createElement('td');
freqCell.textContent = service.frequency || 'Unknown';
freqCell.className = 'text-primary small fw-bold';
row.appendChild(freqCell);
// Status // Status
const statusCell = document.createElement('td'); const statusCell = document.createElement('td');
const statusBadge = document.createElement('span'); const statusBadge = document.createElement('span');
@@ -1061,7 +1068,7 @@ function showServiceError(message) {
const tbody = document.getElementById('services-tbody'); const tbody = document.getElementById('services-tbody');
tbody.innerHTML = ` tbody.innerHTML = `
<tr> <tr>
<td colspan="5" class="text-center text-danger"> <td colspan="6" class="text-center text-danger">
<i class="bi bi-exclamation-triangle"></i> ${message} <i class="bi bi-exclamation-triangle"></i> ${message}
</td> </td>
</tr> </tr>

View File

@@ -1027,19 +1027,37 @@ if ($type == "execute_command") {
// Get systemd services status // Get systemd services status
if ($type == "get_systemd_services") { if ($type == "get_systemd_services") {
try { try {
// List of NebuleAir services to monitor with descriptions // List of NebuleAir services to monitor with descriptions and frequencies
$services = [ $services = [
'nebuleair-npm-data.timer' => 'Collects particulate matter data from NextPM sensor', 'nebuleair-npm-data.timer' => [
'nebuleair-envea-data.timer' => 'Reads environmental data from Envea sensors', 'description' => 'Collects particulate matter data from NextPM sensor',
'nebuleair-sara-data.timer' => 'Transmits collected data via 4G cellular modem', 'frequency' => 'Every 10 seconds'
'nebuleair-bme280-data.timer' => 'Monitors temperature and humidity (BME280)', ],
'nebuleair-mppt-data.timer' => 'Tracks solar panel and battery status', 'nebuleair-envea-data.timer' => [
'nebuleair-db-cleanup-data.timer' => 'Cleans up old data from database' 'description' => 'Reads environmental data from Envea sensors',
'frequency' => 'Every 10 seconds'
],
'nebuleair-sara-data.timer' => [
'description' => 'Transmits collected data via 4G cellular modem',
'frequency' => 'Every 60 seconds'
],
'nebuleair-bme280-data.timer' => [
'description' => 'Monitors temperature and humidity (BME280)',
'frequency' => 'Every 2 minutes'
],
'nebuleair-mppt-data.timer' => [
'description' => 'Tracks solar panel and battery status',
'frequency' => 'Every 2 minutes'
],
'nebuleair-db-cleanup-data.timer' => [
'description' => 'Cleans up old data from database',
'frequency' => 'Daily'
]
]; ];
$serviceStatus = []; $serviceStatus = [];
foreach ($services as $service => $description) { foreach ($services as $service => $serviceInfo) {
// Get service active status // Get service active status
$activeCmd = "systemctl is-active " . escapeshellarg($service) . " 2>/dev/null"; $activeCmd = "systemctl is-active " . escapeshellarg($service) . " 2>/dev/null";
$activeStatus = trim(shell_exec($activeCmd)); $activeStatus = trim(shell_exec($activeCmd));
@@ -1057,7 +1075,8 @@ if ($type == "get_systemd_services") {
$serviceStatus[] = [ $serviceStatus[] = [
'name' => $service, 'name' => $service,
'display_name' => $displayName, 'display_name' => $displayName,
'description' => $description, 'description' => $serviceInfo['description'],
'frequency' => $serviceInfo['frequency'],
'active' => $isActive, 'active' => $isActive,
'enabled' => $isEnabled 'enabled' => $isEnabled
]; ];