Abstract
In the implementation of IBM Tivoli Business Systems Manager, additional functionality may be needed. These functions may be in the form of commands invoked from the context menu of an object. This tip shows the steps needed to add a display active command for a Tivoli Framework based object.
For related information about this topic, refer to the following IBM Redbooks publication:
Tivoli Business Systems Manager V2.1 End-to-end Business Impact Management, SG24-6610-00
Contents
The Tivoli Framework tasks can be invoked using the tgmtask command:
tgmtask -h eehost -u tmeid -k tmepw {-o tmeendpointoid|-r endpointhostname} tskname|tsklib|tskargs
where:
eehost: The event enablement or task server host name
tmeendpointoid: Object ID of the endpoint, in the format of <tmr num>.<dispatcher num>.0+
endpointhostname: Endpoint’s label
tmeid, tmepw: User ID and password to access the TMR
task information: Task name, task library name, and task arguments
With this capability, we can extend the menu for any distributed objects that we can identify as belonging to a Tivoli Management Region where a task server is defined. For simplicity, we define additional commands for resources that are defined from TEC, where an Event Enablement host is one of the attributes. We pick up a generic object that is defined as the cid of G02K and add an extension to perform a DIR command on a Windows platform or a df command on a UNIX platform. We create a Tivoli Framework task called DIRCDrv under TBSMTasks Task Library. The script that the task runs is shown below:
#!/bin/sh
if [ x\"$OS\" = x\"Windows_NT\" ] ; then
CMD.EXE /C DIR C:
else
df
fi
exit 0
We then define a stored procedure called _DIRCDrv, as shown below:
CREATE PROCEDURE _DIRCDrv
@cid ClassID,
@id ObjID,
@ReturnCode INT = NULL OUTPUT
AS
RAISERROR(‘_DIRCDrv: %s, %d’, 0, 1, @cid, @id)
DECLARE @command NVARCHAR(255)
DECLARE @userID NVARCHAR(255)
DECLARE @tmeid NVARCHAR(255)
DECLARE @epname NVARCHAR(255)
IF @cid = ‘LOB’
SELECT @cid = phy_cid, @id = phy_id FROM lob_link WHERE dst_id = @id
SELECT @tmeid = _EEhost, @epname = _MgedSystemName
FROM G02Kcname_V where id = @id
EXEC asisp_getContextUserID @userID OUTPUT
IF @tmeid is NULL
BEGIN
SELECT ‘_DIRCDrv ERROR: Could not locate EE host’
RETURN 8
END
SELECT @command = ‘tgmtask -d TME -h “‘ + @tmeid + ‘” -r “‘ + @epname + ‘” ‘
IF @userID IS NOT NULL SET @command = @command + ‘ -u “‘ + @userID + ‘” -k “********” ‘
SET @command = @command+’ “DIRCDrv|TBSMTasks|’
EXEC @ReturnCode = master..xp_cmdshell @command
RETURN @ReturnCode
GO
We then use DefineDIRCDrv.sqi file to define the method for G02K, as shown below:
include(BusinessObject.sqi)
BEGIN_METHOD(DIRCDrv, ‘Dir of C drive’,’Display C Drive’)
METHOD_PARAM(ReturnCode, ASIVARIANT, ‘RETURN Code’, ‘RETURN Code’)
METHOD_PARAM_FLAG(output)
METHOD_PARAM(Results, ASIDBTABLE, ‘Results’, ‘Results’)
METHOD_PARAM_FLAG(output)
METHOD_PARAM_FLAG(collection)
END_METHOD(DIRCDrv)
BEGIN_METHOD_CALLERS(DIRCDrv)
METHOD_CALLER(G02K)
END_METHOD_CALLERS(DIRCDrv)
We run the sh clsql DefineDIRCDrv.sqi command and invoke the SQL Query Analyzer to load the generated DefineDIRCDrv.sql. Then we run asisp_definemenuitem against the G02K object. This time, we apply to all instances using the command:
EXEC asisp_definemenuitem 'DIRCDrv', 'G02K', 0, 'DIR C Drive', NULL, NULL, 'DIRCDrv', NULL, '', 1342242816
The result of the new menu is shown below:
Special Notices
This material has not been submitted to any formal IBM test and is published AS IS. It has not been the subject of rigorous review. IBM assumes no responsibility for its accuracy or completeness. The use of this information or the implementation of any of these techniques is a client responsibility and depends upon the client's ability to evaluate and integrate them into the client's operational environment.
