| 2 |
|
|
| 3 |
|
# |
| 4 |
|
# i-scream central monitoring system |
| 5 |
+ |
# http://www.i-scream.org.uk |
| 6 |
|
# Copyright (C) 2000-2002 i-scream |
| 7 |
|
# |
| 8 |
|
# This program is free software; you can redistribute it and/or |
| 38 |
|
} |
| 39 |
|
|
| 40 |
|
|
| 41 |
< |
function showStat($title, $value, $input) { |
| 41 |
> |
function showStat($title, $value, $input, $graph="") { |
| 42 |
|
|
| 43 |
|
$report = $value; |
| 44 |
|
|
| 54 |
|
</td> |
| 55 |
|
<td width="50%" align="left" valign="top"> |
| 56 |
|
<? if (preg_match("/^[0-9]+\.?[0-9]*$/", $value)) { |
| 57 |
< |
linkToHistory($report); |
| 57 |
> |
linkToHistory($graph); |
| 58 |
|
} ?> |
| 59 |
|
<?=$value?></td> |
| 60 |
|
</tr> |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
|
| 66 |
< |
function linkToHistory($report) { |
| 66 |
> |
function linkToHistory($graph) { |
| 67 |
|
global $machine; |
| 68 |
< |
$yesterday = date("Y-m-d", time() - 86400); |
| 69 |
< |
echo <<<EOT |
| 70 |
< |
<a href="browser.php?machine_name=$machine&report=$report&day=$yesterday&submit=Show"><img src="minichart.gif" alt="View yesterday's 24-hour chart" width="20" height="20" border="0"></a> |
| 68 |
> |
if(!empty($graph)) { |
| 69 |
> |
echo <<<EOT |
| 70 |
> |
<a href="graphs.php?machine_name=$machine&graph=$graph&submit=Show"><img src="minichart.gif" alt="View historical graphs of this data" width="20" height="20" border="0"></a> |
| 71 |
|
EOT; |
| 72 |
+ |
} |
| 73 |
|
} |
| 74 |
|
|
| 75 |
|
|
| 84 |
|
if ($name || $mount) { |
| 85 |
|
$used = "$diskRoot.p$i.attributes.used"; |
| 86 |
|
$kbytes = "$diskRoot.p$i.attributes.kbytes"; |
| 87 |
< |
showBar("$name<br>($mount)", $used, $kbytes, $units, $input); |
| 87 |
> |
$graph = preg_replace("/_/", "$hex_underscore", $mount); |
| 88 |
> |
$graph = preg_replace("/\//", "$hex_slash", $graph); |
| 89 |
> |
$totalinodes = getPregMatch("$diskRoot.p$i.attributes.totalinodes", $input); |
| 90 |
> |
$freeinodes = getPregMatch("$diskRoot.p$i.attributes.freeinodes", $input); |
| 91 |
> |
showBar("$name ($mount)<br>space used", $used, $kbytes, $units, $input, "disk-$graph"); |
| 92 |
> |
showBar("inodes used", (int) $freeinodes, (int) $totalinodes, " inodes", $input, "", "swap"); |
| 93 |
> |
print " <br><br>\n"; |
| 94 |
|
} |
| 95 |
|
else { |
| 96 |
|
break; |
| 107 |
|
|
| 108 |
|
|
| 109 |
|
# show a bar-represented value. |
| 110 |
< |
function showBar($title, $value, $max, $units, $input, $arrange='normal') { |
| 110 |
> |
function showBar($title, $value, $max, $units, $input, $graph="", $arrange='normal') { |
| 111 |
|
|
| 112 |
|
include("latest_config.inc.php"); |
| 113 |
|
|
| 114 |
|
$report = $value; |
| 115 |
< |
|
| 116 |
< |
$value = getPregMatch($value, $input); |
| 115 |
> |
if (!is_int($value)) { |
| 116 |
> |
$value = getPregMatch($value, $input); |
| 117 |
> |
} |
| 118 |
|
if (!is_int($max)) { |
| 119 |
|
$max = getPregMatch($max, $input); |
| 120 |
|
} |
| 126 |
|
$value = $max - $value; |
| 127 |
|
} |
| 128 |
|
|
| 129 |
< |
$width = intval($max_width * $value / $max); |
| 121 |
< |
|
| 122 |
< |
if ($width < 1) { |
| 129 |
> |
if(empty($max)) { |
| 130 |
|
$width = 1; |
| 131 |
|
} |
| 132 |
+ |
else { |
| 133 |
+ |
$width = intval($max_width * $value / $max); |
| 134 |
+ |
if ($width < 1) { |
| 135 |
+ |
$width = 1; |
| 136 |
+ |
} |
| 137 |
+ |
} |
| 138 |
|
|
| 139 |
|
?> |
| 140 |
|
<table border="0" cellpadding="0" cellspacing="0" align="center"> |
| 141 |
|
<tr> |
| 142 |
< |
<td colspan="2"><? linkToHistory($report); ?> <b><?=$title?></b> <font size="2">(<?=$value?><?=$units?>)</font></td> |
| 142 |
> |
<td colspan="2"><? linkToHistory($graph); ?> <b><?=$title?></b> <font size="2">(<?=$value?><?=$units?>)</font></td> |
| 143 |
|
</tr> |
| 144 |
|
<tr> |
| 145 |
|
<td colspan="2" bgcolor="#eeeeff"><img src="<?=$barImage?>" border="0" height="20" width="<?=$width?>"></td> |
| 150 |
|
<tr> |
| 151 |
|
<td align="left">0<?=$units?></td> |
| 152 |
|
<td align="right"><?=$max?><?=$units?></td> |
| 140 |
– |
</tr> |
| 141 |
– |
<tr> |
| 142 |
– |
<td colspan="2"> </td> |
| 153 |
|
</tr> |
| 154 |
|
</table> |
| 155 |
|
<? |