Advertisement
d1cor

disco_snmp.php

Dec 18th, 2012
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.41 KB | None | 0 0
  1. <pre>
  2. /*******************************************
  3. * Author     : Diego Cordoba / @d1cor      *
  4. * Contact    : d1cor.com.ar                *
  5. *******************************************/
  6. </pre>
  7. <?php
  8. $target_ip=$_GET['ip'];
  9. $community=$_GET['c'];
  10.  
  11. $arreglo = snmprealwalk($target_ip, $community, "dsk");
  12.  
  13. foreach($arreglo as $clave => $valor){
  14.         $variableSnmp=explode("::",$clave);
  15.         $valorSnmp=explode(": ",$valor);
  16.         $var=explode(".",$variableSnmp[1]);
  17.         $arregloDisk[$var[0]][$var[1]]=$valorSnmp[1];
  18. }
  19.  
  20. echo "<h2>Remote FS query via snmp protocol</h2>";
  21. echo "<table border=1><tr><th>FileSystem</th><th>Size</th><th>Used</th><th>Avail</th><th>Percent</th><th>MounPoint \n</th></tr>";
  22. foreach($arregloDisk['dskDevice'] as $disco => $valor){
  23.         echo "<tr><td align=left>".$arregloDisk["dskDevice"][$disco]."</td>";
  24.         echo "<td>".tamanio($arregloDisk["dskTotal"][$disco])."</td>";
  25.         echo "<td>".tamanio($arregloDisk["dskUsed"][$disco])."</td>";
  26.         echo "<td>".tamanio($arregloDisk["dskAvail"][$disco])."</td>";
  27.         echo "<td>".$arregloDisk["dskPercent"][$disco]." %</th>";
  28.         echo "<td align=left>".$arregloDisk["dskPath"][$disco]."\n</td></tr>";
  29. }
  30.  
  31. function tamanio($valor){
  32.         $giga=1024*1024;
  33.         if($valor>$giga)
  34.                 return round($valor/$giga,1)." GB";
  35.         else
  36.                 return round($valor/1024,1)." MB";
  37. }
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement