logo       

Re: Custom Resource Model Problem: msg#00462

sysutils.tivoli.tme10

Subject: Re: Custom Resource Model Problem


Hi,

I would like to add the parameter "param_perl_path" (for example:
c:/perl5/bin/perl.exe) to my resource model ...

But I get errors while running the script !
The problem is the following:

..........
Svc.DefineStrParameter ("param_perl_path", "C:/Tivoli/Perl/bin/Perl5.exe");
...........
var perlpath = Svc.GetStrParameter("param_perl_path");
curScriptResult = Svc.Shell("+perlpath+ chkport.pl "+host+" "+port);


Any ideas ?

Lars

My script:
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
// Decision Tree script
//
// This file was generated by the IBM Tivoli Resource Model Builder.
//
// 01/21/2004 18:56:36
//
// Änderungen wurden durchgeführt von Lars Kleiner 21.01.2004
//
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

// Trace constants to be used by Svc.Trace calls.

var TRACE_ERROR = 0;
var TRACE_FINE = 1;
var TRACE_FINER = 2;
var TRACE_FINEST = 3;

// This variable can be used in your Svc.Trace calls to make it easier to
// search through the log file and find calls made by the resource models.

var TRACE_SOURCE = "RM TRACE: ";

// Return code constants for various error conditions.

var RC_COLLECTION_ERROR = 407;
var RC_INVALID_METRIC = 406;
var RC_INVALID_RESOURCE_TYPE = 801;
var RC_INVALID_VERSION = 802;
var RC_RESOURCE_UNAVAILABLE = 405;

var flagNotFirstRun = 0;
var hTableScriptResult;
var allHosts = new Array();
var allPorts = new Array();
var paramInstances;


// This function defines the default settings of the resource model.
// It is called only once, when the resource model is started.
// Don't modify remarks containing tags like <<....>> ... <<\...>>
// You can write additional initializing code in this function if required.

function SetDefaultConfiguration(Svc)
{
Svc.Trace(TRACE_FINEST, TRACE_SOURCE + "Start
SetDefaultConfiguration");

// General info section
//<<GENERAL_INFO>>
Svc.SetModelName ("Checkport");
Svc.SetProfileName ("1106842375129");
Svc.SetCycleTime (60);
//<<\GENERAL_INFO>>

// Thresholds section
//<<THRESHOLDS_INFO>>
Svc.DefineThreshold ("thr_result", 0.0);
//<<\THRESHOLDS_INFO>>

// Parameters section
//<<PARAMETERS_INFO>>
Svc.DefineStrParameter ("param_host_port", "ogtivadmin01;9495");
Svc.DefineStrParameter ("param_perl_path",
"C:/Tivoli/Perl/bin/Perl5.exe");
//<<\PARAMETERS_INFO>>

// Dynamic model section
//<<DATA_INFO>>
//<<\DATA_INFO>>

// Event definition section
//<<EVENTS_INFO>>
Svc.DefineEvent ("PortFailed" , "MatchingValue,ScriptResult",
"port,host");
//<<\EVENTS_INFO>>

// Logging definition section
//<<LOGGING_INFO>>
//<<\LOGGING_INFO>>

// Place your additional intializing code below.

Svc.Trace(TRACE_FINEST, TRACE_SOURCE + "End
SetDefaultConfiguration");
return (0);
}


// This function is called by the monitoring engine after the resource
// model default settings have been overridden. It is called only once,
// when the resource model is started. You can write additional
// initialization code in this function if required.

function Init(Svc)
{

var k;
var words = new Array(2);

Svc.Trace(TRACE_FINEST, TRACE_SOURCE + "Start Init");

hTableScriptResult = Svc.CreateMap();
hTableParameters = Svc.CreateMap();

paramInstances = Svc.GetStrParameterCount("param_host_port");

if (paramInstances > 0)
{
for (k = 0; k < paramInstances; k++)
{
var line = new
String(Svc.GetStrParameter("param_host_port",k));

words = line.split(/;/);
allHosts[k] = words[0];
allPorts[k] = words[1];
}

}
return (0);

}


// This function contains the monitoring algorithm. It is called
// once per cycle. Implement the monitoring code here.

function VisitTree(Svc)
{
Svc.Trace(TRACE_FINEST, TRACE_SOURCE + "Start VisitTree");

//vars for data source: perl chkport.pl oginnb50 9495
var curScriptResult;
var hashKey;
var found;
var OldScriptResult;
var hPropTable;
var hTableScriptResult;
var ParamCount;
var ParamIdx;
var Different;

//Zusätzliche Variablen
var k;
var host;
var port;

if (paramInstances > 0)
{

for (k = 0; k < paramInstances; k++)
{
hPropTable = Svc.CreateMap();
hTableScriptResult = Svc.CreateMap();
host = allHosts[k];
port = allPorts[k];
Svc.RemoveMapAll(hPropTable);
var perlpath =
Svc.GetStrParameter("param_perl_path");
curScriptResult = Svc.Shell("+perlpath+ chkport.pl
"+host+" "+port);
Svc.SetMapNumElement(hPropTable, "ScriptResult",
curScriptResult);
found = Svc.ExistsMapElement(hTableScriptResult,
hashKey);
if (found)
OldScriptResult =
Svc.GetMapNumValue(hTableScriptResult, hashKey);
else
OldScriptResult = 0;

if (curScriptResult ==
Svc.GetThreshold("thr_result")) {
Svc.SetMapNumElement(hPropTable, "MatchingValue",
Svc.GetThreshold("thr_result"));
Svc.SetMapStrElement(hPropTable, "host", host);
Svc.SetMapStrElement(hPropTable, "port", port);
Svc.SendEventEx ("PortFailed", hPropTable);
}

Svc.SetMapNumElement(hTableScriptResult, hashKey,
curScriptResult);

flagNotFirstRun = true;

}

Svc.DestroyMap(hPropTable);

}

return (0);

}



------------------- L E G A L D I S C L A I M E R -----------------------
Die Informationen in dieser Nachricht sind vertraulich und ausschliesslich fuer
den Adressaten bestimmt.
Kenntnisnahme durch Dritte ist unzulaessig. Die Erstellung
von Kopien oder das Weiterleiten an weitere, nicht originaere
und benannte Adressaten ist nicht vorgesehen und kann
ungesetzlich sein.
Die Meinungen in dieser Nachricht stellen lediglich die
Meinungen des Senders dar. Falls Sie vermuten, dass diese
Nachricht veraendert wurde, setzen Sie sich mit dem
Absender in Verbindung.
Die Markant Handels und Service GmbH uebernimmt ohne
weitere Ueberpruefung keine Verantwortung fuer die
Richtigkeit und Vollstaendigkeit des Inhalts.
Unbefugte Empfaenger werden gebeten, die Vertraulichkeit
der Nachricht zu wahren und den Absender sofort ueber
einen Uebertragungsfehler zu informieren.





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise