Skip to content

Commit

Permalink
add macos storage volumes using df
Browse files Browse the repository at this point in the history
Signed-off-by: si458 <simonsmith5521@gmail.com>
  • Loading branch information
si458 committed May 13, 2024
1 parent e3f6822 commit be3e333
Show file tree
Hide file tree
Showing 4 changed files with 1,854 additions and 1,787 deletions.
8 changes: 8 additions & 0 deletions agents/modules_meshcore/computer-identifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,14 @@ function macos_identifiers()
ret.identifiers.storage_devices = devices;
}

// Fetch storage volumes using df
child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', dataHandler);
child.stdin.write('df -aHY | awk \'NR>1 {printf "{\\"size\\":\\"%s\\",\\"used\\":\\"%s\\",\\"available\\":\\"%s\\",\\"mount_point\\":\\"%s\\",\\"type\\":\\"%s\\"},", $3, $4, $5, $10, $2}\' | sed \'$ s/,$//\' | awk \'BEGIN {printf "["} {printf "%s", $0} END {printf "]"}\'\nexit\n');
child.waitExit();
try { ret.darwin.volumes = JSON.parse(child.stdout.str.trim()); } catch (xx) { }
child = null;

// MacOS Last Boot Up Time
try {
child = require('child_process').execFile('/usr/sbin/sysctl', ['', 'kern.boottime']); // must include blank value at begining for some reason?
Expand Down

0 comments on commit be3e333

Please sign in to comment.