Quote:
| Originally Posted by E-Oreo PHP code could be written to do it, however I have not written it.
If you wish to take the HTTP approach then the process is not that difficult.
You need to deploy a script to each server does something like construct an array of filesystem space (assuming you have more than one filesystem) and then echo's the array using something like serialize or json_encode to encode the array as a string.
Then on your "central" server, you can issue an HTTP request using file_get_contents to each of the servers and request the URL of the script that you deployed to each server. Then you can unserialize or json_decode the response and do whatever you wish with it. |
ahahah i didnt get it..... but my point is when u ping an ip address in the localhost in a php style format hmmmm can it be posible to get his total space? nor free space?
here is my code but it can only specify my own drive in my computer
[PHPNET]
<html>
<body>
<?php
$hostname = gethostbyaddr("192.168.100.10");
function ping($hostname, $port, $timeout)
{
$tB = microtime(true);
$fP = fSockOpen($hostname, $port, $errno, $errstr, $timeout);
if (!$fP) { return "off"; }
$tA = microtime(true);
return round((($tA - $tB) * 1000), 0)." ms";
}
echo ping ("$hostname",80,10);
$df = disk_free_space("D:");
$df2 = disk_free_space("C:");
$dt = disk_total_space("D:");
$dt2 = disk_total_space("C:");
$du = $dt - $df;
$du2 = $dt2 - $df2;
$dp = sprintf('%.2f',($du / $dt) * 100);
$dp2 = sprintf('%.2f',($du2 / $dt2) * 100);
$df = formatSize($df);
$du = formatSize($du);
$dt = formatSize($dt);
$df2 = formatSize($df2);
$du2 = formatSize($du2);
$dt2 = formatSize($dt2);
function formatSize( $bytes )
{
$types = array( 'B', 'KB', 'MB', 'GB', 'TB' );
for( $i = 0; $bytes >= 1024 && $i < ( count( $types ) -1 ); $bytes /=1024, $i++ );
return( round( $bytes, 2 ) . " " . $types[$i] );
}
?>
<style type='text/css'>
.progress {
border: 2px solid #5E96E4;
height: 32px;
width: 540px;
margin: 75px auto;
}
.progress .prgbar {
background: Gold;
width: <?php echo "$dp;" ?>%;
position: relative;
height: 32px;
z-index: 999;
}
.progress .prgbar2 {
background: Gold;
width: <?php echo "$dp2;" ?>%;
position: relative;
height: 32px;
z-index: 999;
}
.progress .prgtext {
color: white;
text-align: center;
font-size: 15px;
padding: 9px 0 0;
width: 540px;
position: absolute;
z-index: 1000;
}
.progress .prginfo {
margin: 3px 0;
}
</style>
</head>
<body bgcolor = "white">
<div class='progress'>
<div class='prgtext'><?php echo $dp; ?>% Disk Used of <?php echo " ".$dt; ?>
</div>
<div class='prgbar'></div>
<div class='prginfo'>
<span style='float: left;'><?php echo "Drive D:"; ?></br>
<?php echo "$du used space of $dt"; ?></br>
<?php echo "$df free space of $dt"; ?></br>
</span>
<span style='clear: both;'></span>
</div>
</div>
<div class='progress'>
<div class='prgtext'><?php echo $dp2; ?>% Disk Used of <?php echo " ".$dt2; ?>
</div>
<div class='prgbar2'></div>
<div class='prginfo'>
<span style='float: left;'><?php echo "Drive C:"; ?></br>
<?php echo "$du2 used space of $dt2"; ?></br>
<?php echo "$df2 free space of $dt2"; ?></br>
</span>
<span style='clear: both;'></span>
</div>
</div>
</html>
</body>
[/PHPNET]