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.24 by pjm2, Tue Mar 13 20:55:43 2001 UTC vs.
Revision 1.31 by pjm2, Sat Mar 17 22:49:32 2001 UTC

# Line 22 | Line 22 | function showStat($title, $value, $input) {
22  
23      $report = $value;
24  
25 <    preg_match("/$value=([^\,]*)[\,\}]/", $input, $matches);
26 <    $value = $matches[1];
25 >    $value = getPregMatch($value, $input);
26      if (empty($value)) {
27          $value = "<i><font color=\"#999999\">not sent</font></i>";
28      }
# Line 53 | Line 52 | EOT;
52   }
53  
54  
55 + # show all disk information.
56 + function showDisks($diskRoot, $units, $input) {
57 +    include("latest_config.inc.php");
58 +
59 +    $i = 0;
60 +    while(1) {
61 +        $name = getPregMatch("$diskRoot.p$i.attributes.name", $input);
62 +        $mount = getPregMatch("$diskRoot.p$i.attributes.mount", $input);
63 +        if ($name || $mount) {
64 +            $used = "$diskRoot.p$i.attributes.used";
65 +            $kbytes = "$diskRoot.p$i.attributes.kbytes";
66 +            showBar("$name ($mount)", $used, $kbytes, $units, $input);
67 +            echo "$name ($mount) - $used/$kbytes<br>";
68 +        }
69 +        else {
70 +            break;
71 +        }
72 +        $i++;
73 +    }
74 +    echo "$i";
75 + }
76 +
77 + # Return a preg_match result.
78 + function getPregMatch($value, $input) {
79 +    preg_match("/$value=([^\,\}]*)[\,\}]/", $input, $matches);
80 +    return $matches[1];
81 + }
82 +
83 +
84   # show a bar-represented value.
85 < function showBar($title, $value, $max, $units, $input) {
85 > function showBar($title, $value, $max, $units, $input, $arrange='normal') {
86  
87      include("latest_config.inc.php");
88  
89      $report = $value;
90  
91 <    preg_match("/$value=([^\,]*)\,/", $input, $matches);
64 <    $value = $matches[1];
91 >    $value = getPregMatch($value, $input);
92      if (!is_int($max)) {
93 <        preg_match("/$max=([^\,]*)\,/", $input, $matches);
67 <        $max = $matches[1];
93 >        $max = getPregMatch($max, $input);
94      }
95      if (empty($value) || empty($max)) {
96          return;
97      }
98  
99 +    if ($arrange == 'swap') {
100 +        $value = $max - $value;
101 +    }
102 +
103      $width = intval($max_width * $value / $max);
104  
105      ?>
# Line 156 | Line 186 | echo <<<EOT
186   EOT;
187  
188         # Read the file.
189 <       #$input = "packet.attributes.machine_name=raptor.ukc.ac.uk,packet.memory.free=10,packet.memory.total=100,";
190 <       $input = file("$latestDirectory/$machine/$latestData");
191 <       # All we need is the first line if there is more than one line.
192 <       $input = $input[0];
189 >       if (file_exists("$latestDirectory/$machine/$latestData")) {
190 >           $input = file("$latestDirectory/$machine/$latestData");
191 >           # All we need is the first line if there is more than one line.
192 >           $input = $input[0];
193 >       }
194  
195         if (empty($input)) {
196 <           echo "<br><br>There was an error reading from the latest packet received.  Please notify your i-scream server administrator.";
196 >           echo "<br><br>There are currently no latest details about <b>$machine</b>.  Please notify your i-scream server administrator if you believe this to be incorrect.";
197         }
198         else {
199             # Display the data specified in the display include.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines