You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apex.apache.org by th...@apache.org on 2015/11/12 04:23:01 UTC

[06/22] incubator-apex-malhar git commit: Cleanup of web resources

http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/9d4baef2/contrib/src/main/html/siteops/server.js
----------------------------------------------------------------------
diff --git a/contrib/src/main/html/siteops/server.js b/contrib/src/main/html/siteops/server.js
deleted file mode 100644
index fe364a2..0000000
--- a/contrib/src/main/html/siteops/server.js
+++ /dev/null
@@ -1,115 +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.
- */
-/**
- * Functions for drawing server load vs time chart.
- */
-
-function RenderServerLoadTimeChart()
-{  
-  // create/delete rows 
-  if (serverLoadTable.getNumberOfRows() < serverLoadDataPoints.length)
-  {    
-    var numRows = serverLoadDataPoints.length - serverLoadTable.getNumberOfRows();
-    serverLoadTable.addRows(numRows);
-  } else {
-    for(var i=(serverLoadTable.getNumberOfRows()-1); i >= serverLoadDataPoints.length; i--)
-    {
-      serverLoadTable.removeRow(i);    
-    }
-  }
-
-  // Populate data table with time/cost data points. 
-  for(var i=0; i < serverLoadTable.getNumberOfRows(); i++)
-  {
-    serverLoadTable.setCell(i, 0, new Date(parseInt(serverLoadDataPoints[i].timestamp)));
-    serverLoadTable.setCell(i, 1, parseFloat(serverLoadDataPoints[i].view));
-  }
-
-  // get chart options
-  var serverName = document.getElementById('servername').value;  
-  var title = "All Servers (PVS/Min)";
-  if (serverName != "all") title = serverName + " (PVS/Min)";
-  var options = {pointSize: 0, lineWidth : 1, legend : { position : 'top'} };
-  options.title = title;
-
-  // Draw line chart.
-  serverLoadChart.draw(serverLoadView, options); 
-}
-
-function DrawServerLoadTime()
-{
-  // get url 
-  var url = "ServerLoad.php?from=" + Math.floor(serverLoadLookback);
-  if ( serverName && (serverName.length > 0))
-  {   
-    url += "&server=" + serverName;    
-  }
-
-  // fetch data  
-    try
-  {
-    var connect = new XMLHttpRequest();
-    connect.onreadystatechange = function() {
-      if(connect.readyState==4 && connect.status==200) {
-        serverLoadData = connect.response;
-        var pts = JSON.parse(serverLoadData);
-        for(var i=0; i <  pts.length; i++) 
-        {
-          serverLoadDataPoints.push(pts[i]);
-          delete pts[i];
-        }
-        delete pts;
-        sortByKey(serverLoadDataPoints, "timestamp");
-        RenderServerLoadTimeChart();
-        delete serverLoadData;
-        delete serverLoadDataPoints;
-        serverLoadDataPoints = new Array();
-      }
-    }
-    connect.open('GET',  url, true);
-    connect.send(null);
-  } catch(e) {
-  }
-  serverLoadLookback = (new Date().getTime()/1000) -  (3600*serverLoadInterval) - 60;
-}
-
-function HandleServerLoadTimeSubmit()
-{
-  // reset intercval  
-  if(serverNowPlaying) clearInterval(serverNowPlaying);
-
-  // get params 
-  serverName = document.getElementById('servername').value;
-  serverLoadLookback = document.getElementById('serverloadlookback').value;
-  if ( !serverLoadLookback || (serverLoadLookback == "")) {
-    serverLoadLookback = (new Date().getTime()/1000) - 3600;
-  }  else {
-    serverLoadLookback = (new Date().getTime()/1000) - 3600 * serverLoadLookback;
-  }
-
-  // set from values  
-  document.getElementById('servername').value = serverName;
-  var lookback = document.getElementById('serverloadlookback').value;
-  document.getElementById('serverloadlookback').value = lookback;
-  serverLoadInterval = lookback;
-       
-  // darw server load/time chart  
-  DrawServerLoadTime();
-  serverNowPlaying = setInterval(DrawServerLoadTime, 60 * 1000); 
-}

http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/9d4baef2/contrib/src/main/html/siteops/serverfail.js
----------------------------------------------------------------------
diff --git a/contrib/src/main/html/siteops/serverfail.js b/contrib/src/main/html/siteops/serverfail.js
deleted file mode 100644
index 76e5bf5..0000000
--- a/contrib/src/main/html/siteops/serverfail.js
+++ /dev/null
@@ -1,64 +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.
- */
-/**
- * Functions fro charting top url table.
- */
-
-function DrawServer404TableChart()
-{
-  try
-  {
-    var connect = new XMLHttpRequest();
-    connect.onreadystatechange = function() {
-      if(connect.readyState==4 && connect.status==200) {
-        var data = connect.response;
-        var pts = JSON.parse(data);
-        var server404 = new google.visualization.DataTable();
-        server404.addColumn('string', 'SERVER');
-        server404.addColumn('number', '404/sec');
-        server404.addRows(10);
-        for(var i=0; ((i <  pts.length)&&(i < 10)); i++) 
-        {
-          var row = pts[i].split("##");
-          if ((row[0] == null)||(row[0] == ""))
-          {
-            server404.setCell(i, 0, "-");
-          } else {
-            server404.setCell(i, 0, row[0]);
-          }
-          if ((row[1] == null)||(row[1] == ""))
-          {
-            server404.setCell(i, 1, 0);
-          } else {
-            server404.setCell(i, 1, parseInt(row[1]));
-          }
-        }
-        //document.getElementById('risky_client_div').innerHTML = data;
-        //document.getElementById('risky_client_div').innerHTML = server404.getNumberOfRows();
-        server404TableChart.draw(server404, {showRowNumber: true});
-        delete server404;
-        delete data;
-        delete pts;
-      }
-    }
-    connect.open('GET',  "Server404.php", true);
-    connect.send(null);
-  } catch(e) {
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/9d4baef2/demos/machinedata/src/main/html/global.js
----------------------------------------------------------------------
diff --git a/demos/machinedata/src/main/html/global.js b/demos/machinedata/src/main/html/global.js
new file mode 100644
index 0000000..753f58f
--- /dev/null
+++ b/demos/machinedata/src/main/html/global.js
@@ -0,0 +1,269 @@
+/*
+ * 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.
+ */
+/**
+ * Declaration and initialization for global variables.
+ */
+
+// url parameters   
+var params;
+
+// Data Points 
+var aggrData; 
+var aggrDataPoints;
+var contData;
+var contDataPoints;
+
+// CPU data table 
+var cpuTable;
+var cpuChart; 
+var cpuView;
+
+// ram data table 
+var ramTable;
+var ramChart; 
+var ramView;  
+
+// hdd data table 
+var hddTable;
+var hddChart; 
+var hddView;  
+
+// chart options
+var chartOptions;
+
+// Date formatter  
+var dateFormatter;
+
+// window look back value 
+var lookback;
+var aggrLookBack;
+var contLookBack;
+var contRefresh;
+
+// Get split query string
+function QueryString() {
+  var query_string = {};
+  var query = window.location.search.substring(1);
+  return query;
+}
+function SplitQuery(query)
+{  
+	var params = {};
+	var vars = query.split("&");
+	for (var i=0;i<vars.length;i++)
+	{
+		var pair = vars[i].split("=");
+		if(pair.length == 2) 
+		{
+			params[pair[0]] = pair[1];
+		}
+	}
+	return params;
+}  
+
+// Initialize global variable(s)
+function InitializeGlobal()
+{
+  // Initialize params  
+  params = SplitQuery(QueryString()); 
+       
+  // Initialize data points 
+  aggrDataPoints = new Array();
+  contDataPoints = new Array();
+    
+  // Initialize cpu table 
+  cpuTable = new google.visualization.DataTable(); 
+  cpuTable.addColumn('datetime', 'Time');
+  cpuTable.addColumn('number', 'CPU');
+  chartOptions = { width: 600, height: 300, legend: 'none', pointSize: 0, lineWidth : 1 };
+  cpuChart = new google.visualization.ScatterChart(document.getElementById('chart_div'));
+  cpuView = new google.visualization.DataView(cpuTable);
+
+  // Initialize ram table 
+  ramTable = new google.visualization.DataTable(); 
+  ramTable.addColumn('datetime', 'Time');
+  ramTable.addColumn('number', 'RAM');;
+  ramChart = new google.visualization.ScatterChart(document.getElementById('chart1_div'));
+  ramView = new google.visualization.DataView(ramTable);
+
+  // Initialize hdd table 
+  hddTable = new google.visualization.DataTable(); 
+  hddTable.addColumn('datetime', 'Time');
+  hddTable.addColumn('number', 'HDD');;
+  hddChart = new google.visualization.ScatterChart(document.getElementById('chart2_div'));
+  hddView = new google.visualization.DataView(hddTable);
+    
+  // get lookback value  
+  lookback = (new Date().getTime()/1000) - 3600*6;
+  if (params['lookback'] && (params['lookback'].length > 0)) lookback = (new Date().getTime()/1000) - (3600*(parseInt(params['lookback'])));
+  aggrLookBack = lookback;
+     
+  // get continuos lookback 
+  contLookBack = lookback;
+  contRefresh = 5;
+
+  // get param lookback  
+  paramLookBack = 6;
+  if (params['lookback'] && (params['lookback'].length > 0)) paramLookBack = parseInt(params['lookback']);
+  //if (params['refresh'] && (params['refresh'].length > 0)) contRefresh = parseInt(params['refresh']);
+}
+
+
+/**
+ * Function to create fetch urls from given parameters
+ */
+function DataUrl() 
+{       
+    var url = "json.php?bucket=m";
+    url += "&customer=";
+    if (params['customer'])
+    {	
+      url += params['customer'];
+    }
+    url += "&product=";
+    if (params['product'])
+    {	
+      url += params['product'];
+    }
+    url += "&os=";
+    if (params['os'])
+    {	
+      url += params['os'];
+    }
+    url += "&software1=";
+    if (params['software1'])
+    {
+      url += params['software1'];
+    }
+    url += "&software2=";
+    if (params['software2'])
+    {
+      url += params['software2'];
+    }
+    url += "&software3=";
+    if (params['software3'])
+    {
+      url += params['software3'];
+    }
+     url += "&from=";
+    url += Math.floor(lookback);
+    return url;   
+}
+
+/**
+ * Creates data table with time stamp and cpu values.
+ * Draw line chart for time vs cpu.
+ */
+function DrawCPUChart()
+{
+  // create/delete rows 
+  if (cpuTable.getNumberOfRows() < aggrDataPoints.length)
+  {    
+    var numRows = aggrDataPoints.length - cpuTable.getNumberOfRows();
+    cpuTable.addRows(numRows);
+  } else {
+    for(var i=(cpuTable.getNumberOfRows()-1); i >= aggrDataPoints.length; i--)
+    {
+      cpuTable.removeRow(i);    
+    }
+  }
+    
+  // Populate data table with time/cpu data points. 
+  for(var i=0; i < cpuTable.getNumberOfRows(); i++)
+  {
+    //if(parseFloat(aggrDataPoints[i].cpu) < 500) continue;
+    cpuTable.setCell(i, 0, new Date(parseInt(aggrDataPoints[i].timestamp)));
+    cpuTable.setCell(i, 1, parseFloat(aggrDataPoints[i].cpu));
+  }
+
+  // Draw line chart.
+  chartOptions.title = 'CPU Usage (%)';
+  cpuChart.draw(cpuView, chartOptions); 
+}     
+
+/**
+ * Creates data table with time stamp and revenu values.
+ * Draw line chart for time vs ram.
+ */
+function DrawRAMChart()
+{
+  // create/delete rows 
+  if (ramTable.getNumberOfRows() < aggrDataPoints.length)
+  {    
+    var numRows = aggrDataPoints.length - ramTable.getNumberOfRows();
+    ramTable.addRows(numRows);
+  } else {
+    for(var i=(ramTable.getNumberOfRows()-1); i >= aggrDataPoints.length; i--)
+    {
+      ramTable.removeRow(i);    
+    }
+  }
+
+  // Populate data table with time/ram data points. 
+  for(var i=0; i < ramTable.getNumberOfRows(); i++)
+  {
+    ramTable.setCell(i, 0, new Date(parseInt(aggrDataPoints[i].timestamp)));
+    ramTable.setCell(i, 1, parseFloat(aggrDataPoints[i].ram));
+  }
+
+  // Draw line chart.
+  chartOptions.title = 'RAM Usage (%)';
+  ramChart.draw(ramView, chartOptions); 
+}  
+
+/**
+ * Creates data table with time stamp and hdd values.
+ * Draw line chart for time vs hdd.
+ */
+function DrawHDDChart()
+{
+  // create/delete rows 
+  if (hddTable.getNumberOfRows() < aggrDataPoints.length)
+  {    
+    var numRows = aggrDataPoints.length - hddTable.getNumberOfRows();
+    hddTable.addRows(numRows);
+  } else {
+    for(var i=(hddTable.getNumberOfRows()-1); i >= aggrDataPoints.length; i--)
+    {
+      hddTable.removeRow(i);    
+    }
+  }
+
+  // Populate data table with time/hdd data points. 
+  for(var i=0; i < hddTable.getNumberOfRows(); i++)
+  {
+    hddTable.setCell(i, 0, new Date(parseInt(aggrDataPoints[i].timestamp)));
+    hddTable.setCell(i, 1, parseInt(aggrDataPoints[i].hdd));
+  }
+
+  // Draw line chart.
+  chartOptions.title = 'HDD Usage (%)';
+  hddChart.draw(hddView, chartOptions); 
+}
+
+/**
+ * Sort json array  
+ */
+function sortByKey(array, key) {
+    return array.sort(function(a, b) {
+        var x = a[key]; var y = b[key];
+        return ((x < y) ? -1 : ((x > y) ? 1 : 0));
+    });
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/9d4baef2/demos/machinedata/src/main/html/index.php
----------------------------------------------------------------------
diff --git a/demos/machinedata/src/main/html/index.php b/demos/machinedata/src/main/html/index.php
new file mode 100644
index 0000000..aa1aadc
--- /dev/null
+++ b/demos/machinedata/src/main/html/index.php
@@ -0,0 +1,268 @@
+/*
+ * 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.
+ */
+<!--
+ --  Copyright (c) 2012-2013 Malhar, Inc.
+ --  All Rights Reserved.
+ -->
+    
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Data Torrent : Machine Generated Data Demo </title>
+
+<link rel="stylesheet" type="text/css" href="malhar.css">
+
+<!-- Google charts include -->
+<script type="text/javascript" src="https://www.google.com/jsapi"></script>
+<script type="text/javascript">
+google.load('visualization', '1', {'packages':['corechart']});
+</script>
+
+<!-- Malhar charting utils -->
+<script type="text/javascript" src="global.js"></script>
+
+<!-- window onload -->
+<script type="text/javascript">
+
+function DrawAggrCharts()
+{
+  // get refresh url 
+  lookback = aggrLookBack; 
+  var url = DataUrl();        
+
+  // fetch data, draw charts
+  try
+  {
+    var connect = new XMLHttpRequest();
+    connect.onreadystatechange = function() {
+      if(connect.readyState==4 && connect.status==200) {
+
+console.log(url);
+        aggrData = connect.response;
+        var pts = JSON.parse(aggrData);
+        aggrDataPoints = new Array();
+        for(var i=0; i <  pts.length; i++) aggrDataPoints.push(pts[i]);
+        DrawCPUChart();
+        DrawRAMChart();
+        DrawHDDChart();
+        //DrawImpressionsChart();
+        delete aggrData;
+      }
+    }
+    connect.open('GET',  url, true);
+    connect.send(null);
+  } catch(e) {
+  }
+  aggrLookBack += 30;
+}
+
+function DrawContCharts()  
+{    
+  // get refresh url 
+  lookback = contLookBack; 
+  var url = DataUrl();    
+  //document.getElementById('chart_div').innerHTML = url;
+
+  // fetch data, draw charts
+  try
+  {
+    var connect = new XMLHttpRequest();
+    connect.onreadystatechange = function() {
+      if(connect.readyState==4 && connect.status==200) {
+        contData = connect.response;   
+        var newPts = JSON.parse(contData); 
+        contDataPoints = new Array();
+        for(var i=0; i <  newPts.length; i++) contDataPoints.push(newPts[i]);
+        DrawCtrChart() ;
+        DrawMarginChart();
+        delete contData;
+        delete newPts;
+      }
+    }
+    connect.open('GET',  url, true);
+    connect.send(null);
+  } catch(e) {
+  }
+  contLookBack += contRefresh;
+}
+
+window.onload = function() {
+
+  // Initialize global 
+  InitializeGlobal();   
+
+  // Inituialize form fields  
+  if (params['customer']) document.getElementById('customer').value = params['customer'];
+  if (params['product']) document.getElementById('product').value = params['product'];
+  if (params['os']) document.getElementById('os').value = params['os'];
+  if (params['software1']) document.getElementById('software1').value = params['software1'];
+  if (params['software2']) document.getElementById('software2').value = params['software2'];
+  if (params['software3']) document.getElementById('software3').value = params['software3'];
+  if (params['refresh'])
+  {
+    document.getElementById('refresh').value = params['refresh'];   
+  } else {
+    document.getElementById('refresh').value = 5;
+  }    
+  if (params['lookback'])
+  {
+    document.getElementById('lookback').value = params['lookback'];   
+  } else {
+    document.getElementById('lookback').value = 6;
+  }
+       
+  // draw charts 
+  DrawAggrCharts();
+  //DrawContCharts();
+  setInterval(DrawAggrCharts, 30000);
+  //setInterval(DrawContCharts, contRefresh * 1000);
+};
+
+</script>
+
+</head>
+<body>
+
+    <div id="header">
+        <ul class="dashboard-modes">
+            <li>
+                <a href="#" class="active">Machine Generated Data Demo </a>
+            </li>
+        </ul>
+
+    </div>
+	
+	<div id="main">
+    <div id="pagecontent">
+        <div class="dashboardMgr">
+            <div class="inner" style="">
+                <h2 class="title">View Real Time Data Charts</h2> 
+                <form method="GET" action="index.php">
+                    
+                    <label for="customer">Customer ID:</label>
+                    <select name="customer" id="customer" style="width:200px;">
+                  		<option value="">ALL</option>
+                		<?php
+                   			for ($i = 1; $i <= 5; $i++) {
+                  				print "<option value=\"$i\">Customer $i</option>\n";
+                			}
+                		?>
+             		</select>
+             		
+            		<label for="">Product ID:</label>
+            		<select name="product" id="product" style="width:200px;">
+              		    <option value="">ALL</option>
+                		<?php
+                			for ($i = 4; $i <= 6; $i++) {
+                  				print "<option value=\"$i\">Product $i</option>\n";
+                			}
+                		?>
+            		</select>
+        		
+        		    <label for="">Product OS:</label>
+            		<select name="os" id="os" style="width:200px;">
+              		    <option value="">ALL</option>
+        		        <?php
+                			for ($i = 10; $i <= 12; $i++) {
+                  				print "<option value=\"$i\">OS $i</option>\n";
+                			}
+        	            ?>
+            		</select>
+            		
+                    <label for="software1">Software1 Ver:</label>
+                    <select name="software1" id="software1" style="width:200px;">
+                  		<option value="">ALL</option>
+                		<?php
+                   			for ($i = 10; $i <= 12; $i++) {
+                  				print "<option value=\"$i\">Software1 Version $i</option>\n";
+                			}
+                		?>
+             		</select>
+
+                    <label for="software2">Software2 Ver:</label>
+                    <select name="software2" id="software2" style="width:200px;">
+                  		<option value="">ALL</option>
+                		<?php
+                   			for ($i = 12; $i <= 14; $i++) {
+                  				print "<option value=\"$i\">Software2 Version $i</option>\n";
+                			}
+                		?>
+             		</select>
+
+                    <label for="software3">Software3 Ver:</label>
+                    <select name="software3" id="software3" style="width:200px;">
+                  		<option value="">ALL</option>
+                		<?php
+                   			for ($i = 4; $i <= 6; $i++) {
+                  				print "<option value=\"$i\">Software3 Version $i</option>\n";
+                			}
+                		?>
+             		</select>
+
+            		<label for="">Refresh Interval:</label>
+            		<div class="input-append">
+                        <input type="text" name="refresh" id="refresh" class="input-small"/>
+                        <span class="add-on">Secs</span>
+                    </div>
+                    
+
+        		    <label for="">Look Back:</label>
+        		    <div class="input-append">
+                        <input type="text" name="lookback" id="lookback" class="input-small"/>
+                        <span class="add-on">Hours</span>
+                    </div>
+                    
+                    <input type="submit" value="submit" class="btn btn-primary" />
+                    
+                </form>
+            </div>
+            <div class="collapser-container">
+                <div class="collapser">
+                    <div class="collapse-dot"></div>
+                    <div class="collapse-dot"></div>
+                    <div class="collapse-dot"></div>
+                </div>
+            </div>
+        </div>
+        <div class="dashboardMain">
+            
+	<!-- <table><tbody>
+                <tr>
+        	      <td><div id="chart_div"></div></td>	
+        	      <td><div id="chart1_div" ></div></td>	
+                 </tr>
+                 <tr>
+        	     <td><div id="chart2_div" ></div></td>	
+        	     <td><div id="chart3_div" ></div></td>
+                 </tr>
+                 <tr>
+        	   <td><div id="chart4_div" ></div></td>	
+        	    <td><div id="chart5_div" ></div></td>	
+                 </tr>
+        	 </tr></tbody></table> -->
+    	<div class="chart-ctnr" id="chart_div"></div>
+        <div class="chart-ctnr" id="chart1_div" ></div>	
+        <div class="chart-ctnr" id="chart2_div" ></div>	
+<!--        <div class="chart-ctnr" id="chart3_div" ></div>
+        <div class="chart-ctnr" id="chart4_div" ></div>	
+        <div class="chart-ctnr" id="chart5_div" ></div> -->
+        </div>		
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/9d4baef2/demos/machinedata/src/main/html/json.php
----------------------------------------------------------------------
diff --git a/demos/machinedata/src/main/html/json.php b/demos/machinedata/src/main/html/json.php
new file mode 100644
index 0000000..75a7117
--- /dev/null
+++ b/demos/machinedata/src/main/html/json.php
@@ -0,0 +1,96 @@
+<?php
+/*
+ * 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.
+ */
+header("Content-type: application/json");
+$redis = new Redis();
+$redis->connect('localhost');
+$redis->select(15);
+$from = $_GET['from'];
+$bucket = $_GET['bucket'];
+$customer = $_GET['customer'];
+$product = $_GET['product'];
+$os = $_GET['os'];
+$software1 = $_GET['software1'];
+$software2 = $_GET['software2'];
+$software3 = $_GET['software3'];
+
+switch ($bucket) {
+case 'D':
+  $format = 'Ymd';
+  $incr = 60 * 60 * 24;
+  break;
+case 'h':
+  $format = 'YmdH';
+  $incr = 60 * 60;
+  break;
+case 'm':
+  $format = 'YmdHi';
+  $incr = 60;
+  break;
+default:
+  break;
+}
+
+$arr = array();
+if ($customer != '') {
+  $arr[] = "0:".$customer;
+} 
+if ($product != '') {
+  $arr[] = "1:".$product;
+} 
+if ($os != '') {
+  $arr[] = "2:".$os;
+} 
+if ($software1 != '') {
+  $arr[] = "3:".$software1;
+} 
+if ($software2 != '') {
+  $arr[] = "4:".$software2;
+} 
+if ($software3 != '') {
+  $arr[] = "5:".$software3;
+} 
+$subpattern = "";
+if (count($arr) != 0) {
+  $subpattern = join("|", $arr);
+}
+
+$result = array();
+
+while ($from < time()) {
+  $date = gmdate($format, $from);
+  if ($subpattern != '') {
+    $key = $bucket . '|' . $date . '|' . $subpattern;
+  } else {
+    $key = $bucket . '|' . $date ;
+  }
+  $hash = $redis->hGetAll($key);
+  if ($hash) {
+    $cpu = $hash['cpu'];
+    $ram = $hash['ram'];
+    $hdd = $hash['hdd'];
+    $result[] = array('timestamp'=> $from * 1000, 'cpu'=>$cpu, 'ram'=>$ram, 'hdd'=>$hdd);
+  }
+  $from += $incr;
+}
+
+array_pop($result);
+print json_encode($result);
+
+?>