Witam mam problem nie wiem jak dopsaic do tego kodu zeby wyswietlal load avarange


  1. <?
  2. echo '<?xml version="1.0" encoding="UTF-8"?>' . "n";
  3. require('sslib.php');
  4.  
  5. $server = $_GET['server'];
  6. $servers = GetServerList();
  7.  
  8. if(!file_exists(SS_PATH_GFX))
  9. mkdir(SS_PATH_GFX,0777);
  10. ?>
  11. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  12. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
  13. <head>
  14.  <link rel="stylesheet" href="shoutstats.css" type="text/css" media="screen" />
  15. </head>
  16. <body>
  17. <?
  18. // a specific server has been selected
  19. if(strlen($server)):
  20.  
  21. // generate and display the 24 hours server specific graph
  22. $txt_freq = 'hourly';
  23. $rrdgfx=SS_PATH_GFX."/hourly-{$servers[$server]['host']}.{$servers[$server]['port']}.png";
  24. $rrdfile=SS_PATH_RRD."/{$servers[$server]['host']}.{$servers[$server]['port']}.rrd";
  25. exec(SS_RRDTOOL_COMMAND . " graph $rrdgfx --lazy -l 0 -a PNG DEF:myaudience=$rrdfile:audience:AVERAGE LINE2:myaudience#FF0000");
  26. DisplayGraph($txt_freq, $rrdgfx);
  27.  
  28. // generate and display the 7 days server specific graph
  29. $txt_freq = 'daily';
  30. $rrdgfx=SS_PATH_GFX."/daily-{$servers[$server]['host']}.{$servers[$server]['port']}.png";
  31. exec(SS_RRDTOOL_COMMAND . " graph $rrdgfx --lazy -l 0 -a PNG -s e-1w DEF:myaudience=$rrdfile:audience:AVERAGE LINE2:myaudience#FF0000");
  32. DisplayGraph($txt_freq, $rrdgfx);
  33.  
  34. // generate and display the 5 weeks server specific graph
  35. $txt_freq = 'weekly';
  36. $rrdgfx=SS_PATH_GFX."/weekly-{$servers[$server]['host']}.{$servers[$server]['port']}.png";
  37. exec(SS_RRDTOOL_COMMAND . " graph $rrdgfx --lazy -l 0 -a PNG -s e-5w DEF:myaudience=$rrdfile:audience:AVERAGE LINE2:myaudience#FF0000");
  38. DisplayGraph($txt_freq, $rrdgfx);
  39.  
  40. // generate and display the 12 months server specific graph
  41. $txt_freq = 'monthly';
  42. $rrdgfx=SS_PATH_GFX."/monthly-{$servers[$server]['host']}.{$servers[$server]['port']}.png";
  43. exec(SS_RRDTOOL_COMMAND . " graph $rrdgfx --lazy -l 0 -a PNG -s e-1y DEF:myaudience=$rrdfile:audience:AVERAGE LINE2:myaudience#FF0000");
  44. DisplayGraph($txt_freq, $rrdgfx);
  45.  
  46. // generate and display the 12 months server specific graph
  47. $txt_freq = 'uptime';
  48. $rrdgfx=SS_PATH_GFX."/uptime-{$servers[$server]['host']}.{$servers[$server]['port']}.png";
  49. exec(SS_RRDTOOL_COMMAND . ' graph $rrdgfx --start 1183882501 --end 1183896901 --imgformat PNG --lazy -w 700 -h 300 COMMENT:"From 2007-07-08 10:15:01 To 2007-07-08 14:15:01c" COMMENT:"n" --title "eLuna Web Server - Load Average" --vertical-label="" --units-exponent 0 --lower-limit 0 DEF:load_1mn=rrd/01_load/load.rrd:load_1mn:AVERAGE DEF:load_5mn=rrd/01_load/load.rrd:load_5mn:AVERAGE DEF:load_15mn=rrd/01_load/load.rrd:load_15mn:AVERAGE CDEF:mysum=load_1mn,load_5mn,+,load_15mn,+ AREA:load_
    1mn#EACC00:" 1mn load average " GPRINT:load_1mn:LAST:"Current: %5.2lf " GPRINT:load_1mn:AVERAGE:"Average: %5.2lf " GPRINT:load_1mn:MAX:"Max: %5.2lfn" STACK:load_5mn#EA8F00:" 5mn load average " GPRINT:load_5mn:LAST:"Current: %5.2lf " GPRINT:load_5mn:AVERAGE:"Average: %5.2lf " GPRINT:load_5mn:MAX:"Max: %5.2lfn" STACK:load_15mn#FF0000:"15mn load average " GPRINT:load_15mn:LAST:"Current: %5.2lf " GPRINT:load_15mn:AVERAGE:"Average: %5.2lf " GPRINT:load_15mn:MAX:"Max: %5.2lfn" LINE1:mysum#000000'
    );
  50. DisplayGraph($txt_freq, $rrdgfx);
  51. // no server has been selected
  52. else:
  53.  
  54. $rrdexecend = ' ';
  55. $i = 0;
  56. foreach ($servers as $n => $s)
  57. {
  58. $rrdfile = SS_PATH_RRD."/{$s['host']}.{$s['port']}.rrd";
  59. $rrdexecend .= "DEF:myaudience$i=$rrdfile:audience:AVERAGE ";
  60. $rrdexecend .= "CDEF:audience$i=myaudience$i,UN,0,myaudience$i,IF ";
  61. $i++;
  62. }
  63. if(count($servers)>1) {
  64. $rrdexecend .= 'CDEF:mytotal=';
  65. for($i=0; $i<count($servers); $i++)
  66. $rrdexecend .= "audience$i,";
  67. for($i=0; $i<count($servers)-2; $i++)
  68. $rrdexecend .= '+,';
  69. $rrdexecend .= '+ ';
  70. } else {
  71. $rrdexecend .= 'CDEF:mytotal=audience0 ';
  72. }
  73. $rrdexecend .= 'LINE2:mytotal#FF0000';
  74.  
  75. // generate and display the 24 hours graph
  76. $txt_freq = 'hourly';
  77. $rrdgfx = SS_PATH_GFX.'/hourly-all.png';
  78. $rrdexecstart = SS_RRDTOOL_COMMAND . " graph $rrdgfx --lazy -l 0 -a PNG";
  79. exec($rrdexecstart.$rrdexecend);
  80. DisplayGraph($txt_freq, $rrdgfx);
  81.  
  82. // generate and display the 7 days graph
  83. $txt_freq = 'daily';
  84. $rrdgfx = SS_PATH_GFX.'/daily-all.png';
  85. $rrdexecstart = SS_RRDTOOL_COMMAND . " graph $rrdgfx --lazy -l 0 -a PNG -s e-1w";
  86. exec($rrdexecstart.$rrdexecend);
  87. DisplayGraph($txt_freq, $rrdgfx);
  88.  
  89. // generate and display the 5 weeks graph
  90. $txt_freq = 'weekly';
  91. $rrdgfx = SS_PATH_GFX.'/weekly-all.png';
  92. $rrdexecstart = SS_RRDTOOL_COMMAND . " graph $rrdgfx --lazy -l 0 -a PNG -s e-5w";
  93. exec($rrdexecstart.$rrdexecend);
  94. DisplayGraph($txt_freq, $rrdgfx);
  95.  
  96. // generate and display the 12 months graph
  97. $txt_freq = 'monthly';
  98. $rrdgfx = SS_PATH_GFX.'/monthly-all.png';
  99. $rrdexecstart = SS_RRDTOOL_COMMAND . " graph $rrdgfx --lazy -l 0 -a PNG -s e-1y";
  100. exec($rrdexecstart.$rrdexecend);
  101. DisplayGraph($txt_freq, $rrdgfx);
  102.  
  103. // generate and display the 12 months graph
  104. $txt_freq = 'uptime';
  105. $rrdgfx = SS_PATH_GFX.'/uptime.png';
  106. $rrdexecstart = SS_RRDTOOL_COMMAND . "uptime";
  107. exec($rrdexecstart.$rrdexecend);
  108. DisplayGraph($txt_freq, $rrdgfx);
  109.  
  110. endif;
  111. ?>