Commit 6b86f43d 6b86f43d3193ca732ac68315d94acb1041400f37 by WFLG

Skapat en sitescope.js javascript fil under jetty mappen med custom

monitor koden för sitescope. Bör göras om sen till en template.
1 parent 4498b621
/*************************** LILOM JavaScript ***************************/
/** The lilom.jar file must be deployed in the <package path>\lib dir ***/
/** on the sitescope server installation, otherwise the import will *****/
/** fail and the Utils class cannot be found ****************************/
/************************************************************************/
// Java imports
importPackage(java.lang);
importPackage(com.lil.om);
// Connection String to Oracle for this monitor (format is hostname:port:sid:user:pass)
var con = "vmorasrv:1521:XE:system:Passw0rd";
// Where to find the OraMonREST service
var oramonsrv = "http://localhost:8989/OraMonREST";
// Age that we allow for the data (for caching)
// Set to 0 to force update of data on each monitor run. Set to one second less than the Monitor Run Settings Frequency in seconds for normal use.
var age = 14;
// Creates an object of a custom Java Utils class defined in lilom.jar
var utils = new Utils();
var json, result;
try {
result = utils.wget(oramonsrv+"/getData?connectionString="+con+"&age="+age);
json = JSON.parse(result);
if(json.error == false) {
result = utils.wget(oramonsrv+"/getMetrics?connectionString="+con);
json = JSON.parse(result);
if(json.error == false) {
// We have results, create the monitors
for(var i=0; i < json.nvarray.length; i++) {
myContext.getScriptResult().setValue(json.nvarray[i].name, json.nvarray[i].value);
}
myContext.getScriptResult().setAvailability(true);
myContext.getScriptResult().setSummary("Success");
} else {
myContext.getScriptResult().setAvailability(false);
myContext.getScriptResult().setSummary("Error3: " + json.msg);
}
} else {
myContext.getScriptResult().setAvailability(false);
myContext.getScriptResult().setSummary("Error2: " + json.msg);
}
} catch (e) {
myContext.getScriptResult().setAvailability(false);
myContext.getScriptResult().setSummary("Error1: " + result);
}
// Logger for debug messages. The logger writes messages to <SiteScope>\logs\custom_monitors\custom_monitor.log
//var logger = myContext.getMonitorLog();
//logger.info("debug string");
/*********************************************************************************/
\ No newline at end of file