onering-report-plugins 0.0.52 → 0.0.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,69 +3,6 @@
3
3
  #
4
4
 
5
5
  report do
6
- # ------------------------------------------------------------------------------
7
- # block devices
8
- #
9
- blocks = []
10
-
11
- Facter.value('blockdevices').split(/\W+/).each do |dev|
12
-
13
- block = {
14
- :name => dev,
15
- :device => (File.exists?("/dev/#{dev}") ? "/dev/#{dev}" : nil),
16
- :vendor => Facter.value("blockdevice_#{dev}_vendor"),
17
- :model => Facter.value("blockdevice_#{dev}_model"),
18
- :size => (Integer(Facter.value("blockdevice_#{dev}_size")) rescue nil)
19
- }
20
-
21
- if File.directory?("/sys/block/#{dev}")
22
- block[:removable] = (File.read("/sys/block/#{dev}/removable").to_s.chomp.strip == '1' rescue nil)
23
- block[:readonly] = (File.read("/sys/block/#{dev}/ro").to_s.chomp.strip == '1' rescue nil)
24
- block[:solidstate] = (File.read("/sys/block/#{dev}/queue/rotational").to_s.chomp.strip == '0' rescue nil)
25
- block[:sectorsize] = {}
26
-
27
- %w{
28
- logical
29
- physical
30
- }.each do |s|
31
- block[:sectorsize][s.to_sym] = (Integer(File.read("/sys/block/#{dev}/queue/#{s}_block_size").chomp.strip) rescue nil)
32
- end
33
- end
34
-
35
- blocks << block.compact
36
- end
37
-
38
- # ------------------------------------------------------------------------------
39
- # partitions
40
- #
41
- # partitions = []
42
-
43
- # begin
44
- # File.read("/proc/partitions").lines.each do |line|
45
- # next if line == line.first
46
- # line = line.chomp.strip
47
- # next if line.empty?
48
-
49
- # line = line.split(/\s+/)
50
-
51
- # # for the moment, just interested in sd devices
52
- # # numbers sources from /proc/devices
53
- # #
54
- # next unless [
55
- # 8,65,66,67,68,69,70,71,128,129,130,131,132,133,134,135
56
- # ].include?(line[0].to_i)
57
-
58
- # # only get numbered partitions (not whole-device entries)
59
- # next unless line[-1] =~ /^\D+\d+$/
60
-
61
- # partition = {
62
- # :name => line[-1],
63
- # }
64
- # end
65
- # rescue
66
- # nil
67
- # end
68
-
69
6
  # ------------------------------------------------------------------------------
70
7
  # mounts
71
8
  #
@@ -185,7 +122,5 @@ report do
185
122
 
186
123
  d[:@smart] = Facter.value('smart')
187
124
 
188
- d[:@block] = blocks unless blocks.empty?
189
-
190
125
  stat :disk, d.compact
191
126
  end
@@ -0,0 +1,126 @@
1
+ # Onering Collector - Disk Statistics plugin
2
+ # provides data on disks, mounts, and RAID configuration
3
+ #
4
+
5
+ report do
6
+ # ------------------------------------------------------------------------------
7
+ # mounts
8
+ #
9
+ mounts = {}
10
+ current_dev = nil
11
+
12
+ uuids = Hash[Dir["/dev/disk/by-uuid/*"].collect{|i|
13
+ [File.expand_path(File.readlink(i), File.dirname(i)), File.basename(i)]
14
+ }]
15
+
16
+ File.read("/etc/mtab").lines.each do |line|
17
+ dev,mount,fstype,flags,dump,pass = line.split(/\s+/)
18
+
19
+ mounts[dev] = {
20
+ :mount => mount,
21
+ :device => dev,
22
+ :filesystem => fstype,
23
+ :flags => flags.split(/\s*,\s*/),
24
+ :uuid => uuids[dev]
25
+ }.compact
26
+ end
27
+
28
+ # logical space utilization
29
+ Facter::Util::Resolution.exec("df 2> /dev/null").to_s.lines.each do |line|
30
+ next if line =~ /^Filesystem/
31
+ parts = line.split(/\s+/)
32
+
33
+ if parts.length == 1
34
+ current_dev = parts.first
35
+ next
36
+
37
+ else
38
+ dev,kblk,used,free,percent,mount = parts
39
+ dev = current_dev if dev.empty?
40
+ next unless mounts[dev] and mounts[dev].is_a?(Hash)
41
+
42
+ mounts[dev][:used] = (used.to_i * 1024)
43
+ mounts[dev][:available] = (free.to_i * 1024)
44
+ mounts[dev][:total] = (mounts[dev][:available] + mounts[dev][:used])
45
+ mounts[dev][:percent_used] = percent.delete('%').to_i
46
+ end
47
+ end
48
+
49
+
50
+ # ------------------------------------------------------------------------------
51
+ # LVM
52
+ #
53
+ vg = {}
54
+
55
+ # volume groups
56
+ Facter::Util::Resolution.exec("vgdisplay -c 2> /dev/null").to_s.lines.each do |line|
57
+ line = line.strip.chomp.split(':')
58
+
59
+ vg[line[0]] = {
60
+ :name => line[0],
61
+ :uuid => line[16],
62
+ :size => (line[11].to_i*1024),
63
+ :extents => {
64
+ :size => (line[12].to_i * 1024),
65
+ :total => line[13].to_i,
66
+ :allocated => line[14].to_i,
67
+ :free => line[15].to_i
68
+ },
69
+ :volumes => [],
70
+ :disks => []
71
+ }
72
+ end
73
+
74
+ # logical volumes
75
+ Facter::Util::Resolution.exec("lvdisplay -c 2> /dev/null").to_s.lines.each do |line|
76
+ line = line.strip.chomp.split(':')
77
+
78
+ unless vg[line[1]].nil?
79
+ vg[line[1]][:volumes] << {
80
+ :name => line[0],
81
+ :sectors => line[6].to_i,
82
+ :extents => line[7].to_i,
83
+ :size => (vg[line[1]][:extents][:size] * line[7].to_i)
84
+ }
85
+ end
86
+ end
87
+
88
+
89
+ # physical volumes
90
+ Facter::Util::Resolution.exec("pvdisplay -c 2> /dev/null").to_s.lines.each do |line|
91
+ line = line.strip.chomp.split(':')
92
+
93
+ unless vg[line[1]].nil?
94
+ vg[line[1]][:disks] << {
95
+ :name => line[0],
96
+ :uuid => line[11],
97
+ :size => (line[8].to_i * (line[7].to_i * 1024)), # See Note 1 below
98
+ :extents => {
99
+ :size => (line[7].to_i * 1024),
100
+ :total => line[8].to_i,
101
+ :allocated => line[10].to_i,
102
+ :free => line[9].to_i
103
+ }
104
+ }
105
+
106
+ # the output of certain versions of pvdisplay -c reports a blatantly incorrect
107
+ # physical volume total size. the workaround is to calculate the actual total size
108
+ # via (total extents * extent size)
109
+ #
110
+ # this may or may not be GPT related
111
+ #
112
+ end
113
+ end
114
+
115
+
116
+ d = {}
117
+
118
+ d[:@mounts] = (Hash[mounts.select{|k,v| k =~ /^\/dev\/((h|s|xv|v)d|mapper|vgc)/ }].values rescue nil)
119
+ d[:lvm] = {
120
+ :@groups => vg.values
121
+ } unless vg.values.empty?
122
+
123
+ d[:@smart] = Facter.value('smart')
124
+
125
+ stat :disk, d.compact
126
+ end
@@ -0,0 +1,191 @@
1
+ # Onering Collector - Disk Statistics plugin
2
+ # provides data on disks, mounts, and RAID configuration
3
+ #
4
+
5
+ report do
6
+ # ------------------------------------------------------------------------------
7
+ # block devices
8
+ #
9
+ blocks = []
10
+
11
+ Facter.value('blockdevices').split(/\W+/).each do |dev|
12
+
13
+ block = {
14
+ :name => dev,
15
+ :device => (File.exists?("/dev/#{dev}") ? "/dev/#{dev}" : nil),
16
+ :vendor => Facter.value("blockdevice_#{dev}_vendor"),
17
+ :model => Facter.value("blockdevice_#{dev}_model"),
18
+ :size => (Integer(Facter.value("blockdevice_#{dev}_size")) rescue nil)
19
+ }
20
+
21
+ if File.directory?("/sys/block/#{dev}")
22
+ block[:removable] = (File.read("/sys/block/#{dev}/removable").to_s.chomp.strip == '1' rescue nil)
23
+ block[:readonly] = (File.read("/sys/block/#{dev}/ro").to_s.chomp.strip == '1' rescue nil)
24
+ block[:solidstate] = (File.read("/sys/block/#{dev}/queue/rotational").to_s.chomp.strip == '0' rescue nil)
25
+ block[:sectorsize] = {}
26
+
27
+ %w{
28
+ logical
29
+ physical
30
+ }.each do |s|
31
+ block[:sectorsize][s.to_sym] = (Integer(File.read("/sys/block/#{dev}/queue/#{s}_block_size").chomp.strip) rescue nil)
32
+ end
33
+ end
34
+
35
+ blocks << block.compact
36
+ end
37
+
38
+ # ------------------------------------------------------------------------------
39
+ # partitions
40
+ #
41
+ # partitions = []
42
+
43
+ # begin
44
+ # File.read("/proc/partitions").lines.each do |line|
45
+ # next if line == line.first
46
+ # line = line.chomp.strip
47
+ # next if line.empty?
48
+
49
+ # line = line.split(/\s+/)
50
+
51
+ # # for the moment, just interested in sd devices
52
+ # # numbers sources from /proc/devices
53
+ # #
54
+ # next unless [
55
+ # 8,65,66,67,68,69,70,71,128,129,130,131,132,133,134,135
56
+ # ].include?(line[0].to_i)
57
+
58
+ # # only get numbered partitions (not whole-device entries)
59
+ # next unless line[-1] =~ /^\D+\d+$/
60
+
61
+ # partition = {
62
+ # :name => line[-1],
63
+ # }
64
+ # end
65
+ # rescue
66
+ # nil
67
+ # end
68
+
69
+ # ------------------------------------------------------------------------------
70
+ # mounts
71
+ #
72
+ mounts = {}
73
+ current_dev = nil
74
+
75
+ uuids = Hash[Dir["/dev/disk/by-uuid/*"].collect{|i|
76
+ [File.expand_path(File.readlink(i), File.dirname(i)), File.basename(i)]
77
+ }]
78
+
79
+ File.read("/etc/mtab").lines.each do |line|
80
+ dev,mount,fstype,flags,dump,pass = line.split(/\s+/)
81
+
82
+ mounts[dev] = {
83
+ :mount => mount,
84
+ :device => dev,
85
+ :filesystem => fstype,
86
+ :flags => flags.split(/\s*,\s*/),
87
+ :uuid => uuids[dev]
88
+ }.compact
89
+ end
90
+
91
+ # logical space utilization
92
+ Facter::Util::Resolution.exec("df 2> /dev/null").to_s.lines.each do |line|
93
+ next if line =~ /^Filesystem/
94
+ parts = line.split(/\s+/)
95
+
96
+ if parts.length == 1
97
+ current_dev = parts.first
98
+ next
99
+
100
+ else
101
+ dev,kblk,used,free,percent,mount = parts
102
+ dev = current_dev if dev.empty?
103
+ next unless mounts[dev] and mounts[dev].is_a?(Hash)
104
+
105
+ mounts[dev][:used] = (used.to_i * 1024)
106
+ mounts[dev][:available] = (free.to_i * 1024)
107
+ mounts[dev][:total] = (mounts[dev][:available] + mounts[dev][:used])
108
+ mounts[dev][:percent_used] = percent.delete('%').to_i
109
+ end
110
+ end
111
+
112
+
113
+ # ------------------------------------------------------------------------------
114
+ # LVM
115
+ #
116
+ vg = {}
117
+
118
+ # volume groups
119
+ Facter::Util::Resolution.exec("vgdisplay -c 2> /dev/null").to_s.lines.each do |line|
120
+ line = line.strip.chomp.split(':')
121
+
122
+ vg[line[0]] = {
123
+ :name => line[0],
124
+ :uuid => line[16],
125
+ :size => (line[11].to_i*1024),
126
+ :extents => {
127
+ :size => (line[12].to_i * 1024),
128
+ :total => line[13].to_i,
129
+ :allocated => line[14].to_i,
130
+ :free => line[15].to_i
131
+ },
132
+ :volumes => [],
133
+ :disks => []
134
+ }
135
+ end
136
+
137
+ # logical volumes
138
+ Facter::Util::Resolution.exec("lvdisplay -c 2> /dev/null").to_s.lines.each do |line|
139
+ line = line.strip.chomp.split(':')
140
+
141
+ unless vg[line[1]].nil?
142
+ vg[line[1]][:volumes] << {
143
+ :name => line[0],
144
+ :sectors => line[6].to_i,
145
+ :extents => line[7].to_i,
146
+ :size => (vg[line[1]][:extents][:size] * line[7].to_i)
147
+ }
148
+ end
149
+ end
150
+
151
+
152
+ # physical volumes
153
+ Facter::Util::Resolution.exec("pvdisplay -c 2> /dev/null").to_s.lines.each do |line|
154
+ line = line.strip.chomp.split(':')
155
+
156
+ unless vg[line[1]].nil?
157
+ vg[line[1]][:disks] << {
158
+ :name => line[0],
159
+ :uuid => line[11],
160
+ :size => (line[8].to_i * (line[7].to_i * 1024)), # See Note 1 below
161
+ :extents => {
162
+ :size => (line[7].to_i * 1024),
163
+ :total => line[8].to_i,
164
+ :allocated => line[10].to_i,
165
+ :free => line[9].to_i
166
+ }
167
+ }
168
+
169
+ # the output of certain versions of pvdisplay -c reports a blatantly incorrect
170
+ # physical volume total size. the workaround is to calculate the actual total size
171
+ # via (total extents * extent size)
172
+ #
173
+ # this may or may not be GPT related
174
+ #
175
+ end
176
+ end
177
+
178
+
179
+ d = {}
180
+
181
+ d[:@mounts] = (Hash[mounts.select{|k,v| k =~ /^\/dev\/((h|s|xv|v)d|mapper|vgc)/ }].values rescue nil)
182
+ d[:lvm] = {
183
+ :@groups => vg.values
184
+ } unless vg.values.empty?
185
+
186
+ d[:@smart] = Facter.value('smart')
187
+
188
+ d[:@block] = blocks unless blocks.empty?
189
+
190
+ stat :disk, d.compact
191
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onering-report-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.52
4
+ version: 0.0.53
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: onering-client
16
- requirement: &9384000 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *9384000
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  description: Base plugins for providing system information via the Onering client
26
31
  utility
27
32
  email: ghetzel@outbrain.com
@@ -29,34 +34,36 @@ executables: []
29
34
  extensions: []
30
35
  extra_rdoc_files: []
31
36
  files:
37
+ - lib/reporter/default/properties_facter.rb
38
+ - lib/reporter/default/stats_virident.rb
39
+ - lib/reporter/default/stats_disk_52.rb
40
+ - lib/reporter/default/stats_disk.rb
41
+ - lib/reporter/default/properties_xen.rb
42
+ - lib/reporter/default/properties_openvz.rb
43
+ - lib/reporter/default/properties_haproxy.rb
44
+ - lib/reporter/default/properties_network.rb
45
+ - lib/reporter/default/properties_physical.rb
46
+ - lib/reporter/default/properties_ohai.rb
47
+ - lib/reporter/default/stats_disk_49.rb
48
+ - lib/reporter/default/stats_zfs.rb
49
+ - lib/reporter/default/stats_base.rb
50
+ - lib/reporter/default/properties_services.rb
51
+ - lib/reporter/default/properties_chef.rb
32
52
  - lib/facter/onering_properties_openvz.rb
33
- - lib/facter/onering_properties_network.rb
34
- - lib/facter/onering_properties_virident.rb
35
- - lib/facter/onering_properties_netstat.rb
36
- - lib/facter/onering_properties_services.rb
37
53
  - lib/facter/onering_properties_chef.rb
38
54
  - lib/facter/onering_properties_onering.rb
39
55
  - lib/facter/onering_properties_physical.rb
56
+ - lib/facter/onering_properties_xen.rb
57
+ - lib/facter/onering_properties_netstat.rb
58
+ - lib/facter/onering_properties_services.rb
59
+ - lib/facter/onering_properties_virident.rb
60
+ - lib/facter/onering_properties_zfs.rb
61
+ - lib/facter/onering_properties_network.rb
40
62
  - lib/facter/onering_properties_system.rb
41
63
  - lib/facter/onering_properties_id.rb
42
- - lib/facter/onering_properties_haproxy.rb
43
64
  - lib/facter/onering_disk_smart.rb
44
- - lib/facter/onering_properties_zfs.rb
45
- - lib/facter/onering_properties_xen.rb
65
+ - lib/facter/onering_properties_haproxy.rb
46
66
  - lib/etc/facter.list
47
- - lib/reporter/default/properties_physical.rb
48
- - lib/reporter/default/properties_facter.rb
49
- - lib/reporter/default/stats_disk.rb
50
- - lib/reporter/default/stats_zfs.rb
51
- - lib/reporter/default/properties_openvz.rb
52
- - lib/reporter/default/properties_xen.rb
53
- - lib/reporter/default/properties_chef.rb
54
- - lib/reporter/default/stats_virident.rb
55
- - lib/reporter/default/properties_ohai.rb
56
- - lib/reporter/default/properties_haproxy.rb
57
- - lib/reporter/default/properties_network.rb
58
- - lib/reporter/default/properties_services.rb
59
- - lib/reporter/default/stats_base.rb
60
67
  homepage: https://github.com/outbrain/onering-report-plugins
61
68
  licenses: []
62
69
  post_install_message:
@@ -77,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
84
  version: '0'
78
85
  requirements: []
79
86
  rubyforge_project:
80
- rubygems_version: 1.8.11
87
+ rubygems_version: 1.8.23
81
88
  signing_key:
82
89
  specification_version: 3
83
90
  summary: Onering system reporting plugins