Class: Diskmon::ZpoolsTree
- Inherits:
-
Object
- Object
- Diskmon::ZpoolsTree
- Defined in:
- lib/diskmon/client/zpoolstree.rb
Instance Method Summary collapse
- #checksum_errors(device) ⇒ Object
-
#get_pool_param(pool, param) ⇒ Object
free_space total_space last_command health.
-
#initialize ⇒ ZpoolsTree
constructor
A new instance of ZpoolsTree.
- #read_errors(device) ⇒ Object
- #which_pool(device) ⇒ Object
- #write_errors(device) ⇒ Object
Constructor Details
#initialize ⇒ ZpoolsTree
Returns a new instance of ZpoolsTree.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/diskmon/client/zpoolstree.rb', line 4 def initialize @disks = {} @pools = {} IO.popen("/usr/sbin/zpool status") do |zpool_status_io| pool_name = '' zpool_status_io.each_line do |l| case l when /pool: / pool_name = l.split[1] @pools[pool_name] = {} @pools[pool_name]["health"] = `/usr/sbin/zpool get health #{pool_name} | grep #{pool_name}`.split[2] @pools[pool_name]["free_space"] = `/usr/sbin/zpool get free #{pool_name} | grep #{pool_name}`.split[2] @pools[pool_name]["total_space"] = `/usr/sbin/zpool get allocated #{pool_name} | grep #{pool_name}`.split[2] history_events = [] IO.popen("/usr/sbin/zpool history #{pool_name}") do |zpool_history_io| zpool_history_io.each_line do |l| case l when /^[0-9]/ then history_events.push(l) end end end @pools[pool_name]["last_command"] = history_events[-1].chomp when /c[0-9]t/ disk_name = l.split[0] if disk_name =~ /s0/ disk_name = disk_name.slice(0,6) # dirty hack for rpool disks(with slice) end @disks[disk_name] = {} @disks[disk_name]["zpool"] = pool_name @disks[disk_name]["read_errors"] = l.split[2] @disks[disk_name]["write_errors"] = l.split[3] @disks[disk_name]["checksum_errors"] = l.split[4] end end end # p @disks if $DEBUG # p @pools if $DEBUG end |
Instance Method Details
#checksum_errors(device) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/diskmon/client/zpoolstree.rb', line 83 def checksum_errors(device) if @disks.include? device @disks[device]["checksum_errors"] else nil end end |
#get_pool_param(pool, param) ⇒ Object
free_space total_space last_command health
95 96 97 98 99 100 101 |
# File 'lib/diskmon/client/zpoolstree.rb', line 95 def get_pool_param(pool, param) if @pools.include? pool @pools[pool][param] else nil end end |
#read_errors(device) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/diskmon/client/zpoolstree.rb', line 67 def read_errors(device) if @disks.include? device @disks[device]["read_errors"] else nil end end |
#which_pool(device) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/diskmon/client/zpoolstree.rb', line 59 def which_pool(device) if @disks.include? device @disks[device]["zpool"] else nil end end |
#write_errors(device) ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/diskmon/client/zpoolstree.rb', line 75 def write_errors(device) if @disks.include? device @disks[device]["write_errors"] else nil end end |