#!/usr/bin/perl -w
ServDoc - give you a complete (?) Documentation of all the hard- and software on your system
$Id: ServDoc,v 1.9 2004/01/03 20:43:25 uherbst Exp $
ServDoc [-h|help] [-v|version] [--debug feature,intensity] [--output_format ascii|html]
ServDoc runs a variety of checks and gives the output in different formats to you.
The goal of ServDoc is a oneshot-online-documentation of your whole system with all the hardware, all the software, all the configurations, all the batch-jobs and so on.
To archive this goal ServDoc is written very modular to allow easy extensions of your special software.
Every ``feature'' is a part of ServDoc, a module, a submodule or something like that. ``intensity'' is a integer number between 0 and 9. 0 means no debug output, 9 means very much debug output.
The feature ``ALL'' stands for all features.
You can find a list of all features in [SERVDOC_HOME]/doc/README.debugfeaturelist or in the userguide.
To configure more than one feature, you can give that option more then once.
Ulrich Herbst <Ulrich.Herbst@gmx.de>
#---------------------------------------------------------------------- require 5.005; # standard perl modules use strict; # print error about unknown variables ... use English; # long internal variable names; use FindBin; # In which directory is ServDoc itself ? # There has to be the module and the lib dir! use lib $FindBin::Bin. "/lib"; # Here are the ServDoc-perl-modules use vars qw($options); # our own perl modules use ServDoc; #---------------------------------------------------------------------- $options->{Version} = '$Id: ServDoc,v 1.9 2004/01/03 20:43:25 uherbst Exp $'; # We need the cmdline to call the modules with the same debug options. $options->{cmdline} = join " ", @ARGV; sub debug { ServDoc_debug( "ServDoc", $options, shift, shift ); } $options = &process_cmdline($options); $options->{output_format} ||= "ascii"; #---------------------------------------------------------------------- # ServDoc itself is very easy: query all modules, collect the input # and put it to the output module. debug( 9, i18n_std('running',$0)); my @ModuleOutput = do_all_modules( $options, "$FindBin::Bin/modules" ); do_output(@ModuleOutput); sub do_output { open( OUTPUT, "| $EXECUTABLE_NAME $FindBin::Bin/output_modules/ServDoc_" . $options->{output_format} . " $options->{cmdline}" ); print OUTPUT '<?xml version="1.0" encoding="ISO-8859-1"?>'; print '<!DOCTYPE ServDoc SYSTEM "ServDoc.dtd">'; print OUTPUT "<ServDoc>\n"; print OUTPUT @ModuleOutput; print OUTPUT "\n</ServDoc>\n"; close(OUTPUT); }
@output=do_all_modules($options,$module_path);
Execute all modules in module_path and collect the output.
The modules sit in module_path and there filename starts with ``ServDoc_''. For unix systems, the ServDoc_ - modules have to have the x-right. For windows this is not necessary.
Only modules in $module_path will be executed. Modules in Subdirectories won't be executed.
$options has to be a hash reference. $options->{cmdline} has to be a string with the debug options from the commandline.
The modules will be called as arguments to the same perl executable as ServDoc is called with. (with other words: every module called with do_all_modules can be a perl script! (perl evalutes the Shebang-Line (#!/bin/sh) and therefor perl calls that shell if needed))
If there are more than one module named ``ServDoc_xxx--<OSNAME>'' where <OSNAME> something like ``aix'',``linux'',... is, than only the module with the correct OSNAME (look at $OSNAME in your perl) is executed.
If there isn't a ServDoc_xxx--<OSNAME> with the correct OSNAME, then ServDoc_xxx--other is executed (if exists).
sub do_all_modules { my $options = shift; # you need $options->{cmdline} to call # the submodules with the appropriate # debug information. my $ModulePath = shift; my @ModuleOutput; my @modules = sort (<$ModulePath/ServDoc_*>); my $last_osmodule = ""; foreach my $module (@modules) { if ($OSNAME !~/Win/) { next if ( !-x $module); # This is not a executable } # OSNAME ? if ( $module =~ /ServDoc_(.*)--.*/ ) { my $modulename = $1; if ( $last_osmodule =~ /ServDoc_$modulename/ ) { # We have processed this modul already next; } # it exists ServDoc_$1--$OSNAME my @os_module = grep /ServDoc_$modulename--$OSNAME$/, @modules; if ($#os_module > -1) { push @ModuleOutput, `$EXECUTABLE_NAME $os_module[0] $options->{cmdline}`; $last_osmodule = $os_module[0]; next; } else { # There isn't ServDoc_$1--$OSNAME, # Maybe there's ServDoc_$1--other @os_module = grep /ServDoc_$modulename--other/,@modules; if ($#os_module > -1) { push @ModuleOutput, `$EXECUTABLE_NAME $os_module[0] $options->{cmdline}`; $last_osmodule = $os_module[0]; next; } } } # FIXME: We should do something with STDERR push @ModuleOutput, `$EXECUTABLE_NAME $module $options->{cmdline}`; } return @ModuleOutput; } #----------------------------------------------------------------------