10
<?php
// $Id: uptime.php,v 0.1.1 2004/05/14 10:27am David Wagner $ //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
//
// Config Section
// Configure these values to match what you want
//
// Table BGCOLOR
$bgcolor = '#CCCCCC';
//
// Table Border
$border = '0';
$border_color = '#000000';
//
// Graph image to use. Prefferably keep this to 10*2 in dimmensions.
//$image = "{X_SITEURL}images/bar.gif";
$image = 'images/bar.gif';
$load = exec('cat /proc/loadavg');
$load = explode(' ',$load);
array_pop($load);
array_pop($load);
$scale = '1.5';
$total = ($load[0]*100);
$bar = $total*$scale;
echo'<table width="100" height="10" border="'.$border.'" bordercolor="'.$border_color.'">
<tr>
<td bgcolor="'.$bgcolor.'"><img src="'.$image.'" width="'.$bar.'" height="10" border="0"></td>
</tr>
</table>';
?>
Well I have made that, which seems to work alright. I set it to use the 1 minute average but the 5 and 15 minute averages can be used by setting $load[0] to $load[1] and $load[2] respectively. The only problem I am having is when I put this into a custom php block it distorts the page badly. Any help with this from others would be great.