Calculate disk share size externally


Recommended Posts

Looking to run some code on an external host to calculate my local unraid disk size etc. This is some code I've done in PHP, however I do not think it's possible to do this remotely with this technique. Anyone have any ideas or suggestions?

 

<?php

$dt = disk_total_space( '/mnt/cache' );
$df = disk_free_space( '/mnt/cache' );

$du = $dt - $df;
$dp = sprintf( '%.2f', ( $du / $dt ) * 100 );
$df = formatSize( $df );
$du = formatSize( $du );
$dt = formatSize( $dt );

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 ] );
}

?>



 

Link to comment
On 5/6/2020 at 7:06 AM, Squid said:

First off, /mnt/cache doesn't exist remotely and you'd have to do it via an smb share

Yes, I understand that. It was just an example because I am almost certain using that PHP code it does not pull external values. 

Anyone have any idea how to pull those values remotely? Also maybe like uptime counter?

Thanks

Link to comment

Ok, so I can do it directly on the server instead of remotely. I already have a reverse proxy setup with nginx and php functioning, however it does not seem to be able to access /mnt/user/SHARE for calculations? 

What can I do to get the permissions right?

Thanks

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.