ainoy31 Posted April 28, 2009 Share Posted April 28, 2009 I need to check disk space on a remote server from my web application. I have tried this piece of code: $access = "ssh user@server-ip-address df -k"; $data = shell_exec($access); If nothing prints out. I know there is the disk_total_space("/") function but since this is on a remote server. Much appreciation on any suggestions. AM Quote Link to comment https://forums.phpfreaks.com/topic/155983-solved-remote-server-access/ Share on other sites More sharing options...
ignace Posted April 28, 2009 Share Posted April 28, 2009 You can not do this directly, you need to go by a script on your remote server who retrieves that specific piece of information. On your remote server you put this file: <?php print disk_total_space('/'); ?> On your server you then do: <?php $diskspace = file_get_contents('http://domain/path/to/file/php', 'r'); // assuming your server allows to read remote files echo $diskspace; ?> Quote Link to comment https://forums.phpfreaks.com/topic/155983-solved-remote-server-access/#findComment-821121 Share on other sites More sharing options...
ainoy31 Posted April 28, 2009 Author Share Posted April 28, 2009 i set this up as a cron job. such as the following in a php file: $space = shell_exec("ssh (hostname or ip address) df -k | grep sda3 | awk '{print $5}'"); this will return the usage in percentage. Hope this helps someone else out. Quote Link to comment https://forums.phpfreaks.com/topic/155983-solved-remote-server-access/#findComment-821304 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.