Advertisement
bret_miller

memcron 0.6.7-Bret index.php

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