Diff -- /var/www/vhosts/3dshawn.com/site1/servers.cgi
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
to e9d45d948070
Unified diff
Naive LCS-based line diff. Additions in emerald, deletions in rose. Both sides decompressed live from BLOB_STORE.| 1 | #!/usr/bin/perl | |
| 2 | use strict; use warnings; use CGI (); | |
| 3 | use MODS::Config; use MODS::DBConnect; use MODS::Template; use MODS::PageWrapper; | |
| 4 | my $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"; | |
| 6 | my $dbh = $db->db_connect or die "DB connect failed\n"; | |
| 7 | my @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__); | |
| 13 | foreach 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 | ||
| 20 | my @body = $tpl->template('servers.html', | |
| 21 | { rows => \@rows, has_rows => scalar(@rows) ? 1 : 0, total => scalar @rows }); | |
| 22 | MODS::PageWrapper->new->wrapper( | |
| 23 | page_title => 'Servers & agents', page_key => 'servers', | |
| 24 | body_html => join('', @body), userinfo => { display_name => 'Operator' }, | |
| 25 | ); |