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
1 /*************************** LILOM JavaScript ***************************/
2 /** The lilom.jar file must be deployed in the <package path>\lib dir ***/
3 /** on the sitescope server installation, otherwise the import will *****/
4 /** fail and the Utils class cannot be found ****************************/
5 /************************************************************************/
6
7 // Java imports
8 importPackage(java.lang);
9 importPackage(com.lil.om);
10
11 // Connection String to Oracle for this monitor (format is hostname:port:sid:user:pass)
12 var con = "vmorasrv:1521:XE:system:Passw0rd";
13
14 // Where to find the OraMonREST service
15 var oramonsrv = "http://localhost:8989/OraMonREST";
16
17 // Age that we allow for the data (for caching)
18 // 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.
19 var age = 14;
20
21 // Creates an object of a custom Java Utils class defined in lilom.jar
22 var utils = new Utils();
23 var json, result;
24
25 try {
26 result = utils.wget(oramonsrv+"/getData?connectionString="+con+"&age="+age);
27 json = JSON.parse(result);
28 if(json.error == false) {
29 result = utils.wget(oramonsrv+"/getMetrics?connectionString="+con);
30 json = JSON.parse(result);
31 if(json.error == false) {
32 // We have results, create the monitors
33 for(var i=0; i < json.nvarray.length; i++) {
34 myContext.getScriptResult().setValue(json.nvarray[i].name, json.nvarray[i].value);
35 }
36 myContext.getScriptResult().setAvailability(true);
37 myContext.getScriptResult().setSummary("Success");
38 } else {
39 myContext.getScriptResult().setAvailability(false);
40 myContext.getScriptResult().setSummary("Error3: " + json.msg);
41 }
42 } else {
43 myContext.getScriptResult().setAvailability(false);
44 myContext.getScriptResult().setSummary("Error2: " + json.msg);
45 }
46 } catch (e) {
47 myContext.getScriptResult().setAvailability(false);
48 myContext.getScriptResult().setSummary("Error1: " + result);
49 }
50
51 // Logger for debug messages. The logger writes messages to <SiteScope>\logs\custom_monitors\custom_monitor.log
52 //var logger = myContext.getMonitorLog();
53 //logger.info("debug string");
54 /*********************************************************************************/
...\ No newline at end of file ...\ No newline at end of file