X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=www%2Fprintbadpcus.php;fp=www%2Fprintbadpcus.php;h=fb86fa3f8ad6768d82526c9d2380736485ef3e22;hb=ba6cc9b30b0741e10033a769202047ddeb96f6d1;hp=0000000000000000000000000000000000000000;hpb=83f273d94a778aa4ff59ba08fa1edf3004a14d36;p=monitor.git diff --git a/www/printbadpcus.php b/www/printbadpcus.php new file mode 100644 index 0000000..fb86fa3 --- /dev/null +++ b/www/printbadpcus.php @@ -0,0 +1,234 @@ + 0 ) { + return join("
", $pcu['complete_entry']); + } else { + return " "; + } +} + +function format_ports($pcu) +{ + $str = ""; + #print print_r(is_array($pcu)) . "
"; + #print print_r(array_key_exists('portstatus', $pcu)) . "
"; + if ( is_array($pcu) && array_key_exists('portstatus', $pcu) ) + { + $portstat = $pcu['portstatus']; + + #foreach ( array('22', '23', '80', '443') $portstat as $port => $state) + foreach ( array('22', '23', '80', '443') as $port) + { + $state = $portstat[$port]; + switch ($state) + { + case "open": + $color = "lightgreen"; + break; + case "filtered": + $color = "gold"; + break; + case "closed": + $color = "indianred"; + break; + default: + $color = "white"; + break; + } + $str .= "$port "; + # . ": " . $state . "
"; + } + } else { + # print print_r(is_array($pcu)) . "
"; + # print print_r(array_key_exists('portstatus', $pcu)) . "
"; + #echo "
";
+		#print_r($pcu['portstatus']);
+		#echo "
"; + } + if ( $str == "" ) + { + $str = "Closed/Filtered"; + } + return $str; +} +function DNS_to_color($dns) +{ + switch ($dns) + { + case "DNS-OK": + return 'lightgreen'; + case "NOHOSTNAME": + return 'white'; + case "DNS-MISMATCH": + return 'gold'; + case "NO-DNS-OR-IP": + case "DNS-NOENTRY": + return 'indianred'; + } + return 'white'; +} + +function reboot_to_color($reboot) +{ + switch ($reboot) + { + case "0": + return "darkseagreen"; + break; + case "NetDown": + return "lightgrey"; + break; + case "Not_Run": + return "lightgrey"; + break; + case "Unsupported_PCU": + return "indianred"; + break; + default: + if ( strpos($reboot, "error") >= 0) + { + return "indianred"; + } else { + return 'white'; + } + break; + } + return "white"; +} + +function get_pcuid($pcu) { return $pcu['pcu_id']; } +function get_dns($pcu) { return $pcu['dnsmatch']; } +function get_dryrun($pcu) { return $pcu['reboot']; } +function get_model($pcu) { return $pcu['model']; } +function get_category_link($category,$header) +{ + return "$header"; +} + +include 'soltesz.php'; +$p = new Pickle(); +$findbad = $p->load("findbadpcus"); +$findbadpcus = array_keys($findbad['nodes']); + +$pculist = array(); +$c = 0; +foreach ( $findbadpcus as $pcu_id ) +{ + if ( is_array($findbad['nodes'][$pcu_id]) ) + { + #if ( in_array('values', $findbad['nodes'][$pcu]) ) + #{ + # echo $pcu . " true
"; + #} else{ + # echo $pcu . " false
"; + #} + if ( array_key_exists('values', $findbad['nodes'][$pcu_id]) ) + { + $pculist[] = $findbad['nodes'][$pcu_id]['values']; + } + } +} +$total = count($pculist); + + +## Sort the pculist + +#$pcu_ids = array_map('get_pcuid', $pculist); +#array_multisort($pcu_ids, SORT_ASC, SORT_NUMERIC, $pculist); + +#$dns_ids = array_map('get_dns', $pculist); +#array_multisort($dns_ids, SORT_ASC, SORT_STRING, $pculist); + +#$dry_ids = array_map('get_dryrun', $pculist); +#array_multisort($dry_ids, SORT_ASC, SORT_STRING, $pculist); +if ( $_GET['category'] ) +{ + $category = $_GET['category']; + if ( $category == "node_ids" ) + { + $newfunc = create_function('$pcu', 'return count($pcu[\'' . $category . '\']);'); + } else { + $newfunc = create_function('$pcu', 'return $pcu[\'' . $category . '\'];'); + } + if ( $newfunc != "" ) + { + $fields = array_map($newfunc, $pculist); + array_multisort($fields, SORT_ASC, SORT_STRING, $pculist); + } else { + echo "ERROR create_function == null
"; + } +} + +if ( $_GET['auth'] ) +{ + $auth = True; +} else { + $auth = False; +} + + +//array_multisort($protocols, SORT_ASC, SORT_STRING, $pculist); +?> + +PLC PCU Info + + + +Total PCUs : + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CountUsernamePasswordNotes
'>'>'>
+ + +