aio_elin 1.0.4 → 1.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f0b123e9cd10b5626da970c2a561cadfabf139f344327e2c1c013a24d32a9c5
4
- data.tar.gz: 0005a9d8ccb56d409aae674fc3775e7239c9504adbdbfe361e6a5eb6b117d981
3
+ metadata.gz: 7705e0b0dfd3a615aaaea053cd08f487f6d28a2ff52836a84a53c060db2f32e0
4
+ data.tar.gz: 68891b269da5dd3e5718dd561378485ef2af1c48cb1e6f2adab335d3001d45fd
5
5
  SHA512:
6
- metadata.gz: 3016258178646dd402fe05a686200033ad180a4dbcdb76dfff557aa66ecbf0dcf6f26e3b6414547fd4e528f9643afb764bc021c574a8378af1c08cf3727a1d93
7
- data.tar.gz: 90444a28a0a6e30d576f0825e008b7a911d389336bbf5aab23acc6e8220630b4c7d9548c93a9601af305fac64f50426985093a9c972176b8a7c01553104905fa
6
+ metadata.gz: d9ade4e7e071112527b159cdca410b5a3811459e088fa8fe6fccaaa40b048487f06d25c02295fe2c6aae4eeb1747d435ee24e37b539c2cfb525dfaf918251c4c
7
+ data.tar.gz: 9c9cf70d64214bbe40677add0bca5bd9895d7f4e3f348581c3366b7ba55e83122dc0b9f6c603240527bc54413461b9f316dcc69b048c8d51ab63c28740e26bca
@@ -58,8 +58,8 @@ module Aio::Parse
58
58
  progress_bar(total, i+1, name)
59
59
 
60
60
  # Debug处
61
- if name == "B_HBWHA_CAM_DS01"
62
- #puts "now"
61
+ if name == "CIB41_CS_H5500SW01"
62
+ #debugger
63
63
  end
64
64
  new_klass = klass.parse
65
65
  device_manager[name] = new_klass.instance
@@ -25,7 +25,7 @@ class Aio::Module::Cmd::H3C::DisplayCpu < Aio::Module::Cmd::H3C
25
25
  cont = self.context.dup
26
26
  useful[:cpu] = {}
27
27
  loop do
28
- cont.readline_range(/Slot \d+ CPU usage/, reg_blank) do |cont_layer|
28
+ cont.readline_range(/Slot \d+ (CPU \d+\s+){0,1}CPU usage/, reg_blank) do |cont_layer|
29
29
  parse_cpu(cont_layer)
30
30
  end
31
31
  end
@@ -34,7 +34,9 @@ class Aio::Module::Cmd::H3C::DisplayCpu < Aio::Module::Cmd::H3C
34
34
  def parse_cpu(context)
35
35
  cpu = {}
36
36
  useful[:cpu] = cpu
37
- context.readline_match_block(/Slot (?<slot_id>\d+) CPU/) do |block|
37
+ context.readline_match_block(/Slot (?<slot_id>\d+) (CPU \d+\s+){0,1}CPU/) do |block|
38
+ # 目前只保留 slot 0 的CPU使用率
39
+ #return if block[:slot_id].to_s != '0'
38
40
  block.update(cpu, :slot_id)
39
41
  end
40
42
  context.readline_match_block(/(?<seconds_5>\d+)% in last 5 seconds/) do |block|
@@ -3,88 +3,77 @@
3
3
  require "aio/core"
4
4
 
5
5
  class Aio::Module::Cmd::H3C::DisplayFan < Aio::Module::Cmd::H3C
6
- include Aio::Module
6
+ include Aio::Module
7
7
 
8
- def initialize
9
- super({
10
- :cmd_full => "display fan",
11
- :cmd_short => "dis fan",
12
- :author => "Elin",
13
- :description => "This is H3C Command# display fan",
14
- :ranking => Ranking_1,
15
- :platform => "all",
16
- :benchmark => {
17
- :fan_status => ["=~", /Normal/],
18
- },
19
- })
20
- end
8
+ def initialize
9
+ super({
10
+ :cmd_full => "display fan",
11
+ :cmd_short => "dis fan",
12
+ :author => "Elin",
13
+ :description => "This is H3C Command# display fan",
14
+ :ranking => Ranking_1,
15
+ :platform => "all",
16
+ :benchmark => {
17
+ :fan_status => ["=~", /Normal/],
18
+ },
19
+ })
20
+ end
21
21
 
22
- def parse
23
- cont = self.context.dup
24
- useful[:fan] = {}
25
- case device_template
26
- when Template_1
27
- cont.readline_range_loop(/Slot/, /Slot/) do |cont_layer|
28
- parse_slot(cont_layer)
29
- end
30
- when Template_2
31
- cont.readline_range_loop(/Unit/, /Unit/) do |cont_layer|
32
- parse_unit(cont_layer)
33
- end
34
- end
22
+ def parse
23
+ cont = self.context.dup
24
+ useful[:fan] = {}
25
+ case device_template
26
+ when Template_1
27
+ cont.readline_range_loop(/Slot/, /Slot/) do |cont_layer|
28
+ parse_slot(cont_layer)
29
+ end
30
+ when Template_2
31
+ cont.readline_range_loop(/Unit/, /Unit/) do |cont_layer|
32
+ parse_unit(cont_layer)
33
+ end
34
+ end
35
+ end
35
36
 
36
- end
37
+ # 遇到的有两种情况,开头是Slot 或者是 Unit
37
38
 
38
- =begin
39
- # 遇到的有两种情况,开头是Slot 或者是 Unit
40
- def parse_def(context)
41
- case context[0]
42
- when /Slot/
43
- parse_slot(context)
44
- when /Unit/
45
- parse_unit(context)
46
- end
47
- end
48
- =end
39
+ def parse_slot(context)
40
+ fan = {}
41
+ context.readline_match_block(/Slot (?<slot_id>\d+)/) do |block|
42
+ useful[:fan] = {}
43
+ useful[:fan]["slot_#{block[:slot_id]}"] = fan
44
+ block.update(fan, :slot_id)
45
+ end
46
+ context.readline_range_loop(/FAN \d+/, reg_blank) do |cont_layer|
47
+ parse_slot_2(cont_layer, fan)
48
+ end
49
+ end
49
50
 
50
- def parse_slot(context)
51
- fan = {}
52
- context.readline_match_block(/Slot (?<slot_id>\d+)/) do |block|
53
- useful[:fan] = {}
54
- useful[:fan]["slot_#{block[:slot_id]}"] = fan
55
- block.update(fan, :slot_id)
56
- end
57
- context.readline_range_loop(/FAN \d+/, reg_blank) do |cont_layer|
58
- parse_slot_2(cont_layer, fan)
59
- end
60
- end
51
+ def parse_slot_2(context, fan)
52
+ fan_id = nil
53
+ context.readline_match_block(/FAN (?<fan_id>\d+)/) do |block|
54
+ fan_id = block[:fan_id]
55
+ fan["fan_#{fan_id}"] = {}
56
+ block.update(fan["fan_#{fan_id}"], :fan_id)
57
+ end
58
+ context.readline_match_block(/State : (?<fan_status>.*)/) do |block|
59
+ block.warning_serious(fan["fan_#{fan_id}"], :fan_status, self)
60
+ end
61
+ end
61
62
 
62
- def parse_slot_2(context, fan)
63
- fan_id = nil
64
- context.readline_match_block(/FAN (?<fan_id>\d+)/) do |block|
65
- fan_id = block[:fan_id]
66
- fan["fan_#{fan_id}"] = {}
67
- block.update(fan["fan_#{fan_id}"], :fan_id)
68
- end
69
- context.readline_match_block(/State : (?<fan_status>.*)/) do |block|
70
- block.warning_serious(fan["fan_#{fan_id}"], :fan_status, self)
71
- end
72
- end
63
+ def parse_unit(context)
64
+ fan = {}
65
+ context.readline_match_block(/Unit (?<slot_id>\d+)/) do |block|
66
+ useful[:fan]["slot_#{block[:slot_id]}"] = fan
67
+ block.update(fan, :slot_id)
68
+ end
69
+ context.readline_match_block_loop(/Fan (?<fan_id>\d+) State: (?<fan_status>.*)/, reg_blank) do |block|
70
+ fan_id = block[:fan_id]
71
+ fan["fan_#{fan_id}"] = {}
72
+ block.update(fan["fan_#{fan_id}"], :fan_id)
73
+ block.warning_serious(fan["fan_#{fan_id}"], :fan_status, self)
74
+ end
75
+ end
73
76
 
74
- def parse_unit(context)
75
- fan = {}
76
- context.readline_match_block(/Unit (?<slot_id>\d+)/) do |block|
77
- useful[:fan]["slot_#{block[:slot_id]}"] = fan
78
- block.update(fan, :slot_id)
79
- end
80
- context.readline_match_block_loop(/Fan (?<fan_id>\d+) State: (?<fan_status>.*)/, reg_blank) do |block|
81
- fan_id = block[:fan_id]
82
- fan["fan_#{fan_id}"] = {}
83
- block.update(fan["fan_#{fan_id}"], :fan_id)
84
- block.warning_serious(fan["fan_#{fan_id}"], :fan_status, self)
85
- end
86
- end
87
-
88
77
  end
89
78
 
90
79
 
@@ -3,33 +3,54 @@
3
3
  require "aio/core"
4
4
 
5
5
  class Aio::Module::Cmd::H3C::DisplayMemory < Aio::Module::Cmd::H3C
6
- include Aio::Module
7
-
8
- def initialize
9
- super({
10
- :cmd_full => "display memory",
11
- :cmd_short => "dis mem",
12
- :author => "Elin",
13
- :description => "This is H3C Command# display memory",
14
- :ranking => Ranking_1,
15
- :platform => "all",
16
- :benchmark => {}
17
- })
18
- end
19
-
20
- def parse
21
- cont = self.context.dup
22
- memory = {}
23
- useful[:memory] = memory
24
- cont.readline_match_block(/System Total Memory\(bytes\): (?<total_memory>\d+)/) do |block|
25
- #block.update(memory, :total_memory)
26
- end
27
- cont.readline_match_block(/Total Used Memory\(bytes\): (?<used_memory>\d+)/) do |block|
28
- #block.update(memory, :used_memory)
29
- end
30
- cont.readline_match_block(/Used Rate: (?<used_rate>\d+)%/) do |block|
31
- block.update(memory, :used_rate)
32
- end
33
- end
6
+ include Aio::Module
7
+
8
+ def initialize
9
+ super({
10
+ :cmd_full => "display memory",
11
+ :cmd_short => "dis mem",
12
+ :author => "Elin",
13
+ :description => "This is H3C Command# display memory",
14
+ :ranking => Ranking_1,
15
+ :platform => "all",
16
+ :benchmark => {}
17
+ })
18
+ end
19
+
20
+ def parse
21
+ cont = self.context.dup
22
+ #memory = {}
23
+ #useful[:memory] = memory
24
+
25
+ case device_template
26
+ when Template_3
27
+ parse_template_3(cont)
28
+ else
29
+ parse_default(cont)
30
+ end
31
+ end
32
+
33
+ def parse_default(cont)
34
+ useful[:memory] = {}
35
+ cont.readline_match_block(/System Total Memory\(bytes\): (?<total_memory>\d+)/) do |block|
36
+ #block.update(memory, :total_memory)
37
+ end
38
+ cont.readline_match_block(/Total Used Memory\(bytes\): (?<used_memory>\d+)/) do |block|
39
+ #block.update(memory, :used_memory)
40
+ end
41
+ cont.readline_match_block(/Used Rate: (?<used_rate>\d+)%/) do |block|
42
+ block.update(useful[:memory], :used_rate)
43
+ end
44
+ end
45
+
46
+ # MSR56-60 模板
47
+ def parse_template_3(cont)
48
+ useful[:memory] = {}
49
+ cont.readline_match_block(/Total Used Free Shared Buffers Cached FreeRatio/) {|b|b}
50
+ cont.readline_match_block(/Mem: .* (?<used_free>\d+\.\d)%$/) do |block|
51
+ used = 100 - block[:used_free].to_f
52
+ block.update(useful[:memory], :used_rate, used.to_s[0,4])
53
+ end
54
+ end
34
55
  end
35
56
 
@@ -29,17 +29,27 @@ class Aio::Module::Cmd::H3C::DisplayVersion < Aio::Module::Cmd::H3C
29
29
  cont.readline_match_block(/Comware Software, Version (?<version>.*)/) do |block|
30
30
  block.update(soft_info, :version)
31
31
  key_stand_version(block[:version])
32
+
33
+ # 按版本来确定
34
+ case block[:version]
35
+ when /^7\./ # 当是7.x 版本的时候,show memory 会不一样
36
+ key_stand_template Template_3
37
+ else
38
+ key_stand_template Template_1
39
+ end
40
+
32
41
  end
33
42
  cont.readline_match_block(/.*/)
34
43
  cont.readline_match_block(/H3C (?<device_model>.*) uptime is (?<uptime>.*)/) do |block|
44
+ key_stand_h3c
35
45
  block.update(soft_info, :device_model)
36
46
  block.update(soft_info, :uptime)
37
47
  key_stand_model(block[:device_model])
48
+
49
+ # 按设备类型来确定
38
50
  case block[:device_model]
39
51
  when /3600|8800/ # 当是S3600,S5500,S8800 的时候
40
52
  key_stand_template Template_2
41
- else
42
- key_stand_template Template_1
43
53
  end
44
54
  end
45
55
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aio_elin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-06 00:00:00.000000000 Z
11
+ date: 2018-12-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 网络设备巡检工具
14
14
  email: 365433079@qq.com