<& /htmlheader &> Sort simulations % if ($sort_by eq 'a') { alphabetically | by time | by user % } elsif ($sort_by eq 'u') { alphabetically | by time | by user % } else { alphabetically | by time | by user % }

% foreach my $instance (@sorted_instances) {
<& instcard, info => $dbinfo{$instance} &>
% }

<& /htmlfooter &> <%args> $show_all => 0 $sort_by => 't' <%init> use File::Slurp; my %dbinfo; my @databases = grep /psmops/, `echo 'show databases' | /usr/bin/mysql -umops -pmops -h mops00`; #my @databases = grep /psmops/, `echo 'show databases' | mysql -umops -pmops -h localhost`; my $home; # database's $MOPS_HOME foreach my $dbname (@databases) { my $desc; my $descfile; my $verfile; $dbname =~ s/\W+//g; # strip | and whitespace $home = '/usr/local/MOPS_DEV'; $descfile = "$home/var/$dbname/config/description"; $verfile = "$home/var/$dbname/config/version"; if ($show_all or -e "$home/var/$dbname/config/version") { # Better version check here eventually. if (-e $descfile) { $desc = read_file($descfile); } if (-e $verfile) { my @st = stat($verfile); my $modified = scalar(localtime($st[9])); my $owner = getpwuid($st[4]); my ($version) = grep !/^#/, read_file($verfile); chomp $version; if ($version >= 200606) { $dbinfo{$dbname} = { name => $dbname, # desc => ($desc or 'N/A') . " ($version)", desc => ($desc or 'N/A'), version => $version, timestamp => (-M $verfile), modified => $modified, owner => $owner, }; } } } } my @sorted_instances; if ($sort_by eq 'a') { @sorted_instances = sort { $a cmp $b } keys %dbinfo; } elsif ($sort_by eq 'u') { @sorted_instances = sort { $dbinfo{$a}->{owner} cmp $dbinfo{$b}->{owner} } keys %dbinfo; } else { @sorted_instances = sort { $dbinfo{$a}->{timestamp} <=> $dbinfo{$b}->{timestamp} } keys %dbinfo; }