SmartFile API and Bash

Most systems administrators know bash and are comfortable on the command line.  Smartfile makes it easy for them to monitor their developer’s disk usage from bash using just curl.

You’ll need both the api key and the api password.

curl -X GET 'https://${apikey}:${apipassword}

This will gather all account info and present a basic text that works fine for grep.  Other formats would require the installation of js or similar, so they are avoided for this case.  Additional formats and available info can be seen here.

disk_bytes_limit will provide total space available
disk_bytes_tally will provide currently used space

Smartfile does not update space usage immediately. Changes are queued and then updated within a few minutes depending on system load at the time.

#set -x
#Define endpoint
#Gather disk size from text output
disksize=`curl -X GET $endpoint/api/2/whoami/?format=txt | grep disk_bytes_limit | awk -F : '{ print $2 }' | sed 's/,$//'`
#Gather disk space usage from text output
diskuse=`curl -X GET $endpoint/api/2/whoami/?format=txt | grep disk_bytes_tally | awk -F : '{ print $2 }' | sed 's/,$//'`
#Multiple by 100 to avoid the need of bc
#Create %
echo $usage

SmartFile is a business file mangement platform that gives you more control, compliance and security.