lib/reporter/default/stats_disk.rb in onering-report-plugins-0.0.49 vs lib/reporter/default/stats_disk.rb in onering-report-plugins-0.0.50
- old
+ new
@@ -2,10 +2,71 @@
# provides data on disks, mounts, and RAID configuration
#
report do
# ------------------------------------------------------------------------------
+# block devices
+#
+ blocks = []
+
+ Facter.value('blockdevices').split(/\W+/).each do |dev|
+
+ block = {
+ :vendor => Facter.value("blockdevice_#{dev}_vendor"),
+ :model => Facter.value("blockdevice_#{dev}_model"),
+ :size => (Integer(Facter.value("blockdevice_#{dev}_size")) rescue nil)
+ }
+
+ if File.directory?("/sys/block/#{dev}")
+ block[:removable] = (File.read("/sys/block/#{dev}/removable").to_s.chomp.strip == '1' rescue nil)
+ block[:readonly] = (File.read("/sys/block/#{dev}/ro").to_s.chomp.strip == '1' rescue nil)
+ block[:solidstate] = (File.read("/sys/block/#{dev}/queue/rotational").to_s.chomp.strip == '0' rescue nil)
+ block[:sectorsize] = {}
+
+ %w{
+ logical
+ physical
+ }.each do |s|
+ block[:sectorsize][s.to_sym] = (Integer(File.read("/sys/block/#{dev}/queue/#{s}_block_size").chomp.strip) rescue nil)
+ end
+ end
+
+ blocks << block.compact
+ end
+
+# ------------------------------------------------------------------------------
+# partitions
+#
+ # partitions = []
+
+ # begin
+ # File.read("/proc/partitions").lines.each do |line|
+ # next if line == line.first
+ # line = line.chomp.strip
+ # next if line.empty?
+
+ # line = line.split(/\s+/)
+
+ # # for the moment, just interested in sd devices
+ # # numbers sources from /proc/devices
+ # #
+ # next unless [
+ # 8,65,66,67,68,69,70,71,128,129,130,131,132,133,134,135
+ # ].include?(line[0].to_i)
+
+ # # only get numbered partitions (not whole-device entries)
+ # next unless line[-1] =~ /^\D+\d+$/
+
+ # partition = {
+ # :name => line[-1],
+ # }
+ # end
+ # rescue
+ # nil
+ # end
+
+# ------------------------------------------------------------------------------
# mounts
#
mounts = {}
current_dev = nil
@@ -119,8 +180,10 @@
d[:lvm] = {
:@groups => vg.values
} unless vg.values.empty?
d[:@smart] = Facter.value('smart')
+
+ d[:@block] = blocks unless blocks.empty?
stat :disk, d.compact
end