After installing some security upgrades to my OS, I need to reboot my server. I would like to do that when there are no students logged-in to Webwork.
I have a vague memory of Webwork 1.9 providing a way for me to see a list of active logins (for system or for course), but I have not found an easy way to do that with Webwork 2.4. My current thought is to look at time-stamps for timing.log and the course transaction logs --- perhaps even doing a tail on each and checking times for individual lines (and finding "logout" as last entry in timing.log). If there is a simpler (or more reliable) way to do this task, I will welcome suggestions.
thanks,
dick lane
If you have only a few classes, you can go into the class web site and look at the classlist editor. There the students who are logged in are marked as active.
Wojciech Komornicki
Wojciech Komornicki
At one time Nandor Sieben posted a script that gets active logins. (Or at least those logins that haven't timed out.) Below is the version we are using. (I don't remember if I had to modify it slightly or not.)
Bob Byerly
#!/usr/bin/perl
# Prints a list of active webwork users. Assumes sql_single layout.
# Author: Nandor Sieben
$password = 'XXXXXX'; #your password here
sub mysql {
my ($sql) = @_;
# print "$sql";
qx[mysql -s -u webworkWrite -p$password webwork << EOF
$sql
EOF
];
}
@tables= mysql(q[show tables like '%key';]);
$ctime=time;
foreach $table (@tables) {
chop $table;
@rows=mysql(qq[select user_id, timestamp from $table]);
foreach $row (@rows) {
if ( $row =~ /(\S+)\s+(\S+)/)
{
$name=$1;
$stamp=$2;
$age =($ctime - $stamp) / 60;
if ($age < 10)
{
$table =~ s/_key//;
print "$table\t $name\t $age\n";
}
}
}
}
Bob Byerly
#!/usr/bin/perl
# Prints a list of active webwork users. Assumes sql_single layout.
# Author: Nandor Sieben
$password = 'XXXXXX'; #your password here
sub mysql {
my ($sql) = @_;
# print "$sql";
qx[mysql -s -u webworkWrite -p$password webwork << EOF
$sql
EOF
];
}
@tables= mysql(q[show tables like '%key';]);
$ctime=time;
foreach $table (@tables) {
chop $table;
@rows=mysql(qq[select user_id, timestamp from $table]);
foreach $row (@rows) {
if ( $row =~ /(\S+)\s+(\S+)/)
{
$name=$1;
$stamp=$2;
$age =($ctime - $stamp) / 60;
if ($age < 10)
{
$table =~ s/_key//;
print "$table\t $name\t $age\n";
}
}
}
}
Several courses on my development machine have a name including "-" and this script terminates with "ERROR 1064 (42000)" messages mentioning each of them.
On the other hand, it works well on my production server (which has no hyphenated course-names) --- thanks Bob (and Nandor and Wojciech).
dick
On the other hand, it works well on my production server (which has no hyphenated course-names) --- thanks Bob (and Nandor and Wojciech).
dick