use LSE::Database::Connection ;
use LSE::Monitor ;
use LSE::Config;
use CGI ;
use strict ;
use warnings ;
my $q = new CGI ;
print $q->header ;
my @table_cols = ('servname', 'hostname','pid','proxy','stop') ;
my $table_name = 'services' ;
print "
\n" ;
print "\n";
print "LSE Services List\n";
print "";
foreach my $col (@table_cols) {
print "| $col | " ;
}
print "
\n";
my $dbh = getConnection() ;
#Check to make sure the current user has the right priveleges
my $current_user = $dbh->quote($ENV{REMOTE_USER}) ;
my $sth = $dbh->prepare("select * from users where userid = $current_user") ;
$sth->execute ;
my $current_user_info = $sth->fetchrow_hashref ;
#If not an administrator don't allow to view page
if ($current_user_info->{gid} ne 'admin')
{
print "Error: you aren't authorized to view this page" ;
exit ;
}
#there might be a bug here in returning from the klll
if ( $q->param('stop_pid') ) {
my $dying_pid = $dbh->quote($q->param('stop_pid')) ;
my $dying_host = $dbh->quote($q->param('stop_host'));
my $com = "select * from $table_name where pid=$dying_pid and hostname=$dying_host";
#print "$com" ;
$sth = $dbh->prepare($com) ;
$sth->execute() ;
my $deadrow = $sth->fetchrow_hashref() ;
print "\n";
LSE::Monitor::killSoapService($deadrow);
print "\n";
}
if( $q->param('startservice') ) {
my $start_type = $q->param('startservice');
my $start_machine = $q->param('machine');
print "\n";
LSE::Monitor::startSoapService($start_type,$start_machine);
print "\n";
}
#Begin ordinary work for the list
my $cmd = "select * from $table_name " ;
if (defined $q->param('sort')) {
my $sortval = $q->param('sort');
$cmd = "$cmd order by $sortval" ;
#if the sort parameter is defined, then check to see
#if the reverse parameter is defined
if (defined $q->param('reverse') &&
$q->param('reverse') eq 'true' ) {
$cmd = "$cmd desc" ;
}
#include this print for degubing purposes
#print $cmd ;
}
$sth = $dbh->prepare($cmd) ;
$sth->execute;
while ( my $row = $sth->fetchrow_hashref )
{
#create an empty anonymous hash
print "\n" ;
foreach my $col (@table_cols) {
#populate the hash with columns from the row
#display information in table form.
if ( defined $row->{$col} ) {
print "\t| $row->{$col} | \n" ;
}
elsif ( $col eq 'stop' and $row->{pid}) {
print "\t" ;
print "\n";
print "\t | \n" ;
}
else {
print "\t | | \n" ;
}
}
print "
\n" ;
} #end while
print "
" ;
my $scfg = getServiceConfig();
print "\n";
print qq(Reload
Note: If you started a new service, you should reload to see its status by clicking here rather than using your Reload button, or you might accidentally start extra services
);