[! use strict; use Proxmox::Utils; use Proxmox::HTMLTable; use Proxmox::Config::System; use Proxmox::ConfigServer; !] [- my $system_cfg = $fdat{__system_config}; my $lic = $system_cfg->{license}; my $cluster = $system_cfg->get ('administration', 'cluster'); my $url = $req_rec->uri; my $out; my $table_cl = Proxmox::HTMLTable->new ([]); my @header_cl = ('1', '100px', __('Node Name'), '1', '100px', __('IP Address'), '1', '50px', __('Role'), '1', '50px', __('State'), '1', '100px', __('Uptime'), '1', '60px', 'Load', '1', '60px', 'Memory', '1', '60px', 'Disk', ); $table_cl->add_headline (\@header_cl); my $table_sync = Proxmox::HTMLTable->new ([]); my @header_sync = ('1', '150px', __('Synchronized Nodes'), '1', '150px', __('IP Address'), '1', '100px', __('Sync Status'), '1', '200px', __('Last succesfull sync'), '1', '100px', __('Delay (minutes)'), ); $table_sync->add_headline (\@header_sync); if ($cluster) { my $cinfo = $system_cfg->clusterinfo (); if ($lic->valid() && $lic->can_cluster()) { if ($fdat{cid}) { my $ni; foreach my $n (@{$cinfo->{nodes}}) { next if $n->{cid} ne $fdat{cid}; if ($n->{cid} eq $fdat{cid}) { $ni = $n; last; } } if ($ni) { my $status; eval { my $conn = Proxmox::ConfigClient::connect ($ni->{configport}); $status = $conn->ping()->result; }; if ($status) { my $headline = sprintf (__("System Status for node '%s'"), $ni->{name}); $out .= Proxmox::HTMLTable::status_to_html ($status, $headline); $out .= "
"; my $si = $status->{syncinfo}; my $sfound = 0; foreach my $ni (@{$cinfo->{nodes}}) { my $lastsync = $si->{"CID_$ni->{cid}"}; next if !defined ($lastsync); $sfound = 1; my $sdiff = time() - $lastsync; $sdiff = 0 if $sdiff < 0; my $sstatus = 'OK'; my $dstatus = '-'; if ($sdiff > (60*3)) { $sstatus = 'nosync'; $dstatus = int (($sdiff + 59)/60); } my $synctime = localtime ($lastsync); $table_sync->add_row ('', $ni->{name}, $ni->{ip}, $sstatus, $synctime, $dstatus); } $out .= $table_sync->out_table () if $sfound; } else { $out .= "

" . sprintf (__("Host '%s' not reachable."), $ni->{name}) . "

"; } } else { $out .="

" . sprintf (__("Invalid cluster ID '%d'."), $fdat{cid}) . "

"; } } else { foreach my $ni (@{$cinfo->{nodes}}) { my $status; eval { my $conn = Proxmox::ConfigClient::connect ($ni->{configport}); $status = $conn->ping()->result; }; my $role = $ni->{role}; $role = 'Master' if $role eq 'M'; $role = 'Node' if $role eq 'N'; if ($status) { my $state = $status->{insync} ? 'active' : 'nosync'; if ($status->{licwarning} || $status->{kavlicwarning}) { $state = 'license' } $table_cl->set_row_link ("$url?cid=$ni->{cid}"); $table_cl->add_row ('', $ni->{cid} eq $cinfo->{local}->{cid} ? 'localhost' : $ni->{name}, $ni->{ip}, $role, $state, $status->{uptime}->{uptimestrshort}, $status->{uptime}->{avg1}, int (0.5 + ($status->{meminfo}->{mbmemused}*100/$status->{meminfo}->{mbmemtotal})) . '%', int (0.5 + ($status->{hdinfo}->{used}*100/$status->{hdinfo}->{avail})) . '%'); } else { $table_cl->set_col_span ([1,1,1,5]); my $msg = __("Host not reachable"); $table_cl->add_row ('', $ni->{name}, $ni->{ip}, $role, "$msg"); } } $out .= $table_cl->out_table (); } } else { $table_cl->set_col_span ([8]); my $msg = Proxmox::Utils::msg ('noclusterlic'); $table_cl->add_row ('', "$msg"); } } else { $out .= "

"; if ($lic->valid() && $lic->can_cluster()) { $out .= __("No cluster defined."); } else { $out .= Proxmox::Utils::msg ('noclusterlic'); } $out .= "

"; } print OUT $out; -]