Advertisement
bentech4u

Untitled

May 14th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.53 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. $GlobalDomainIp = $_GET['ip'];
  4.  
  5. $connection = ssh2_connect($GlobalDomainIp, 22, array('hostkey'=>'ssh-rsa'));
  6. if (ssh2_auth_pubkey_file($connection, 'root',
  7.                           '/var/www/html/ssh/id_rsa.pub',
  8.                           '/var/www/html/ssh/id_rsa', 'secret')) {
  9.   //echo "Public Key Authentication Successful\n";
  10. } else {
  11.   die('Public Key Authentication Failed');
  12. }
  13.  
  14. function GetFromSsh($value){
  15.         global $connection;
  16.         if($GetValueStream = ssh2_exec($connection,$value)){
  17.         stream_set_blocking($GetValueStream,true);
  18.         return  stream_get_contents($GetValueStream);
  19.         }
  20. }
  21.  
  22. //echo "<strong>Server Model : ". GetFromSsh("prtconf -b | grep banner-name | cut -d':' -f2") ."</strong>";
  23. //echo "<br/>";
  24. echo "<strong>".GetFromSsh("prtconf | grep Memory") ."</strong>";
  25. echo "<br/>";
  26. echo "<br/>";
  27.  
  28.     $result= GetFromSsh("zoneadm list -cv");
  29.     $resultArray = preg_split('/[\s]+/',trim($result));
  30.     $rows = array_chunk($resultArray,6);
  31.     $columns = array_shift($rows);
  32.     $data = array();
  33.     foreach ($rows as $row) {
  34.     $q = array_combine($columns, $row);
  35.  
  36.     if($q['NAME']=="global"){
  37.            $q['NAME'] = GetFromSsh("hostname");
  38.            $q['IP'] = $GlobalDomainIp;
  39.            $q['BRAND'] = "YES";
  40.            $GDname = $q['NAME'];
  41.         }
  42.     else{
  43.         $q['IP'] = GetFromSsh("zonecfg -z ".$q['NAME'] ." info | grep address | awk '{print $2}'");
  44.         $q['BRAND'] = "NO";
  45.     }
  46.     $data[] = $q;
  47.     }
  48. echo "<br/>";
  49. echo "<br/>";
  50. echo "<table  border=\"1\" width=\"70%\" cellpadding=\"0\" cellspacing=\"0\" id=\"product-table\" align=\"center\">";
  51. echo "<tr bgcolor=\"#FFCC99\">";
  52. echo "<th width=\"2%\" ><a href=\"\">ID</a></th>";
  53. echo "<th width=\"11%\"><a href=\"\">Hostname</a></th>";
  54. echo "<th width=\"11%\"><a href=\"\">Global Domain</a></th>";
  55. echo "<th width=\"22%\"><a href=\"\">ZoneRoot</a></th>";
  56. echo "<th width=\"11%\"><a href=\"\">IP Address</a></th>";
  57. echo "<th width=\"6%\"><a href=\"\">Zone State</a></th>";
  58. echo "</tr>";
  59. for($i=0;$i<count($data);$i++){
  60. echo "<tr>";
  61. echo "<td>".$i." </td>";
  62. echo "<td>".$data[$i]['NAME']. "</td>";
  63. echo "<td>".$data[$i]['BRAND']. "</td>";
  64. echo "<td>".$data[$i]['PATH']. "</td>";
  65. echo "<td>".$data[$i]['IP']. "</td>";
  66. echo "<td>".$data[$i]['STATUS']."</td>";
  67. echo "</tr>";
  68. }
  69. echo "</table>";
  70.  
  71. echo "<br/>";
  72. echo "<div align=\"center\">";
  73. echo "<input type=\"button\" name=\"Home\" id=\"Home\" value=\"Home\" onClick=\"window.location.href='check.html';\">";
  74. echo "</div>";
  75.  
  76. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement