Sha256: d5d917cb1589a2c6381dcd4d72766042b18b45463d6f58b016f15ff926f64b93
Contents?: true
Size: 424 Bytes
Versions: 9
Compression:
Stored size: 424 Bytes
Contents
#!/usr/bin/env ruby require 'json' df_cmd = 'df -kP' # or without -P on non-gnu... info = %x{#{df_cmd}}.split(/\n/).drop(1). map{|l| l.split(/\s+/).values_at(0,2,3,5)} # fs, used, free, mount .find_all{|x| not(x[0] =~ /^(udev|tmpfs|none)$/)} out = {} info.each {|x| out[x[0]] = { used: (x[1].to_f / 1024**2).round(6), # GB significant down to 4kB free: (x[2].to_f / 1024**2).round(6), }} puts JSON::generate(out)
Version data entries
9 entries across 9 versions & 1 rubygems