3 function plc_site_link($site_name)
5 return "https://www.planet-lab.org/db/sites/index.php?site_pattern=" . $site_name;
8 function pcu_link($pcu)
10 return "https://www.planet-lab.org/db/sites/pcu.php?id=" . $pcu['pcu_id'];
13 function pcu_site($pcu)
15 if ( array_key_exists('plcsite', $pcu) ):
16 return $pcu['plcsite']['login_base'];
22 function pcu_name($pcu)
24 if ( $pcu['hostname'] != NULL and $pcu['hostname'] != "" ):
25 return $pcu['hostname'];
30 function pcu_entry($pcu)
32 if ( count($pcu['complete_entry']) > 0 ) {
33 return join("<BR>", $pcu['complete_entry']);
39 function format_ports($pcu)
42 #print print_r(is_array($pcu)) . "<BR>";
43 #print print_r(array_key_exists('portstatus', $pcu)) . "<BR>";
44 if ( is_array($pcu) && array_key_exists('portstatus', $pcu) && count(array_keys($pcu['portstatus'])) > 0 )
46 $portstat = $pcu['portstatus'];
48 #foreach ( array('22', '23', '80', '443') $portstat as $port => $state)
49 foreach ( array('22', '23', '80', '443') as $port)
51 $state = $portstat[$port];
55 $color = "lightgreen";
67 $str .= "<span style='background-color: $color'>$port</span> ";
68 # . ": " . $state . "<br>";
71 # print print_r(is_array($pcu)) . "<BR>";
72 # print print_r(array_key_exists('portstatus', $pcu)) . "<BR>";
74 #print_r($pcu['portstatus']);
79 $str = "Closed/Filtered";
83 function DNS_to_color($dns)
99 function reboot_to_str($reboot)
113 function reboot_to_color($reboot)
118 return "darkseagreen";
126 case "Unsupported_PCU":
130 if ( strpos($reboot, "error") >= 0)
141 function get_pcuid($pcu) { return $pcu['pcu_id']; }
142 function get_dns($pcu) { return $pcu['dnsmatch']; }
143 function get_dryrun($pcu) { return $pcu['reboot']; }
144 function get_model($pcu) { return $pcu['model']; }
145 function get_category_link($category,$header)
147 return "<a href='printbadpcus.php?category=$category'>$header</a>";
150 include 'soltesz.php';
152 $findbad = $p->load("findbadpcus");
153 $findbadpcus = array_keys($findbad['nodes']);
157 foreach ( $findbadpcus as $pcu_id )
159 if ( is_array($findbad['nodes'][$pcu_id]) )
161 #if ( in_array('values', $findbad['nodes'][$pcu]) )
163 # echo $pcu . " true<BR>";
165 # echo $pcu . " false<br>";
167 if ( array_key_exists('values', $findbad['nodes'][$pcu_id]) )
169 $pculist[] = $findbad['nodes'][$pcu_id]['values'];
173 $total = count($pculist);
177 if ( $_GET['category'] )
179 $category = $_GET['category'];
180 if ( $category == "node_ids" )
182 $newfunc = create_function('$pcu', 'return count($pcu[\'' . $category . '\']);');
183 } else if ( $category == "login_base" )
185 $newfunc = create_function('$pcu', 'return $pcu[\'plcsite\'][\'' . $category . '\'];');
187 $newfunc = create_function('$pcu', 'return $pcu[\'' . $category . '\'];');
189 if ( $newfunc != "" )
191 $fields = array_map($newfunc, $pculist);
192 array_multisort($fields, SORT_ASC, SORT_STRING, $pculist);
194 echo "ERROR create_function == null<BR>";
199 //array_multisort($protocols, SORT_ASC, SORT_STRING, $pculist);
202 <title>PLC PCU Info</title>
206 Total PCUs : <?= $total ?>
210 <th><?= get_category_link("pcu_id", "PCU ID") ?></th>
211 <th><?= get_category_link("login_base", "Site") ?></th>
212 <th><?= get_category_link("hostname", "PCU Name") ?></th>
213 <th><?= get_category_link("complete_entry", "Incomplete Fields") ?></th>
214 <th><?= get_category_link("dnsmatch", "DNS Status") ?></th>
215 <th><?= get_category_link("portstatus", "Port Status") ?></th>
216 <th><?= get_category_link("reboot", "Dry Run Results") ?></th>
217 <th><?= get_category_link("model", "Model") ?></th>
218 <th><?= get_category_link("node_ids", "Nodes") ?></th>
221 <?php $reachable_nodes = 0; ?>
222 <?php foreach ( $pculist as $pcu ): ?>
224 <td><?= $count ?></td>
225 <td id='id<?= $pcu['pcu_id'] ?>'><a href='<?= pcu_link($pcu) ?>'><?= $pcu['pcu_id'] ?></a></td>
226 <td><a href='<?= plc_site_link(pcu_site($pcu)) ?>'><?= pcu_site($pcu) ?></a></td>
227 <td><?= pcu_name($pcu) ?></td>
228 <td><?= pcu_entry($pcu) ?></td>
229 <td bgcolor='<?= DNS_to_color($pcu['dnsmatch']) ?>'><?= $pcu['dnsmatch'] ?></td>
230 <td><?= format_ports($pcu) ?></td>
231 <td bgcolor='<?= reboot_to_color($pcu['reboot']) ?>'><?= reboot_to_str($pcu['reboot']) ?></td>
232 <td nowrap><?= $pcu['model'] ?></td>
233 <td><?= count( $pcu['node_ids'] ) ?></td>
236 <?php if ( $pcu['reboot'] == "0" ) $reachable_nodes+=count($pcu['node_ids']); ?>
237 <?php $count += 1; ?>
241 <b>Reachable Nodes:</b> <?= $reachable_nodes ?>