Sha256: ca5741775ff0114985baf33d74fb783a59e0cda668a032ed031fb3df4f03354e
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
module Adminix module Helpers module Command def self.which(arg1) output = `which #{arg1}` output = output.split("\n")[0] output.empty? ? nil : output end def self.whoami output = `whoami` output.split("\n")[0] end def self.home ENV['HOME'] end def self.git_clone(repo, branch = 'master') bin = 'git' `#{bin} clone #{repo} -b #{branch}` end def mkdir_p(dirname) `mkdir -p #{dirname}` end def self.run_system_command(command) `#{command}` end def self.debian_memory_load output = `free -m | awk 'NR==2{printf "%s/%s", $3,$2,$3*100/$2 }'` output.split('/') end def self.systemctl_enabled? !`which systemctl`.length.zero? end def self.darwin_memory_load output = `free -m | awk 'NR==2{printf "%s/%s", $3,$2,$3*100/$2 }'` output.split('/') end def self.debian_cpu_load `top -bn1 | grep load | awk '{printf "%.2f\\\n", $(NF-2)}'`.to_f end def self.darwin_cpu_load `ps -A -o %cpu | awk '{s+=$1} END {print s}'`.to_f end def self.debian_disk_usage output = `df -h | awk '$NF=="/"{printf "%d/%d\\\n", $3,$2,$5}'` output.split('/') end def self.debian_temperature output = `cat /sys/class/thermal/thermal_zone*/temp` temperatures = output.split("\n").map(&:to_i) return nil if temperatures.empty? temperatures.reduce(:+) / temperatures.size end def self.darwin_disk_usage output = `df -h | awk '$NF=="/"{printf "%d/%d", $3,$2,$5}'` used, disk_size = output.split('/') [used.to_f * 1024, disk_size.to_f * 1024] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
adminix-0.2 | lib/adminix/helpers/command.rb |