Jump to content
KJThaDon

Calculate disk share size externally

7 posts in this topic Last Reply

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

?>



 

Share this post


Link to post

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

Share this post


Link to post
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

Share this post


Link to post

Anyone have any ideas? Just want to be able to pull my share size spaced used and remaining..

Share this post


Link to post

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

Share this post


Link to post

If you're running this as a container, then you would have to add in appropriate path mappings to access /mnt/user from within the container.

Share this post


Link to post

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.