File:  [LON-CAPA] / loncom / debugging_tools / getties.pl
Revision 1.2: download - view: text, annotated - select for diffs
Mon Jul 4 09:24:50 2011 UTC (12 years, 8 months ago) by foxr
Branches: MAIN
CVS tags: version_2_12_X, version_2_11_X, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0_RC2, version_2_11_0_RC1, version_2_11_0, language_hyphenation_merge, language_hyphenation, HEAD, BZ4492-merge, BZ4492-feature_horizontal_radioresponse, BZ4492-feature_Support_horizontal_radioresponse, BZ4492-Support_horizontal_radioresponse
Centralize knowledge of where the tmp directory is within LONCAPA.pm

#
# as this is a standalong file..that may ot be able to access the LONCAPA
# module, I'm leaving the temp directory knoweldge uncentralized
#    - R. Fox 7/1/2011
#

use strict;

my $loncapa_tempdir = '/home/httpd/perl/tmp'; # configure the temp dir here.

my $result=`ls -l /proc/*/fd/* | grep $loncapa_tempdir`;
my @result=split("\n",$result);
my (@pids,@files);
foreach my $line (@result) {
	if ($line=~m-/proc/(\d+)/fd-) {
		push(@pids,$1);
		$line=~m-(/home/httpd/perl/tmp/.*)-;
		push(@files,$1);
	}
}

$result=`wget --http-user=lonadm -q --http-passwd=litelite --output-document=- http://localhost/server-status`;

@result=split('<tr>',$result);

foreach my $line (@result) {
	if ($line =~ m -</b><td>(\d+)<td>-) {
		my $curpid=$1;
		print ("curpid is $1\n");
		for (my $i=0;$i<=$#pids;$i++) {
			my $pid=@pids[$i];
			my $file=@files[$i];
			if ($curpid == $pid) {
				$line=~m-<td nowrap>([^<]*)</tr>-;
				print("$pid has a tmp file $file, last known request is $1\n");
			}
		}
	}
}


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>