Changeset 143 for trunk/web/addons/toga/search.php
- Timestamp:
- 06/16/05 16:21:06 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/addons/toga/search.php
r142 r143 118 118 119 119 $time_fields = explode( ':', $time ); 120 reset( $time_fields );121 122 print_r( $time_fields );123 120 124 121 $hours = $time_fields[0]; … … 161 158 function makeSearchPage() { 162 159 global $clustername, $tpl, $id, $user, $name, $start_from_time, $start_to_time, $queue; 163 global $end_from_time, $end_to_time, $filter; 160 global $end_from_time, $end_to_time, $filter, $default_showhosts, $m, $hosts_up; 161 162 $metricname = $m; 164 163 165 164 $tpl->assign( "cluster", $clustername ); … … 210 209 $tpl->assign( "runningtime", makeTime( $runningtime ) ); 211 210 212 print_r( $job ); 213 print_r( $nodes ); 214 //output jobzooi 215 211 //print_r( $job ); 212 //print_r( $nodes ); 216 213 } 214 217 215 218 216 if( count( $search_ids ) == 1 ) { 219 217 220 218 $tpl->newBlock( "showhosts" ); 219 220 $showhosts = isset($sh) ? $sh : $default_showhosts; 221 //if( !$showhosts) $showhosts = $default_showhosts; 222 $tpl->assign("checked$showhosts", "checked"); 223 224 # Present a width list 225 $cols_menu = "<SELECT NAME=\"hc\" OnChange=\"toga_form.submit();\">\n"; 226 227 $hostcols = ($hc) ? $hc : 4; 228 229 foreach(range(1,25) as $cols) { 230 $cols_menu .= "<OPTION VALUE=$cols "; 231 if ($cols == $hostcols) 232 $cols_menu .= "SELECTED"; 233 $cols_menu .= ">$cols\n"; 234 } 235 $cols_menu .= "</SELECT>\n"; 236 237 $tpl->assign("metric","$metricname $units"); 238 $tpl->assign("id", $id); 239 # Host columns menu defined in header.php 240 $tpl->assign("cols_menu", $cols_menu); 241 242 if( $showhosts ) { 243 //bla 244 245 if( !isset($start) ) $start="jobstart"; 246 if( !isset($stop) ) $stop="now"; 247 //$tpl->assign("start", $start); 248 //$tpl->assign("stop", $stop); 249 250 $sorted_hosts = array(); 251 $hosts_up = $jobs[$filter[id]][nodes]; 252 253 $r = intval($job_runningtime * 1.25); 254 255 $jobrange = ($job_runningtime < 3600) ? -3600 : -$r ; 256 $jobstart = $report_time - $job_runningtime; 257 258 if ($reports[$metricname]) 259 $metricval = "g"; 260 else 261 $metricval = "m"; 262 263 foreach ($hosts_up as $host ) { 264 $host = $host. '.'.$domain; 265 $cpus = $metrics[$host]["cpu_num"][VAL]; 266 if (!$cpus) $cpus=1; 267 $load_one = $metrics[$host]["load_one"][VAL]; 268 $load = ((float) $load_one)/$cpus; 269 $host_load[$host] = $load; 270 $percent_hosts[load_color($load)] += 1; 271 if ($metricname=="load_one") 272 $sorted_hosts[$host] = $load; 273 else 274 $sorted_hosts[$host] = $metrics[$host][$metricname][VAL]; 275 } 276 switch ($sort) { 277 case "descending": 278 arsort($sorted_hosts); 279 break; 280 case "by hostname": 281 ksort($sorted_hosts); 282 break; 283 default: 284 case "ascending": 285 asort($sorted_hosts); 286 break; 287 } 288 289 //$sorted_hosts = array_merge($down_hosts, $sorted_hosts); 290 291 # First pass to find the max value in all graphs for this 292 # metric. The $start,$end variables comes from get_context.php, 293 # included in index.php. 294 list($min, $max) = find_limits($sorted_hosts, $metricname); 295 296 # Second pass to output the graphs or metrics. 297 $i = 1; 298 foreach ( $sorted_hosts as $host=>$value ) { 299 $tpl->newBlock ("sorted_list"); 300 //$host = $host. '.'.$domain; 301 $host_url = rawurlencode($host); 302 $cluster_url = rawurlencode($clustername); 303 304 $textval = ""; 305 //printf("host = %s, value = %s", $host, $value); 306 //echo "$host: $value, "; 307 $val = $metrics[$host][$metricname]; 308 $class = "metric"; 309 $host_link="\"?c=$cluster_url&h=$host_url&r=job&jr=$jobrange&js=$jobstart\""; 310 311 if ($val[TYPE]=="timestamp" or $always_timestamp[$metricname]) { 312 $textval = date("r", $val[VAL]); 313 } elseif ($val[TYPE]=="string" or $val[SLOPE]=="zero" or $always_constant[$metricname] or ($max_graphs > 0 and $i > $max_graphs )) { 314 $textval = "$val[VAL] $val[UNITS]"; 315 } else { 316 $load_color = load_color($host_load[$host]); 317 $graphargs = ($reports[$metricname]) ? "g=$metricname&" : "m=$metricname&"; 318 $graphargs .= "z=small&c=$cluster_url&h=$host_url&l=$load_color" ."&v=$val[VAL]&x=$max&n=$min&r=job&jr=$jobrange&js=$jobstart"; 319 } 320 if ($textval) { 321 $cell="<td class=$class>". "<b><a href=$host_link>$host</a></b><br>". "<i>$metricname:</i> <b>$textval</b></td>"; 322 } else { 323 $cell="<td><a href=$host_link>". "<img src=\"../../graph.php?$graphargs\" ". "alt=\"$host\" height=112 width=225 border=0></a></td>"; 324 } 325 326 $tpl->assign("metric_image", $cell); 327 if (! ($i++ % $hostcols) ) 328 $tpl->assign ("br", "</tr><tr>"); 329 } 330 331 //einde bla 332 } 221 333 } 222 334 223 // show search results224 225 335 } 226 336 }
Note: See TracChangeset
for help on using the changeset viewer.