Here's my hack-y fact that adds facts for mounted partitions on linux w/ disk used, available, and total as well as a fact for all available mounts.
-Doug --- begin --- mounts = [] mntpoints=`mount -t ext2,ext3,ext4,reiserfs,xfs` mntpoints.split(/\n/).each do |m| mount = m.split(/ /)[2] mounts << mount end Facter.add("mounts") do confine :kernel => :linux setcode do mounts.join(',') end end mounts.each do |mount| output = %x{df #{mount}} output.each do |str| dsk_size = nil dsk_used = nil dsk_avail = nil if str =~ /^\S+\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+/ dsk_size = $1 dsk_used = $2 dsk_avail = $3 Facter.add("mount_#{mount}_size") do setcode do dsk_size end end Facter.add("mount_#{mount}_used") do setcode do dsk_used end end Facter.add("mount_#{mount}_avail") do setcode do dsk_avail end end end end end --- end --- On 07/07/2011 01:53 PM, Kent wrote: > HI Victor, > > You can write a simple custom Fact (leveraging the Facter library that > Puppet uses) that will run something like 'df' and parse the output. > Your puppet agents will report their disk usage, along with all the > other Facts, every time they make a Puppet run. > > -Kent > > On Jul 6, 8:34 pm, Victor Hooi <victorh...@gmail.com> wrote: >> Hi, >> >> I'm currently looking at migrating from some home-rolled Python scripts to >> using Puppet =). >> >> One of the things we need to check for is that there is sufficient free disk >> space on a mountpoint (for logging etc.) this is currently quite easy in >> Python using statvfs(). >> >> Are there any resources in Puppet that might be able to do this? I checked >> the mount type >> (http://docs.puppetlabs.com/references/stable/type.html#mount), but it >> didn't seem to have anything to do this. >> >> Cheers, >> Victor >
signature.asc
Description: OpenPGP digital signature