Messages in this thread | | | From | "Nicholas J. Leon" <> | Date | Wed, 24 Apr 1996 11:21:07 -0400 | Subject | FILE: KernelDB ... now a script! |
| |
Folks -
Alright! Due to popular demand, I have converted my "mailconfig" patch to a Perl5 script.
In addition, I made LOTS of adjustments to what's probed. I suggest that before you execute my script you take a look inside and see what it's looking at. Basically, I probe the /proc file system to gather information on CPU type, kernel info, run a few programs to see what versions they are (Perl, GCC, ...), and peek to see what libraries you have installed (by looking in the /*/lib directories).
Please point your favorite web browser at: http://www.binary9.net/nicholas/kerneldb/
Below is the script itself! Share, enjoy and comment freely!
N! __________________________________________________________________________ Nicholas J. Leon (pgp/finger) nicholas@binary9.net Shinanyaku on Kali:Central descent2/warcraft2 Technical Development, Wachovia Bank real job!
--- cut here --- #!/usr/bin/perl
# mailconfig # # Nicholas J. Leon [nicholas@binary9.net] 4/22/96 # # This sucker basically scans your /proc filesystem for those # entries that help define what type of system you are running # Linux on. The results are mailed to "kerneldb@binary9.net" # # For more information please see # # http://www.binary9.net/nicholas/kerneldb/ # #
$SEP="<- mailconfig ->";
sub getProcInfo { my(@files)=("cpuinfo","devices","filesystems","interrupts","ioports","version", "sys/kernel/osrelease","sys/kernel/ostype", "sys/kernel/domainname","sys/kernel/hostname", "pci","uptime","meminfo" ); my($f);
print "Gathering information from /proc\n";
while ($f=shift @files) { next unless -r "/proc/$f";
print MAILOUT "$SEP proc $f\n"; print MAILOUT `cat /proc/$f`; print MAILOUT "\n"; } }
sub verifyMakefile { my($fn)=@_;
open(IN,"<$fn") || return 0; $_=<IN>;
close IN;
return /^VERSION =/?1:0; }
sub getTargetInfo { my(@places)=(".","..","/usr/src/linux"); my($topdir); my($makefile); my($c,$config);
# make sure we have access to the (right) Makefile while ($topdir=shift @places) { if (-r "$topdir/Makefile" && verifyMakefile("$topdir/Makefile")) { $makefile="$topdir/Makefile"; last; } }
if (!defined($makefile)) { print "Couldn't locate the top level Makefile. Please run $0 from\n"; print "top level Kernel source directory currently running.\n"; return; }
print "Gathering information from $makefile.\n";
open(IN,"<$makefile") || do { print "That failed...hmmmm... $!"; return; };
$c=0;
while ($c++<7) { $_=<IN>;
$VERSION=$1 if /^VERSION = (.*)/; $PATCHLEVEL=$1 if /^PATCHLEVEL = (.*)/; $SUBLEVEL=$1 if /^SUBLEVEL = (.*)/; $ARCH=$1 if /^ARCH = (.*)/; }
close IN;
if ($VERSION && $PATCHLEVEL && $SUBLEVEL && $ARCH) { print MAILOUT "$SEP source version\n"; print MAILOUT "$VERSION.$PATCHLEVEL.$SUBLEVEL\n"; print MAILOUT "\n"; print MAILOUT "$SEP source arch\n"; print MAILOUT "$ARCH\n"; print MAILOUT "\n"; } else { print "Hmmm... found a Makefile, but it didn't have the normal\n"; print "defines at the top... oh well.\n"; }
$config="$topdir/.config";
print "Gathering information from $config.\n";
open(IN,"<$config") || do { print "Couldn't open $config: $!"; return; };
print MAILOUT "$SEP source .config\n";
while (<IN>) { print MAILOUT $_ if /^\s*CONFIG.*=/; }
close IN;
print MAILOUT "\n";
}
sub getCmdInfo { my(@cmds)=("gcc -v","ld -V","perl -v","perl -V","lilo -V"); my($c);
print "Gathering information from various programs.\n";
while ($c=shift @cmds) { print MAILOUT "$SEP command $c\n"; print MAILOUT `sh -c "$c 2>&1"`; print MAILOUT "\n"; }
}
sub getDirs { my(@dirs)=("/lib","/usr/lib","/usr/local/lib"); my($d);
print "Gathering information from various directories.\n";
while ($d=shift @dirs) { print MAILOUT "$SEP dir $d\n"; print MAILOUT `ls -la $d`; print MAILOUT "\n"; } }
$TMPFILE="/tmp/mailconfig.$$";
print <<EOT This program is about to probe various aspect of your system. I suggest that EVERYONE look over the code to see exactly what is being reported. I tried to limit the program's gathering to relevant information, but you privacy folks might be concerned.
The results of this probe will be written to the file $TMPFILE. If the actual mailing of this file doesn't work on your system, you can manually mail the results to "kerneldb\@binary9.net".
EOT ;
print "Are you sure you want to do this [y/N]? "; $ans=<>;
exit unless $ans=~/^y/i;
if (! -d "/proc") { print "Whoops! Mailconfig requires the /proc filesystem!\n"; exit 1; }
open(MAILOUT,">$TMPFILE") || die "Couldn't open $TMPFILE: $!";
getProcInfo; getCmdInfo; getTargetInfo; getDirs;
close MAILOUT;
`mail -s 'KernelDB' kerneldb\@binary9.net < $TMPFILE` && die "Couldn't mail the results ($!), $TMPFILE left intact.\n";
system("rm",$TMPFILE);
| |