Advertisement
bret_miller

memcron 0.6.6-Bret index.php

Nov 18th, 2011
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 18.40 KB | None | 0 0
  1. <?php
  2. $version = '0.6.6-Bret';
  3.  
  4. /*////////////////////////////////////////////////////////////////////////////////////
  5.  
  6.    memCron - DreamHost PS Memory Manager
  7.  
  8.    Author   : Yaosan Yeo
  9.    Version  : 0.6
  10.    Date     : 22 March 2010
  11.    URL      : http://memcron.com/
  12.  
  13.    History  :
  14.     0.6 [2010.03.22] - Added: Support for target memory and cached memory
  15.                      - Added: Version info to the footer
  16.                      - Changed: Now display http server name instead of actual PS name for extra security
  17.  
  18.     0.4.1 [2009.08.10] - Added: favicon for easier recognition of memCron tab in browser
  19.                        - Fixed: Proper max axis value for "Used + Total Memory"
  20.                        - Fixed: Memory calculation due to the 2x increase of swap memory by DreamHost
  21.  
  22.     0.4 [2009.06.28] - Changed: Tooltip for the resources usage graph is now cuter i.e. in yellow! :)
  23.                      - Fixed: Total memory is now displayed correctly on the resources graph by accounting for max swap memory, which is capped at 450MB
  24.  
  25.     0.3 [2009.05.27] - Added: Customizable chart formatting (y-axis) for resource usage graph
  26.                      - Added: New "css" folder to hold css stylesheets (no more css snippet in html head)
  27.                      - Added: Charset information to http header
  28.                      - Added: Generator meta information to XHTML head section
  29.                      - Changed: Chart title changed from "Memory Usage" to "Resources Usage"
  30.                      - Changed: #memchart width increased from 80% to 93%
  31.                      - Fixed: Tooltip fade in now works better in IE (remove filter to restore ClearType)
  32.  
  33.     0.2 [2009.05.03] - Nothing changed.
  34.  
  35.     0.1 [2009.04.30] - Initial release
  36.  
  37. ////////////////////////////////////////////////////////////////////////////////////*/
  38.  
  39. header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
  40. header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  41. header("Content-type: text/html; charset=iso-8859-1");
  42.  
  43. //
  44. // get configuration settings
  45. //
  46.  
  47. $config = dirname(__FILE__) . "/config.cfg";
  48.  
  49. $fp = fopen($config, 'r') or die ("Can't open config file!");
  50.  
  51. $settings = array();
  52.  
  53. while ( $line = fgets($fp) ) {
  54.     if ( substr($line, 0, 1) == '$') {
  55.         $s = preg_split('/[\s]+=[\s]+/', $line);
  56.  
  57.         $key = substr($s[0],1);
  58.         foreach( preg_split('/[";]+/', $s[1]) as $v ) {
  59.             $v = trim($v);
  60.             if ( !empty($v) ) {
  61.                 $value = $v;
  62.             }
  63.         }
  64.         $settings[$key] = $value;
  65.     }
  66. }
  67.  
  68. fclose($fp);
  69.  
  70. $server_name = preg_replace( '/(\w+\.)?([\w-]+)\.(\w+)$/i', '$2.$3', $_SERVER['SERVER_NAME'] );
  71. $ps = php_uname('n');
  72. $num_data_max = $settings['num_data_csv'];
  73.  
  74. $dateTimeZone = new DateTimeZone("America/Los_Angeles");
  75. $dateTime = new DateTime("now", $dateTimeZone);
  76. $timeOffset = $dateTimeZone->getOffset($dateTime);
  77. $gmt_offset = $timeOffset/3600;
  78. //$gmt_offset = -7;
  79. $num_data_default = 300;
  80. $log = dirname(__FILE__) . "/logs/$ps.csv";
  81.  
  82. //
  83. // get form parameters
  84. //
  85.  
  86. $axis = array( "mem", "memt", "mem_used", "mem_free", "mem_total", "cpu_load", "mem_mean", "mem_stdev", "mem_used_tolerance", "mem_free_tolerance", "downsize_count", "mem_target", "mem_cached" );
  87.  
  88. $num_data = ( is_numeric($_GET['n']) ) ? $_GET['n'] : $num_data_default;
  89. $y1 = ( isset($_GET['y1']) && in_array($_GET['y1'], $axis) ) ? $_GET['y1'] : "memt";
  90. $y2 = ( isset($_GET['y2']) && in_array($_GET['y2'], $axis) ) ? $_GET['y2'] : "cpu_load";
  91.  
  92. if ( $num_data > $num_data_max ) {
  93.     $num_data = $num_data_max;
  94. } else if ( $num_data < 1 ) {
  95.     $num_data = 1;
  96. }
  97.  
  98. $fp = fopen($log, 'r') or die ("Can't open log file!");
  99.  
  100. $unix_time = array();
  101. $mem_total = array();
  102. $mem_used = array();
  103. $mem_free = array();
  104. $cpu_load = array();
  105. $mem_mean = array();
  106. $mem_stdev = array();
  107. $mem_used_tolerance = array();
  108. $mem_free_tolerance = array();
  109. $downsize_count = array();
  110. $mem_target = array();
  111. $mem_cached = array();
  112.  
  113. // generate data array from log file
  114. while ( $y = trim( fgets($fp) ) ) {
  115.     list($t,$mt,$mu,$cpu,$mm,$ms,$mut,$mft,$dc,$mtg,$mc) = explode(",", $y);
  116.     $t = ( $t + $gmt_offset*3600 ) * 1000;
  117.  
  118.     array_push( $unix_time, $t );
  119.     array_push( $mem_total, $mt );
  120.     array_push( $mem_used, $mu );
  121.     array_push( $mem_free, $mt-$mu-$mc );
  122.     array_push( $cpu_load, $cpu );
  123.     array_push( $mem_mean, $mm );
  124.     array_push( $mem_stdev, $ms );
  125.     array_push( $mem_used_tolerance, $mut );
  126.     array_push( $mem_free_tolerance, $mft );
  127.     array_push( $downsize_count, $dc );
  128.     array_push( $mem_target, $mtg );
  129.     array_push( $mem_cached, $mc );
  130. }
  131.  
  132. fclose($fp);
  133.  
  134. // slice array based on "n"
  135. function sliceArray($arg, $num) {
  136.     return array_slice( $arg, count($arg) - $num );
  137. }
  138.  
  139. if ( $num_data < count($mem_total) ) {
  140.     $unix_time = sliceArray( $unix_time, $num_data );
  141.     $mem_total = sliceArray( $mem_total, $num_data );
  142.     $mem_used = sliceArray( $mem_used, $num_data );
  143.     $mem_free = sliceArray( $mem_free, $num_data );
  144.     $cpu_load = sliceArray( $cpu_load, $num_data );
  145.     $mem_mean = sliceArray( $mem_mean, $num_data );
  146.     $mem_stdev = sliceArray( $mem_stdev, $num_data );
  147.     $mem_used_tolerance = sliceArray( $mem_used_tolerance, $num_data );
  148.     $mem_free_tolerance = sliceArray( $mem_free_tolerance, $num_data );
  149.     $downsize_count = sliceArray( $downsize_count, $num_data );
  150.     $mem_target = sliceArray( $mem_target, $num_data );
  151.     $mem_cached = sliceArray( $mem_cached, $num_data );
  152. } else {
  153.     $num_data = count($mem_total);
  154. }
  155.  
  156. // get option values for y axis
  157. function getOptions($axis) {
  158.     global $mem_total, $mem_used, $mem_free,
  159.            $cpu_load, $mem_mean, $mem_stdev,
  160.            $mem_used_tolerance, $mem_free_tolerance, $downsize_count,
  161.            $mem_target, $mem_cached;
  162.     $min = 0;
  163.     $max = max($mem_total);
  164.     $max = ($max < 450) ? $max * 2 : $max + 450;
  165.     switch ($axis) {
  166.         case "mem":
  167.             $unit = "mb";
  168.             break;
  169.         case "memt":
  170.             $max = max( $max, max($mem_target) );
  171.             $unit = "mb";
  172.             break;
  173.         case "mem_total":
  174.             $unit = "mb";
  175.             break;
  176.         case "mem_used":
  177.             $unit = "mb";
  178.             break;
  179.         case "mem_free":
  180.             $unit = "mb";
  181.             break;
  182.         case "cpu_load":
  183.             $max = max( max($cpu_load), 3 );
  184.             $unit = " load";
  185.             break;
  186.         case "mem_mean":
  187.             $max = max($mem_mean);
  188.             $min = min($mem_mean);
  189.             $diff = round(($max-$min)*0.1);
  190.             $max += $diff;
  191.             $min -= $diff;
  192.             $unit = "mb";
  193.             break;
  194.         case "mem_stdev":
  195.             $max = max($mem_stdev);
  196.             $min = min($mem_stdev);
  197.             $diff = round(($max-$min)*0.1);
  198.             $max += $diff;
  199.             $min -= $diff;
  200.             $unit = "mb";
  201.             break;
  202.         case "mem_used_tolerance":
  203.             $max = max($mem_used_tolerance);
  204.             $unit = "mb";
  205.             break;
  206.         case "mem_free_tolerance":
  207.             $max = max($mem_free_tolerance);
  208.             $unit = "mb";
  209.             break;
  210.         case "downsize_count":
  211.             $max = max($downsize_count);
  212.             $unit = " count";
  213.             break;
  214.         case "mem_target":
  215.             $max = max( $max, max($mem_target) );
  216.             $unit = "mb";
  217.             break;
  218.         case "mem_cached":
  219.             $unit = "mb";
  220.             break;
  221.     }
  222.     return array($max, $min, $unit);
  223. }
  224.  
  225. $y1_options = getOptions($y1);
  226. $y2_options = getOptions($y2);
  227.  
  228. $y1_unit = array_pop($y1_options);
  229. $y2_unit = array_pop($y2_options);
  230.  
  231. $y1_min = array_pop($y1_options);
  232. $y2_min = array_pop($y2_options);
  233.  
  234. $y1_max = array_pop($y1_options);
  235. $y2_max = array_pop($y2_options);
  236.  
  237.  
  238. // construct data array for js
  239. function getData($axis) {
  240.     global $mem_total, $mem_used, $mem_free,
  241.            $cpu_load, $mem_mean, $mem_stdev,
  242.            $mem_used_tolerance, $mem_free_tolerance, $downsize_count,
  243.            $mem_target, $mem_cached;
  244.  
  245.     switch ($axis) {
  246.         case "mem":
  247.             array_push( $mem_used, "Used Memory" );
  248.             array_push( $mem_total, "Total Memory" );
  249.             $data = array( $mem_used, $mem_total );
  250.             array_pop($mem_used);
  251.             array_pop($mem_total);
  252.             break;
  253.         case "memt":
  254.             array_push( $mem_used, "Used Memory" );
  255.             array_push( $mem_total, "Total Memory" );
  256.             array_push( $mem_target, "Target Memory");
  257.             $data = array( $mem_used, $mem_total, $mem_target );
  258.             array_pop($mem_used);
  259.             array_pop($mem_total);
  260.             array_pop($mem_target);
  261.             break;
  262.         case "mem_total":
  263.             array_push( $mem_total, "Total Memory" );
  264.             $data = $mem_total;
  265.             array_pop($mem_total);
  266.             break;
  267.         case "mem_used":
  268.             array_push( $mem_used, "Used Memory" );
  269.             $data = $mem_used;
  270.             array_pop($mem_used);
  271.             break;
  272.         case "mem_free":
  273.             array_push( $mem_free, "Free Memory" );
  274.             $data = $mem_free;
  275.             array_pop($mem_free);
  276.             break;
  277.         case "cpu_load":
  278.             array_push( $cpu_load, "CPU Load" );
  279.             $data = $cpu_load;
  280.             array_pop($cpu_load);
  281.             break;
  282.         case "mem_mean":
  283.             array_push( $mem_mean, "Mean (used memory)" );
  284.             $data = $mem_mean;
  285.             array_pop($mem_mean);
  286.             break;
  287.         case "mem_stdev":
  288.             array_push( $mem_stdev, "Standard Deviation (used memory)" );
  289.             $data = $mem_stdev;
  290.             array_pop($mem_stdev);
  291.             break;
  292.         case "mem_used_tolerance":
  293.             array_push( $mem_used_tolerance, "Tolerance (used memory)" );
  294.             $data = $mem_used_tolerance;
  295.             array_pop($mem_used_tolerance);
  296.             break;
  297.         case "mem_free_tolerance":
  298.             array_push( $mem_free_tolerance, "Tolerance (free memory)" );
  299.             $data = $mem_free_tolerance;
  300.             array_pop($mem_free_tolerance);
  301.             break;
  302.         case "downsize_count":
  303.             array_push( $downsize_count, "Downsize Count");
  304.             $data = $downsize_count;
  305.             array_pop($downsize_count);
  306.             break;
  307.         case "mem_target":
  308.             array_push( $mem_target, "Target Memory");
  309.             $data = $mem_target;
  310.             array_pop($mem_target);
  311.             break;
  312.         case "mem_cached":
  313.             array_push( $mem_cached, "Cached Memory");
  314.             $data = $mem_cached;
  315.             array_pop($mem_cached);
  316.             break;
  317.     }
  318.     return $data;
  319. }
  320.  
  321. $d1 = getData($y1);
  322. if ( is_array($d1[0]) ) {
  323.     $d5 = $d1[2];
  324.     $d2 = $d1[1];
  325.     $d1 = $d1[0];
  326. }
  327.  
  328. $d3 = getData($y2);
  329. if ( is_array($d3[0]) ) {
  330.     $d6 = $d3[2];
  331.     $d4 = $d3[1];
  332.     $d3 = $d3[0];
  333. }
  334.  
  335. // get label
  336. $d1_label = array_pop($d1);
  337. if ($d2) { $d2_label = array_pop($d2); }
  338. if ($d5) { $d5_label = array_pop($d5); }
  339.  
  340. $d3_label = array_pop($d3);
  341. if ($d4) { $d4_label = array_pop($d4); }
  342. if ($d6) { $d6_label = array_pop($d6); }
  343.  
  344. $i = 0;
  345. foreach ( $unix_time as $t ) {
  346.     $d1[$i] = "[$t," . $d1[$i]. "]";
  347.     if ($d2) { $d2[$i] = "[$t," . $d2[$i]. "]"; }
  348.     if ($d5) { $d5[$i] = "[$t," . $d5[$i]. "]"; }
  349.    
  350.     $d3[$i] = "[$t," . $d3[$i]. "]";
  351.     if ($d4) { $d4[$i] = "[$t," . $d4[$i]. "]"; }
  352.     if ($d6) { $d6[$i] = "[$t," . $d6[$i]. "]"; }
  353.     $i++;
  354. }
  355.  
  356. // get line width
  357. $line_width = 3;
  358.  
  359. if ( $num_data >= 200 ) {
  360.     $line_width = 3 - ( $num_data - 200 ) / 200;
  361.     $line_width = max(1, $line_width);
  362.     $line_width = round($line_width, 0);
  363. }
  364. ?>
  365. <!DOCTYPE html
  366.      PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  367.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  368. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  369. <head>
  370.     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  371.     <meta name="robots" content="noindex" />
  372.     <meta name="generator" content="memCron <?php echo $version; ?>" />
  373.  
  374.     <title>Resources Usage for <?php echo $ps; ?> &laquo; memCron</title>
  375.     <link rel="icon" href="/favicon.ico" />
  376.  
  377.     <!--[if IE]><script language="javascript" type="text/javascript" src="js/excanvas.pack.js"></script><![endif]-->
  378.     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
  379.     <script type="text/javascript" src="js/jquery.flot.pack.js"></script>
  380.     <script type="text/javascript" src="js/thickbox-compressed.js"></script>
  381.  
  382.     <link rel="stylesheet" href="css/memcron.css" type="text/css" media="screen" />
  383.     <link rel="stylesheet" href="css/thickbox.css" type="text/css" media="screen" />
  384. </head>
  385. <body id="memcron">
  386.     <h1>Resources Usage for <?php echo "$server_name [$ps]"; ?></h1>
  387.     <div id="content">
  388.         <div id="memchart"></div>
  389.         <noscript><p>Please turn on Javascript to see the graph</p></noscript>
  390.         <form method="get" action="./">
  391.             <p>
  392.                 <input type="hidden" name="y1" id="y1" value="<?php echo $y1 ?>" />
  393.                 <input type="hidden" name="y2" id="y2" value="<?php echo $y2 ?>" />
  394.                 Display <input type="text" name="n" id="n" value="<?php echo $num_data ?>" maxlength="<?php echo floor(log10($num_data_max)+1) ?>"></input> data points<a href="#TB_inline?&amp;height=220&amp;width=350&amp;inlineId=customize&amp;modal=true" class="thickbox"><img src="images/chart.png" alt="Customize chart" /></a>
  395.             </p>
  396.         </form>
  397.     </div>
  398.     <div id="customize" style="display:none;">
  399.         <h2>Chart Formatting</h2>
  400.         <p>
  401.             y1 axis:
  402.             <select name="y1axis" id="y1axis">
  403.               <option value="mem">Used & Total Memory</option>
  404.               <option value="memt" selected="selected">Used, Total & Target Memory</option>
  405.               <option value="mem_used">Used Memory</option>
  406.               <option value="mem_free">Free Memory</option>
  407.               <option value="mem_total">Total Memory</option>
  408.               <option value="cpu_load">CPU Load</option>
  409.               <option value="mem_mean">Mean (used memory)</option>
  410.               <option value="mem_stdev">Standard Deviation (used memory)</option>
  411.               <option value="mem_used_tolerance">Tolerance (used memory)</option>
  412.               <option value="mem_free_tolerance">Tolerance (free memory)</option>
  413.               <option value="downsize_count">Downsize Count</option>
  414.               <option value="mem_target">Target Memory</option>
  415.               <option value="mem_cached">Cached Memory</option>
  416.             </select>
  417.         </p>
  418.         <p>
  419.             y2 axis:
  420.             <select name="y2axis" id="y2axis">
  421.               <option value="mem">Used & Total Memory</option>
  422.               <option value="memt">Used, Total & Target Memory</option>
  423.               <option value="mem_used">Used Memory</option>
  424.               <option value="mem_free">Free Memory</option>
  425.               <option value="mem_total">Total Memory</option>
  426.               <option value="cpu_load">CPU Load</option>
  427.               <option value="mem_mean">Mean (used memory)</option>
  428.               <option value="mem_stdev">Standard Deviation (used memory)</option>
  429.               <option value="mem_used_tolerance">Tolerance (used memory)</option>
  430.               <option value="mem_free_tolerance">Tolerance (free memory)</option>
  431.               <option value="downsize_count">Downsize Count</option>
  432.               <option value="mem_target">Target Memory</option>
  433.               <option value="mem_cached">Cached Memory</option>
  434.             </select>
  435.         </p>
  436.         <p>
  437.             <button type="submit" id="ok" onclick="submitForm()">OK</button>
  438.             <button id="cancel" onclick="tb_remove()">Cancel</button>
  439.         </p>
  440.         <script type="text/javascript">
  441.             $("#y1axis option[value='<?php echo $y1 ?>']").attr('selected', 'selected');
  442.             $("#y2axis option[value='<?php echo $y2 ?>']").attr('selected', 'selected');
  443.         </script>
  444.     </div>
  445.     <p class="footer">
  446.         Powered by <a href="http://memcron.com/" title="memCron - DreamHost PS Memory Manager"><img src="images/logo.png" alt="memCron" /></a> <?php echo $version; ?>
  447.     </p>
  448.     <script type="text/javascript">
  449.     //<![CDATA[
  450.     (function($) {
  451.         $.fn.customFadeIn = function(speed, callback) {
  452.             $(this).fadeIn(speed, function() {
  453.                 if(jQuery.browser.msie)
  454.                     $(this).get(0).style.removeAttribute('filter');
  455.                 if(callback != undefined)
  456.                     callback();
  457.             });
  458.         };
  459.         $.fn.customFadeOut = function(speed, callback) {
  460.             $(this).fadeOut(speed, function() {
  461.                 if(jQuery.browser.msie)
  462.                     $(this).get(0).style.removeAttribute('filter');
  463.                 if(callback != undefined)
  464.                     callback();
  465.             });
  466.         };
  467.     })(jQuery);
  468.  
  469.     function showTooltip(x, y, contents) {
  470.         $('<div id="tooltip">' + contents + '<\/div>').css( {
  471.             position: 'absolute',
  472.             display: 'none',
  473.             top: y + 7,
  474.             left: x + 7,
  475.             border: '4px solid #f9e98e',
  476.             padding: '10px 12px',
  477.             color: '#95693d',
  478.             'background-color': '#fbf6aa',
  479.             opacity: 0.99
  480.         }).appendTo("body").customFadeIn(200);
  481.     }
  482.  
  483.     var previousPoint = null;
  484.     $("#memchart").bind("plothover", function (event, pos, item) {
  485.         if (item) {
  486.             if (previousPoint != item.datapoint) {
  487.                 previousPoint = item.datapoint;
  488.  
  489.                 $("#tooltip").remove();
  490.                 var dt = new Date();
  491.                 var x = new Date(item.datapoint[0] + dt.getTimezoneOffset()*60000),
  492.                     y = item.datapoint[1];
  493.  
  494.                 var h = x.getHours();
  495.                 var m = x.getMinutes();
  496.  
  497.                 if (h < 10) { h = "0" + h; }
  498.                 if (m < 10) { m = "0"+ m; }
  499.                 x = h + ":" + m;
  500.  
  501.                 showTooltip(item.pageX, item.pageY,
  502.                             item.series.label + " at " + x + " = " + y);
  503.             }
  504.         }
  505.         else {
  506.             $("#tooltip").remove();
  507.             previousPoint = null;
  508.         }
  509.     });
  510.  
  511.     function submitForm() {
  512.         if( $("#y1axis :selected").val() == $("#y2axis :selected").val() ) {
  513.             alert("Data for y1 axis and y2 axis cannot be the same!");
  514.         } else {
  515.             tb_remove();
  516.             $("#y1").val( $("#y1axis").val() );
  517.             $("#y2").val( $("#y2axis").val() );
  518.             $("form").submit();
  519.         }
  520.     }
  521.  
  522.     function resizeGraph() {
  523.         var w = Math.round($(window).width()*0.93);
  524.         var h = Math.round($(window).height()-263);
  525.         if (w < 350) { w = 350; }
  526.         if (h < 200) { h = 200; }
  527.         $('#memchart').width(w);
  528.         $('#memchart').height(h);
  529.         $.plot($("#memchart"), [ <?php echo "d1" . ( (!empty($d2)) ? ", d2" : "" ) . ", d3" . ( (!empty($d4)) ? ", d4" : "" ) . ( (!empty($d5)) ? ", d5" : "" ) . ( (!empty($d6)) ? ", d6" : "" ); ?> ], options );
  530.     }
  531.  
  532.     var d1 = {
  533.         label: "<?php echo $d1_label ?>",
  534.         data: [ <?php echo implode( ",", $d1 ); ?> ],
  535.         yaxis: 1
  536.     };
  537. <?php if ($d2) { ?>
  538.     var d2 = {
  539.         label: "<?php echo $d2_label ?>",
  540.         data: [ <?php echo implode( ",", $d2 ); ?> ],
  541.         yaxis: 1
  542.     };
  543. <?php } ?>
  544. <?php if ($d5) { ?>
  545.     var d5 = {
  546.         label: "<?php echo $d5_label ?>",
  547.         data: [ <?php echo implode( ",", $d5 ); ?> ],
  548.         yaxis: 1
  549.     };
  550. <?php } ?>
  551.     var d3 = {
  552.         label: "<?php echo $d3_label ?>",
  553.         data: [ <?php echo implode( ",", $d3 ); ?> ],
  554.         yaxis: 2
  555.     };
  556. <?php if ($d4) { ?>
  557.     var d4 = {
  558.         label: "<?php echo $d4_label ?>",
  559.         data: [ <?php echo implode( ",", $d4 ); ?> ],
  560.         yaxis: 2
  561.     };
  562. <?php } ?>
  563. <?php if ($d6) { ?>
  564.     var d6 = {
  565.         label: "<?php echo $d6_label ?>",
  566.         data: [ <?php echo implode( ",", $d6 ); ?> ],
  567.         yaxis: 2
  568.     };
  569. <?php } ?>
  570.  
  571.     var options = {
  572.         lines: { show: true, lineWidth: <?php echo $line_width ?> },
  573.         points: { show: <?php echo ($line_width >= 3) ? "true" : "false"; ?> },
  574.         selection: { mode: "xy" },
  575.         legend: { position: 'nw' },
  576.         grid: { hoverable: true, clickable: false },
  577.         shadowSize: 3,
  578.         xaxis: { mode: "time", timeformat: "%H:%M" },
  579.         yaxis: { min: <?php echo $y1_min ?>, max: <?php echo $y1_max ?>, tickFormatter: function (v, axis) { return v.toFixed(axis.tickDecimals) + "<?php echo $y1_unit ?>" } },
  580.         y2axis: { min: <?php echo $y2_min ?>, max: <?php echo $y2_max ?>, tickFormatter: function (v, axis) { return v.toFixed(axis.tickDecimals) + "<?php echo $y2_unit ?>" } }
  581.     };
  582.  
  583.     $(window).resize(function() { resizeGraph(); });
  584.  
  585.     $(document).ready(function() {
  586.         resizeGraph();
  587.     });
  588.     //]]>
  589.     </script>
  590. </body>
  591. </html>
  592.  
  593.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement