Skip to content

Commit

Permalink
web: Add server detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
donald committed Apr 19, 2020
1 parent 405bfcb commit c487c6c
Showing 1 changed file with 60 additions and 2 deletions.
62 changes: 60 additions & 2 deletions web/pages/mxq/mxq.in
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,62 @@ sub group {
return $out;
}

sub server_detail {
my ($daemon_id) = @_;
$dbh or db_init();
my $out=h1('MXQ DAEMON '.$daemon_id);
my @cols=qw(
daemon_id daemon_name
status hostname mxq_version boot_id pid_starttime
daemon_pid daemon_slots daemon_memory daemon_maxtime
daemon_memory_limit_slot_soft daemon_memory_limit_slot_hard
daemon_jobs_running daemon_slots_running
daemon_threads_running daemon_memory_used
mtime daemon_start daemon_stop daemon_flags prerequisites
);
my $sth=$dbh->prepare('SELECT '.join(',',@cols).' FROM mxq_daemon WHERE daemon_id=? LIMIT 1', undef);
$sth->execute($daemon_id);
my %o=%{$sth->fetchrow_hashref('NAME_lc')};

$out.=<<"EOF";
<pre>
daemon_id : $o{daemon_id}
daemon_name : $o{daemon_name}
status : $o{status}
hostname : $o{hostname}
mxq_version : $o{mxq_version}
boot_id ; $o{boot_id}
pid_starttime : $o{pid_starttime}
daemon_pid : $o{daemon_pid}
daemon_slots : $o{daemon_slots}
daemon_memory : $o{daemon_memory}
daemon_maxtime : $o{daemon_maxtime}
daemon_memory_limit_slot_soft : $o{daemon_memory_limit_slot_soft}
daemon_memory_limit_slot_hard : $o{daemon_memory_limit_slot_hard}
daemon_jobs_running : $o{daemon_jobs_running}
daemon_slots_running : $o{daemon_slots_running}
daemon_threads_running : $o{daemon_threads_running}
daemon_memory_used : $o{daemon_memory_used}
mtime : $o{mtime}
daemon_start : $o{daemon_start}
daemon_stop : $o{daemon_stop}
daemon_flags : $o{daemon_flags}
prerequisites : $o{prerequisites}
</pre>
EOF
}


sub job {
my ($job_id)=@_;

Expand Down Expand Up @@ -764,6 +820,7 @@ sub active_jobs() {
return h1('MXQ Running Jobs').job_table_running().h1('MXQ Pending Jobs').job_table_pending();
}


sub server() {
$dbh or db_init();
$hostconfig or hostconfig_init();
Expand All @@ -784,7 +841,6 @@ sub server() {

$out.='<table class="server">';


$out.=$q->Tr($q->th([
'id',
'name',
Expand Down Expand Up @@ -832,7 +888,7 @@ sub server() {
delete($dead_hosts->{$hostname});

$out.=$q->Tr(
$q->td({class=>'number'},$daemon_id),
$q->td({class=>'number'},$q->a({href=>selfurl("/server/$daemon_id")},$daemon_id)),
$q->td($daemon_name),
$q->td(daemon_status($status)),
$q->td($hostname),
Expand Down Expand Up @@ -903,6 +959,8 @@ if ($path_info eq '') {
print header().HEAD().top_menu().group($1,$2);
} elsif ($path_info =~ /\/job\/(\d+)$/) {
print header().HEAD().top_menu().job($1);
} elsif ($path_info =~ /\/server\/(\d+)$/) {
print header().HEAD().top_menu().server_detail($1);
} else {
print header(-status => 404).HEAD().top_menu().'<h1>not found</h1>';
}

0 comments on commit c487c6c

Please sign in to comment.