Skip to content

Instantly share code, notes, and snippets.

@jvmvik
Created December 22, 2022 14:35
Show Gist options
  • Save jvmvik/9515ed80ae07a36cd8fe98470e319182 to your computer and use it in GitHub Desktop.
Save jvmvik/9515ed80ae07a36cd8fe98470e319182 to your computer and use it in GitHub Desktop.
Jenkins gist

Jenkins CI

Check the disk space with a self contain script based on Ruby Execute this shell scritp on remote host using ssh

rm check_disk.rb

tee -a check_disk.rb <<EOF 
# parse mount point VM (TODO customize for your machine)
usage = \`df\`.split("\n").grep(/VM/)
           .map { |l| l.split(/\s+/)[4][0..-2].to_i }.first
# allow up 90% disk usage
ok = (usage < 90)
if ok
 puts "ok: #{100-usage}% free disk"
 exit(0)
end
puts "error: only #{100-usage}% free disk expect > 10%"
exit(1)
EOF

ruby check_disk.rb 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment