#!/usr/bin/perl -w # # DATE: 21 August, 2002 # VERSION: 0.2.1 # use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; #Location of Perl $whereperl = join("
", split(/\s+/, qx/whereis perl/)); #Location of Sendmail $wheresendmail = join("
", split(/\s+/, qx/whereis sendmail/)); #Location of Current Directory $currentdirectory = `pwd`; # List of processes $processes = qx/ps aux/; $processes =~ s/
/\n/gi; $processes =~ s/
/\n\n/gi; $processes =~ s/<(?:[^>'"]*|(['"]).*?\1)*>//gs; #Perl Variables $perlversion = $]; $path_tar = join("
", split(/\s+/, qx/whereis tar/)); $path_gzip = join("
", split(/\s+/, qx/whereis gzip/)); $path_apache = join("
", split(/\s+/, qx/whereis apache/)); $path_httpd = join("
", split(/\s+/, qx/whereis httpd/)); $path_php = join("
", split(/\s+/, qx/whereis php/)); $path_mysql = join("
", split(/\s+/, qx/whereis mysql/)); $path_man = join("
", split(/\s+/, qx/whereis man/)); $path_perldoc = join("
", split(/\s+/, qx/whereis perldoc/)); #Perl Os $perlos = $^O; $perlos_version = get_server('version'); $perlos_version =~ s/#/
#/s; $perlos_version =~ s/\(/
(/s; $perlos_cpu = get_server_detail('cpuinfo'); $perlos_mem = get_server_detail('meminfo'); $perlos_mem =~ s/^.*?\n.*?\n.*?\n//s; $perlos_dsk = `df`; sub get_server { open PROC, "", ); close PROC; return $res ? $res : undef; } sub get_server_detail { open PROC, "); close PROC; return $res ? $res : undef; } #Module Paths foreach $line (@INC) { $modulepaths .= "$line
"; } #Environment Variables $environment = qq~ ~; $PAGE_FOOTER = "
"; @allkeys = keys(%ENV); foreach $key (@allkeys) { $value = $ENV{$key}; if ($value eq "") {$value = "-";} $environment .= qq~ ~; } $environment .= qq~
ENVIRONMENT VARIABLES 5
$key $value
~; $documentroot = $ENV{'DOCUMENT_ROOT'}; if ($documentroot ne "") { @lines = `du -c -k $documentroot`; $lastline = @lines-1; ($diskusage) = split/[\t| ]/,$lines[$lastline]; } #Server Software $serverip = $ENV{'SERVER_ADDR'}; $servername = $ENV{'SERVER_NAME'}; $serverport = $ENV{'SERVER_PORT'}; $serversoftware = $ENV{'SERVER_SOFTWARE'}; $serveruptime = `uptime 2>/dev/null`; #Localtime ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); @months = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); $date = sprintf("%02d-%s-%04d",$mday,$months[$mon],$year+1900); $time = sprintf("%02d:%02d:%02d",$hour,$min,$sec); $localtime = "$date, $time"; #GMTtime ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time); @months = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); $date = sprintf("%02d-%s-%04d",$mday,$months[$mon],$year+1900); $time = sprintf("%02d:%02d:%02d",$hour,$min,$sec); $gmttime = "$date, $time"; print qq~ Perl Info

PERL INFORMATION 5
Perl version $perlversion
Perl $whereperl
Sendmail $wheresendmail

SERVER INFORMATION 5
Name $servername
IP $serverip
Listing Port $serverport
Document Root $documentroot
Disk Usage by Root $diskusage KB
Server stamp $serversoftware
Server Time (Local) $localtime
Server Time (GMT) $gmttime
Server Uptime/Load at $serveruptime
Server Details

OPERATING SYSTEM:
$perlos_version

CPU UTILIZATION:

MEMORY UTILIZATION:

DISK UTILIZATION:

Module Paths $modulepaths
Path(s) to TAR $path_tar
Path(s) to GZIP $path_gzip
Path to APACHE/HTTPD $path_apache

$path_httpd

Path to PHP $path_php
Path to MYSQL $path_mysql
Path to MAN (Unix manual) $path_man
Path to PERLDOC $path_perldoc
Processes currently on the server

$environment
LIST OF ALL INSTALLED PERL MODULES 5
  ~; &vars; find(\&wanted,@INC); $modcount = 0; foreach $line(@foundmods) { $match = lc($line); if ($found{$line}[0] >0) {$found{$line} = [$found{$line}[0]+1,$match]} else {$found{$line} = ["1",$match];$modcount++} } @foundmods = sort count keys(%found); sub count { return $found{$a}[1] cmp $found{$b}[1] } $third = $modcount/3; $count=0; $firstroundtotal = 0; foreach $mod(@foundmods) { chomp $mod; $count++; if ($count <= $third) { $firstroundtotal++; print qq~ $firstroundtotal. $mod
~; } else { push (@mod1,$mod) } } $count = 0; print qq~
~; foreach $mod1(@mod1) { chomp $mod1; $count++; if ($count <= $third){} else { push (@mod2,$mod1)}}$count = 0; foreach $mod2(@mod2) { chomp $mod2; $count++; if ($count <= $third) { $firstroundtotal++; print qq~ $firstroundtotal. $mod2
~; }}; sub vars {use File::Find;} sub wanted { $count = 0; if ($File::Find::name =~ /\.pm$/) { open(MODFILE,$File::Find::name) || return; while(){ if (/^ *package +(\S+);/){ push (@foundmods, $1); last; } } } } print qq~

~; $extime = (time - $^T); print qq~
page execution time $extime seconds ~;