lib/ohai/plugins/freebsd/filesystem.rb in ohai-6.24.2 vs lib/ohai/plugins/freebsd/filesystem.rb in ohai-7.0.0.rc.0
- old
+ new
@@ -14,44 +14,44 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
-provides "filesystem"
+Ohai.plugin(:Filesystem) do
+ provides "filesystem"
-fs = Mash.new
+ collect_data(:freebsd) do
+ fs = Mash.new
-# Grab filesystem data from df
-popen4("df") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each do |line|
- case line
- when /^Filesystem/
- next
- when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
- filesystem = $1
- fs[filesystem] = Mash.new
- fs[filesystem][:kb_size] = $2
- fs[filesystem][:kb_used] = $3
- fs[filesystem][:kb_available] = $4
- fs[filesystem][:percent_used] = $5
- fs[filesystem][:mount] = $6
+ # Grab filesystem data from df
+ so = shell_out("df")
+ so.stdout.lines do |line|
+ case line
+ when /^Filesystem/
+ next
+ when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
+ filesystem = $1
+ fs[filesystem] = Mash.new
+ fs[filesystem][:kb_size] = $2
+ fs[filesystem][:kb_used] = $3
+ fs[filesystem][:kb_available] = $4
+ fs[filesystem][:percent_used] = $5
+ fs[filesystem][:mount] = $6
+ end
end
- end
-end
-# Grab mount information from mount
-popen4("mount -l") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each do |line|
- if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
- filesystem = $1
- fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
- fs[filesystem][:mount] = $2
- fs[filesystem][:fs_type] = $3
- fs[filesystem][:mount_options] = $4.split(/,\s*/)
+ # Grab mount information from mount
+ so = shell_out("mount -l")
+ so.stdout.lines do |line|
+ if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
+ filesystem = $1
+ fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
+ fs[filesystem][:mount] = $2
+ fs[filesystem][:fs_type] = $3
+ fs[filesystem][:mount_options] = $4.split(/,\s*/)
+ end
end
+
+ # Set the filesystem data
+ filesystem fs
end
end
-
-# Set the filesystem data
-filesystem fs