14 Replies Latest reply on Dec 1, 2015 3:18 PM by Jim Campbell

    How do I pass the selected server to run a job to a vb script?

    Charles Berman

      I inherited a vbscript that was run from a pc desktop and use BladeLogic to access the servers. There are several issues I am running into trying to get it to work on my pc so I want to move it into Bladelogic. My first issue is that this script is looking for a file with the list of servers in it.

       

      But since I need to select servers to execute the job. I want to pass the selected servers to a variable in the script. right now it is defined as text file on the desktop

       

      How do I pass the selected server (from within BladeLogic) to run a job that is a vb script in the depot?

       

      Another piece of this would be to redirect the output form the vbscript back to a file on the desktop.

       

      Everything that was done with this script was executed from a folder on a pc desktop

       

       

      thank you

        • 1. Re: How do I pass the selected server to run a job to a vb script?
          Jim Wilson

          Discussion successfully moved from  BladeLogic to Server Automation

          • 2. Re: How do I pass the selected server to run a job to a vb script?
            Bill Robinson

            why do you need to use a text file to pass targets to a job?  why can't you use the job targets ?

            • 3. Re: How do I pass the selected server to run a job to a vb script?
              Charles Berman

              This was just the way the script was written. What you are asking is what i want to do but do not know how.

               

              I would think I can but don't even know what the BL variable name would be called let alone how to pass otinto the VB script.

              • 4. Re: How do I pass the selected server to run a job to a vb script?
                Charles Berman

                here is the Script content:

                ' Declare variables

                Dim outputFile, serverscan, title, os, errOut, logPath, shellResponse, tmpOut, adminun, adminpw

                 

                 

                ' Set output file to output scan results.

                outputFile = "output.rtf"

                tmpFile = "output.tmp"

                reportFile = "report.txt"

                 

                 

                ' Set Input File. This file will contain a list of servers to check.

                serverscan = "serverscan.txt"

                 

                 

                ' Set HP Bladesystem Administration username and password

                adminun = "admin"

                adminpw = "100church"

                 

                 

                ' Create or clear output files

                InitializeFile outputFile

                InitializeFile tmpFile

                InitializeFile reportFile

                 

                 

                ' For loop to process each server in the outputFile

                For Each serverName In FileToArray(serverscan, False)

                 

                 

                  ' Remove spaces from serverName variable

                  serverName = Trim(serverName)

                 

                  ' Header for each server in output report

                  title = VbCRLF & " --- " & serverName & " --- " & VbCRLF

                  WriteToFile outputFile, title

                  WriteToFile reportFile, title

                 

                 

                  ' Get Operating System (uname)

                  os = ReturnOS

                  os = Replace(os, vbCr, "")

                  os = Replace(os, vbLf, "")

                  os = Left(os, 5)

                 

                 

                  ' Server is Linux. Perform linux specific checks

                  If os = "Linux" Then

                 

                  logPath = "/var/log/messages"

                 

                 

                  ' Perform Linux checks

                  GetOSVersion

                  ServerUptime

                  checkPermitRoot

                  checkKdump

                  checkLogWatchJob

                  CheckCALicError

                  'VerifySNMP

                  'CheckSnmpWarnings

                  CheckLSOF

                  CheckNTPService

                  CheckVMwareTools

                  CheckVCSLicWarnings

                  CheckAvahiDaemonService

                  'CheckDSMService

                  ViewVolumeGroups

                  'HPBladeConfigCheck

                  Last25Messages

                 

                 

                  ' Server is Solaris

                  ElseIf os = "SunOS" Then

                 

                  logPath = "/var/adm/messages"

                 

                 

                  ' Perform Solaris checks

                  GetOSVersion

                  ServerUptime

                  'VerifySNMP

                  CheckNTPService

                  checkPermitRoot

                  CheckLSOF

                  CheckSolarisDump

                  ViewVolumeGroups

                  CheckCALicError

                  OutputEEPROM

                  Last25Messages

                 

                 

                  ' Server is AIX

                  ElseIf os = "AIX" Then

                 

                  logPath = "errpt"

                 

                 

                  ' Perform AIX checks

                  GetOSVersion

                  ServerUptime

                  'VerifySNMP

                  CheckNTPService

                  CheckLSOF

                  checkPermitRoot

                  ViewVolumeGroups

                  Last25Messages

                  CheckRootVGMirror

                  CheckAIXDumpSize

                  CheckClusterStatus

                 

                 

                 

                 

                  ' Unable to connect to server via BladeLogic or OS is not supported by this script.

                  Else

                  errOut = VbCRLF & " ! Unable to connect to " & serverName & ". This script currently does not find a supportable OS or BladeLogic cannot connect to the server. Skipping checks."

                  WriteToFile outputFile, errOut

                  WriteToFile reportFile, errOut

                 

                 

                  End If

                 

                 

                  ' Footer for each server in output report

                  title = VbCRLF & "----------------------------"

                  WriteToFile outputFile, title

                 

                 

                 

                 

                Next

                 

                 

                ' Display output report to screen using Wordpad

                Set objShell = CreateObject("WScript.Shell")

                objShell.Run("notepad " & reportFile)

                objShell.Run("wordpad " & outputFile)

                 

                 

                ' Function to open input file, read the list of servers and return an array containing the list of servers.

                Function FileToArray(ByVal strFile, ByVal blnUNICODE)

                 

                 

                  Const FOR_READING = 1

                  Dim objFSO, objTS, strContents

                 

                 

                  FileToArray = Split("")

                 

                  Set objFSO = CreateObject("Scripting.FileSystemObject")

                 

                 

                  If objFSO.FileExists(strFile) Then

                  On Error Resume Next

                  Set objTS = objFSO.OpenTextFile(strFile, FOR_READING, False, blnUNICODE)

                  If Err = 0 Then

                  strContents = objTS.ReadAll

                  objTS.Close

                  FileToArray = Split(strContents, vbNewLine)

                  End If

                  End If

                 

                 

                End Function

                 

                 

                 

                 

                Function CheckAIXDumpSize ()

                 

                 

                  If os = "AIX" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " /usr/lib/ras/dumpcheck -p | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* AIX Dump Check (/usr/lib/ras/dumpcheck -p | wc -l) "

                  'CheckServer serverName, outputFile, cmdString, strOut

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp > 0 Then

                  strOut = " * Not enough disk space to capture a system dump. Please add disk space for this purpose. ( /usr/lib/ras/dumpcheck -p )" & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                 

                 

                  Else

                  errOut = VbCRLF & "! Unable to complete AIX Dump Size Check on " & serverName & ". Skipping check."

                  WriteToFile outputFile, errOut

                 

                 

                  End If

                 

                 

                 

                 

                End Function

                 

                 

                Function CheckClusterStatus ()

                 

                 

                  If os = "AIX" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " ps -ef | grep HACMP | grep -v grep >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Is HACMP running? (ps -ef | grep HACMP) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " ps -ef | grep VRTS | grep -v grep >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Is VCS running? (ps -ef | grep VRTS) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  Else

                  errOut = VbCRLF & "! Unable to complete AIX Dump Size Check on " & serverName & ". Skipping check."

                  WriteToFile outputFile, errOut

                 

                 

                  End If

                 

                 

                 

                 

                End Function

                 

                 

                ' Function to check Solaris dump settings

                Function CheckSolarisDump ()

                 

                 

                  If os = "SunOS" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " coreadm >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Core Dump Settings (coreadm) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " dumpadm >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Dump Settings (dumpadm) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " ls /opt/SUNWexplo/bin/explorer | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Is Oracle Explorer Installed? (ls /opt/SUNWexplo/bin/explorer | wc -l) "

                  'CheckServer serverName, outputFile, cmdString, strOut

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp < 1 Then

                  strOut = " * Oracle (Sun) Explorer not found under /opt/SUNWexplo/bin/explorer. Please install Oracle (Sun) Explorer." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                  Else

                  errOut = VbCRLF & "! Unable to complete Solaris Dump Check on " & serverName & ". Skipping check."

                  WriteToFile outputFile, errOut

                 

                  End If

                 

                 

                End Function

                 

                 

                ' Function to return Linux operating system version

                Function GetOSVersion ()

                 

                 

                  If os = "Linux" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " cat /etc/redhat-release"

                  strOut = VbCRLF & "* OS Version (cat /etc/redhat-release) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  ElseIf os = "SunOS" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " uname -a >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* OS Version (uname -a) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  ElseIf os = "AIX" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " uname -a >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* OS Version (uname -a) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " oslevel -r >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* OS Level (oslevel -r) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  Else

                  errOut = VbCRLF & "! Unable to complete OS Version Check on " & serverName & ". Skipping check."

                  WriteToFile outputFile, errOut

                 

                  End If

                 

                 

                End Function

                 

                 

                 

                 

                ' Function to check the system uptime

                Function ServerUptime ()

                 

                 

                 

                 

                 

                 

                  If os = "Linux" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " awk '{print $1/60/60/24}' /proc/uptime >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* System Uptime (awk '{print $1/60/60/24}' /proc/uptime) "

                 

                 

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp > 180 Then

                  strOut = " * Server uptime exceeds 180 days. Please reboot the server." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                  Else

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " uptime >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* System Uptime (uptime) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  End If

                 

                 

                 

                 

                 

                 

                End Function

                 

                 

                 

                 

                ' Function to grep for PermitRootLogin in /etc/ssh/sshd_config

                Function checkPermitRoot ()

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " grep 'PermitRootLogin no' /etc/ssh/sshd_config | grep -v '#' | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* PermitRoot setting (grep 'PermitRootLogin no' /etc/ssh/sshd_config | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp < 1 Then

                  strOut = " * Set PermitRootLogin to no in /etc/ssh/sshd_config" & vbCRLF

                  WriteToFile reportFile, strOut

                 

                 

                  Else

                  ' If PermitRootLogin is set to no at least once, check to see if any PermitRootLogin yes entries exist.

                  cmdString = "%comspec% /c nexec " & serverName & " grep 'PermitRootLogin yes' /etc/ssh/sshd_config | grep -v '#' | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* PermitRoot setting (grep 'PermitRootLogin yes' /etc/ssh/sshd_config | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                  If strGetTmp > 0 Then

                  strOut = " * Comment 'PermitRootLogin yes' entries in /etc/ssh/sshd_config" & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                  End If

                 

                 

                End Function

                 

                 

                 

                 

                ' Function to check kdump configuration and current status

                Function checkKdump ()

                 

                 

                  ' Cat kdump.conf minus comments

                  cmdString = "%comspec% /c nexec " & serverName & " grep -v '#' /etc/kdump.conf >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Kdump configuration (grep -v '#' /etc/kdump.conf) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  ' Is kdump configured to start in chkconfig?

                  cmdString = "%comspec% /c nexec " & serverName & " chkconfig --list kdump | grep on | wc -l  >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Kdump Enabled after reboot? (chkconfig --list kdump | grep on | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp < 1 Then

                  strOut = " * Enable and configure kdump" & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                  ' Is the kdump service running?

                  cmdString = "%comspec% /c nexec " & serverName & " service kdump status >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Kdump currently running? (service kdump status) "

                  'CheckServer serverName, outputFile, cmdString, strOut

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp <> "Kdump is operational" Then

                  strOut = " * Kdump service is not running." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                 

                  ' Is the Magic SYSRQ setting configured in /etc/sysctl.conf?

                  cmdString = "%comspec% /c nexec " & serverName & " /sbin/sysctl -a | grep 'sysrq = 1' | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Is Magic SysRQ enabled to trigger a dump? (/sbin/sysctl -a | grep 'sysrq = 1' | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp < 1 Then

                  strOut = " * Set kernel.sysrq = 1 in /etc/sysctl.conf and apply using /sbin/sysctl -p" & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                End Function

                 

                 

                 

                 

                ' Function to verify LogWatch is running on the server.

                Function checkLogWatchJob ()

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " ls /etc/cron.daily/0logwatch | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Is Logwatch Enabled? (ls /etc/cron.daily/0logwatch | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp > 0 Then

                  strOut = " * Disable Logwatch cron job ( rm /etc/cron.daily/0logwatch ) and clear all files in the /var/spool/clientmqueue directory. " & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                End Function

                 

                 

                ' Function to see if lsof is available

                Function checkLSOF ()

                 

                 

                  If os = "SunOS" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " ls /usr/local/bin/lsof /usr/sbin/lsof | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Is LSOF installed? (ls /usr/local/bin/lsof /usr/sbin/lsof | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp < 1 Then

                  strOut = " * LSOF was not found. Please install LSOF. " & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                  ElseIf os = "Linux" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " which lsof | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Is LSOF installed? (which lsof) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp < 1 Then

                  strOut = " * LSOF is not installed. Please install LSOF. " & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                 

                 

                  ElseIf os = "AIX" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " which lsof | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Is LSOF installed? (which lsof | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                  If strGetTmp < 1 Then

                  strOut = " * LSOF is not installed. Please install LSOF. " & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                  Else

                 

                  errOut = VbCRLF & "! Unable to complete LSOF Service Check on " & serverName & ". Skipping check."

                  WriteToFile outputFile, errOut

                 

                 

                  End If

                 

                 

                End Function

                 

                 

                 

                 

                ' Function to check HP Bladesystem Configuration

                Function HPBladeConfigCheck ()

                 

                 

                  If os = "Linux" Then

                 

                  ' Check Hardware version using dmidecode

                  cmdString = "%comspec% /c nexec " & serverName & " dmidecode -t 1 | grep -i manufacturer | awk '{print $2}'"

                  strGetTmp = RWTempFile(cmdString)

                  strGetTmp = Trim(strGetTmp)

                 

                 

                  ' If Hardware is HP (and not VMware), proceed with further checks.

                  If strGetTmp = "HP" Then

                 

                  ' Get Enclosure Name using dmidecode

                  cmdString = "%comspec% /c nexec " & serverName & " dmidecode -t 204 | grep -i enclosure | grep -i name"

                  strGetTmp = RWTempFile(cmdString)

                  ' Trim name from variable

                  strGetTmp = Mid(strGetTmp, InStr(strGetTmp, ": "))

                  ' Remove colon

                  strGetTmp = Replace(strGetTmp,": ","")

                  ' Remove spaces

                  strGetTmp = Trim(strGetTmp)

                  enclName = strGetTmp

                 

                 

                  ' Get Server Bay number using dmidecode

                  cmdString = "%comspec% /c nexec " & serverName & " dmidecode -t 204 | grep -i server"

                  strGetTmp = RWTempFile(cmdString)

                  ' Trim name from variable

                  strGetTmp = Mid(strGetTmp, InStr(strGetTmp, ": "))

                  ' Remove colon

                  strGetTmp = Replace(strGetTmp,": ","")

                  ' Remove spaces

                  strGetTmp = Trim(strGetTmp)

                  srvrBay = strGetTmp

                 

                 

                 

                 

                  ' Write MAC addresses to the output.rtf report

                  cmdString = "%comspec% /c nexec " & serverName & " ifconfig -a | grep HWaddr >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Server MAC addresses "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  ' Call BladeConfigGrab to write Blade config to output.rtf

                  BladeConfigGrab enclName, srvrBay

                 

                 

                  End If

                 

                 

                  End If

                 

                 

                End Function

                 

                 

                ' Function to check if rootvg on AIX is mirrored

                 

                 

                Function CheckRootVGMirror ()

                 

                 

                  If os = "AIX" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " lsvg -l rootvg | grep -v STATE | grep -v sysdump | tr -s ' ' | cut -f5 -d' ' | grep '1' | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Total unmirrored logical volumes in rootvg? (lsvg -l rootvg | grep -v STATE | grep -v sysdump | tr -s ' ' | cut -f5 -d' ' | grep '1' | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                  If strGetTmp > 0 Then

                  strOut = " * Not all volumes are mirrored in rootvg. " & strGetTmp & " unmirrored volumes detected (not including sysdump LVs) in rootvg. Please resolve before go-live " & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                  Else

                 

                  errOut = VbCRLF & "! Unable to complete rootvg mirror check on " & serverName & ". Skipping check."

                  WriteToFile outputFile, errOut

                 

                 

                  End If

                 

                 

                 

                 

                End Function

                 

                 

                ' Function to grab Blade Configuration and write it to output.rtf

                Function BladeConfigGrab (ByVal enclName, ByVal srvrBay)

                 

                 

                  ' Get Virtual Connect IP Address from Enclosure

                  VCIPAddress = GetVCIPAddress(enclName)

                  VCIPAddress = VerifyVCIPAddress(VCIPAddress)

                 

                 

                 

                 

                  ' Get Server Profile Name from Virtual Connect

                  srvrProfile = GrabProfileName(VCIPAddress, srvrBay)

                 

                 

                  ' Output LOM to MAC address mapping from Onboard Administrator

                  GrabLOMConfig enclName, srvrBay

                 

                 

                  ' Output Ethernet configuration from Virtual Connect

                  GrabEnetConfig VCIPAddress, srvrProfile

                 

                 

                End Function

                 

                 

                 

                 

                ' Function to grab the Virtual Connect IP address

                Function GetVCIPAddress (ByVal enclName)

                 

                 

                  ' Set path to plink.exe to current directory

                  Set oShell = CreateObject("WScript.Shell")

                  plinkexe = oShell.CurrentDirectory

                  plinkexe = plinkexe & "\plink.exe"

                 

                 

                  cmdString = "%comspec% /c echo yes | " & plinkexe & " -ssh -pw " & adminpw & " " & adminun & "@" & enclName & " show vcmode | findstr URL"

                 

                 

                msgbox cmdString

                  strGetTmp = RWTempFile(cmdString)

                 

                 

                 

                 

                  ' Grab IP Address

                  strGetTmp = Mid(strGetTmp, InStr(strGetTmp, "//"))

                 

                 

                  ' Remove forward slashes

                  strGetTmp = Replace(strGetTmp,"/","")

                 

                 

                  ' Remove spaces

                  strGetTmp = Trim(strGetTmp)

                 

                 

                  GetVCIPAddress = strGetTmp

                 

                End Function

                 

                 

                 

                 

                ' Validate Virtual Connect IP address

                Function VerifyVCIPAddress (ByVal VCIPAddress)

                 

                 

                  Set oShell = CreateObject("WScript.Shell")

                  plinkexe2 = oShell.CurrentDirectory

                  plinkexe2 = plinkexe2 & "\plink.exe"

                 

                 

                  'cmdString = "%comspec% /c echo yes | plink.exe -ssh -pw " & adminpw & " " & adminun & "@" & VCIPAddress  & " show profile | findstr " & chr(34) & "Please use IP Address" & chr(34)

                  cmdString = "%comspec% /c echo yes | " & plinkexe2 & " -ssh -pw " & adminpw & " " & adminun & "@" & VCIPAddress & " show profile | findstr " & chr(34) & "Please use IP Address" & chr(34)

                msgbox cmdString

                  strGetTmp = RWTempFile(cmdString)

                 

                  if strGetTmp = "" Then

                 

                 

                  VerifyVCIPAddress = VCIPAddress

                 

                 

                  Else

                  ' Trim name from variable

                  strGetTmp = Mid(strGetTmp, InStr(strGetTmp, ": "))

                 

                  ' Remove colon

                  strGetTmp = Replace(strGetTmp,": ","")

                msgbox "strGetTmp=" & strGetTmp & "."

                 

                 

                  VerifyVCIPAddress = strGetTmp

                  End If

                 

                End Function

                 

                 

                 

                 

                ' Function to grab the Profile name in Virtual Connect

                Function GrabProfileName (ByVal VCIPAddress, ByVal srvrBay)

                 

                 

                  ' Set path to plink.exe to current directory

                  Set oShell = CreateObject("WScript.Shell")

                  plinkexe3 = oShell.CurrentDirectory

                  plinkexe3 = plinkexe3 & "\plink.exe"

                 

                 

                  cmdString = "%comspec% /c echo yes | " & plinkexe3 & " -ssh -pw " & adminpw & " " & adminun & "@" & VCIPAddress & " show server enc0:" & srvrBay & " | findstr BL | findstr Profile"

                msgbox cmdString

                 

                 

                  strGetTmp = RWTempFile(cmdString)

                 

                 

                msgbox "strGetTmp(Ln616):" & strGetTmp & "."

                 

                 

                  ' Trim name from variable

                  strGetTmp = Mid(strGetTmp, InStr(strGetTmp, ": "))

                 

                 

                  ' Remove colon

                  strGetTmp = Replace(strGetTmp,": ","")

                msgbox "strGetTmp=" & strGetTmp & "."

                 

                  GrabProfileName = strGetTmp

                 

                End Function

                 

                 

                 

                 

                ' Function to grab the Profile ethernet configuration from Virtual Connect

                Function GrabLOMConfig (ByVal enclName, ByVal srvrBay)

                 

                 

                  ' Set path to plink.exe to current directory

                  Set oShell = CreateObject("WScript.Shell")

                  plinkexe = oShell.CurrentDirectory

                  plinkexe = plinkexe & "\plink.exe"

                 

                 

                  cmdString = "%comspec% /c echo yes | " & plinkexe & " -ssh -pw " & adminpw & " " & adminun & "@" & enclName & " show server info " & srvrBay & " | findstr LOM >> " & outputFile & " 2>&1"

                 

                 

                msgbox cmdString

                 

                 

                  WriteToFile outputFile, " "

                  WriteToFile outputFile, "--- LOM Configuration ---"

                  WriteToFile outputFile, shellResponse

                 

                 

                  Set objShell = CreateObject("Wscript.Shell")

                  shellResponse = objShell.Run(cmdString,0,true)

                 

                 

                 

                 

                 

                End Function

                 

                 

                ' Function to grab the Profile ethernet to LOM mappings from the Onboard Administrator

                Function GrabEnetConfig (ByVal VCIPAddress, ByVal srvrProfile)

                 

                 

                  ' Set path to plink.exe to current directory

                  Set oShell = CreateObject("WScript.Shell")

                  plinkexe = oShell.CurrentDirectory

                  plinkexe = plinkexe & "\plink.exe"

                 

                 

                  cmdString = "%comspec% /c echo yes | " & plinkexe & " -ssh -pw " & adminpw & " " & adminun & "@" & VCIPAddress  & " show enet-connection " & srvrProfile & "  >> " & outputFile & " 2>&1"

                 

                 

                msgbox cmdString

                 

                 

                  WriteToFile outputFile, "--- Virtual Connect Ethernet Configuration ---"

                  WriteToFile outputFile, shellResponse

                 

                 

                  Set objShell = CreateObject("Wscript.Shell")

                  shellResponse = objShell.Run(cmdString,0,true)

                 

                 

                 

                End Function

                 

                 

                 

                 

                 

                 

                ' Function to check status of NTP.

                Function CheckNTPService ()

                 

                 

                  If os = "Linux" Then

                 

                 

                  ' Is the NTP service enabled in chkconfig?

                  cmdString = "%comspec% /c nexec " & serverName & " chkconfig --list ntpd | grep on | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* NTPD Enabled after reboot? (chkconfig --list ntpd | grep on | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp < 1 Then

                  strOut = " * NTP is not configured to start after a reboot. Please enable service ( /sbin/chkconfig ntpd on )." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                  ' Is the NTP service running

                  cmdString = "%comspec% /c nexec " & serverName & " service ntpd status >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* NTPD currently running? (service ntpd status) "

                  'CheckServer serverName, outputFile, cmdString, strOut

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp = "ntpd dead but pid file exists" Then

                  strOut = " * The NTP daemon is not running. Error: ntp dead but pid file exists. Please resolve before go-live." & vbCRLF

                  WriteToFile reportFile, strOut

                 

                  ElseIf strGetTmp = "ntpd is stopped" Then

                  strOut = " * The NTP daemon is not running. Please start the NTP service ( /sbin/service ntpd start )." & vbCRLF

                  WriteToFile reportFile, strOut

                 

                  End If

                 

                 

                  ' Is the NTP driftfile configured properly?

                  cmdString = "%comspec% /c nexec " & serverName & " grep driftfile /etc/ntp.conf | awk '{print $2}' >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Is the NTPD driftfile configured properly? (grep driftfile /etc/ntp.conf | awk '{print $2}') "

                  'CheckServer serverName, outputFile, cmdString, strOut

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If Not ((strGetTmp = "/var/lib/ntp/ntp.drift") Or (strGetTmp = "/var/lib/ntp/drift")) Then

                  strOut = " * Value for driftfile does not match the standard configuration. Please change 'driftfile " & strGetTmp & "' to driftfile /var/lib/ntp/drift in /etc/ntp.conf and restart NTPD ( /sbin/service ntpd restart )." & vbCRLF

                  WriteToFile reportFile, strOut

                 

                  End If

                 

                 

                  ' Are RHEL NTP servers configured?

                  cmdString = "%comspec% /c nexec " & serverName & " grep rhel.pool.ntp.org /etc/ntp.conf | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* RHEL NTP servers configured instead of internal NTP servers? (grep rhel.pool.ntp.org /etc/ntp.conf | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp > 0 Then

                  strOut = " * NTPD is pointing to external RHEL NTP servers. Please configure internal NTP servers in /etc/ntp.conf." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                 

                 

                  ' Output ntp.conf minus comments

                  cmdString = "%comspec% /c nexec " & serverName & " grep -v '#' /etc/ntp.conf >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* NTPD configuration (grep -v '#' /etc/ntp.conf) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  ' Show active NTP connections.

                  cmdString = "%comspec% /c nexec " & serverName & " ntpq -p >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* NTPD Status (ntpq -p) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  ElseIf os = "SunOS" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " svcs -a | grep ntp:default | cut -f1 -d' ' >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* NTPD currently running? (svcs -a | grep ntp:default | cut -f1 -d' ' ) "

                  'CheckServer serverName, outputFile, cmdString, strOut

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp = "maintenance" Then

                  strOut = " * The NTP daemon is in maintenance mode. Please bring it out of maintenance mode." & vbCRLF

                  WriteToFile reportFile, strOut

                 

                  ElseIf strGetTmp = "offline" Then

                  strOut = " * The NTP daemon is not running. Please start the NTP service ( svcadm enable svc:/network/ntp:default )." & vbCRLF

                  WriteToFile reportFile, strOut

                 

                 

                  ElseIf strGetTmp = "disabled" Then

                  strOut = " * The NTP daemon is not running. Please start the NTP service ( svcadm enable svc:/network/ntp:default )." & vbCRLF

                  WriteToFile reportFile, strOut

                 

                 

                  End If

                 

                 

                  ElseIf os = "AIX" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " lssrc -s xntpd | grep active | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* NTPD currently running? (lssrc -s xntpd | grep active | wc -l) "

                  'CheckServer serverName, outputFile, cmdString, strOut

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp < 1 Then

                  strOut = " * NTP is not running. Please enable/configure service ( startsrc -s xntpd )." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                  Else

                  errOut = VbCRLF & "! Unable to complete NTP Service Check on " & serverName & ". Skipping check."

                  WriteToFile outputFile, errOut

                 

                 

                  End If

                 

                 

                End Function

                 

                 

                 

                 

                ' Function to check the status of the TSM Backup service in Linux

                Function CheckDSMService ()

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " chkconfig --list dsm | grep ':on' | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* TSM Enabled after reboot? (chkconfig --list dsm | grep ':on' | wc -l) "

                  'CheckServer serverName, outputFile, cmdString, strOut

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp < 1 Then

                  strOut = " * The TSM service (dsm) is not configured to start after a reboot. Please enable service ( /sbin/chkconfig dsm on )." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " service dsm status >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* TSM currently running? (service dsm status) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                End Function

                 

                 

                 

                 

                ' Function to check the status of the Avahi Daemon service in Linux

                Function CheckAvahiDaemonService ()

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " chkconfig --list avahi-daemon | grep ':on' | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Avahi-Daemon Enabled after reboot? (chkconfig --list avahi-daemon | grep ':on' | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp > 0 Then

                  strOut = " * Disable avahi-daemon ( /sbin/chkconfig avahi-daemon off )." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " service avahi-daemon status >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Avahi-Daemon currently running? (service avahi-daemon status) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp = "Avahi daemon is running" Then

                  strOut = " * Stop avahi-daemon service ( /sbin/service avahi-daemon stop )." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                End Function

                 

                 

                 

                 

                 

                 

                ' Function to check the version and time synchronization settings if VMware Tools is running.

                Function CheckVMwareTools ()

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " vmware-toolbox-cmd -v >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* VMware Tools version (vmware-toolbox-cmd -v) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " vmware-toolbox-cmd timesync status >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* VMware Time Synchronization (vmware-toolbox-cmd timesync status) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp = "Enabled" Then

                  strOut = " * Disable VMware Tools Time Synchronization ( vmware-toolbox-cmd timesync disable ). NTP should be used for time synchronization." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                 

                 

                End Function

                 

                 

                 

                 

                ' Function to view configured physical volumes and logical volumes.

                Function ViewVolumeGroups ()

                 

                 

                  If os = "Linux" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " pvs >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Physical Volume Report (pvs) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                  cmdString = "%comspec% /c nexec " & serverName & " lvs >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Logical Volume Report (lvs) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " multipath -ll >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Multipath Topology (/sbin/multipath -ll) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  ElseIf os = "AIX" Then

                 

                 

                  '' Does not work. Must be done manually.

                  'cmdString = "%comspec% /c nexec " & serverName & " lsvg -l `lsvg` >> " & outputFile & " 2>&1"

                  'strOut = VbCRLF & "* AIX Volume Group Report (lsvg -l `lsvg`) "

                  'CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " powermt display >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* EMC Multipathing (powermt display) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " lspath >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* AIX Multipathing (lspath) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " /usr/lpp/mmfs/bin/mmlsconfig >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* GPFS/MMFS Filesystem Clustering (/usr/lpp/mmfs/bin/mmlsconfig) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  ElseIf os = "SunOS" Then

                 

                 

                  'Metastat Output

                  cmdString = "%comspec% /c nexec " & serverName & " metastat >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Metastat (/usr/sbin/metastat) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                  ' Check for Metastat Errors

                  cmdString = "%comspec% /c nexec " & serverName & " metastat | grep 'Needs maintenance' | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Metastat (/usr/sbin/metastat) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                 

                 

                  If strGetTmp > 0 Then

                  strOut = " * Metastat Needs maintenance errors detected. Please repair before go-live." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " zpool list >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* ZPool List (zpool list) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " zpool status -v >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* ZPool Status (zpool status -v) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " zfs list >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* ZFS List (zfs list) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                  cmdString = "%comspec% /c nexec " & serverName & " powermt display >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* EMC Multipathing (powermt display) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  Else

                  errOut = VbCRLF & "! Unable to complete Volume Group Check on " & serverName & ". Skipping check."

                  WriteToFile outputFile, errOut

                 

                 

                  End If

                End Function

                 

                 

                ' Function to output EEPROM variable settings

                Function OutputEEPROM

                 

                 

                  If os = "SunOS" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " eeprom | sort >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* EEPROM variables (eeprom | sort ) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  Else

                  errOut = VbCRLF & "! Unable to output the EEPROM variables on " & serverName & ". Skipping check."

                  WriteToFile outputFile, errOut

                 

                 

                  End If

                 

                 

                End Function

                 

                 

                ' Function to view the last 50 messages from the system messages or AIX error report

                Function Last25Messages

                 

                 

                  If os = "Linux" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " cat " & logPath & " | tail -25 >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Last 25 messages (tail -25 " & logPath &" ) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                  ElseIf os = "SunOS" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " cat " & logPath & " | tail -25 >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Last 25 messages (tail -25 " & logPath &" ) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  ElseIf os = "AIX" Then

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " " & logPath & " | head -25 >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Last 25 messages (errpt | head -25) "

                  CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                 

                  Else

                  errOut = VbCRLF & "! Unable to output last 25 messages on " & serverName & ". Skipping check."

                  WriteToFile outputFile, errOut

                 

                 

                  End If

                 

                 

                End Function

                 

                 

                ' Function to check message logs for CA errors

                Function CheckCALicError ()

                 

                 

                  ' CA License errors

                  cmdString = "%comspec% /c nexec " & serverName & " " & chr(34) & "grep CA_LIC " & logPath & " | wc -l" & chr(34) & " >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* CA License errors? (grep CA_LIC " & logPath & " | wc -l)"

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp > 10 Then

                 

                 

                  ' Was the ca.olf file edited in the last week?

                  cmdString2 = "%comspec% /c nexec " & serverName & " " & chr(34) & "echo `date +%s` - `stat -c %Z /opt/CA/SharedComponents/ca_lic/ca.olf`| bc" & chr(34) & " >> " & outputFile & " 2>&1"

                  strGetTmp2 = RWTempFile(cmdString2)

                 

                  ' If the unix timestamp

                  If strGetTmp2 > 604800 Then

                  strOut = " * CA eTrust License errors found in "& logPath & ". Please install license. " & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                  End If

                 

                 

                  ' XAACM errors in log

                  cmdString = "%comspec% /c nexec " & serverName & " " & chr(34) & "grep xaacm.bnymellon.net " & logPath & " | wc -l" & chr(34) & " >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* eTrust unable to communicate with XAACM server? (grep xaacm.bnymellon.net " & logPath & " | wc -l)"

                  'CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp > 15 Then

                 

                 

                  strOut = " * CA eTrust communication errors found in "& logPath & ". 'Unable to communicate with [xaacm.bnymellon.net]'. Please resolve before go-live. " & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                 

                 

                  ' eTrust license library errors

                  cmdString = "%comspec% /c nexec " & serverName & " grep 0xB003 " & logPath & " | grep seoswd | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* eTrust license library errors? (grep 0xB003 " & logPath & " | grep seoswd | wc -l)"

                  'CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp > 10 Then

                  strOut = " * CA eTrust license library errors found in "& logPath & ". 'seoswd: Failed to load license library, Error = 0xB003'. Please resolve before go-live" & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                 

                 

                End Function

                 

                 

                 

                 

                ' Function to verify SNMP is setup and configured for Orion

                Function VerifySNMP ()

                 

                  Dim snmpdPath, rocommString, sunosRevision

                 

                 

                  rocommString = "g1AnT5S"

                 

                 

                  If os = "Linux" Then

                 

                 

                  snmpdPath = "/etc/snmp/snmpd.conf"

                 

                 

                  ' Is SNMPD service configured?

                  cmdString = "%comspec% /c nexec " & serverName & " chkconfig --list snmpd | grep ':on' | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* SNMPD Enabled after reboot? (chkconfig --list snmpd | grep ':on' | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                  If strGetTmp < 1 Then

                  strOut = " * Enable SNMPD daemon ( /sbin/chkconfig snmpd on )." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                 

                 

                  ' Is SNMPD service running?

                  cmdString = "%comspec% /c nexec " & serverName & " ps -ef | grep snmpd | grep -v grep | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Is the SNMPD service running? (ps -ef | grep snmpd | grep -v grep | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                  If strGetTmp < 1 Then

                  strOut = " * Start the SNMPD service ( /sbin/service snmpd start )." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                 

                 

                  ' Is Orion Read Only string found in snmpd.conf

                  cmdString = "%comspec% /c nexec " & serverName & " grep " & rocommString & " " & snmpdPath & " | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Is Orion RO Community string setup? (grep " & rocommString & " " & snmpdPath & " | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                  If strGetTmp < 1 Then

                 

                 

                  strOut = " * SNMPD read-only community string not found in SNMPD configuration ( " & snmpdPath & " ) for Orion monitoring. Please configure Orion string. Directions: http://share.bnymellon.net/SiteDirectory/TSG/IAE/DSED/USE/Shared Documents/Platform Documentation/SNMPD " & vbCRLF

                  WriteToFile reportFile, strOut

                 

                  End If

                 

                 

                 

                 

                  ' Is SNMPD Verbose Logging disabled?

                  cmdString = "%comspec% /c nexec " & serverName & " grep 'OPTIONS=" & chr(34) & "-Lsd -Lf /dev/null -p /var/run/snmpd.pid" & chr(34) & "' /etc/sysconfig/snmpd.options | grep -v '#' | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* SNMPD Enabled after reboot? (grep 'OPTIONS=" & chr(34) & "-Lsd -Lf /dev/null -p /var/run/snmpd.pid" & chr(34) & "' /etc/sysconfig/snmpd.options | grep -v '#' | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                  If strGetTmp < 1 Then

                  strOut = " * Please add the OPTIONS variable in /etc/sysconfig/snmpd.options listed in the Linux SNMP setup document under http://share.bnymellon.net/SiteDirectory/TSG/IAE/DSED/USE/Shared Documents/Platform Documentation/SNMPD ." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " grep dontLogTCPWrappersConnects " & snmpdPath & " | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Is SNMPD verbose logging disabled? (grep dontLogTCPWrappersConnects " & snmpdPath & " | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                  If strGetTmp < 1 Then

                  strOut = " * Please add dontLogTCPWrappersConnects entry in " & snmpdPath & ". Please reference the Linux SNMP setup document under http://share.bnymellon.net/SiteDirectory/TSG/IAE/DSED/USE/Shared Documents/Platform Documentation/SNMPD for specific directions." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                  ElseIf os = "SunOS" Then

                 

                 

                  ' Locate path to snmpd.conf

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " find /etc -name snmpd.conf | head -1  >> " & outputFile & " 2>&1"

                  strGetTmp = RWTempFile(cmdString)

                 

                  snmpdPath = strGetTmp

                 

                 

                 

                  ' Get version of Solaris

                  cmdString = "%comspec% /c nexec " & serverName & " uname -r >> " & outputFile & " 2>&1"

                  strGetTmp = RWTempFile(cmdString)

                 

                  sunosRevision = strGetTmp

                 

                 

                  If sunosRevision = "5.8" or sunosRevision = "5.9" Then

                 

                 

                  ' Is SNMPD service running?

                  cmdString = "%comspec% /c nexec " & serverName & " ps -ef | grep snmpd | grep -v grep | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Is the SNMPD service running? (ps -ef | grep snmpd | grep -v grep | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                  If strGetTmp < 1 Then

                  strOut = " * SNMPD is not running. Please start SNMPD. ( /etc/init.d/snmpdx start )." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                 

                 

                  ' Is Orion Read Only string found in snmpd.conf

                  cmdString = "%comspec% /c nexec " & serverName & " grep " & rocommString & " " & snmpdPath & " | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Is Orion RO Community string setup? (grep " & rocommString & " " & snmpdPath & " | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                  If strGetTmp < 1 Then

                 

                  strOut = " * SNMPD read-only community string not found in SNMPD configuration ( " & snmpdPath & " ) for Orion monitoring. Please configure Orion string. Directions: http://share.bnymellon.net/SiteDirectory/TSG/IAE/DSED/USE/Shared Documents/Platform Documentation/SNMPD " & vbCRLF

                  WriteToFile reportFile, strOut

                 

                  End If

                 

                 

                 

                 

                  ElseIf sunosRevision = "5.10" Then

                 

                 

                  ' Check to see if the SNMPD service is not running.

                  cmdString = "%comspec% /c nexec " & serverName & " svcs -a | grep snmpdx | cut -f1 -d' ' | head -1 >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* SNMPD currently running? (svcs -a | grep snmpdx | cut -f1 -d' ' | head -1 ) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp = "maintenance" Then

                  strOut = " * The SNMP daemon is in maintenance mode. Please bring it out of maintenance mode." & vbCRLF

                  WriteToFile reportFile, strOut

                 

                  ElseIf strGetTmp = "offline" Then

                  strOut = " * The SNMP daemon is not running. Please start the SNMP service." & vbCRLF

                  WriteToFile reportFile, strOut

                 

                  ElseIf strGetTmp = "disabled" Then

                  strOut = " * The SNMP daemon is disabled. Please enable the SNMP service." & vbCRLF

                  WriteToFile reportFile, strOut

                 

                  End If

                 

                 

                 

                 

                  ' Is Orion Read Only string found in snmpd.conf

                  cmdString = "%comspec% /c nexec " & serverName & " grep " & rocommString & " " & snmpdPath & " | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Is Orion RO Community string setup? (grep " & rocommString & " " & snmpdPath & " | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                  If strGetTmp < 1 Then

                 

                 

                  strOut = " * SNMPD read-only community string not found in SNMPD configuration ( " & snmpdPath & " ) for Orion monitoring. Please configure Orion string. Directions: http://share.bnymellon.net/SiteDirectory/TSG/IAE/DSED/USE/Shared Documents/Platform Documentation/SNMPD " & vbCRLF

                  WriteToFile reportFile, strOut

                 

                  End If

                 

                 

                  Else

                  errOut = VbCRLF & "! Unable to check SNMP configuration on Solaris server " & serverName & ". Skipping check."

                  WriteToFile outputFile, errOut

                 

                  End If

                 

                 

                 

                 

                 

                 

                 

                 

                  ElseIf os = "AIX" Then

                 

                 

                  snmpdPath = "/etc/snmpd.conf"

                 

                  'Is SNMPD service running?

                  cmdString = "%comspec% /c nexec " & serverName & " lssrc -s snmpd | grep active | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* SNMPD currently running? (lssrc -s snmpd | grep active | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp < 1 Then

                  strOut = " * SNMPD is not running. Please enable/configure service ( startsrc -s snmpd )." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                 

                 

                  ' Is Orion Read Only string found in snmpd.conf

                  cmdString = "%comspec% /c nexec " & serverName & " grep " & rocommString & " " & snmpdPath & " | wc -l >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* Is Orion RO Community string setup? (grep " & rocommString & " " & snmpdPath & " | wc -l) "

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp < 1 Then

                 

                 

                  strOut = " * SNMPD read-only community string not found in SNMPD configuration ( " & snmpdPath & " ) for Orion monitoring. Please configure Orion string. Directions: http://share.bnymellon.net/SiteDirectory/TSG/IAE/DSED/USE/Shared Documents/Platform Documentation/SNMPD " & vbCRLF

                  WriteToFile reportFile, strOut

                 

                  End If

                 

                 

                 

                  Else

                  errOut = VbCRLF & "! Unable to check SNMP configuration on " & serverName & ". Skipping check."

                  WriteToFile outputFile, errOut

                 

                 

                  End If

                 

                 

                End Function

                 

                 

                ' Function to check message logs for a large number of SNMP warnings

                Function CheckSnmpWarnings ()

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " " & chr(34) & "grep snmpd " & logPath & " | wc -l" & chr(34) & " >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* SNMPD errors? (grep snmpd " & logPath & " | wc -l) "

                 

                 

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp > 100 Then

                 

                 

                  If os = "Linux" Then

                 

                 

                  ' Is SNMPD configured to start after a reboot?

                  cmdString2 = "%comspec% /c nexec " & serverName & " chkconfig --list snmpd | grep ':on' | wc -l >> " & outputFile & " 2>&1"

                  strGetTmp2 = RWTempFile(cmdString2)

                 

                  If strGetTmp2 > 0 Then

                  strOut = " * SNMPD notification message flooding found in " & logPath & ". Please disable SNMPD ( /sbin/chkconfig snmpd off  /sbin/service snmpd stop )." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                  Else

                  strOut = " * SNMPD notification message flooding found in " & logPath & ". Please disable SNMPD ( /sbin/chkconfig snmpd off  /sbin/service snmpd stop )." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                  End If

                 

                 

                End Function

                 

                 

                 

                 

                ' Function to check message logs for VCS License errors

                Function CheckVCSLicWarnings ()

                 

                 

                  cmdString = "%comspec% /c nexec " & serverName & " " & chr(34) & "grep V-365-1-1 " & logPath & " | wc -l" & chr(34) & " >> " & outputFile & " 2>&1"

                  strOut = VbCRLF & "* VCS License entitlement errors? (grep V-365-1-1 " & logPath & " | wc -l) "

                  'CheckServer serverName, outputFile, cmdString, strOut

                 

                 

                  strGetTmp = RWTempFile(cmdString)

                  strOut = strOut & ": " & strGetTmp & vbCRLF

                  WriteToFile outputFile, strOut

                 

                 

                  If strGetTmp > 2 Then

                  strOut = " * VCS license errors found in " & logPath & ". Please install VCS license." & vbCRLF

                  WriteToFile reportFile, strOut

                  End If

                 

                 

                 

                 

                End Function

                 

                 

                 

                 

                ' Code to execute nexec commands to BladeLogic used by each check.

                Function CheckServer (ByVal serverName, ByVal outputFile, ByVal cmdString, ByVal strOut)

                 

                 

                  WriteToFile outputFile, strOut

                  Set objShell = CreateObject("Wscript.Shell")

                  shellResponse = objShell.Run(cmdString,0,true)

                 

                 

                End Function

                 

                 

                 

                 

                ' Code to write text passed to the function to the outputFile provided.

                Function WriteToFile (ByVal outputFile, ByVal myText)

                 

                 

                  Dim objFSO 'As FileSystemObject

                  Dim objTextFile 'As Object

                 

                 

                  myText = myText & VbCRLF

                 

                    Const ForAppending = 8

                   

                  Set objFSO = CreateObject("Scripting.FileSystemObject")

                  Set objTextFile = objFSO.OpenTextFile(outputFile, ForAppending)

                   

                  objTextFile.Write (myText)

                 

                  objTextFile.Close

                 

                 

                End Function

                 

                 

                ' Code to create the output file if it does not exist or clear the file.

                Function InitializeFile (ByVal outputFile)

                 

                 

                  Dim objFSO

                  Set fso = CreateObject("Scripting.FileSystemObject")

                  If (fso.FileExists(outputFile)) Then

                  Set objFile = fso.OpenTextFile(outputFile, 2)

                  objFile.Write ""

                  objFile.Close

                  Else

                  Set objFile = fso.CreateTextFile(outputFile, True)

                 

                 

                  End If

                 

                 

                 

                End Function

                 

                 

                ' Code to check the OS platform (Linux, AIX, SunOS, etc...)

                Function ReturnOS ()

                 

                 

                  Set objShell = CreateObject("Wscript.Shell")

                  cmdString = "%comspec% /c nexec " & serverName & " uname"

                  tmpVar = RWTempFile(cmdString)

                  ReturnOS = tmpVar

                 

                 

                End Function

                 

                 

                ' Function to write output to temporary file and transfer to variable

                Function RWTempFile (ByVal cmdString)

                 

                 

                 

                  Set objFSO2 = CreateObject("Scripting.FileSystemObject")

                 

                 

                  ' Check to see if tmp file exists, if not create it.

                  If (objFSO2.FileExists(tmpFile)) Then

                 

                 

                  ' File exists, skip this check

                 

                 

                  Else

                  Set objFile2 = objFSO2.CreateTextFile(tmpFile)

                  objFile2.Close

                 

                 

                  End If

                 

                 

                  ' Append temporary file to cmdString

                  cmdString = cmdString & " > " & tmpFile

                 

                 

                 

                 

                 

                 

                  'Run cmdString command and write output to temp

                  If (objFSO2.FileExists(tmpFile)) Then

                 

                  Set objShell = CreateObject("Wscript.Shell")

                  shellResponse = objShell.Run(cmdString,0,true)

                  ' Remove blank lines from output.

                  RemoveBlankLinesTemp tmpFile

                 

                 

                  End If

                 

                 

                  ' Read output from Temp File to variable

                  Set objReadFile2 = objFSO2.OpenTextFile(tmpFile, 1)

                  Do Until objReadFile2.AtEndOfStream

                 

                 

                  strLine = objReadFile2.Readline

                 

                 

                  Loop

                 

                 

                  ' Delete contents of Temp File

                  If (objFSO2.FileExists(tmpFile)) Then

                 

                  Set objFile2 = objFSO2.OpenTextFile(tmpFile, 2)

                  objFile2.Write ""

                  objFile2.Close

                 

                 

                  End If

                 

                  'Return output

                  tmpVar = strLine

                  RWTempFile = tmpVar

                }

                 

                 

                End Function

                 

                 

                ' Clean and remove blank lines from temporary file

                Function RemoveBlankLinesTemp (ByVal tmpFile)

                 

                 

                  Const ForReading = 1

                  Const ForWriting = 2

                 

                 

                  Set objFSO = CreateObject("Scripting.FileSystemObject")

                  Set objFile = objFSO.OpenTextFile(tmpFile, ForReading)

                 

                 

                  Do Until objFile.AtEndOfStream

                     strLine = objFile.Readline

                     strLine = Trim(strLine)

                     If Len(strLine) > 0 Then

                         strNewContents = strNewContents & strLine & vbCrLf

                     End If

                  Loop

                 

                  objFile.Close

                 

                  Set objFile = objFSO.OpenTextFile(tmpFile, ForWriting)

                  objFile.Write strNewContents

                  objFile.Close

                 

                 

                 

                 

                End Function

                • 5. Re: How do I pass the selected server to run a job to a vb script?
                  Bill Robinson

                  can you post the script ?

                   

                  you can't run a vb script directly in bsa, you need to have a nsh or batch wrapper to call it.  let's see what it's doing though as maybe you don't need to use vb.

                  • 6. Re: How do I pass the selected server to run a job to a vb script?
                    Charles Berman

                    I just posted it. There are more things in here to get around.

                    • 7. Re: How do I pass the selected server to run a job to a vb script?
                      Bill Robinson

                      so this doesn't make a lot of sense - why is there a vb wrapper to call nexec/nsh ?  why not just call nexec/nsh directly ?  i would re-write this in native nsh and write it to take the target list as input.

                      • 8. Re: How do I pass the selected server to run a job to a vb script?
                        Charles Berman

                        I believe because of the files that he creates on the desktop. Hard to guess but this is a classic tale of he left the company and I can not ask him. When it works for the primary users it is nice to have the output files just open on their desktop. then they just copy bits of the file into emails and archive the master file.

                         

                        But ....

                        • 9. Re: How do I pass the selected server to run a job to a vb script?
                          Charles Berman

                          Do you know if I could take the output from the nsh scripting and have it create and open the file on the desktop?

                           

                          If so, how?

                          • 10. Re: How do I pass the selected server to run a job to a vb script?
                            Bill Robinson

                            "There are several issues I am running into trying to get it to work on my pc so I want to move it into Bladelogic"

                             

                            -> what issues are you running into while trying to get it working on your pc ?

                             

                            -> why do you think moving it into bsa will resolve the issues ?

                             

                            what is the purpose of the script?  it generates some information about servers registered in bsa and then what?  if you run this as a bsa job, unless you have a rscd agent on your desktop and the appserver can communicate w/ it there is no way to have bsa drop anything on your desktop.

                            • 11. Re: How do I pass the selected server to run a job to a vb script?
                              Charles Berman

                              Your last statement about having an agent on the laptop will effectively kill this project for me.

                               

                              At best I will just rewrite the job for use within the console.

                               

                              Thank you

                              • 12. Re: How do I pass the selected server to run a job to a vb script?
                                Bill Robinson

                                Ok, but that doesn’t really answer what you need to do w/ the output.  if you are just getting inventory info there are native ways to get that (eg a snapshot job) and you may not need a script at all.

                                • 13. Re: How do I pass the selected server to run a job to a vb script?
                                  Charles Berman

                                  The report shows compliance with regards to our deployment spec. It becomes a pass fail. the results are then shared to the appropriate staff members and actions are taken as need to fix things that are not compliant.

                                   

                                  I inherited this script and may just use it as a template and start from scratch within BL.

                                   

                                  Thank you.

                                  • 14. Re: How do I pass the selected server to run a job to a vb script?
                                    Jim Campbell

                                    I didn't read the whole script but I don't see where it wraps getting a credential or setting a role so you would probably need to do that first.  All of the calls to nexec are going to need a credential and role.

                                     

                                    It also looks like it needs 'plink.exe' which I guess is an ssh client on the machine from which you are running the script