Diff -- /var/www/vhosts/3dshawn.com/site1/servers.cgi

O Operator
Diff

/var/www/vhosts/3dshawn.com/site1/servers.cgi

added on local at 2026-07-10 18:57:31

Added
+25
lines
Removed
-0
lines
Context
0
unchanged
Blobs
from
to e9d45d948070
Restore this content →
Unified diff
Naive LCS-based line diff. Additions in emerald, deletions in rose. Both sides decompressed live from BLOB_STORE.
1#!/usr/bin/perl
2use strict; use warnings; use CGI ();
3use MODS::Config; use MODS::DBConnect; use MODS::Template; use MODS::PageWrapper;
4my $db = MODS::DBConnect->new; my $tpl = MODS::Template->new;
5$|=1; print "Content-Type: text/html; charset=utf-8\nCache-Control: no-cache\n\n";
6my $dbh = $db->db_connect or die "DB connect failed\n";
7my @rows = $db->db_readwrite_multiple($dbh, q~
8 SELECT server_id, server_name, hostname, ip_address, role, agent_version, status,
9 DATE_FORMAT(last_heartbeat_at, '%b %d, %Y %H:%i') AS heartbeat_h,
10 DATE_FORMAT(created_at, '%b %d, %Y') AS created_h
11 FROM SERVERS ORDER BY (status='active') DESC, server_id ASC
12~, __FILE__, __LINE__);
13foreach my $r (@rows) {
14 $r->{status_pill} = $r->{status} eq 'active' ? 'pill-ok' :
15 $r->{status} eq 'offline' ? 'pill-bad' : 'pill-mute';
16 $r->{heartbeat_h} //= 'never';
17}
18$db->db_disconnect($dbh);
19
20my @body = $tpl->template('servers.html',
21 { rows => \@rows, has_rows => scalar(@rows) ? 1 : 0, total => scalar @rows });
22MODS::PageWrapper->new->wrapper(
23 page_title => 'Servers & agents', page_key => 'servers',
24 body_html => join('', @body), userinfo => { display_name => 'Operator' },
25);