OSX Disk Monitor

Hi, I want to use a Spark Core to control an addressable LED strip that is an indicator of how much disk space is used on our file server.

I’m guessing there are many ways to do this but am thinking I would need some code running on our server that would read how much space is left then store that info in a file a web server. That file would be read by the Spark and then mapped to the LED strip.

Do people think this is a good idea or are there more direct ways of using the Spark to do this? The spark will be on the same internal network as the server.

Any ideas?



You could send it to the Particle directly, that way it doesn’t have to poll for data, so it’s more real-time.

Great, are there any examples that would get me in the right direction?



1 Like

You could use Spark.function() with the JavaScript library for example. Direct TCP/IP or UDP should also be possible. If you do a quick forum search for either, plenty topics should pop up.

did you say OSX? you could try an AppleScript with that Spark.function( )

set sparkDeviceID to "yourDeviceID"
set sparkAccessToken to "yourAccessToken"
set hardDriveCapacity to 500 as integer  -- mine is 500 gig

tell application "Finder"
	set free_space to the free space of the startup disk
	set free_space_in_GB to round (free_space / 1.0E+9) rounding down
	set percent_HD_used to ((hardDriveCapacity - free_space_in_GB) / hardDriveCapacity * 100) as integer
	say "There is " & free_space_in_GB & " gigabytes of free space left on the disk. that is " & percent_HD_used & "percent used"
	set curl_command to "curl -k https://api.spark.io/v1/devices/" & sparkDeviceID & "/setDimLevel -d access_token=" & sparkAccessToken & " -d params=" & percent_HD_used
	log curl_command
	do shell script curl_command
end tell

Wow, this looks perfect. I’ll check it out ASAP.