Skip to content

Commit

Permalink
Implement mem_total for OS X
Browse files Browse the repository at this point in the history
  • Loading branch information
Garrett Smith committed Jan 19, 2017
1 parent d85488c commit e829338
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions priv/bin/sys-attrs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -o pipefail

OS=$(uname -s)

cpu-desc() {
Expand All @@ -34,10 +36,12 @@ cpu-cores() {

mem-total() {
if [ "$OS" = "Darwin" ]; then
# TODO: use sysctl hw.memsize
echo ""
local mem_bytes
mem_bytes=`sysctl hw.memsize | awk '{ print $2 }'`
echo "$(( $mem_bytes / 1024 / 1024 )) MB"
else
local mem_kb=`cat /proc/meminfo | grep MemTotal | awk '{ print $2 }'`
local mem_kb
mem_kb=`cat /proc/meminfo | grep MemTotal | awk '{ print $2 }'`
echo "$(( $mem_kb / 1024 )) MB"
fi
}
Expand Down

0 comments on commit e829338

Please sign in to comment.