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.39 by tdb, Sun May 19 21:09:57 2002 UTC vs.
Revision 1.45 by tdb, Sun Aug 1 10:40:28 2004 UTC

# Line 2 | Line 2
2  
3   #
4   # i-scream central monitoring system
5 + # http://www.i-scream.org
6   # Copyright (C) 2000-2002 i-scream
7   #
8   # This program is free software; you can redistribute it and/or
# Line 37 | Line 38 | function printLine($title) {
38   }
39  
40  
41 < function showStat($title, $value, $input) {
41 > function showStat($title, $value, $input, $graph="") {
42  
43      $report = $value;
44  
# Line 53 | Line 54 | function showStat($title, $value, $input) {
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>
# Line 62 | Line 63 | function showStat($title, $value, $input) {
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  
# Line 81 | Line 83 | function showDisks($diskRoot, $units, $input) {
83          $mount = getPregMatch("$diskRoot.p$i.attributes.mount", $input);
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);
86 >            $total = "$diskRoot.p$i.attributes.total";
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, $total, $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;
# Line 91 | Line 99 | function showDisks($diskRoot, $units, $input) {
99      }
100   }
101  
102 +
103 + # show all disk IO information.
104 + function showDiskIO($diskRoot, $input) {
105 +    include("latest_config.inc.php");
106 +
107 +    $i = 0;
108 +    while(1) {
109 +        $name = getPregMatch("$diskRoot.p$i.attributes.name", $input);
110 +        if ($name) {
111 +            print "<br><center><b>(Disk $name)</b></center>";
112 +            showStat("Read bytes (per sec)", "$diskRoot.p$i.attributes.rbytes", $input, "diskio-$name");
113 +            showStat("Write bytes (per sec)", "$diskRoot.p$i.attributes.wbytes", $input, "diskio-$name");
114 +            print "          <br>\n";
115 +        }
116 +        else {
117 +            break;
118 +        }
119 +        $i++;
120 +    }
121 + }
122 +
123 +
124 + # show all network information.
125 + function showNet($netRoot, $input) {
126 +    include("latest_config.inc.php");
127 +                                                                                
128 +    $i = 0;
129 +    while(1) {
130 +        $name = getPregMatch("$netRoot.p$i.attributes.name", $input);
131 +        if ($name) {
132 +            print "<br><center><b>(Network Interface $name)</b></center>";
133 +            showStat("Received bytes (per sec)", "$netRoot.p$i.attributes.rx", $input, "net-$name");
134 +            showStat("Transfered bytes (per sec)", "$netRoot.p$i.attributes.tx", $input, "net-$name");
135 +            print "          <br>\n";
136 +        }
137 +        else {
138 +            break;
139 +        }
140 +        $i++;
141 +    }
142 + }
143 +
144 +
145   # Return a preg_match result.
146   function getPregMatch($value, $input) {
147      preg_match("/$value=([^\,\}]*)[\,\}]/", $input, $matches);
# Line 99 | Line 150 | function getPregMatch($value, $input) {
150  
151  
152   # show a bar-represented value.
153 < function showBar($title, $value, $max, $units, $input, $arrange='normal') {
153 > function showBar($title, $value, $max, $units, $input, $graph="", $arrange='normal') {
154  
155      include("latest_config.inc.php");
156  
157      $report = $value;
158 <
159 <    $value = getPregMatch($value, $input);
158 >    if (!is_int($value)) {
159 >        $value = getPregMatch($value, $input);
160 >    }
161      if (!is_int($max)) {
162          $max = getPregMatch($max, $input);
163      }
164 <    if (!isset($value) || empty($max)) {
164 >    if (!isset($value) || !isset($max)) {
165          return;
166      }
167  
# Line 117 | Line 169 | function showBar($title, $value, $max, $units, $input,
169          $value = $max - $value;
170      }
171  
172 <    $width = intval($max_width * $value / $max);
121 <
122 <    if ($width < 1) {
172 >    if(empty($max)) {
173          $width = 1;
174      }
175 +    else {
176 +        $width = intval($max_width * $value / $max);
177 +        if ($width < 1) {
178 +            $width = 1;
179 +        }
180 +    }
181  
182      ?>
183          <table border="0" cellpadding="0" cellspacing="0" align="center">
184            <tr>
185 <            <td colspan="2"><? linkToHistory($report); ?> <b><?=$title?></b> <font size="2">(<?=$value?><?=$units?>)</font></td>
185 >            <td colspan="2"><? linkToHistory($graph); ?> <b><?=$title?></b> <font size="2">(<?=$value?><?=$units?>)</font></td>
186            </tr>
187            <tr>
188              <td colspan="2" bgcolor="#eeeeff"><img src="<?=$barImage?>" border="0" height="20" width="<?=$width?>"></td>
# Line 137 | Line 193 | function showBar($title, $value, $max, $units, $input,
193            <tr>
194              <td align="left">0<?=$units?></td>
195              <td align="right"><?=$max?><?=$units?></td>
140          </tr>
141          <tr>
142            <td colspan="2">&nbsp;</td>
196            </tr>
197          </table>
198      <?

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines