http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/database-scripts/oracle/monitoring-script.sql ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/database-scripts/oracle/monitoring-script.sql b/extensions/das/modules/artifacts/monitoring-dashboard/database-scripts/oracle/monitoring-script.sql new file mode 100644 index 0000000..97109d9 --- /dev/null +++ b/extensions/das/modules/artifacts/monitoring-dashboard/database-scripts/oracle/monitoring-script.sql @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +CREATE TABLE AVG_MEMORY_CONSUMPTION_STATS(Time NUMBER(20), ClusterId VARCHAR2(150), ClusterInstanceId VARCHAR2(150), +NetworkPartitionId VARCHAR2(150), Value NUMERIC); +CREATE TABLE M_AVG_MEMORY_CONSUMPTION_STATS(Time NUMBER(20), MemberId VARCHAR2(150), ClusterId VARCHAR2(150), +ClusterInstanceId VARCHAR2(150), NetworkPartitionId VARCHAR2(150), Value NUMERIC); +CREATE TABLE AVG_LOAD_AVERAGE_STATS(Time NUMBER(20), ClusterId VARCHAR2(150), ClusterInstanceId VARCHAR2(150), +NetworkPartitionId VARCHAR2(150), Value NUMERIC); +CREATE TABLE M_AVG_LOAD_AVERAGE_STATS(Time NUMBER(20), MemberId VARCHAR2(150), ClusterId VARCHAR2(150), +ClusterInstanceId VARCHAR2(150), NetworkPartitionId VARCHAR2(150), Value NUMERIC); +CREATE TABLE AVG_IN_FLIGHT_REQUESTS(Time NUMBER(20), ClusterId VARCHAR2(150), ClusterInstanceId VARCHAR2(150), +NetworkPartitionId VARCHAR2(150), Count NUMERIC); +CREATE TABLE SCALING_DETAILS(Time NUMBER(20), ScalingDecisionId VARCHAR2(150), ClusterId VARCHAR2(150), +MinInstanceCount INT, MaxInstanceCount INT, RIFPredicted INT, RIFThreshold INT, RIFRequiredInstances INT, MCPredicted + INT, MCThreshold INT, MCRequiredInstances INT, LAPredicted INT, LAThreshold INT,LARequiredInstances INT, + RequiredInstanceCount INT, ActiveInstanceCount INT, AdditionalInstanceCount INT, ScalingReason VARCHAR2(150)); +
http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/health-stats-clusters.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/health-stats-clusters.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/health-stats-clusters.jag deleted file mode 100644 index 767be3a..0000000 --- a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/health-stats-clusters.jag +++ /dev/null @@ -1,42 +0,0 @@ -<% -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -include("monitoring-authentication.jag"); - -(function () { - - var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); - - try { - var clusterInstanceId = request.getParameter('clusterInstanceId'); - var result = db.query("SELECT DISTINCT ClusterId FROM AVERAGE_MEMORY_CONSUMPTION_STATS"); - - if (result != null) { - print(result); - } - } - catch (e) { - print(e.toString()); - } - finally { - db.close(); - } -}()); -%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/health-stats-members.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/health-stats-members.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/health-stats-members.jag deleted file mode 100644 index c8cb711..0000000 --- a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/health-stats-members.jag +++ /dev/null @@ -1,42 +0,0 @@ -<% -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -include("monitoring-authentication.jag"); - -(function () { - - var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); - - try { - var clusterId = request.getParameter('clusterId'); - var result = db.query("SELECT DISTINCT MemberId FROM MEMBER_AVERAGE_MEMORY_CONSUMPTION_STATS WHERE ClusterId=?", clusterId); - - if (result != null) { - print(result); - } - } - catch (e) { - print(e.toString()); - } - finally { - db.close(); - } -}()); -%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/in-flight-request.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/in-flight-request.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/in-flight-request.jag deleted file mode 100644 index 9015b1e..0000000 --- a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/in-flight-request.jag +++ /dev/null @@ -1,84 +0,0 @@ -<% -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -include("monitoring-authentication.jag"); - -(function () { - var log = new Log(); - - var TIME_INTERVAL_1 = '30 Min'; - var TIME_INTERVAL_2 = '1 Hour'; - var TIME_INTERVAL_3 = '1 Day'; - var TIME_INTERVAL_4 = '1 Week'; - var TIME_INTERVAL_5 = '1 Month'; - - var content = request.getContent(); - var contentAsString = null; - if (content != '' && content != null) { - contentAsString = stringify(content); - if (log.isDebugEnabled()) { - log.debug("Value of content: " + contentAsString); - } - } - - var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); - - try { - var result; - - var timeInterval = request.getParameter("time"); - var interval = 1800000; - var x_axis_interval; - var time_format; - if (timeInterval === TIME_INTERVAL_1) { - interval = 1800000; - x_axis_interval = 60; - time_format = '%h:%i'; - } else if (timeInterval === TIME_INTERVAL_2) { - interval = 3600000; - x_axis_interval = 120; - time_format = '%h:%i'; - } else if (timeInterval === TIME_INTERVAL_3) { - interval = 86400000; - x_axis_interval = 2880; - time_format = '%Y:%m:%d %h:%i'; - } else if (timeInterval === TIME_INTERVAL_4) { - interval = 604800000; - x_axis_interval = 20160; - time_format = '%Y:%m:%d %h:%i'; - } else if (timeInterval === TIME_INTERVAL_5) { - interval = 2419200000; - x_axis_interval = 80640; - time_format = '%Y:%m:%d'; - } - - var clusterId = request.getParameter("clusterId"); - result = db.query("SELECT FROM_UNIXTIME(CEILING( Time/('" + x_axis_interval + "'*1000)) *'" + x_axis_interval + "', '" + time_format + "') AS Time, AVG(Count) AS Count FROM AVERAGE_IN_FLIGHT_REQUESTS WHERE ClusterId=? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) GROUP BY FROM_UNIXTIME( CEILING( Time/('" + x_axis_interval + "'*1000)) *'"+x_axis_interval+"', '%Y:%m:%d %h:%i'), ClusterId", clusterId); - print(result); - - } - catch (e) { - print(e.toString()); - } - finally { - db.close(); - } -}()); -%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/load-average.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/load-average.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/load-average.jag deleted file mode 100644 index ce436ae..0000000 --- a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/load-average.jag +++ /dev/null @@ -1,91 +0,0 @@ -<% -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -include("monitoring-authentication.jag"); - -(function () { - var log = new Log(); - - var TIME_INTERVAL_1 = '30 Min'; - var TIME_INTERVAL_2 = '1 Hour'; - var TIME_INTERVAL_3 = '1 Day'; - var TIME_INTERVAL_4 = '1 Week'; - var TIME_INTERVAL_5 = '1 Month'; - var ALL_MEMBERS = 'All Members'; - - var content = request.getContent(); - var contentAsString = null; - if (content != '' && content != null) { - contentAsString = stringify(content); - if (log.isDebugEnabled()) { - log.debug("Value of content: " + contentAsString); - } - } - - var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); - - try { - var result; - - var timeInterval = request.getParameter("time"); - var interval = 1800000; - var x_axis_interval; - var time_format; - if (timeInterval === TIME_INTERVAL_1) { - interval = 1800000; - x_axis_interval = 60; - time_format = '%h:%i'; - } else if (timeInterval === TIME_INTERVAL_2) { - interval = 3600000; - x_axis_interval = 120; - time_format = '%h:%i'; - } else if (timeInterval === TIME_INTERVAL_3) { - interval = 86400000; - x_axis_interval = 2880; - time_format = '%Y:%m:%d %h:%i'; - } else if (timeInterval === TIME_INTERVAL_4) { - interval = 604800000; - x_axis_interval = 20160; - time_format = '%Y:%m:%d %h:%i'; - } else if (timeInterval === TIME_INTERVAL_5) { - interval = 2419200000; - x_axis_interval = 80640; - time_format = '%Y:%m:%d'; - } - - var clusterId = request.getParameter("clusterId"); - var memberId = request.getParameter("memberId"); - - if (memberId == ALL_MEMBERS) { - result = db.query("SELECT FROM_UNIXTIME(CEILING( Time/('" + x_axis_interval + "'*1000)) *'" + x_axis_interval + "', '" + time_format + "') AS Time, AVG(Value) AS Value FROM AVERAGE_LOAD_AVERAGE_STATS WHERE ClusterId=? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) GROUP BY FROM_UNIXTIME( CEILING( Time/('" + x_axis_interval + "'*1000)) *'"+x_axis_interval+"', '%Y:%m:%d %h:%i'), ClusterId", clusterId); - }else{ - result = db.query("SELECT FROM_UNIXTIME(CEILING( Time/('" + x_axis_interval + "'*1000)) *'" + x_axis_interval + "', '" + time_format + "') AS Time, AVG(Value) AS Value FROM MEMBER_AVERAGE_LOAD_AVERAGE_STATS WHERE ClusterId=? AND MemberId=? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) GROUP BY FROM_UNIXTIME( CEILING( Time/('" + x_axis_interval + "'*1000)) *'"+x_axis_interval+"', '%Y:%m:%d %h:%i'), ClusterId, MemberId", clusterId, memberId); - } - print(result); - - } - catch (e) { - print(e.toString()); - } - finally { - db.close(); - } -}()); -%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/memory-usage.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/memory-usage.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/memory-usage.jag deleted file mode 100644 index 54d66d4..0000000 --- a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/memory-usage.jag +++ /dev/null @@ -1,91 +0,0 @@ -<% -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -include("monitoring-authentication.jag"); - -(function () { - var log = new Log(); - - var TIME_INTERVAL_1 = '30 Min'; - var TIME_INTERVAL_2 = '1 Hour'; - var TIME_INTERVAL_3 = '1 Day'; - var TIME_INTERVAL_4 = '1 Week'; - var TIME_INTERVAL_5 = '1 Month'; - var ALL_MEMBERS = 'All Members'; - - var content = request.getContent(); - var contentAsString = null; - if (content != '' && content != null) { - contentAsString = stringify(content); - if (log.isDebugEnabled()) { - log.debug("Value of content: " + contentAsString); - } - } - - var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); - - try { - var result; - - var timeInterval = request.getParameter("time"); - var interval = 1800000; - var x_axis_interval; - var time_format; - if (timeInterval === TIME_INTERVAL_1) { - interval = 1800000; - x_axis_interval = 60; - time_format = '%h:%i'; - } else if (timeInterval === TIME_INTERVAL_2) { - interval = 3600000; - x_axis_interval = 120; - time_format = '%h:%i'; - } else if (timeInterval === TIME_INTERVAL_3) { - interval = 86400000; - x_axis_interval = 2880; - time_format = '%Y:%m:%d %h:%i'; - } else if (timeInterval === TIME_INTERVAL_4) { - interval = 604800000; - x_axis_interval = 20160; - time_format = '%Y:%m:%d %h:%i'; - } else if (timeInterval === TIME_INTERVAL_5) { - interval = 2419200000; - x_axis_interval = 80640; - time_format = '%Y:%m:%d'; - } - - var clusterId = request.getParameter("clusterId"); - var memberId = request.getParameter("memberId"); - - if (memberId == ALL_MEMBERS) { - result = db.query("SELECT FROM_UNIXTIME(CEILING( Time/('" + x_axis_interval + "'*1000)) *'" + x_axis_interval + "', '" + time_format + "') AS Time, AVG(Value) AS Value FROM AVERAGE_MEMORY_CONSUMPTION_STATS WHERE ClusterId=? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) GROUP BY FROM_UNIXTIME( CEILING( Time/('" + x_axis_interval + "'*1000)) *'"+x_axis_interval+"', '%Y:%m:%d %h:%i'), ClusterId", clusterId); - } else { - result = db.query("SELECT FROM_UNIXTIME(CEILING( Time/('" + x_axis_interval + "'*1000)) *'" + x_axis_interval + "', '" + time_format + "') AS Time, AVG(Value) AS Value FROM MEMBER_AVERAGE_MEMORY_CONSUMPTION_STATS WHERE ClusterId=? AND MemberId=? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) GROUP BY FROM_UNIXTIME( CEILING( Time/('" + x_axis_interval + "'*1000)) *'"+x_axis_interval+"', '%Y:%m:%d %h:%i'), ClusterId, MemberId", clusterId, memberId); - } - print(result); - - } - catch (e) { - print(e.toString()); - } - finally { - db.close(); - } -}()); -%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/monitoring-authentication.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/monitoring-authentication.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/monitoring-authentication.jag deleted file mode 100644 index dd2448c..0000000 --- a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/monitoring-authentication.jag +++ /dev/null @@ -1,74 +0,0 @@ -<% -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -(function () { - var log = new Log(); - - var HTTPS_TRANSPORT = "https"; - var AUTHORIZATION_HEADER = "Authorization"; - var ANALYTICS_SERVICE = "/services/AnalyticsWebService"; - var AUTHENTICATION_SERVICE = "/services/AuthenticationAdmin"; - var AUTH_TOKEN = "authToken"; - var LOCALHOST = "localhost"; - var HTTP_USER_NOT_AUTHENTICATED = 403; - - var carbon = require('carbon'); - var configs = require('/configs/designer.json'); - var HTTPConstants = Packages.org.apache.axis2.transport.http.HTTPConstants; - var AnalyticsWebServiceStub = Packages.org.wso2.carbon.analytics.webservice.stub.AnalyticsWebServiceStub; - var AuthenticationAdminStub = Packages.org.wso2.carbon.authenticator.stub.AuthenticationAdminStub; - - var analyticsWSUrl = carbon.server.address(HTTPS_TRANSPORT) + ANALYTICS_SERVICE; - var authenticationWSUrl = carbon.server.address(HTTPS_TRANSPORT) + AUTHENTICATION_SERVICE; - var analyticsStub; - try { - analyticsStub = new AnalyticsWebServiceStub(analyticsWSUrl); - } catch (e) { - if (log.isDebugEnabled()) { - log.debug("Unable to instantiate AnalyticsWebServiceStub instance. This could be a CEP server. Returning"); - } - return; - } - var serviceClient = analyticsStub._getServiceClient(); - var options = serviceClient.getOptions(); - options.setManageSession(true); - - var authParam = request.getHeader(AUTHORIZATION_HEADER); - if (authParam != null) { - credentials = JSUtils.authenticate(authParam); - authenticationAdminStub = new AuthenticationAdminStub(authenticationWSUrl); - authenticationAdminStub.login(credentials[0], credentials[1], LOCALHOST); - var serviceContext = authenticationAdminStub._getServiceClient().getLastOperationContext() - .getServiceContext(); - var sessionCookie = serviceContext.getProperty(HTTPConstants.COOKIE_STRING); - options.setProperty(HTTPConstants.COOKIE_STRING, sessionCookie); - } else { - var token = session.get(AUTH_TOKEN); - if (token != null) { - options.setProperty(HTTPConstants.COOKIE_STRING, token); - } else { - log.error("user is not authenticated!"); - response.status = HTTP_USER_NOT_AUTHENTICATED; - print('{ "status": "Failed", "message": "User is not authenticated." }'); - return; - } - } -}); -%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/health-stats-clusters.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/health-stats-clusters.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/health-stats-clusters.jag new file mode 100644 index 0000000..d7339cf --- /dev/null +++ b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/health-stats-clusters.jag @@ -0,0 +1,42 @@ +<% +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +include("monitoring-authentication.jag"); + +(function () { + + var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); + + try { + var clusterInstanceId = request.getParameter('clusterInstanceId'); + var result = db.query("SELECT DISTINCT ClusterId FROM AVG_MEMORY_CONSUMPTION_STATS"); + + if (result != null) { + print(result); + } + } + catch (e) { + print(e.toString()); + } + finally { + db.close(); + } +}()); +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/health-stats-members.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/health-stats-members.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/health-stats-members.jag new file mode 100644 index 0000000..0b50209 --- /dev/null +++ b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/health-stats-members.jag @@ -0,0 +1,42 @@ +<% +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +include("monitoring-authentication.jag"); + +(function () { + + var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); + + try { + var clusterId = request.getParameter('clusterId'); + var result = db.query("SELECT DISTINCT MemberId FROM M_AVG_MEMORY_CONSUMPTION_STATS WHERE ClusterId=?", clusterId); + + if (result != null) { + print(result); + } + } + catch (e) { + print(e.toString()); + } + finally { + db.close(); + } +}()); +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/in-flight-request.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/in-flight-request.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/in-flight-request.jag new file mode 100644 index 0000000..e5478e8 --- /dev/null +++ b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/in-flight-request.jag @@ -0,0 +1,84 @@ +<% +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +include("monitoring-authentication.jag"); + +(function () { + var log = new Log(); + + var TIME_INTERVAL_1 = '30 Min'; + var TIME_INTERVAL_2 = '1 Hour'; + var TIME_INTERVAL_3 = '1 Day'; + var TIME_INTERVAL_4 = '1 Week'; + var TIME_INTERVAL_5 = '1 Month'; + + var content = request.getContent(); + var contentAsString = null; + if (content != '' && content != null) { + contentAsString = stringify(content); + if (log.isDebugEnabled()) { + log.debug("Value of content: " + contentAsString); + } + } + + var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); + + try { + var result; + + var timeInterval = request.getParameter("time"); + var interval = 1800000; + var x_axis_interval; + var time_format; + if (timeInterval === TIME_INTERVAL_1) { + interval = 1800000; + x_axis_interval = 60; + time_format = '%h:%i'; + } else if (timeInterval === TIME_INTERVAL_2) { + interval = 3600000; + x_axis_interval = 120; + time_format = '%h:%i'; + } else if (timeInterval === TIME_INTERVAL_3) { + interval = 86400000; + x_axis_interval = 2880; + time_format = '%Y:%m:%d %h:%i'; + } else if (timeInterval === TIME_INTERVAL_4) { + interval = 604800000; + x_axis_interval = 20160; + time_format = '%Y:%m:%d %h:%i'; + } else if (timeInterval === TIME_INTERVAL_5) { + interval = 2419200000; + x_axis_interval = 80640; + time_format = '%Y:%m:%d'; + } + + var clusterId = request.getParameter("clusterId"); + result = db.query("SELECT FROM_UNIXTIME(CEILING( Time/('" + x_axis_interval + "'*1000)) *'" + x_axis_interval + "', '" + time_format + "') AS Time, AVG(Count) AS Count FROM AVG_IN_FLIGHT_REQUESTS WHERE ClusterId=? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) GROUP BY FROM_UNIXTIME( CEILING( Time/('" + x_axis_interval + "'*1000)) *'"+x_axis_interval+"', '%Y:%m:%d %h:%i'), ClusterId", clusterId); + print(result); + + } + catch (e) { + print(e.toString()); + } + finally { + db.close(); + } +}()); +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/load-average.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/load-average.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/load-average.jag new file mode 100644 index 0000000..84ed3ad --- /dev/null +++ b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/load-average.jag @@ -0,0 +1,91 @@ +<% +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +include("monitoring-authentication.jag"); + +(function () { + var log = new Log(); + + var TIME_INTERVAL_1 = '30 Min'; + var TIME_INTERVAL_2 = '1 Hour'; + var TIME_INTERVAL_3 = '1 Day'; + var TIME_INTERVAL_4 = '1 Week'; + var TIME_INTERVAL_5 = '1 Month'; + var ALL_MEMBERS = 'All Members'; + + var content = request.getContent(); + var contentAsString = null; + if (content != '' && content != null) { + contentAsString = stringify(content); + if (log.isDebugEnabled()) { + log.debug("Value of content: " + contentAsString); + } + } + + var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); + + try { + var result; + + var timeInterval = request.getParameter("time"); + var interval = 1800000; + var x_axis_interval; + var time_format; + if (timeInterval === TIME_INTERVAL_1) { + interval = 1800000; + x_axis_interval = 60; + time_format = '%h:%i'; + } else if (timeInterval === TIME_INTERVAL_2) { + interval = 3600000; + x_axis_interval = 120; + time_format = '%h:%i'; + } else if (timeInterval === TIME_INTERVAL_3) { + interval = 86400000; + x_axis_interval = 2880; + time_format = '%Y:%m:%d %h:%i'; + } else if (timeInterval === TIME_INTERVAL_4) { + interval = 604800000; + x_axis_interval = 20160; + time_format = '%Y:%m:%d %h:%i'; + } else if (timeInterval === TIME_INTERVAL_5) { + interval = 2419200000; + x_axis_interval = 80640; + time_format = '%Y:%m:%d'; + } + + var clusterId = request.getParameter("clusterId"); + var memberId = request.getParameter("memberId"); + + if (memberId == ALL_MEMBERS) { + result = db.query("SELECT FROM_UNIXTIME(CEILING( Time/('" + x_axis_interval + "'*1000)) *'" + x_axis_interval + "', '" + time_format + "') AS Time, AVG(Value) AS Value FROM AVG_LOAD_AVERAGE_STATS WHERE ClusterId=? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) GROUP BY FROM_UNIXTIME( CEILING( Time/('" + x_axis_interval + "'*1000)) *'"+x_axis_interval+"', '%Y:%m:%d %h:%i'), ClusterId", clusterId); + }else{ + result = db.query("SELECT FROM_UNIXTIME(CEILING( Time/('" + x_axis_interval + "'*1000)) *'" + x_axis_interval + "', '" + time_format + "') AS Time, AVG(Value) AS Value FROM M_AVG_LOAD_AVERAGE_STATS WHERE ClusterId=? AND MemberId=? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) GROUP BY FROM_UNIXTIME( CEILING( Time/('" + x_axis_interval + "'*1000)) *'"+x_axis_interval+"', '%Y:%m:%d %h:%i'), ClusterId, MemberId", clusterId, memberId); + } + print(result); + + } + catch (e) { + print(e.toString()); + } + finally { + db.close(); + } +}()); +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/memory-usage.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/memory-usage.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/memory-usage.jag new file mode 100644 index 0000000..4ca7b37 --- /dev/null +++ b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/memory-usage.jag @@ -0,0 +1,91 @@ +<% +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +include("monitoring-authentication.jag"); + +(function () { + var log = new Log(); + + var TIME_INTERVAL_1 = '30 Min'; + var TIME_INTERVAL_2 = '1 Hour'; + var TIME_INTERVAL_3 = '1 Day'; + var TIME_INTERVAL_4 = '1 Week'; + var TIME_INTERVAL_5 = '1 Month'; + var ALL_MEMBERS = 'All Members'; + + var content = request.getContent(); + var contentAsString = null; + if (content != '' && content != null) { + contentAsString = stringify(content); + if (log.isDebugEnabled()) { + log.debug("Value of content: " + contentAsString); + } + } + + var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); + + try { + var result; + + var timeInterval = request.getParameter("time"); + var interval = 1800000; + var x_axis_interval; + var time_format; + if (timeInterval === TIME_INTERVAL_1) { + interval = 1800000; + x_axis_interval = 60; + time_format = '%h:%i'; + } else if (timeInterval === TIME_INTERVAL_2) { + interval = 3600000; + x_axis_interval = 120; + time_format = '%h:%i'; + } else if (timeInterval === TIME_INTERVAL_3) { + interval = 86400000; + x_axis_interval = 2880; + time_format = '%Y:%m:%d %h:%i'; + } else if (timeInterval === TIME_INTERVAL_4) { + interval = 604800000; + x_axis_interval = 20160; + time_format = '%Y:%m:%d %h:%i'; + } else if (timeInterval === TIME_INTERVAL_5) { + interval = 2419200000; + x_axis_interval = 80640; + time_format = '%Y:%m:%d'; + } + + var clusterId = request.getParameter("clusterId"); + var memberId = request.getParameter("memberId"); + + if (memberId == ALL_MEMBERS) { + result = db.query("SELECT FROM_UNIXTIME(CEILING( Time/('" + x_axis_interval + "'*1000)) *'" + x_axis_interval + "', '" + time_format + "') AS Time, AVG(Value) AS Value FROM AVG_MEMORY_CONSUMPTION_STATS WHERE ClusterId=? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) GROUP BY FROM_UNIXTIME( CEILING( Time/('" + x_axis_interval + "'*1000)) *'"+x_axis_interval+"', '%Y:%m:%d %h:%i'), ClusterId", clusterId); + } else { + result = db.query("SELECT FROM_UNIXTIME(CEILING( Time/('" + x_axis_interval + "'*1000)) *'" + x_axis_interval + "', '" + time_format + "') AS Time, AVG(Value) AS Value FROM M_AVG_MEMORY_CONSUMPTION_STATS WHERE ClusterId=? AND MemberId=? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) GROUP BY FROM_UNIXTIME( CEILING( Time/('" + x_axis_interval + "'*1000)) *'"+x_axis_interval+"', '%Y:%m:%d %h:%i'), ClusterId, MemberId", clusterId, memberId); + } + print(result); + + } + catch (e) { + print(e.toString()); + } + finally { + db.close(); + } +}()); +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/monitoring-authentication.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/monitoring-authentication.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/monitoring-authentication.jag new file mode 100644 index 0000000..dd2448c --- /dev/null +++ b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/monitoring-authentication.jag @@ -0,0 +1,74 @@ +<% +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +(function () { + var log = new Log(); + + var HTTPS_TRANSPORT = "https"; + var AUTHORIZATION_HEADER = "Authorization"; + var ANALYTICS_SERVICE = "/services/AnalyticsWebService"; + var AUTHENTICATION_SERVICE = "/services/AuthenticationAdmin"; + var AUTH_TOKEN = "authToken"; + var LOCALHOST = "localhost"; + var HTTP_USER_NOT_AUTHENTICATED = 403; + + var carbon = require('carbon'); + var configs = require('/configs/designer.json'); + var HTTPConstants = Packages.org.apache.axis2.transport.http.HTTPConstants; + var AnalyticsWebServiceStub = Packages.org.wso2.carbon.analytics.webservice.stub.AnalyticsWebServiceStub; + var AuthenticationAdminStub = Packages.org.wso2.carbon.authenticator.stub.AuthenticationAdminStub; + + var analyticsWSUrl = carbon.server.address(HTTPS_TRANSPORT) + ANALYTICS_SERVICE; + var authenticationWSUrl = carbon.server.address(HTTPS_TRANSPORT) + AUTHENTICATION_SERVICE; + var analyticsStub; + try { + analyticsStub = new AnalyticsWebServiceStub(analyticsWSUrl); + } catch (e) { + if (log.isDebugEnabled()) { + log.debug("Unable to instantiate AnalyticsWebServiceStub instance. This could be a CEP server. Returning"); + } + return; + } + var serviceClient = analyticsStub._getServiceClient(); + var options = serviceClient.getOptions(); + options.setManageSession(true); + + var authParam = request.getHeader(AUTHORIZATION_HEADER); + if (authParam != null) { + credentials = JSUtils.authenticate(authParam); + authenticationAdminStub = new AuthenticationAdminStub(authenticationWSUrl); + authenticationAdminStub.login(credentials[0], credentials[1], LOCALHOST); + var serviceContext = authenticationAdminStub._getServiceClient().getLastOperationContext() + .getServiceContext(); + var sessionCookie = serviceContext.getProperty(HTTPConstants.COOKIE_STRING); + options.setProperty(HTTPConstants.COOKIE_STRING, sessionCookie); + } else { + var token = session.get(AUTH_TOKEN); + if (token != null) { + options.setProperty(HTTPConstants.COOKIE_STRING, token); + } else { + log.error("user is not authenticated!"); + response.status = HTTP_USER_NOT_AUTHENTICATED; + print('{ "status": "Failed", "message": "User is not authenticated." }'); + return; + } + } +}); +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/scaling-details.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/scaling-details.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/scaling-details.jag new file mode 100644 index 0000000..c74e3d3 --- /dev/null +++ b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/mysql/scaling-details.jag @@ -0,0 +1,73 @@ +<% +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +include("monitoring-authentication.jag"); + +(function () { + var log = new Log(); + + var TIME_INTERVAL_1 = '30 Min'; + var TIME_INTERVAL_2 = '1 Hour'; + var TIME_INTERVAL_3 = '1 Day'; + var TIME_INTERVAL_4 = '1 Week'; + var TIME_INTERVAL_5 = '1 Month'; + var ALL_CLUSTERS = 'All Clusters'; + + var content = request.getContent(); + var contentAsString = null; + if (content != '' && content != null) { + contentAsString = stringify(content); + if (log.isDebugEnabled()) { + log.debug("Value of content: " + contentAsString); + } + } + + var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); + + try { + var result; + + var timeInterval = request.getParameter("time"); + var interval = 1800000; + + if (timeInterval === TIME_INTERVAL_1) { + interval = 1800000; + } else if (timeInterval === TIME_INTERVAL_2) { + interval = 3600000; + } else if (timeInterval === TIME_INTERVAL_3) { + interval = 86400000; + } else if (timeInterval === TIME_INTERVAL_4) { + interval = 604800000; + } else if (timeInterval === TIME_INTERVAL_5) { + interval = 2419200000; + } + + var clusterId = request.getParameter("clusterId"); + result = db.query("SELECT FROM_UNIXTIME(CEILING( Time/1000 ), '%Y:%m:%d %h:%i') AS Time, ClusterId, MinInstanceCount, MaxInstanceCount, RIFPredicted, RIFThreshold, RIFRequiredInstances, MCPredicted, MCThreshold, MCRequiredInstances, LAPredicted, LAThreshold, LARequiredInstances, RequiredInstanceCount, ActiveInstanceCount, AdditionalInstanceCount, ScalingReason FROM SCALING_DETAILS WHERE ClusterId= ? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000)", clusterId); + print(result); + } + catch (e) { + print(e.toString()); + } + finally { + db.close(); + } +}()); +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/health-stats-clusters.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/health-stats-clusters.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/health-stats-clusters.jag new file mode 100644 index 0000000..d31a758 --- /dev/null +++ b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/health-stats-clusters.jag @@ -0,0 +1,42 @@ +<% +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +include("monitoring-authentication.jag"); + +(function () { + + var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); + + try { + var clusterInstanceId = request.getParameter('clusterInstanceId'); + var result = db.query("SELECT DISTINCT ClusterId \"ClusterId\" FROM AVG_MEMORY_CONSUMPTION_STATS"); + + if (result != null) { + print(result); + } + } + catch (e) { + print(e.toString()); + } + finally { + db.close(); + } +}()); +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/health-stats-members.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/health-stats-members.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/health-stats-members.jag new file mode 100644 index 0000000..71dff24 --- /dev/null +++ b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/health-stats-members.jag @@ -0,0 +1,43 @@ +<% +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +include("monitoring-authentication.jag"); + +(function () { + + var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); + + try { + var clusterId = request.getParameter('clusterId'); + var result = db.query("SELECT DISTINCT MemberId \"MemberId\" FROM M_AVG_MEMORY_CONSUMPTION_STATS WHERE " + + "ClusterId=?", clusterId); + + if (result != null) { + print(result); + } + } + catch (e) { + print(e.toString()); + } + finally { + db.close(); + } +}()); +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/in-flight-request.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/in-flight-request.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/in-flight-request.jag new file mode 100644 index 0000000..dd98b08 --- /dev/null +++ b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/in-flight-request.jag @@ -0,0 +1,94 @@ +<% +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +include("monitoring-authentication.jag"); + +(function () { + var log = new Log(); + + var TIME_INTERVAL_1 = '30 Min'; + var TIME_INTERVAL_2 = '1 Hour'; + var TIME_INTERVAL_3 = '1 Day'; + var TIME_INTERVAL_4 = '1 Week'; + var TIME_INTERVAL_5 = '1 Month'; + + var content = request.getContent(); + var contentAsString = null; + if (content != '' && content != null) { + contentAsString = stringify(content); + if (log.isDebugEnabled()) { + log.debug("Value of content: " + contentAsString); + } + } + + var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); + + try { + var result; + + var timeInterval = request.getParameter("time"); + var interval = 1800; + var x_axis_interval; + var time_format; + if (timeInterval === TIME_INTERVAL_1) { + interval = 1800; + x_axis_interval = 60; + time_format = 'hh24:mi'; + } else if (timeInterval === TIME_INTERVAL_2) { + interval = 3600; + x_axis_interval = 120; + time_format = 'hh24:mi'; + } else if (timeInterval === TIME_INTERVAL_3) { + interval = 86400; + x_axis_interval = 2880; + time_format = 'yyyy-mm-dd hh24:mi'; + } else if (timeInterval === TIME_INTERVAL_4) { + interval = 604800; + x_axis_interval = 20160; + time_format = 'yyyy-mm-dd hh24:mi'; + } else if (timeInterval === TIME_INTERVAL_5) { + interval = 2419200; + x_axis_interval = 80640; + time_format = 'yyyy-mm-dd'; + } + + var clusterId = request.getParameter("clusterId"); + result = db.query("SELECT TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL(CEIL" + + "(Time/(" + x_axis_interval + " * 1000)) * " + x_axis_interval + ", 'second')) AT LOCAL, '" + + time_format + "') \"Time\", AVG(Count) AS \"Count\" FROM AVG_IN_FLIGHT_REQUESTS WHERE ClusterId=? AND" + + " TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL(Time/1000,'second')) " + + "AT LOCAL, 'yyyy-mm-dd hh24:mi') BETWEEN TO_CHAR(LOCALTIMESTAMP - NUMTODSINTERVAL(" + interval + ", " + + "'second'),'yyyy-mm-dd hh24:mi') AND TO_CHAR(LOCALTIMESTAMP,'yyyy-mm-dd hh24:mi') GROUP BY TO_CHAR(" + + "(TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL(CEIL(Time/(" + x_axis_interval + + " * 1000)) * " + x_axis_interval + ", 'second')) AT LOCAL, '" + time_format + "'), ClusterId ORDER " + + "BY TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL(CEIL(Time/(" + + x_axis_interval + " * 1000)) * " + x_axis_interval + ", 'second')) AT LOCAL, '" + time_format + "')", + clusterId); + print(result); + + } + catch (e) { + print(e.toString()); + } + finally { + db.close(); + } +}()); +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/load-average.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/load-average.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/load-average.jag new file mode 100644 index 0000000..4083979 --- /dev/null +++ b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/load-average.jag @@ -0,0 +1,112 @@ +<% +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +include("monitoring-authentication.jag"); + +(function () { + var log = new Log(); + + var TIME_INTERVAL_1 = '30 Min'; + var TIME_INTERVAL_2 = '1 Hour'; + var TIME_INTERVAL_3 = '1 Day'; + var TIME_INTERVAL_4 = '1 Week'; + var TIME_INTERVAL_5 = '1 Month'; + var ALL_MEMBERS = 'All Members'; + + var content = request.getContent(); + var contentAsString = null; + if (content != '' && content != null) { + contentAsString = stringify(content); + if (log.isDebugEnabled()) { + log.debug("Value of content: " + contentAsString); + } + } + + var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); + + try { + var result; + + var timeInterval = request.getParameter("time"); + var interval = 1800; + var x_axis_interval; + var time_format; + if (timeInterval === TIME_INTERVAL_1) { + interval = 1800; + x_axis_interval = 60; + time_format = 'hh24:mi'; + } else if (timeInterval === TIME_INTERVAL_2) { + interval = 3600; + x_axis_interval = 120; + time_format = 'hh24:mi'; + } else if (timeInterval === TIME_INTERVAL_3) { + interval = 86400; + x_axis_interval = 2880; + time_format = 'yyyy-mm-dd hh24:mi'; + } else if (timeInterval === TIME_INTERVAL_4) { + interval = 604800; + x_axis_interval = 20160; + time_format = 'yyyy-mm-dd hh24:mi'; + } else if (timeInterval === TIME_INTERVAL_5) { + interval = 2419200; + x_axis_interval = 80640; + time_format = 'yyyy-mm-dd'; + } + + var clusterId = request.getParameter("clusterId"); + var memberId = request.getParameter("memberId"); + + if (memberId == ALL_MEMBERS) { + result = db.query("SELECT TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL" + + "(CEIL(Time/(" + x_axis_interval + " * 1000)) * " + x_axis_interval + ", 'second')) AT LOCAL, '" + + time_format + "') AS \"Time\", AVG(Value) AS \"Value\" FROM AVG_LOAD_AVERAGE_STATS WHERE " + + "ClusterId=? AND TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL" + + "(Time/1000,'second')) AT LOCAL, 'yyyy-mm-dd hh24:mi') BETWEEN TO_CHAR(LOCALTIMESTAMP - " + + "NUMTODSINTERVAL(" + interval + ", 'second'),'yyyy-mm-dd hh24:mi') AND TO_CHAR(LOCALTIMESTAMP," + + "'yyyy-mm-dd hh24:mi') GROUP BY TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + " + + "NUMTODSINTERVAL(CEIL(Time/(" + x_axis_interval + " * 1000)) * " + x_axis_interval + ", 'second')" + + ") AT LOCAL, '" + time_format + "') ORDER BY TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME " + + "ZONE 'UTC' + NUMTODSINTERVAL(CEIL(Time/(" + x_axis_interval + " * 1000)) * " + x_axis_interval + + ", 'second')) AT LOCAL, '" + time_format + "')", clusterId); + } else { + result = db.query("SELECT TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL" + + "(CEIL(Time/(" + x_axis_interval + " * 1000)) * " + x_axis_interval + ", 'second')) AT LOCAL, '" + + time_format + "') AS \"Time\", AVG(Value) AS \"Value\" FROM M_AVG_LOAD_AVERAGE_STATS WHERE " + + "ClusterId=? AND MemberId=? AND TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + " + + "NUMTODSINTERVAL(Time/1000,'second')) AT LOCAL, 'yyyy-mm-dd hh24:mi') BETWEEN TO_CHAR" + + "(LOCALTIMESTAMP - NUMTODSINTERVAL(" + interval + ", 'second'),'yyyy-mm-dd hh24:mi') AND TO_CHAR" + + "(LOCALTIMESTAMP,'yyyy-mm-dd hh24:mi') GROUP BY TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME " + + "ZONE 'UTC' + NUMTODSINTERVAL(CEIL(Time/(" + x_axis_interval + " * 1000)) * " + x_axis_interval + + ", 'second')) AT LOCAL, '" + time_format + "'), ClusterId, MemberId ORDER BY TO_CHAR((TIMESTAMP " + + "'1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL(CEIL(Time/(" + x_axis_interval + " *" + + " 1000)) * " + x_axis_interval + ", 'second')) AT LOCAL, '" + time_format + "')", clusterId, + memberId); + } + print(result); + + } + catch (e) { + print(e.toString()); + } + finally { + db.close(); + } +}()); +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/memory-usage.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/memory-usage.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/memory-usage.jag new file mode 100644 index 0000000..1aaf920 --- /dev/null +++ b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/memory-usage.jag @@ -0,0 +1,112 @@ +<% +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +include("monitoring-authentication.jag"); + +(function () { + var log = new Log(); + + var TIME_INTERVAL_1 = '30 Min'; + var TIME_INTERVAL_2 = '1 Hour'; + var TIME_INTERVAL_3 = '1 Day'; + var TIME_INTERVAL_4 = '1 Week'; + var TIME_INTERVAL_5 = '1 Month'; + var ALL_MEMBERS = 'All Members'; + + var content = request.getContent(); + var contentAsString = null; + if (content != '' && content != null) { + contentAsString = stringify(content); + if (log.isDebugEnabled()) { + log.debug("Value of content: " + contentAsString); + } + } + + var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); + + try { + var result; + + var timeInterval = request.getParameter("time"); + var interval = 1800; + var x_axis_interval; + var time_format; + if (timeInterval === TIME_INTERVAL_1) { + interval = 1800; + x_axis_interval = 60; + time_format = 'hh24:mi'; + } else if (timeInterval === TIME_INTERVAL_2) { + interval = 3600; + x_axis_interval = 120; + time_format = 'hh24:mi'; + } else if (timeInterval === TIME_INTERVAL_3) { + interval = 86400; + x_axis_interval = 2880; + time_format = 'yyyy-mm-dd hh24:mi'; + } else if (timeInterval === TIME_INTERVAL_4) { + interval = 604800; + x_axis_interval = 20160; + time_format = 'yyyy-mm-dd hh24:mi'; + } else if (timeInterval === TIME_INTERVAL_5) { + interval = 2419200; + x_axis_interval = 80640; + time_format = 'yyyy-mm-dd'; + } + + var clusterId = request.getParameter("clusterId"); + var memberId = request.getParameter("memberId"); + + if (memberId == ALL_MEMBERS) { + result = db.query("SELECT TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL" + + "(CEIL(Time/(" + x_axis_interval + " * 1000)) * " + x_axis_interval + ", 'second')) AT LOCAL, '" + + time_format + "') AS \"Time\", AVG(Value) AS \"Value\" FROM AVG_MEMORY_CONSUMPTION_STATS WHERE " + + "ClusterId=? AND TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL" + + "(Time/1000,'second')) AT LOCAL, 'yyyy-mm-dd hh24:mi') BETWEEN TO_CHAR(LOCALTIMESTAMP - " + + "NUMTODSINTERVAL(" + interval + ", 'second'),'yyyy-mm-dd hh24:mi') AND TO_CHAR(LOCALTIMESTAMP," + + "'yyyy-mm-dd hh24:mi') GROUP BY TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + " + + "NUMTODSINTERVAL(CEIL(Time/(" + x_axis_interval + " * 1000)) * " + x_axis_interval + ", 'second')" + + ") AT LOCAL, '" + time_format + "'), ClusterId ORDER BY TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' " + + "AT TIME ZONE 'UTC' + NUMTODSINTERVAL(CEIL(Time/(" + x_axis_interval + " * 1000)) * " + + x_axis_interval + ", 'second')) AT LOCAL, '" + time_format + "')", clusterId); + } else { + result = db.query("SELECT TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL" + + "(CEIL(Time/(" + x_axis_interval + " * 1000)) * " + x_axis_interval + ", 'second')) AT LOCAL , '" + + time_format + "') AS \"Time\", AVG(Value) AS \"Value\" FROM M_AVG_MEMORY_CONSUMPTION_STATS " + + "WHERE ClusterId=? AND MemberId=? AND TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC'" + + " + NUMTODSINTERVAL(Time/1000,'second')) AT LOCAL, 'yyyy-mm-dd hh24:mi') BETWEEN TO_CHAR" + + "(LOCALTIMESTAMP - NUMTODSINTERVAL(" + interval + ", 'second'),'yyyy-mm-dd hh24:mi') AND TO_CHAR" + + "(LOCALTIMESTAMP,'yyyy-mm-dd hh24:mi') GROUP BY TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME " + + "ZONE 'UTC' + NUMTODSINTERVAL(CEIL(Time/(" + x_axis_interval + " * 1000)) * " + x_axis_interval + + ", 'second')) AT LOCAL, '" + time_format + "'), ClusterId, MemberId ORDER BY TO_CHAR((TIMESTAMP " + + "'1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL(CEIL(Time/(" + x_axis_interval + " *" + + " 1000)) * " + x_axis_interval + ", 'second')) AT LOCAL, '" + time_format + "')", clusterId, + memberId); + } + print(result); + + } + catch (e) { + print(e.toString()); + } + finally { + db.close(); + } +}()); +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/monitoring-authentication.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/monitoring-authentication.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/monitoring-authentication.jag new file mode 100644 index 0000000..dd2448c --- /dev/null +++ b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/monitoring-authentication.jag @@ -0,0 +1,74 @@ +<% +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +(function () { + var log = new Log(); + + var HTTPS_TRANSPORT = "https"; + var AUTHORIZATION_HEADER = "Authorization"; + var ANALYTICS_SERVICE = "/services/AnalyticsWebService"; + var AUTHENTICATION_SERVICE = "/services/AuthenticationAdmin"; + var AUTH_TOKEN = "authToken"; + var LOCALHOST = "localhost"; + var HTTP_USER_NOT_AUTHENTICATED = 403; + + var carbon = require('carbon'); + var configs = require('/configs/designer.json'); + var HTTPConstants = Packages.org.apache.axis2.transport.http.HTTPConstants; + var AnalyticsWebServiceStub = Packages.org.wso2.carbon.analytics.webservice.stub.AnalyticsWebServiceStub; + var AuthenticationAdminStub = Packages.org.wso2.carbon.authenticator.stub.AuthenticationAdminStub; + + var analyticsWSUrl = carbon.server.address(HTTPS_TRANSPORT) + ANALYTICS_SERVICE; + var authenticationWSUrl = carbon.server.address(HTTPS_TRANSPORT) + AUTHENTICATION_SERVICE; + var analyticsStub; + try { + analyticsStub = new AnalyticsWebServiceStub(analyticsWSUrl); + } catch (e) { + if (log.isDebugEnabled()) { + log.debug("Unable to instantiate AnalyticsWebServiceStub instance. This could be a CEP server. Returning"); + } + return; + } + var serviceClient = analyticsStub._getServiceClient(); + var options = serviceClient.getOptions(); + options.setManageSession(true); + + var authParam = request.getHeader(AUTHORIZATION_HEADER); + if (authParam != null) { + credentials = JSUtils.authenticate(authParam); + authenticationAdminStub = new AuthenticationAdminStub(authenticationWSUrl); + authenticationAdminStub.login(credentials[0], credentials[1], LOCALHOST); + var serviceContext = authenticationAdminStub._getServiceClient().getLastOperationContext() + .getServiceContext(); + var sessionCookie = serviceContext.getProperty(HTTPConstants.COOKIE_STRING); + options.setProperty(HTTPConstants.COOKIE_STRING, sessionCookie); + } else { + var token = session.get(AUTH_TOKEN); + if (token != null) { + options.setProperty(HTTPConstants.COOKIE_STRING, token); + } else { + log.error("user is not authenticated!"); + response.status = HTTP_USER_NOT_AUTHENTICATED; + print('{ "status": "Failed", "message": "User is not authenticated." }'); + return; + } + } +}); +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/scaling-details.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/scaling-details.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/scaling-details.jag new file mode 100644 index 0000000..fa868e2 --- /dev/null +++ b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/oracle/scaling-details.jag @@ -0,0 +1,85 @@ +<% +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +include("monitoring-authentication.jag"); + +(function () { + var log = new Log(); + + var TIME_INTERVAL_1 = '30 Min'; + var TIME_INTERVAL_2 = '1 Hour'; + var TIME_INTERVAL_3 = '1 Day'; + var TIME_INTERVAL_4 = '1 Week'; + var TIME_INTERVAL_5 = '1 Month'; + var ALL_CLUSTERS = 'All Clusters'; + + var content = request.getContent(); + var contentAsString = null; + if (content != '' && content != null) { + contentAsString = stringify(content); + if (log.isDebugEnabled()) { + log.debug("Value of content: " + contentAsString); + } + } + + var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); + + try { + var result; + var timeInterval = request.getParameter("time"); + var interval = 1800; + var time_format = 'yyyy-mm-dd hh24:mi'; + if (timeInterval === TIME_INTERVAL_1) { + interval = 1800; + } else if (timeInterval === TIME_INTERVAL_2) { + interval = 3600; + } else if (timeInterval === TIME_INTERVAL_3) { + interval = 86400; + } else if (timeInterval === TIME_INTERVAL_4) { + interval = 604800; + } else if (timeInterval === TIME_INTERVAL_5) { + interval = 2419200; + } + + var clusterId = request.getParameter("clusterId"); + result = db.query("SELECT TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL(CEIL" + + "(Time/1000), 'second')) AT LOCAL, '" + time_format + "') AS \"Time\", ClusterId \"ClusterId\", " + + "MinInstanceCount \"MinInstanceCount\", MaxInstanceCount \"MaxInstanceCount\", RIFPredicted " + + "\"RIFPredicted\", RIFThreshold \"RIFThreshold\", RIFRequiredInstances \"RIFRequiredInstances\", " + + "MCPredicted \"MCPredicted\", MCThreshold \"MCThreshold\", MCRequiredInstances " + + "\"MCRequiredInstances\", LAPredicted \"LAPredicted\", LAThreshold \"LAThreshold\", " + + "LARequiredInstances \"LARequiredInstances\", RequiredInstanceCount \"RequiredInstanceCount\", " + + "ActiveInstanceCount \"ActiveInstanceCount\", AdditionalInstanceCount \"AdditionalInstanceCount\", " + + "ScalingReason \"ScalingReason\" FROM SCALING_DETAILS WHERE ClusterId=? AND TO_CHAR((TIMESTAMP " + + "'1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL(Time/1000,'second')) AT LOCAL, " + + "'yyyy-mm-dd hh24:mi') BETWEEN TO_CHAR(LOCALTIMESTAMP - NUMTODSINTERVAL(" + interval + ", 'second')," + + "'yyyy-mm-dd hh24:mi') AND TO_CHAR(LOCALTIMESTAMP,'yyyy-mm-dd hh24:mi') ORDER BY TO_CHAR((TIMESTAMP " + + "'1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL(CEIL(Time/1000), 'second')) AT LOCAL, '" + + time_format + "')", clusterId); + print(result); + } + catch (e) { + print(e.toString()); + } + finally { + db.close(); + } +}()); +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/scaling-details.jag ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/scaling-details.jag b/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/scaling-details.jag deleted file mode 100644 index c74e3d3..0000000 --- a/extensions/das/modules/artifacts/monitoring-dashboard/jaggery-files/scaling-details.jag +++ /dev/null @@ -1,73 +0,0 @@ -<% -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -include("monitoring-authentication.jag"); - -(function () { - var log = new Log(); - - var TIME_INTERVAL_1 = '30 Min'; - var TIME_INTERVAL_2 = '1 Hour'; - var TIME_INTERVAL_3 = '1 Day'; - var TIME_INTERVAL_4 = '1 Week'; - var TIME_INTERVAL_5 = '1 Month'; - var ALL_CLUSTERS = 'All Clusters'; - - var content = request.getContent(); - var contentAsString = null; - if (content != '' && content != null) { - contentAsString = stringify(content); - if (log.isDebugEnabled()) { - log.debug("Value of content: " + contentAsString); - } - } - - var db = new Database("WSO2_ANALYTICS_EVENT_STORE_DB"); - - try { - var result; - - var timeInterval = request.getParameter("time"); - var interval = 1800000; - - if (timeInterval === TIME_INTERVAL_1) { - interval = 1800000; - } else if (timeInterval === TIME_INTERVAL_2) { - interval = 3600000; - } else if (timeInterval === TIME_INTERVAL_3) { - interval = 86400000; - } else if (timeInterval === TIME_INTERVAL_4) { - interval = 604800000; - } else if (timeInterval === TIME_INTERVAL_5) { - interval = 2419200000; - } - - var clusterId = request.getParameter("clusterId"); - result = db.query("SELECT FROM_UNIXTIME(CEILING( Time/1000 ), '%Y:%m:%d %h:%i') AS Time, ClusterId, MinInstanceCount, MaxInstanceCount, RIFPredicted, RIFThreshold, RIFRequiredInstances, MCPredicted, MCThreshold, MCRequiredInstances, LAPredicted, LAThreshold, LARequiredInstances, RequiredInstanceCount, ActiveInstanceCount, AdditionalInstanceCount, ScalingReason FROM SCALING_DETAILS WHERE ClusterId= ? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000)", clusterId); - print(result); - } - catch (e) { - print(e.toString()); - } - finally { - db.close(); - } -}()); -%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/artifacts/monitoring-dashboard/monitoring-mysqlscript.sql ---------------------------------------------------------------------- diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/monitoring-mysqlscript.sql b/extensions/das/modules/artifacts/monitoring-dashboard/monitoring-mysqlscript.sql deleted file mode 100644 index 0155fa7..0000000 --- a/extensions/das/modules/artifacts/monitoring-dashboard/monitoring-mysqlscript.sql +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -CREATE DATABASE IF NOT EXISTS ANALYTICS_FS_DB; -CREATE DATABASE IF NOT EXISTS ANALYTICS_EVENT_STORE; -CREATE DATABASE IF NOT EXISTS ANALYTICS_PROCESSED_DATA_STORE; -CREATE TABLE ANALYTICS_EVENT_STORE.AVERAGE_MEMORY_CONSUMPTION_STATS(Time long, ClusterId VARCHAR(150), ClusterInstanceId VARCHAR(150), NetworkPartitionId VARCHAR(150), Value DOUBLE); -CREATE TABLE ANALYTICS_EVENT_STORE.MEMBER_AVERAGE_MEMORY_CONSUMPTION_STATS(Time long, MemberId VARCHAR(150), ClusterId VARCHAR(150), ClusterInstanceId VARCHAR(150), NetworkPartitionId VARCHAR(150), Value DOUBLE); -CREATE TABLE ANALYTICS_EVENT_STORE.AVERAGE_LOAD_AVERAGE_STATS(Time long, ClusterId VARCHAR(150), ClusterInstanceId VARCHAR(150), NetworkPartitionId VARCHAR(150), Value DOUBLE); -CREATE TABLE ANALYTICS_EVENT_STORE.MEMBER_AVERAGE_LOAD_AVERAGE_STATS(Time long, MemberId VARCHAR(150), ClusterId VARCHAR(150), ClusterInstanceId VARCHAR(150), NetworkPartitionId VARCHAR(150), Value DOUBLE); -CREATE TABLE ANALYTICS_EVENT_STORE.AVERAGE_IN_FLIGHT_REQUESTS(Time long, ClusterId VARCHAR(150), ClusterInstanceId VARCHAR(150), NetworkPartitionId VARCHAR(150), COUNT DOUBLE); -CREATE TABLE ANALYTICS_EVENT_STORE.SCALING_DETAILS(Time VARCHAR(50), ScalingDecisionId VARCHAR(150), ClusterId VARCHAR(150), MinInstanceCount INT, MaxInstanceCount INT, RIFPredicted INT, RIFThreshold INT ,RIFRequiredInstances INT, MCPredicted INT, MCThreshold INT, MCRequiredInstances INT ,LAPredicted INT, LAThreshold INT,LARequiredInstances INT,RequiredInstanceCount INT ,ActiveInstanceCount INT, AdditionalInstanceCount INT, ScalingReason VARCHAR(150)); http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/distribution/README.md ---------------------------------------------------------------------- diff --git a/extensions/das/modules/distribution/README.md b/extensions/das/modules/distribution/README.md index 0ae46c9..c3641b3 100644 --- a/extensions/das/modules/distribution/README.md +++ b/extensions/das/modules/distribution/README.md @@ -8,40 +8,42 @@ monitoring feature as below: 1. Add org.apache.stratos.das.extension-<stratos-version>.jar file to <DAS-HOME>/repository/components/lib/. -2. Add UDF class '<class-name>org.apache.stratos.das.extension.TimeUDF</class-name>' to 'spark-udf-config.xml' file -in <DAS-HOME>/repository/conf/analytics/spark/' folder. +2. Add UDF class `<class-name>org.apache.stratos.das.extension.TimeUDF</class-name>` to 'spark-udf-config.xml' file +in `<DAS-HOME>/repository/conf/analytics/spark/` folder. -3. Add jaggery files which can be found in <Stratos-DAS-Distribution>/metering-dashboard/jaggery-files/ to DAS server - path <DAS_HOME/repository/deployment/server/jaggeryapps/portal/controllers/apis/. +3. Add jaggery files needed for your database type which can be found in +`<Stratos-DAS-Distribution>/metering-dashboard/jaggery-files/<db>/` to DAS server path +`<DAS_HOME/repository/deployment/server/jaggeryapps/portal/controllers/apis/`. -4. Create MySQL database and tables using queries in -<Stratos-DAS-Distribution>/metering-dashboard/metering-mysqlscript.sql manually. +4. Create MySQL/Oracle database and tables using queries in +`<Stratos-DAS-Distribution>/metering-dashboard/database-scripts/<db>/metering-script.sql` manually. -5. Apply ues-patch files in <Stratos-DAS-Distribution>/metering-dashboard/ues-patch/ to DAS below: +5. Apply ues-patch files in `<Stratos-DAS-Distribution>/metering-dashboard/ues-patch/` to DAS below: - Copy 'ues-gadgets.js' and 'ues-pubsub.js' files to - <DAS-HOME>/repository/deployment/server/jaggeryapps/portal/js/ folder. - - Copy 'dashboard.jag' file to <DAS-HOME>/repository/deployment/server/jaggeryapps/portal/theme/templates/ folder. + `<DAS-HOME>/repository/deployment/server/jaggeryapps/portal/js/` folder. + - Copy 'dashboard.jag' file to `<DAS-HOME>/repository/deployment/server/jaggeryapps/portal/theme/templates/` folder. -6. Add stratos-metering-service car file in <Stratos-DAS-Distribution>/metering-dashboard/ to -<DAS-HOME>/repository/deployment/server/carbonapps/ to generate the metering dashboard. +6. Add stratos-metering-service car file in `<Stratos-DAS-Distribution>/metering-dashboard/` to +`<DAS-HOME>/repository/deployment/server/carbonapps/` to generate the metering dashboard. ## Follow the below steps to configure DAS for monitoring dashboard: -1. Add jaggery files which can be found in <Stratos-DAS-Distribution>/monitoring-dashboard/jaggery-files/ to DAS path -'<DAS_HOME/repository/deployment/server/jaggeryapps/portal/controllers/apis/'. +1. Add jaggery files needed for your database type which can be found in +`<Stratos-DAS-Distribution>/monitoring-dashboard/jaggery-files/<db>/` to DAS path +`<DAS_HOME/repository/deployment/server/jaggeryapps/portal/controllers/apis/. -2. Create MySQL database and tables using queries in -<Stratos-DAS-Distribution>/monitoring-dashboard/monitoring-mysqlscript.sql manually. +2. Create MySQL/Oracle database and tables using queries in +`<Stratos-DAS-Distribution>/monitoring-dashboard/database-scripts/<db>/monitoring-script.sql` manually. -3. Copy CEP EventFormatter artifacts in <Stratos-DAS-Distribution>/wso2cep-<version>/eventformatters/ to -<CEP-HOME>/repository/deployment/server/eventformatters/. +3. Copy CEP EventFormatter artifacts in `<Stratos-DAS-Distribution>/wso2cep-<version>/eventformatters/` to +`<CEP-HOME>/repository/deployment/server/eventformatters/`. -4. Copy CEP OutputEventAdapter artifact in <Stratos-DAS-Distribution>/wso2cep-<version>/outputeventadaptors/ to -<CEP-HOME>/repository/deployment/server/outputeventadaptors and update the tcp and ssl ports according to DAS server +4. Copy CEP OutputEventAdapter artifact in `<Stratos-DAS-Distribution>/wso2cep-<version>/outputeventadaptors/` to +`<CEP-HOME>/repository/deployment/server/outputeventadaptors/` and update the tcp and ssl ports according to DAS server port offset. -5. Add stratos-monitoring-service car file in <Stratos-DAS-Distribution>/monitoring-dashboard/ to -<DAS-HOME>/repository/deployment/server/carbonapps/ to generate the monitoring dashboard. +5. Add stratos-monitoring-service car file in `<Stratos-DAS-Distribution>/monitoring-dashboard/` to +`<DAS-HOME>/repository/deployment/server/carbonapps/` to generate the monitoring dashboard. Please refer below link for more information on WSO2 DAS. http://git-wip-us.apache.org/repos/asf/stratos/blob/3fe8c452/extensions/das/modules/distribution/src/assembly/bin.xml ---------------------------------------------------------------------- diff --git a/extensions/das/modules/distribution/src/assembly/bin.xml b/extensions/das/modules/distribution/src/assembly/bin.xml index 59e0a57..dd6fdda 100755 --- a/extensions/das/modules/distribution/src/assembly/bin.xml +++ b/extensions/das/modules/distribution/src/assembly/bin.xml @@ -28,8 +28,8 @@ <directory>../artifacts/</directory> <outputDirectory>${project.artifactId}-${project.version}</outputDirectory> <includes> - <include>metering-dashboard/jaggery-files/*.jag</include> - <include>monitoring-dashboard/jaggery-files/*.jag</include> + <include>metering-dashboard/jaggery-files/**/*.jag</include> + <include>monitoring-dashboard/jaggery-files/**/*.jag</include> <include>metering-dashboard/ues-patch/*.*</include> <include>**/*.sql</include> <include>**/*.md</include>
