ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/reports/php/latest/latest.php
(Generate patch)

Comparing projects/cms/source/reports/php/latest/latest.php (file contents):
Revision 1.45 by tdb, Sun Aug 1 10:40:28 2004 UTC vs.
Revision 1.46 by tdb, Fri Feb 11 14:05:31 2005 UTC

# Line 32 | Line 32 | include("latest_config.inc.php");
32  
33   include("iutils.inc.php");
34  
35 + if ($formMethod == "GET") {
36 +    $machine = $_GET['machine'];
37 + }
38 +
39 +
40   function printLine($title) {
41      echo "<hr style=\"color:#9999ff;\">";
42      echo "<b>$title</b>";
43   }
44  
45  
46 + function showUptime($title, $value, $input, $graph="") {
47 +    $report = $value;
48 +
49 +    $value = getPregMatch($value, $input);
50 +    if (!isset($value)) {
51 +        $value = "<i><font color=\"#999999\">not sent</font></i>";
52 +    }
53 +    ?>
54 +        <table border="0" width="100%">
55 +          <tr>
56 +            <td width="50%" align="right" valign="top">
57 +             <b><?=$title?></b>
58 +            </td>
59 +            <td width="50%" align="left" valign="top">
60 +             <? if (preg_match("/^[0-9]+\.?[0-9]*$/", $value)) {
61 +                    linkToHistory($graph);
62 +                } ?>
63 +              <?=uptime($value)?> (<?=$value?> seconds)</td>
64 +          </tr>
65 +        </table>
66 +    <?
67 + }
68 +
69 +
70   function showStat($title, $value, $input, $graph="") {
71  
72      $report = $value;
# Line 73 | Line 102 | EOT;
102   }
103  
104  
105 + # convert bytes to MB
106 + function b2Mb($bytes) {
107 +    $mb = $bytes / (1024*1024);
108 +    return (int) $mb;
109 + }
110 +
111 +
112 + # Convert seconds uptime to something readable
113 + function uptime($until) {
114 +    $day = date('z', $until);
115 +    $hour = date('G', $until);
116 +    $hour = $hour - 1; # one too many
117 +    $minute = date('i', $until);
118 +    $return = "";
119 +    if ($day) {
120 +        $return = "$return$day Days ";
121 +    }
122 +    if ($hour) {
123 +        $return = "$return$hour Hours ";
124 +    }
125 +    return "$return$minute Mins";
126 + }
127 +
128 +
129   # show all disk information.
130   function showDisks($diskRoot, $units, $input) {
131      include("latest_config.inc.php");
# Line 89 | Line 142 | function showDisks($diskRoot, $units, $input) {
142              $totalinodes = getPregMatch("$diskRoot.p$i.attributes.totalinodes", $input);
143              $freeinodes = getPregMatch("$diskRoot.p$i.attributes.freeinodes", $input);
144              showBar("$name ($mount)<br>space used", $used, $total, $units, $input, "disk-$graph");
145 <            showBar("inodes used", (int) $freeinodes, (int) $totalinodes, " inodes", $input, "", "swap");
145 >            showBar("inodes used", (float) $freeinodes, (float) $totalinodes, " inodes", $input, "", "swap");
146 >            showStat("FS Type", "$diskRoot.p$i.attributes.fstype", $input);
147              print "          <br><br>\n";
148          }
149          else {
# Line 141 | Line 195 | function showNet($netRoot, $input) {
195      }
196   }
197  
198 + # show all mail queue information
199 + function showMailQ($mailqRoot, $input) {
200 +    include("latest_config.inc.php");
201  
202 +    $i = 0;
203 +    while(1) {
204 +        $name = getPregMatch("$mailqRoot.p$i.attributes.name", $input);
205 +        if ($name) {
206 +            print "<br><center><b>($name)</b></center>";
207 +            $name = preg_replace("/\s+/", "", $name);
208 +            showStat("Messages in queue", "$mailqRoot.p$i.attributes.size", $input, "mailq-$name");
209 +            print "          <br>\n";
210 +        }
211 +        else {
212 +            break;
213 +        }
214 +        $i++;
215 +    }
216 + }
217 +
218   # Return a preg_match result.
219   function getPregMatch($value, $input) {
220      preg_match("/$value=([^\,\}]*)[\,\}]/", $input, $matches);
# Line 167 | Line 240 | function showBar($title, $value, $max, $units, $input,
240  
241      if ($arrange == 'swap') {
242          $value = $max - $value;
243 +    }
244 +
245 +    if ($units == 'MB') {
246 +        $value = b2Mb ($value);
247 +        $max = b2Mb ($max);
248      }
249  
250      if(empty($max)) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines