Changeset 329
- Timestamp:
- 04/22/07 15:36:26 (16 years ago)
- Location:
- trunk/web/addons/job_monarch
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/addons/job_monarch/conf.php
r305 r329 1 1 <?php 2 3 // Sort nodes in clusterimage by 4 // 5 $SORTBY_HOSTNAME = "gb-r{x}n{y}.irc.sara.nl"; 6 $SORT_ORDER = "asc"; 7 8 $SORT_XLABEL = "rack"; 9 $SORT_YLABEL = "node"; 10 2 11 // Show hosts in a jobview by default? 3 12 // … … 40 49 // (250 pixels is same width as Ganglia's pie chart) 41 50 // 42 $BIG_CLUSTERIMAGE_MAXWIDTH = 250;51 $BIG_CLUSTERIMAGE_MAXWIDTH = 450; 43 52 44 53 // The size of a single node in the small clusterimage -
trunk/web/addons/job_monarch/image.php
r326 r329 45 45 $myxml_data = $ds->getData(); 46 46 47 print_f( "%s\n", $myxml_data );47 //print_f( "%s\n", $myxml_data ); 48 48 } 49 49 return $myxml_data; -
trunk/web/addons/job_monarch/libtoga.php
r326 r329 77 77 global $JOB_ARCHIVE_DIR; 78 78 global $JOB_ARCHIVE_DBASE; 79 global $SORTBY_HOSTNAME; 80 global $SORT_ORDER; 81 global $skan_str; 82 global $x_first, $y_first; 79 83 80 84 $my_dir = getcwd(); … … 1053 1057 global $SMALL_CLUSTERIMAGE_MAXWIDTH, $SMALL_CLUSTERIMAGE_NODEWIDTH; 1054 1058 global $BIG_CLUSTERIMAGE_MAXWIDTH, $BIG_CLUSTERIMAGE_NODEWIDTH; 1059 1060 global $SORTBY_HOSTNAME, $SORT_ORDER, $skan_str; 1061 global $x_first, $y_first; 1055 1062 1056 1063 $mydatag = $this->dataget; … … 1092 1099 $y_offset = 0; 1093 1100 $font = 2; 1101 $fontwidth = ImageFontWidth( $font ); 1094 1102 $fontheight = ImageFontHeight( $font ); 1095 1103 $fontspaceing = 2; … … 1099 1107 $this->height = ($y_offset + (($node_rows*$node_width)+1) ); 1100 1108 1101 $image = imageCreateTrueColor( $max_width, ($y_offset + (($node_rows*$node_width)+1) ) );1102 $colorwhite = imageColorAllocate( $image, 255, 255, 255 );1103 imageFill( $image, 0, 0, $colorwhite );1104 1105 if( $this->isSmall() ) {1106 1107 $colorblue = imageColorAllocate( $image, 0, 0, 255 );1108 1109 imageString( $image, $font, 2, 2, "Monarch Joblist - cluster: ".$this->clustername, $colorblue );1110 }1109 //$image = imageCreateTrueColor( $max_width, ($y_offset + (($node_rows*$node_width)+1) ) ); 1110 //$colorwhite = imageColorAllocate( $image, 255, 255, 255 ); 1111 //imageFill( $image, 0, 0, $colorwhite ); 1112 1113 //if( $this->isSmall() ) { 1114 1115 // $colorblue = imageColorAllocate( $image, 0, 0, 255 ); 1116 1117 // imageString( $image, $font, 2, 2, "Monarch Joblist - cluster: ".$this->clustername, $colorblue ); 1118 //} 1111 1119 1112 1120 $jobs = $mydatag->getJobs(); … … 1116 1124 //print_r($filtered_nodes); 1117 1125 1118 for( $n = 0; $n < $node_rows; $n++ ) { 1126 if( $SORTBY_HOSTNAME != "" ) 1127 { 1128 1129 $sorted = array(); 1130 1131 $x_first = 0; 1132 $y_first = 0; 1133 1134 1135 if( strpos( $SORTBY_HOSTNAME, "{x}" ) < strpos( $SORTBY_HOSTNAME, "{y}" ) ) 1136 { 1119 1137 1120 for( $m = 0; $m < $nodes_per_row; $m++ ) { 1138 $x_first = 1; 1139 } 1140 else 1141 { 1142 $y_first = 1; 1143 1144 } 1145 1146 $skan_str = str_replace( "{x}", "%d", $SORTBY_HOSTNAME ); 1147 $skan_str = str_replace( "{y}", "%d", $skan_str ); 1148 1149 $x_min = null; 1150 $x_max = null; 1151 $y_min = null; 1152 $y_max = null; 1153 1154 foreach( $nodes as $hostname => $node ) 1155 { 1156 //$n = sscanf( $hostname, $skan_str, $i, $j ); 1157 if( $x_first ) 1158 { 1159 $n = sscanf( $hostname, $skan_str, $x, $y ); 1160 } 1161 else if( $y_first ) 1162 { 1163 $n = sscanf( $hostname, $skan_str, $y, $x ); 1164 } 1165 1166 //printf( "n %s\n", $n ); 1167 1168 // Remove nodes that don't match 1169 // 1170 if( $n < 2 ) 1171 { 1172 unset( $nodes[$hostname] ); 1173 } 1174 1175 if( !$x_min ) 1176 { 1177 $x_min = $x; 1178 } 1179 else if( $x < $x_min ) 1180 { 1181 $x_min = $x; 1182 } 1183 if( !$x_max ) 1184 { 1185 $x_max = $x; 1186 } 1187 else if( $x > $x_max ) 1188 { 1189 $x_max = $x; 1190 } 1191 if( !$y_min ) 1192 { 1193 $y_min = $y; 1194 } 1195 else if( $y < $y_min ) 1196 { 1197 $y_min = $y; 1198 } 1199 if( !$y_max ) 1200 { 1201 $y_max = $y; 1202 } 1203 else if( $y > $y_max ) 1204 { 1205 $y_max = $y; 1206 } 1207 } 1208 1209 //printf( "ss %s\n", $skan_str); 1210 $sorted_nodes = usort( $nodes, "cmp" ); 1211 1212 $x_offset = 0; 1213 $cur_node = 0; 1214 1215 //printf( "xmin %s xmax %s\n", $x_min, $x_max ); 1216 //printf( "ymin %s ymax %s\n", $y_min, $y_max ); 1217 1218 // werkt 1219 //print_r( $nodes ); 1220 1221 $image = imageCreateTrueColor( $this->width, ($y_offset + (($node_rows*$node_width)+1) ) ); 1222 $colorwhite = imageColorAllocate( $image, 255, 255, 255 ); 1223 1224 imageFill( $image, 0, 0, $colorwhite ); 1225 1226 //if( $this->isSmall() ) { 1227 1228 // $colorblue = imageColorAllocate( $image, 0, 0, 255 ); 1229 1230 // imageString( $image, $font, 2, 2, "Monarch Joblist - cluster: ".$this->clustername, $colorblue ); 1231 //} 1232 1233 for( $n = $x_min; $n <= $x_max; $n++ ) 1234 { 1235 for( $m = $y_min; $m <= $y_max; $m++ ) 1236 { 1237 if( $x_min > 0 ) 1238 { 1239 $x = $x_offset + ( ($n-$x_min) * $node_width ); 1240 } 1241 if( $y_min > 0 ) 1242 { 1243 $y = $y_offset + ( ($m-$y_min) * $node_width ); 1244 } 1245 1246 if( isset( $nodes[$cur_node] ) ) { 1247 1248 1249 $host = $nodes[$cur_node]->getHostname(); 1250 1251 if( $x_first ) 1252 { 1253 $nn = sscanf( $host, $skan_str, $rx, $ry ); 1254 } 1255 else if( $y_first ) 1256 { 1257 $nn = sscanf( $host, $skan_str, $ry, $rx ); 1258 } 1259 if ( $nn < 2 ) 1260 { 1261 continue; 1262 } 1263 if( ( $rx - $x_min ) > $n ) 1264 { 1265 $m = $y_max; 1266 continue; 1267 } 1268 1269 if( !in_array( $host, $filtered_nodes ) ) 1270 $nodes[$cur_node]->setShowinfo( 0 ); 1271 1272 $nodes[$cur_node]->setCoords( $x, $y ); 1273 $nodes[$cur_node]->setImage( $image ); 1274 1275 //print_r( $nodes[$cur_node] ); 1276 1277 if( $this->isSmall() ) 1278 $nodes[$cur_node]->drawSmall(); 1279 else if( $this->isBig() ) 1280 $nodes[$cur_node]->drawBig(); 1281 } 1282 $cur_node++; 1283 } 1284 } 1285 1286 } 1287 else 1288 { 1289 $image = imageCreateTrueColor( $max_width, ($y_offset + (($node_rows*$node_width)+1) ) ); 1290 $colorwhite = imageColorAllocate( $image, 255, 255, 255 ); 1291 1292 imageFill( $image, 0, 0, $colorwhite ); 1293 1294 if( $this->isSmall() ) { 1295 1296 $colorblue = imageColorAllocate( $image, 0, 0, 255 ); 1297 1298 imageString( $image, $font, 2, 2, "Monarch Joblist - cluster: ".$this->clustername, $colorblue ); 1299 } 1300 1301 for( $n = 0; $n < $node_rows; $n++ ) { 1121 1302 1122 $x = ($m * $node_width); 1123 $y = $y_offset + ($n * $node_width); 1124 1125 $cur_node = ($n * $nodes_per_row) + ($m); 1126 $host = $nodes_hosts[$cur_node]; 1127 1128 if( isset( $nodes[$host] ) ) { 1129 1130 $nodes[$host]->setCoords( $x, $y ); 1131 $nodes[$host]->setImage( $image ); 1132 1133 if( !in_array( $host, $filtered_nodes ) ) 1134 $nodes[$host]->setShowinfo( 0 ); 1135 1136 if( $this->isSmall() ) 1137 $nodes[$host]->drawSmall(); 1138 else if( $this->isBig() ) 1139 $nodes[$host]->drawBig(); 1303 for( $m = 0; $m < $nodes_per_row; $m++ ) { 1304 1305 $x = ($m * $node_width); 1306 $y = $y_offset + ($n * $node_width); 1307 1308 $cur_node = ($n * $nodes_per_row) + ($m); 1309 $host = $nodes_hosts[$cur_node]; 1310 1311 if( isset( $nodes[$host] ) ) { 1312 1313 $nodes[$host]->setCoords( $x, $y ); 1314 $nodes[$host]->setImage( $image ); 1315 1316 if( !in_array( $host, $filtered_nodes ) ) 1317 $nodes[$host]->setShowinfo( 0 ); 1318 1319 if( $this->isSmall() ) 1320 $nodes[$host]->drawSmall(); 1321 else if( $this->isBig() ) 1322 $nodes[$host]->drawBig(); 1323 } 1140 1324 } 1141 1325 } … … 1349 1533 } 1350 1534 1535 function array_rem( $val, &$arr ) 1536 { 1537 // Delete val from arr 1538 // 1539 $i = array_search( $val, $arr ); 1540 1541 if( $i == false ) return false; 1542 1543 $arr = array_merge( array_slice( $arr, 0, $i ), array_slice( $arr, $i+1, count( $arr ) ) ); 1544 1545 return true; 1546 } 1547 1548 function cmp( $a, $b ) 1549 { 1550 global $SORT_ORDER; 1551 global $skan_str; 1552 global $x_first, $y_first; 1553 1554 $a_node = $a; 1555 $b_node = $b; 1556 $a = $a_node->getHostname(); 1557 $b = $b_node->getHostname(); 1558 1559 if( $a == $b ) return 0; 1560 1561 if( $x_first ) 1562 { 1563 $n = sscanf( $a, $skan_str, $a_x, $a_y ); 1564 $n = sscanf( $b, $skan_str, $b_x, $b_y ); 1565 } 1566 else if( $y_first ) 1567 { 1568 $n = sscanf( $a, $skan_str, $a_y, $a_x ); 1569 $n = sscanf( $b, $skan_str, $b_y, $b_x ); 1570 } 1571 1572 if ( $SORT_ORDER=="desc" ) 1573 { 1574 1575 // 1 = a < b 1576 // -1 = a > b 1577 // 1578 if ($a_x == $b_x) 1579 { 1580 if ($a_y < $b_y) 1581 { 1582 return 1; 1583 } 1584 else if ($a_y > $b_y) 1585 { 1586 return -1; 1587 } 1588 } 1589 else if ($a_x < $b_x) 1590 { 1591 return 1; 1592 } 1593 else if ($a_x > $b_x) 1594 { 1595 return -1; 1596 } 1597 } 1598 else if ( $SORT_ORDER == "asc" ) 1599 { 1600 1601 // 1 = a > b 1602 // -1 = a < b 1603 // 1604 if ($a_x == $b_x) 1605 { 1606 if ($a_y > $b_y) 1607 { 1608 return 1; 1609 } 1610 else if ($a_y < $b_y) 1611 { 1612 return -1; 1613 } 1614 } 1615 else if ($a_x > $b_x) 1616 { 1617 return 1; 1618 } 1619 else if ($a_x < $b_x) 1620 { 1621 return -1; 1622 } 1623 } 1624 } 1351 1625 function makeTime( $time ) { 1352 1626
Note: See TracChangeset
for help on using the changeset viewer.