{"size": 1257, "ext": "js", "max_stars_repo_path": "freediskspace.js", "max_stars_repo_name": "scripting/freeDiskSpace", "max_stars_repo_stars_event_min_datetime": "2018-12-10T02:20:31.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-26T00:09:01.000Z", "max_issues_repo_path": "freediskspace.js", "max_issues_repo_name": "scripting/freeDiskSpace", "max_issues_repo_issues_event_min_datetime": "2018-12-15T22:19:11.000Z", "max_issues_repo_issues_event_max_datetime": "2018-12-16T03:15:29.000Z", "max_forks_repo_path": "freediskspace.js", "max_forks_repo_name": "scripting/freeDiskSpace", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 25.6530612245, "max_line_length": 62, "alphanum_fraction": 0.6428003182}
const myProductName = "Free Disk Space", myVersion = "0.4.9"; 

exports.get = getFreeDiskSpace; 

const fs = require ("fs");
const utils = require ("daveutils");
const s3 = require ("daves3");
const cmd = require ("node-cmd"); 

function getFreeDiskSpace (stats, callback) {
	var whenstart = new Date ();
	cmd.get ("df /", function (err, data, stderr) {
		var line2 = utils.stringNthField (data, "\n", 2);
		
		function popnext () {
			var word;
			line2 = utils.trimWhitespace (line2);
			word = utils.stringNthField (line2, " ", 1);
			line2 = utils.stringDelete (line2, 1, word.length);
			return (word);
			}
		popnext (); //throw away first string
		var ctTotal = popnext ();
		
		var ctUsed = popnext ();
		
		var ctAvailable = popnext ();
		
		var percent = ((ctTotal - ctUsed) / ctTotal) * 100;
		
		stats.productName = myProductName;
		stats.version = myVersion;
		stats.percent = Math.round (percent);
		stats.ctTotal = ctTotal;
		stats.ctUsed = ctUsed;
		stats.ctAvailable = ctAvailable;
		stats.ctSecs = utils.secondsSince (whenstart);
		stats.whenLastUpdate = new Date ();
		if (stats.ctUpdates === undefined) {
			stats.ctUpdates = 0;
			}
		stats.ctUpdates++;
		
		if (callback !== undefined) { //10/11/19 by DW
			callback ();
			}
		});
	}
