Ask Your Question
0

Custom fact - get disk size?

asked 2015-06-09 05:41:12 -0500

qwerty_face gravatar image

I have a custom fact that is using the following to obtain the root volume disk size:

s = Facter::Core::Execution.exec('df -k | head -n 2 | tail -n 1 | awk \'{print $2}\'').chomp

Or:

s = Facter::Core::Execution.exec('df -hk /myfolder | tail -n 1 | awk \'{print $1}\'').chomp

I then do some arithmetic on sand compute a value in Gb. It is not an ideal solution and will cause problems later on. Ideally I'd have a way to interrogate volumes/disks and get the associated attributes rather than executing this shell command. As is explained in the accepted answer here: http://stackoverflow.com/questions/45...

On that note is it possible to use statements such as:

require 'sys/filesystem'

From within custom facts? If so, how would one go about installing the 'sys/filesystem' library as suggested in that SO thread?

All input appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-06-09 06:17:30 -0500

you've probably seen it already but there is a blockdevice fact - if you have a standard build and know root is always on sda say you can do a facter blockdevice_sda which will give the size... there is also a partitions fact that gives details if its just the slice you're after rather than the underlying physical disk.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2015-06-09 05:41:12 -0500

Seen: 2,064 times

Last updated: Jun 09 '15