#!/usr/local/bin/perl # A script that checks the configuration files on a globecom server. # Also, the needed resource directories are checked to be correctly defined. # Also, the needed checked checked to be alive. # # It compares each configuration file with a predefined file from /public/ins/conf . # # The destination server type is required as an argument. The type may be: # GNS or APP # if ($#ARGV < 0) { print "Usage: ConfChecker.sh Type\n"; print " where Type is the server type - one of:\n"; print " GNS - Globecom Neighborhood Server\n"; print " APP - Application Server\n"; exit; } if ($ARGV[0] eq "GNS") { &check_gns(); } # Check a GNS node elsif ($ARGV[0] eq "APP") { &check_app(); } # Check an APP node else { # Illegal argument print "Illegal argument $ARGV[0]\n\n"; print "Usage: ConfChecker.sh Type\n"; print " where Type is the server's type one of:\n"; print " GNS - Globecom Neighborhood Server\n"; print " APP - Application Server\n"; exit; } ## A subroutine to check a GNS node's configuration sub check_gns { $ConfPool = '/public/ins/conf'; # A directory that holds a pool of adjusted config files $ResrcDir = "/data/var"; ## Default resource directory $Hostname = `hostname`; # Set an array with a list of configuration files to check @gns_conf_files = ( "/usr/local/apache/conf/httpd.conf", "/usr/local/gwa/conf/npdd.conf", "/usr/local/gwa/conf/log.conf", "/usr/local/gwa/conf/rus.conf", "/usr/local/gwa/conf/pici.conf", "/usr/local/gwa/conf/sda.conf", "/usr/local/gwa/conf/zax.conf", "/usr/local/gwa/conf/trace.conf", "/usr/local/real/rmserver.cfg"); # Set an array with a list of directories to check @gns_conf_dirs = ( "/usr/local/apache/conf", "/usr/local/apache/libexec/sda.so", "/usr/local/apache/libexec/zax.so", "/usr/local/apache/logs", "/usr/local/gwa/bin", "/usr/local/gwa/lib", "/usr/local/gwa/conf", "/usr/local/real/Logs/rmaccess.log", "/var/run", "$ResrcDir/real/Content", "$ResrcDir/pici/base", "$ResrcDir/spool/$Hostname/sda", "$ResrcDir/gindocs/lptpp", "$ResrcDir/tmp"); # Set an array with a list of processes to check @gns_conf_procs = ( "httpd", "Lsm", "java", # The IsAlive agent "sdad", "rmserver"); # Ask user if wants to check directoriess print "Do you want to check the needed directories? (y)\n"; $answer = ; if (!($answer =~ /n/)) { # Skip if contains 'n' print "Type resource directory name, if not the default /data/var?\n"; print "Type CR, if /data/var\n"; $answer = ; chop ($answer); $ResrcDir = $answer if ($answer =~ /\/\w+/); # Set resource dir if contains '/' # Loop on directories foreach $TestedDir (@gns_conf_dirs) { @listlines = `ls -ld $TestedDir`; $cmdstat = $?; print " Output of ls command against the $TestedDir directory:\n"; print @listlines; print "\n**************** Shit! File/Directory not found!! ******************\n\n" if $cmdstat; print " =================================================================\n\n"; } } ## End of if # Ask user if wants to check configuration files print "Do you want to check the configuration files? (y)\n"; $answer = ; if (!($answer =~ /n/)) { # Skip if contains 'n' # Loop on config files foreach $TestedFile (@gns_conf_files) { # Ask user if wants to check this file print "Do you want to check $TestedFile? (y)\n"; $answer = ; next if ($answer =~ /n/); # Skip if contains 'n' # Extract file name only @path = split(/\//, $TestedFile); $FileName = @path[$#path]; $TemplateFile = "$ConfPool/GLB/$FileName"; @difflines = `diff -sw $TestedFile $TemplateFile`; print " Output of diff command against a template file:\n"; print @difflines; print " =================================================================\n\n"; } } ## End of if # Ask user if wants to check processes print "Do you want to check needed processes? (y)\n"; $answer = ; if (!($answer =~ /n/)) { # Skip if contains 'n' # Loop on processes foreach $TestedProc (@gns_conf_procs) { @pslines = `ps -ef \| grep $TestedProc \| grep -v grep`; $cmdstat = $?; print " Output of ps command against the $TestedProc process:\n"; print @pslines; print "\n**************** Shit! Process not found!! ****************************\n\n" if $cmdstat; print " =================================================================\n\n"; } } ## End of if } ## End of check_gns sub check_app { $ConfPool = '/public/ins/conf'; # A directory that holds a pool of adjusted config files $ResrcDir= "/data/var"; ## Default resource directory # Set an array with a list of configuration files to check @app_conf_files = ( "/usr/local/apache/conf/httpd.conf", "/usr/local/gwa/conf/log.conf", "/usr/local/gwa/conf/npdd.conf", "/usr/local/gwa/conf/trace.conf", "/install/weblogic/weblogic.properties", "/install/weblogic/startWebLogic.sh", "/install/weblogic/shutWebLogic.sh", "/install/weblogic/EJB_Param.ini", "/usr/local/apache/conf/jserv/zone.properties", "/usr/local/apache/conf/jserv/jserv.properties", "/usr/local/apache/conf/jserv/jserv.conf"); # Set an array with a list of directories to check @app_conf_dirs = ( "/usr/local/apache/conf", "/usr/local/apache/conf/jserv", "/usr/local/apache/libexec/sdu.so", "/usr/local/apache/libexec/poll.so", "/usr/local/apache/libexec/mod_jserv.so", "/usr/local/apache/logs", "/usr/local/gwa/bin", "/usr/local/gwa/lib", "/usr/local/gwa/conf", "/usr/local/gwa/share/sdu.dat", "$ResrcDir/spool/sdu", "/var/run", "/install/weblogic/classes/globecom/globalsale/ejbs/userEntityEJB/userDD.ser", "/install/weblogic/classes/globecom/globalsale/ejbs/PKSchedulerBean/PKSchedDD.ser", "/install/weblogic/classes/globecom/globalsale/servlets", "/install/weblogic/classes/oracle", "/install/weblogic/classes/Jars/xmlparserv2.jar", "/install/weblogic/classes/Jars/parser.jar", "/install/weblogic/classes/Jars/pvTree.jar", "/install/weblogic/servlets_logs", "/install/weblogic/globecom_cluster", "/install/weblogic/globecom_cluster/server*", "/usr/local/jdk1.2.1", "/usr/local/JSDK2.0"); # Set an array with a list of processes to check @app_conf_procs = ( "httpd", "JServ", "Lsm", "sdud", "startWebLogic", "ora_db", "tnslsnr"); # Ask user if wants to check directoriess print "Do you want to check the needed directories? (y)\n"; $answer = ; if (!($answer =~ /n/)) { # Skip if contains 'n' print "Type resource directory name, if not the default /data/var?\n"; print "Type CR, if /data/var?\n"; $answer = ; chop ($answer); $ResrcDir = $answer if ($answer =~ /\/\w+/); # Set resource dir if contains '/' # Loop on directories foreach $TestedDir (@app_conf_dirs) { @listlines = `ls -ld $TestedDir`; $cmdstat = $?; print " Output of ls command against the $TestedDir directory:\n"; print @listlines; print "\n**************** Shit! File/Directory not found!! ******************\n\n" if $cmdstat; print " =================================================================\n\n"; } } ## End of if # Ask user if wants to check configuration files print "Do you want to check the configuration files? (y)\n"; $answer = ; if (!($answer =~ /n/)) { # Skip if contains 'n' # Loop on config files foreach $TestedFile (@app_conf_files) { # Ask user if wants to check this file print "Do you want to check $TestedFile? (y)\n"; $answer = ; next if ($answer =~ /n/); # Skip if contains 'n' # Extract file name only @path = split(/\//, $TestedFile); $FileName = @path[$#path]; $TemplateFile = "$ConfPool/GLB/$FileName"; @difflines = `diff -sw $TestedFile $TemplateFile`; print " Output of diff command against a template file:\n"; print @difflines; print " =================================================================\n\n"; } } ## End of if # Ask user if wants to check processes print "Do you want to check needed processes? (y)\n"; $answer = ; if (!($answer =~ /n/)) { # Skip if contains 'n' # Loop on processes foreach $TestedProc (@app_conf_procs) { @pslines = `ps -ef \| grep $TestedProc \| grep -v grep`; $cmdstat = $?; print " Output of ps command against the $TestedProc process:\n"; print @pslines; print "\n**************** Shit! Process not found!! ****************************\n\n" if $cmdstat; print " =================================================================\n\n"; } } ## End of if } ## End of check_app