[LON-CAPA-cvs] cvs: loncom / loncapa_apache.conf /cgi clusterstatus.pl userstatus.pl doc/loncapafiles loncapafiles.lpml
www
lon-capa-cvs@mail.lon-capa.org
Tue, 25 Feb 2003 21:56:48 -0000
www Tue Feb 25 16:56:48 2003 EDT
Added files:
/loncom/cgi userstatus.pl
Modified files:
/doc/loncapafiles loncapafiles.lpml
/loncom loncapa_apache.conf
/loncom/cgi clusterstatus.pl
Log:
Bug #1267 - list of active users via /cgi-bin/userstatus.pl
Trying to get clusterstatus.pl working again. Added ability to ignore
comments in hosts.tab, and took out Net::Ping because that library is kaputt.
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.217 doc/loncapafiles/loncapafiles.lpml:1.218
--- doc/loncapafiles/loncapafiles.lpml:1.217 Thu Feb 20 16:13:33 2003
+++ doc/loncapafiles/loncapafiles.lpml Tue Feb 25 16:56:48 2003
@@ -2,7 +2,7 @@
"http://lpml.sourceforge.net/DTD/lpml.dtd">
<!-- loncapafiles.lpml -->
-<!-- $Id: loncapafiles.lpml,v 1.217 2003/02/20 21:13:33 www Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.218 2003/02/25 21:56:48 www Exp $ -->
<!--
@@ -1239,6 +1239,12 @@
<target dist='default'>home/httpd/cgi-bin/loncron.pl</target>
<categoryname>script</categoryname>
<description>CGI script that starts and pipes output of loncron</description>
+</file>
+<file>
+<source>loncom/cgi/userstatus.pl</source>
+<target dist='default'>home/httpd/cgi-bin/userstatus.pl</target>
+<categoryname>script</categoryname>
+<description>CGI script that shows users currently on machine</description>
</file>
<file>
<source>loncom/loncron</source>
Index: loncom/loncapa_apache.conf
diff -u loncom/loncapa_apache.conf:1.36 loncom/loncapa_apache.conf:1.37
--- loncom/loncapa_apache.conf:1.36 Mon Feb 24 18:32:32 2003
+++ loncom/loncapa_apache.conf Tue Feb 25 16:56:48 2003
@@ -1,7 +1,7 @@
##
## loncapa_apache.conf -- Apache HTTP LON-CAPA configuration file
##
-## $Id: loncapa_apache.conf,v 1.36 2003/02/24 23:32:32 albertel Exp $
+## $Id: loncapa_apache.conf,v 1.37 2003/02/25 21:56:48 www Exp $
##
#
@@ -590,6 +590,13 @@
# ------------------------------------------------- Backdoor Adm Tests/Programs
<Location /cgi-bin/loncron.pl>
+AuthName "LON-CAPA Network Administration"
+AuthType Basic
+AuthUserFile /home/httpd/lonTabs/htpasswd
+require user lonadm
+</Location>
+
+<Location /cgi-bin/userstatus.pl>
AuthName "LON-CAPA Network Administration"
AuthType Basic
AuthUserFile /home/httpd/lonTabs/htpasswd
Index: loncom/cgi/clusterstatus.pl
diff -u loncom/cgi/clusterstatus.pl:1.6 loncom/cgi/clusterstatus.pl:1.7
--- loncom/cgi/clusterstatus.pl:1.6 Mon Feb 3 13:03:52 2003
+++ loncom/cgi/clusterstatus.pl Tue Feb 25 16:56:48 2003
@@ -13,18 +13,6 @@
use LWP::UserAgent();
use HTTP::Headers;
use IO::File;
-use Net::Ping;
-
-sub online {
- my $host=shift;
- return 1;
-# ping is broken
- my $p=Net::Ping->new("tcp",10);
- my $online=$p->ping("$host");
- $p->close();
- undef ($p);
- return $online;
-}
sub connected {
my ($local,$remote)=@_;
@@ -34,8 +22,6 @@
unless ($hostname{$local}) { return 'local_unknown'; }
unless ($hostname{$remote}) { return 'remote_unknown'; }
- unless (&online($hostname{$local})) { return 'local_offline'; }
-
my $ua=new LWP::UserAgent;
my $request=new HTTP::Request('GET',
@@ -68,6 +54,8 @@
$total=0;
while (my $configline=<$config>) {
+ $configline=~s/#.*$//;
+ unless ($configline=~/\w/) { next; }
my ($id,$domain,$role,$name,$ip)=split(/:/,$configline);
$hostname{$id}=$name;
$hostdom{$id}=$domain;
@@ -99,7 +87,7 @@
}
$table.="</tr>";
foreach $local (sort keys %hostname) {
- print "Checking $local ";
+ print "Checking $local: ";
$table.="<tr><td";
if ($local eq $perlvar{'lonHostID'}) {
$table.=" bgcolor=#CCFFBB";
@@ -113,7 +101,6 @@
$hostname{$local}."</a></tt><br>".
"<a href=http://".$hostname{$local}."/cgi-bin/loncron.pl>New Report</a>".
"</td>";
- if (&online($hostname{$local})) {
foreach $remote (sort keys %hostname) {
$status=&connected($local,$remote);
if ($status eq 'ok') {
@@ -133,21 +120,12 @@
print "X";
$table.="<td><b><font color=#FF0000>".$status."</font></b><br>".
"<a href=http://".$hostname{$local}.
- "/lon-status/loncstatus.txt>lonc</a>";
- if (&online($hostname{$remote})) {
- $table.=" <a href=http://".$hostname{$remote}.
+ "/lon-status/loncstatus.txt>lonc</a>".
+ " <a href=http://".$hostname{$remote}.
"/lon-status/londstatus.txt>lond</a>".
"</td>";
- } else {
- $table.=' offline';
- }
-
}
}
- } else {
- print "offline";
- $table.='<th colspan='.$total.'><font color=#FF0000>Offline</font></th>';
- }
$table.="</tr>\n";
print "<br>\n";
}
Index: loncom/cgi/userstatus.pl
+++ loncom/cgi/userstatus.pl
#!/usr/bin/perl
$|=1;
# The LearningOnline Network with CAPA
# User Status
# (Versions
# (Running loncron
# 09/06/01 Gerd Kortemeyer)
# 02/18/02,02/19/02 Gerd Kortemeyer)
use lib '/home/httpd/lib/perl/';
use LONCAPA::Configuration;
use HTTP::Headers;
use IO::File;
print "Content-type: text/html\n\n".
"<html><body bgcolor=#FFFFFF>\n";
# -------------------- Read loncapa.conf (and by default, loncapa_apache.conf).
my $perlvarref=LONCAPA::Configuration::read_conf('loncapa.conf');
my %perlvar=%{$perlvarref};
undef $perlvarref; # remove since sensitive and not needed
delete $perlvar{'lonReceipt'}; # remove since sensitive and not needed
delete $perlvar{'lonSqlAccess'}; # remove since sensitive and not needed
print "<h1>User Status ".localtime()."</h1>";
my $filename;
opendir(DIR,$perlvar{'lonIDsDir'});
%usercounts=();
while ($filename=readdir(DIR)) {
unless ($filename=~/^\./) {
my ($dev,$ino,$mode,$nlink,
$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,
$blksize,$blocks)=stat($perlvar{'lonIDsDir'}.'/'.$filename);
$now=time;
$since=$now-$mtime;
$sinceacc=$now-$atime;
print ("\n\n<hr />");
my %userinfo=();
undef $userinfo;
my $fh=IO::File->new($perlvar{'lonIDsDir'}.'/'.$filename);
while ($line=<$fh>) {
chomp($line);
my ($name,$value)=split(/\=/,$line);
$userinfo{$name}=$value;
}
$fh->close();
$color="#000000";
$userclass="Active";
if ($since>300) { $color="#222222"; }
if ($since>600) { $color="#444444"; }
if ($since>3600) { $color="#666666"; $userclass="Moderately Active"; }
if ($since>7200) { $color="#888888"; }
if ($since>21600) { $color="#AAAAAA"; $userclass="Inactive"; }
$usercount{$userclass}++;
print '<font color="'.$color.'">';
print '<h3>'.$userinfo{'environment.lastname'}.', '.
$userinfo{'environment.firstname'}.' '.
$userinfo{'environment.middlename'}.' '.
$userinfo{'environment.generation'}." (".
$userinfo{'user.name'}."\@".$userinfo{'user.domain'}.
")</h3>\n<b>Login time:</b> ".
localtime($userinfo{'user.login.time'}).
' <b>Browser</b>: '.$userinfo{'browser.type'}." <b>Client:</b> ".
$userinfo{'request.host'}."<br />\n<b>Role: </b>".
$userinfo{'request.role'}." ";
if ($userinfo{'request.course.id'}) {
print "<b>Course:</b> ".
$userinfo{'course.'.$userinfo{'request.course.id'}.'.description'}.
' ('.$userinfo{'request.course.id'}.')';
$usercount{'in Course '.
$userinfo{'course.'.$userinfo{'request.course.id'}.'.description'}.
' ('.$userinfo{'request.course.id'}.')'}++;
} else {
print "Not in a course.";
}
print "<br /><b>Last Transaction:</b> ".localtime($mtime).
" (".$since." secs ago) <br /><b>Last Access:</b> ".localtime($atime).
" (".$sinceacc." secs ago)";
print ("</font>");
}
}
closedir(DIR);
print "<hr /><h2>User Count</h2>";
foreach (sort keys %usercount) {
print "<b>".$_.":</b> ".$usercount{$_}."<br />";
}
print "</body></html>";