When you create custom product-specific VBScript collectors,
the file name must be the same product code as the configuration file
and stored in the/Windows subdirectory. The collector
can contain code to gather actual values for one or many prerequisite
properties. It can also use the common functions and sub routines
to gather those values if required.
Before you begin
Ensure that you review the set of functions and sub routines
in the following appendixes before you create the collectors. Determine
whether you can use any of them to obtain the actual values:
Determine whether the collector must check that the prerequisite
property exists and if it does, what other information must be gathered.
Each check must return a value, whether one exists. For example:
- Check whether the directory exists.
- Check the available disk space for a directory.
- Check whether a product is installed.
- Check what version of the product is installed.
Procedure
- Create a VBScript file. Save the file in the ips_root/Windows directory,
with a variant of the following file naming convention:
product_code[_version].vbs
Where:- product_code
It is the variable to represent a product
code on either Windows or UNIX systems. Product codes identify
the product and optionally the version of the operating system that
is supported by that product. They are stored in the codename.cfg file.
A product that supports multiple platforms might have multiple product
codes, with each one identifying a product, platform, and version
of the operating system as required.
- version is the 8-digit code
to represent the version, release, modification, and level, with 2
digits for each part of the code; for example, 7.3.21 is 07032100.
- Using a VBScript editor, open the file and include the
path to the common_function.vbs if
you must use common functions, as follows:
Include("..\lib\common_function.vbs")
- If you must use the values of the PATH
and -p flag that is passed from the Prerequisite Scanner,
then use Wscript.Arguments() where Wscript.Arguments(0) is the value for PATH. Wscript.Arguments(1) is
the -p flag and its values.
- Add the code to obtain the value for the prerequisite property
by using VBScript COM and functions to access elements of the Windows environment. Run in the Windows Script Host environment.
Ensure the check returns standard output as follows:
WScript.Echo "property_name=" & var_for_value
- property_name that represents
the prerequisite property as written in the configuration file, for
example, env.tcrhome.
- var_for_value, that is, the
VBScript variable for the actual value that the collector obtains
for the prerequisite property.
To check the available disk space for the installation
directory for a product. For example, to check for Tivoli® Monitoring
for Energy Management Reporting and Optimization by
using the getValue() sub
routine, where the prerequisite property is InstallDir:Set wshShell = WScript.CreateObject("WScript.Shell")
'Check the disk space for the installation path that is passed as
the value for the PATH argument
installPath = Wscript.Arguments(0)
sInstallPath= "InstallDir="
Wscript.Echo "installation path : " & installPath
set fso = CreateObject("Scripting.FileSystemObject")
getValue fso, sInstallPath, installPath
'Common sub routine
Sub getValue(fso, sKey, drvPath)
Wscript.Echo "getValue(" & skey & "," & drvPath & ")"
If fso.driveExists(fso.getDriveName(drvPath)) then
Set disk = fso.GetDrive(fso.getDriveName(drvPath))
'Value returned is in bytes. Convert to MB
cSize = CLng((disk.FreeSpace/1024)/1024) & "MB"
WScript.Echo sKey & cSize
Else
Wscript.Echo " Disk for " & sKey & " -> " & drvPath & " does not exist"
End If
End Sub
- Create a batch file to call the VBScript collector. The
batch file must have the same name as the configuration file and a .bat extension, product_code[_version].bat,
as follows:
@echo off
set CMD_LINE_ARGS=
:setArgs
if ""%1""=="""" goto doneSetArgs
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
shift
goto setArgs
:doneSetArgs
cscript.exe //nologo collector_file_name.vbs %CMD_LINE_ARGS%
- Run the VBScript collector to ensure that there are no
runtime errors and debug as necessary.
- Create a custom evaluator only if the standard compare
functions cannot compare the actual and expected values.