diskmon 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/diskmon.gemspec +3 -2
- data/lib/diskmon.rb +2 -18
- data/lib/diskmon/client/zpoolstree.rb +28 -6
- data/lib/diskmon/server/serverapp.rb +28 -0
- data/lib/diskmon/version.rb +1 -1
- metadata +3 -2
data/diskmon.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.summary = %q{Gem for collect statistic from disks}
|
9
9
|
gem.homepage = ""
|
10
10
|
|
11
|
-
gem.files = ["Gemfile", "LICENSE", "README.md", "Rakefile", "bin/diskmon", "diskmon.gemspec", "lib/diskmon.rb", "lib/diskmon/client/collector.rb", "lib/diskmon/client/config.rb", "lib/diskmon/client/harddisk.rb", "lib/diskmon/client/raidcontroller.rb", "lib/diskmon/client/solarismapdev.rb", "lib/diskmon/client/zpoolstree.rb", "lib/diskmon/server/harddisk.rb", "lib/diskmon/server/harddiskreport.rb", "lib/diskmon/version.rb"]
|
11
|
+
gem.files = ["Gemfile", "LICENSE", "README.md", "Rakefile", "bin/diskmon", "diskmon.gemspec", "lib/diskmon.rb", "lib/diskmon/client/collector.rb", "lib/diskmon/client/config.rb", "lib/diskmon/client/harddisk.rb", "lib/diskmon/client/raidcontroller.rb", "lib/diskmon/client/solarismapdev.rb", "lib/diskmon/client/zpoolstree.rb", "lib/diskmon/server/harddisk.rb", "lib/diskmon/server/serverapp.rb", "lib/diskmon/server/harddiskreport.rb", "lib/diskmon/version.rb"]
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
13
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
14
|
gem.name = "diskmon"
|
@@ -16,5 +16,6 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.version = Diskmon::VERSION
|
17
17
|
gem.add_runtime_dependency 'data_mapper'
|
18
18
|
gem.add_runtime_dependency 'sinatra'
|
19
|
-
gem.add_runtime_dependency 'thin'
|
19
|
+
# gem.add_runtime_dependency 'thin'
|
20
|
+
gem.add_runtime_dependency 'dm-sqlite-adapter'
|
20
21
|
end
|
data/lib/diskmon.rb
CHANGED
@@ -9,6 +9,7 @@ require 'data_mapper'
|
|
9
9
|
require 'dm-validations'
|
10
10
|
require 'pp'
|
11
11
|
require "diskmon/server/harddiskreport"
|
12
|
+
require "diskmon/server/serverapp"
|
12
13
|
|
13
14
|
module Diskmon
|
14
15
|
|
@@ -50,24 +51,7 @@ module Diskmon
|
|
50
51
|
|
51
52
|
Diskmon::HardDiskReport.auto_upgrade!
|
52
53
|
|
53
|
-
|
54
|
-
data = request.body.read
|
55
|
-
|
56
|
-
Kernel.puts "// Report from #{request.env['REMOTE_ADDR']}" if $DEBUG
|
57
|
-
|
58
|
-
@m = Marshal.load(data)
|
59
|
-
|
60
|
-
@m.each do |disk|
|
61
|
-
report = Diskmon::HardDiskReport.create(disk.to_hash)
|
62
|
-
report.checksum = disk.checksum
|
63
|
-
|
64
|
-
report.print if $DEBUG
|
65
|
-
|
66
|
-
report.save
|
67
|
-
end
|
68
|
-
|
69
|
-
"OK"
|
70
|
-
end
|
54
|
+
Diskmon::ServerApp.run!
|
71
55
|
end
|
72
56
|
end
|
73
57
|
end
|
@@ -36,10 +36,12 @@ module Diskmon
|
|
36
36
|
|
37
37
|
when /c[0-9]t/
|
38
38
|
disk_name = l.split[0]
|
39
|
+
if disk_name =~ /s0/
|
40
|
+
disk_name = disk_name.slice(0,6) # dirty hack for rpool disks(with slice)
|
41
|
+
end
|
39
42
|
|
40
43
|
@disks[disk_name] = {}
|
41
44
|
@disks[disk_name]["zpool"] = pool_name
|
42
|
-
|
43
45
|
@disks[disk_name]["read_errors"] = l.split[2]
|
44
46
|
@disks[disk_name]["write_errors"] = l.split[3]
|
45
47
|
@disks[disk_name]["checksum_errors"] = l.split[4]
|
@@ -55,19 +57,35 @@ module Diskmon
|
|
55
57
|
end
|
56
58
|
|
57
59
|
def which_pool(device)
|
58
|
-
@disks
|
60
|
+
if @disks.include? device
|
61
|
+
@disks[device]["zpool"]
|
62
|
+
else
|
63
|
+
nil
|
64
|
+
end
|
59
65
|
end
|
60
66
|
|
61
67
|
def read_errors(device)
|
62
|
-
@disks
|
68
|
+
if @disks.include? device
|
69
|
+
@disks[device]["read_errors"]
|
70
|
+
else
|
71
|
+
nil
|
72
|
+
end
|
63
73
|
end
|
64
74
|
|
65
75
|
def write_errors(device)
|
66
|
-
@disks
|
76
|
+
if @disks.include? device
|
77
|
+
@disks[device]["write_errors"]
|
78
|
+
else
|
79
|
+
nil
|
80
|
+
end
|
67
81
|
end
|
68
82
|
|
69
83
|
def checksum_errors(device)
|
70
|
-
@disks
|
84
|
+
if @disks.include? device
|
85
|
+
@disks[device]["checksum_errors"]
|
86
|
+
else
|
87
|
+
nil
|
88
|
+
end
|
71
89
|
end
|
72
90
|
|
73
91
|
# free_space
|
@@ -75,7 +93,11 @@ module Diskmon
|
|
75
93
|
# last_command
|
76
94
|
# health
|
77
95
|
def get_pool_param(pool, param)
|
78
|
-
@pools
|
96
|
+
if @pools.include? pool
|
97
|
+
@pools[pool][param]
|
98
|
+
else
|
99
|
+
nil
|
100
|
+
end
|
79
101
|
end
|
80
102
|
|
81
103
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "sinatra/base"
|
2
|
+
require "diskmon/server/harddisk"
|
3
|
+
|
4
|
+
module Diskmon
|
5
|
+
class ServerApp < Sinatra::Base
|
6
|
+
|
7
|
+
set :port, 7777
|
8
|
+
|
9
|
+
post '/report/new' do
|
10
|
+
data = request.body.read
|
11
|
+
|
12
|
+
Kernel.puts "// Report from #{request.env['REMOTE_ADDR']}" if $DEBUG
|
13
|
+
|
14
|
+
@m = Marshal.load(data)
|
15
|
+
|
16
|
+
@m.each do |disk|
|
17
|
+
report = Diskmon::HardDiskReport.create(disk.to_hash)
|
18
|
+
report.checksum = disk.checksum
|
19
|
+
|
20
|
+
report.print if $DEBUG
|
21
|
+
|
22
|
+
report.save
|
23
|
+
end
|
24
|
+
|
25
|
+
"OK"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/diskmon/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diskmon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
47
|
+
name: dm-sqlite-adapter
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- lib/diskmon/client/solarismapdev.rb
|
82
82
|
- lib/diskmon/client/zpoolstree.rb
|
83
83
|
- lib/diskmon/server/harddisk.rb
|
84
|
+
- lib/diskmon/server/serverapp.rb
|
84
85
|
- lib/diskmon/server/harddiskreport.rb
|
85
86
|
- lib/diskmon/version.rb
|
86
87
|
homepage: ''
|