<!--
You are free to copy and use this sample in accordance with the terms of the
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>
      CPU_Line_chart2
    </title>
  
                <!-- COMMENT: PHP makes variable available to the rest of the 
page-->
                <? $server_name = $_GET["server_name"] ?>
                <? $data_gran = $_GET["data_gran"] ?>
                

    <script type="text/javascript" src="http://www.google.com/jsapi";></script>

    
  </head>
  <body style="font-family: Arial;border: 0 none;">
          <h2> Capacity Vital Signs </h2>
                <form action="http://lpil0219capan01/CPU_Line_chartsarah.php";>
                        Server Name: <input type="text" name="server_name" ><br>
                        Data Gran: <select name="data_gran">
                                <option value="hourly">Hourly</option>
                                <option value="daily">Daily</option>
                                <option value="monthly">Monthly</option>
                        </select> <br>
                                <input type="submit" value="Submit">
                </form>
          
          

        <table border="0" width="100%" cellspacing="0" cellpadding="4">
                <tr>
                        <td width="50%">
                                <div id="chart001" style="min-width:300px; 
min-height:300px; margin: 0 auto">
                                                
                                                <script type="text/javascript">
                                                        
google.load('visualization', '1', {packages: ['corechart']});
                                                </script>
                                                <script type="text/javascript">
                                                          function 
drawVisualization() {
                                                                // Create and 
populate the data table.
                                                                var data = 
google.visualization.arrayToDataTable([
                                                                  ['Date', 
'MAX', 'MIN', 'AVG'],
                                                 <?
                                                        $sql =  "if 
'$data_gran' = 'monthly' begin select convert(varchar,YEAR(effect_dte),4) + '-' 
+ convert(varchar,left(datename(mm,effect_dte),3),4) as 
datestamp,[value_max],[value_min],[value_avg] from dbo.sys_stat_monthly a join 
METRIC b on a.METRIC_ID = b.METRIC_ID where sys_asset_id='$server_name' and 
metric_nam='cpu_busy_util'end ".
                                                                        "else 
if '$data_gran' = 'hourly' begin select convert(varchar,YEAR(effect_dte),4) + 
'-' + convert(varchar,left(datename(mm,effect_dte),3),4) + '-'+ 
convert(varchar,left(datename(dd,effect_dte),3),4) + ' ' + 
convert(varchar,left(datename(hh,effect_dte),3),4) + ':00' as 
datestamp,[value_max],[value_min],[value_avg] from dbo.sys_stat_hourly a join 
METRIC b on a.METRIC_ID = b.METRIC_ID where sys_asset_id='$server_name' and 
metric_nam='cpu_busy_util' and EFFECT_DTE >= GETDATE() -7 end ".
                                                                        "else 
if '$data_gran' = 'daily' begin select convert(varchar,YEAR(effect_dte),4) + 
'-' + convert(varchar,left(datename(mm,effect_dte),3),4) + '-'+ 
convert(varchar,left(datename(dd,effect_dte),3),4)as datestamp, 
[value_max],[value_min],[value_avg] from dbo.sys_stat_daily a join METRIC b on 
a.METRIC_ID = b.METRIC_ID where sys_asset_id='$server_name' and 
metric_nam='cpu_busy_util' and EFFECT_DTE >= GETDATE() -30 end ";


                                                        $odbc = 
odbc_connect('CapacityManagementProd', 'caprpt1', '1Cap9Man') or die('could not 
connect to database');
                                                        odbc_prepare($odbc, 
$sql) or die('could not exec SQL: ' . odbc_errormsg($odbc));
                                                        $res = odbc_exec($odbc, 
$sql) or die('could not exec SQL: ' . odbc_errormsg($odbc));
                                                        
                                                        $counter = 0;
                                                        $data = array();
                                                        while 
(odbc_fetch_array($res))
                                                        {
                                                                
$data['effect_dte'] = odbc_result($res, 1);
                                                                $data['max'] = 
odbc_result($res, 2);
                                                                $data['min'] = 
odbc_result($res, 3);
                                                                $data['avg'] = 
odbc_result($res, 4);
                                                                
                                                                if($counter > 
0) { ?>,<? }

                                                ?>
                                                                ['<? echo 
$data['effect_dte']; ?>',<? echo $data['max']; ?> ,<? echo $data['min']?>,<? 
echo $data['avg']?>]
                                                <?
                                                                $counter++;
                                                        }
                                                        
                                                ?>
                                                                ]);
                                                                
                                                          var options = 
                                                          {
                                                                  title: 
'Simple <? echo $data_gran ?> CPU Chart for <? echo $server_name ?>',
                                                                  curveType: 
"function",
                                                                  width: 700, 
height: 400,
                                                                  vAxis: 
{title:'CPU Util %', maxValue: 100, minValue: 0}
                                                          };
                                                          
                                                                // Create and 
draw the visualization.
                                                                
document.getElementById('chart001').style.display = 'block';
                                                                new 
google.visualization.LineChart(document.getElementById('chart001')).
                                                                        
draw(data, options);
                                                          }
                                                          

                                                          
google.setOnLoadCallback(drawVisualization);
                                                </script>
                                                
                                </div>
                                <small> </small>
                        </td>
                        
                        <td width="50%" style="border-left:1px dotted #cccccc;">
                                <div id="chart002" style="min-width:300px; 
min-height:300px; margin: 0 auto"> 
                                
                                <script type="text/javascript">
                                                        
google.load('visualization', '1', {packages: ['corechart']});
                                                </script>
                                                <script type="text/javascript">
                                                          function 
drawVisualization() {
                                                                // Create and 
populate the data table.
                                                                var data = 
google.visualization.arrayToDataTable([
                                                                  ['Date', 
'MAX', 'MIN', 'AVG'],
                                                 <?
                                                        $sql = "if '$data_gran' 
= 'monthly' begin select convert(varchar,YEAR(effect_dte),4) + '-' + 
convert(varchar,left(datename(mm,effect_dte),3),4) as 
datestamp,[value_max],[value_min],[value_avg] from dbo.sys_stat_monthly a join 
METRIC b on a.METRIC_ID = b.METRIC_ID where sys_asset_id='$server_name' and 
metric_nam= 'mem_used_pct'end ".
                                                                        "else 
if '$data_gran' = 'hourly' begin select convert(varchar,YEAR(effect_dte),4) + 
'-' + convert(varchar,left(datename(mm,effect_dte),3),4) + '-'+ 
convert(varchar,left(datename(dd,effect_dte),3),4) + ' ' + 
convert(varchar,left(datename(hh,effect_dte),3),4) + ':00' as 
datestamp,[value_max],[value_min],[value_avg] from dbo.sys_stat_hourly a join 
METRIC b on a.METRIC_ID = b.METRIC_ID where sys_asset_id='$server_name' and 
metric_nam='mem_used_pct' and EFFECT_DTE >= GETDATE() -7 end ".
                                                                        "else 
if '$data_gran' = 'daily' begin select convert(varchar,YEAR(effect_dte),4) + 
'-' + convert(varchar,left(datename(mm,effect_dte),3),4) + '-'+ 
convert(varchar,left(datename(dd,effect_dte),3),4)as datestamp, 
[value_max],[value_min],[value_avg] from dbo.sys_stat_daily a join METRIC b on 
a.METRIC_ID = b.METRIC_ID where sys_asset_id='$server_name' and 
metric_nam='mem_used_pct' and EFFECT_DTE >= GETDATE() -30 end ";


                                                        $odbc = 
odbc_connect('CapacityManagementProd', 'caprpt1', '1Cap9Man') or die('could not 
connect to database');
                                                        odbc_prepare($odbc, 
$sql) or die('could not exec SQL: ' . odbc_errormsg($odbc));
                                                        $res = odbc_exec($odbc, 
$sql) or die('could not exec SQL: ' . odbc_errormsg($odbc));
                                                        
                                                        $counter = 0;
                                                        $data = array();
                                                        while 
(odbc_fetch_array($res))
                                                        {
                                                                
$data['effect_dte'] = odbc_result($res, 1);
                                                                $data['max'] = 
odbc_result($res, 2);
                                                                $data['min'] = 
odbc_result($res, 3);
                                                                $data['avg'] = 
odbc_result($res, 4);
                                                                
                                                                if($counter > 
0) { ?>,<? }

                                                ?>
                                                                ['<? echo 
$data['effect_dte']; ?>',<? echo $data['max']; ?> ,<? echo $data['min']?>,<? 
echo $data['avg']?>]
                                                <?
                                                                $counter++;
                                                        }
                                                        
                                                ?>
                                                                ]);
                                                        
                                                        
document.getElementById('chart002').style.display = 'block';    
                                                          var options = 
                                                          {
                                                                  title: 
'Simple <? echo $data_gran ?> MEM Chart for <? echo $server_name ?>',
                                                                  curveType: 
"function",
                                                                  width: 700, 
height: 400,
                                                                  vAxis: 
{title:'MEM Util %', maxValue: 100, minValue: 0},
                                                                  hAxis: 
{title:' Date'  }
                                                                  
                                                          };
                                                          
                                                                // Create and 
draw the visualization.
                                                        
document.getElementById('chart002').style.display = 'block';    
                                                        var chart = new 
google.visualization.LineChart(document.getElementById('chart002')).
                                                        draw(data, options);
                                                                
                                                          }
                                                          
                                                          
google.setOnLoadCallback(drawVisualization);
                                                </script>
                                
                                </div>
                                <small> </small>
                        </td>
                </tr>
                
                <tr>
                        <td width="50%" style="border-top:1px dotted #cccccc;">
                                <div id="chart003" style="min-width:300px; 
min-height:300px; margin: 0 auto"></div>
                                <script type="text/javascript">
                                                        
google.load('visualization', '1', {packages: ['corechart']});
                                                </script>
                                                <script type="text/javascript">
                                                          function 
drawVisualization() {
                                                                // Create and 
populate the data table.
                                                                var data = 
google.visualization.arrayToDataTable([
                                                                  ['Disk', 
'Used %'],
                                                 <?
                                                                                
$sql = " if '$data_gran' = 'monthly' ".
                                                                                
                        " begin ".
                                                                                
                        " select ".
                                                                                
                        " convert(date,effect_dte), ".
                                                                                
                        " 
substring(sys_asset_id,CHARINDEX('^',sys_asset_id)+1,810), ".
                                                                                
                        " value_max ".
                                                                                
                        " from SYS_STAT_MONTHLY a join metric b on a.metric_id 
= b.metric_id ".
                                                                                
                        " where METRIC_NAM = 'disk_space_used_pct' ".
                                                                                
                        " and 
substring(sys_asset_id,1,CHARINDEX('^',sys_asset_id)-1) = '$server_name' ".
                                                                                
                        " order by SYS_ASSET_ID ".
                                                                                
                        " end ".
                                                                                
                        " if '$data_gran' = 'hourly' ".
                                                                                
                        " begin ".
                                                                                
                        " select ".
                                                                                
                        " 
substring(sys_asset_id,CHARINDEX('^',sys_asset_id)+1,810), ".
                                                                                
                        " avg(value_max) ".
                                                                                
                        " from SYS_STAT_hourly a join metric b on a.metric_id = 
b.metric_id ".
                                                                                
                        " where METRIC_NAM = 'disk_space_used_pct' ".
                                                                                
                        " and 
substring(sys_asset_id,1,CHARINDEX('^',sys_asset_id)-1) = '$server_name' ".
                                                                                
                        " and EFFECT_DTE >= GETDATE() -3 ".
                                                                                
                        " group by  SYS_ASSET_ID ".
                                                                                
                        " order by SYS_ASSET_ID ".
                                                                                
                        " end ".
                                                                                
                        " if '$data_gran' = 'daily' ".
                                                                                
                        " begin ".
                                                                                
                        " select ".
                                                                                
                        " 
substring(sys_asset_id,CHARINDEX('^',sys_asset_id)+1,810), ".
                                                                                
                        " avg(value_max) ".
                                                                                
                        " from SYS_STAT_Daily a join metric b on a.metric_id = 
b.metric_id ".
                                                                                
                        " where METRIC_NAM = 'disk_space_used_pct' ".
                                                                                
                        " and 
substring(sys_asset_id,1,CHARINDEX('^',sys_asset_id)-1) = '$server_name' ".
                                                                                
                        " and EFFECT_DTE >= GETDATE() -30 ".
                                                                                
                        " group by SYS_ASSET_ID ".
                                                                                
                        " order by SYS_ASSET_ID ".
                                                                                
                        " end ";

                                                        $odbc = 
odbc_connect('CapacityManagementProd', 'caprpt1', '1Cap9Man') or die('could not 
connect to database');
                                                        odbc_prepare($odbc, 
$sql) or die('could not exec SQL: ' . odbc_errormsg($odbc));
                                                        $res = odbc_exec($odbc, 
$sql) or die('could not exec SQL: ' . odbc_errormsg($odbc));
                                                        
                                                        $counter = 0;
                                                        $data = array();
                                                        while 
(odbc_fetch_array($res))
                                                        {
                                                                $data['disk'] = 
odbc_result($res, 1);
                                                                $data['used'] = 
odbc_result($res, 2);
                                                                
                                                                
                                                                if($counter > 
0) { ?>,<? }

                                                ?>
                                                                ['<? echo 
$data['disk']; ?>',<? echo $data['used']; ?>]
                                                <?
                                                                $counter++;
                                                        }
                                                        
                                                ?>
                                                                ]);
                                                                
                                                          var options = 
                                                          {
                                                                  title: 
'Simple <? echo $data_gran ?> Disk Chart for <? echo $server_name ?>',
                                                                  curveType: 
"function",
                                                                  width: 700, 
height: 400,
                                                                  vAxis: 
{title:'Disk Util %', maxValue: 100, minValue: 0}
                                                          };
                                                          
                                                                // Create and 
draw the visualization.
                                                                new 
google.visualization.ColumnChart(document.getElementById('chart003')).
                                                                        
draw(data, options);
                                                          }
                                                          

                                                          
google.setOnLoadCallback(drawVisualization);
                                                </script>
                                
                                </div>
                                
                           
                        </td>
                        
                        <td width="50%" style="border-left:1px dotted #cccccc; 
border-top:1px dotted #cccccc;">
                                <div id="chart_4" style="min-width:300px; 
min-height:300px; margin: 0 auto">sector 4 within div</div>
                           Network Data going here!!!
                        </td>
                </tr>
        </table>
        
  </body>
</html>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to