invoracle 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b48f47f224c20458725773006013f46277f82d10
4
- data.tar.gz: ac8fe16cb61a9c23afbc6bd4f6d49e6cb047860d
3
+ metadata.gz: 84308907a4cb30a7945bb2c4ce410a18ca449a58
4
+ data.tar.gz: 64380199c2ef77130ddb1c9891c30db2ced9c301
5
5
  SHA512:
6
- metadata.gz: 954723ecc43678077287d44e3075b7bbdfc6af09407c1973040e9d741337b50ce9c0d8b715fd9f5e689b502b7698daa7a1a13abd2283d67061b90e591d147a89
7
- data.tar.gz: f194155279830e9fb96cc17de425211df97cecac5a4735de3349ab74f222d48f79bcf9c2c46767a76adfb57aef2cb06b3b5353ae59426e5bad3fac627e539098
6
+ metadata.gz: b15f3895c76951e812fb6ab3e2aa229a8e657a83dd4a732313ddf462888f3a402536ffe614b11c229eda0d232d9282e46ea98b3067a94d204658034b79cb801a
7
+ data.tar.gz: e7131a8eaa268971d6705a65172de81ef392c2bd4495392bcc134acd5500cebdb43fae3170423394d59280b19fdb616f8854b476880165932cae8715df80db29
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ = 0.0.2
2
+ - Invoracle::Cluster is now a JsonDoc subclass
3
+ - Inforacle::Infra::IostatParser added
4
+
1
5
  = 0.0.1
2
6
  - Initial release
3
- - JsonDoc subclass for Invoracle::System
7
+ - JsonDoc subclass for Invoracle::System
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -1,10 +1,28 @@
1
1
  require 'invoracle/system'
2
+ require 'jsondoc'
2
3
 
3
4
  module Invoracle
4
- class Cluster
5
+ class Cluster < JsonDoc::Document
5
6
  attr_accessor :sCluUid
6
7
  attr_accessor :dSystems
7
8
 
9
+ def initialize(sCluUid=nil,dSchema=nil,bDefaultifyDoc=true,bIsStrict=true)
10
+ @dSchema = dSchema || self.getDefaultSchema()
11
+ self.setAttr(:sCluUid,sCluUid) unless sCluUid.nil?
12
+ @bDefaultifyDoc = bDefaultifyDoc ? true : false
13
+ @bIsStrict = bIsStrict ? true : false
14
+ @dDocument = self.getDefaultDocument()
15
+ end
16
+
17
+ def getDefaultSchema()
18
+ dSchema = {
19
+ :type => 'system',
20
+ :properties => {
21
+ :sCluUid => { :default => '', :type => 'string', :description => 'Cluster UID' }
22
+ }
23
+ }
24
+ end
25
+
8
26
  def initialize(sCluUid='')
9
27
  @sCluUid = sCluUid || ''
10
28
  @dSystems = {}
@@ -0,0 +1,152 @@
1
+ module Invoracle::Infra
2
+ class IostatParser
3
+ def initialize()
4
+ sIostatx = ''
5
+ dIostatx = {}
6
+ end
7
+ def getDeviceNames()
8
+ dDeviceNames = {}
9
+ if @dIostatx.has_key?('devices')
10
+ @dIostatx['devices'].each do |dDevice|
11
+ if dDevice.has_key?('Id')
12
+ sDevice = dDevice['Id']
13
+ dDeviceNames[sDevice] = 1
14
+ end
15
+ end
16
+ end
17
+ aDeviceNames = dDeviceNames.keys.sort
18
+ return aDeviceNames
19
+ end
20
+ def getIostatValue(sType=nil,sField=nil,sAggregateFirst=nil,sAggregateSecond=nil)
21
+ if sType == 'device'
22
+ aDevices = @dIostatx['devices']
23
+ return self.getItemsValue(aDevices,sField,sAggregateFirst,sAggregateSecond)
24
+ elsif sType == 'cpu'
25
+ aCpus = @dIostatx['cpus']
26
+ return self.getItemsValue(aCpus,sField,sAggregateFirst,sAggregateSecond)
27
+ end
28
+ return -1.0
29
+ end
30
+ def getItemsValue(aItems=[],sField=nil,sAggregateFirst=nil,sAggregateSecond=nil)
31
+ dItemsData = {}
32
+ aItems.each do |dItem|
33
+ sItemName = dItem['Id']
34
+ dItem.each do |sKey,fVal|
35
+ dItemsData[sItemName] ||= {}
36
+ dItemsData[sItemName][sKey] ||= {}
37
+ dKeyInfo = dItemsData[sItemName][sKey]
38
+ if ! dKeyInfo.has_key?('min') || fVal < dKeyInfo['min']
39
+ dKeyInfo['min'] = fVal
40
+ end
41
+ if ! dKeyInfo.has_key?('max') || fVal > dKeyInfo['max']
42
+ dKeyInfo['max'] = fVal
43
+ end
44
+ if ! dKeyInfo.has_key?('sum')
45
+ dKeyInfo['sum'] = fVal
46
+ else
47
+ dKeyInfo['sum'] += fVal
48
+ end
49
+ if ! dKeyInfo.has_key?('num')
50
+ dKeyInfo['num'] = 1
51
+ else
52
+ dKeyInfo['num'] += 1
53
+ end
54
+ dItemsData[sItemName][sKey] = dKeyInfo
55
+ end
56
+ end
57
+ bValReturn = false
58
+ fValReturn = 0.0
59
+ if sAggregateFirst == 'max' && sAggregateSecond == 'max'
60
+ dItemsData.each do |sItemName,dItemInfo|
61
+ if dItemInfo.has_key?(sField)
62
+ if dItemInfo[sField].has_key?('max')
63
+ if dItemInfo[sField]['max'] > fValReturn
64
+ fValReturn = dItemInfo[sField]['max']
65
+ end
66
+ end
67
+ end
68
+ end
69
+ elsif sAggregateFirst == 'min' && sAggregateSecond == 'min'
70
+ dItemsData.each do |sItemName,dItemInfo|
71
+ if dItemInfo[sField].has_key?('min')
72
+ if ! bValReturn
73
+ fValReturn = dItemInfo[sField]['min']
74
+ bValReturn = true
75
+ elsif dItemInfo[sField]['min'] < fValReturn
76
+ fValReturn = dItemInfo[sField]['min']
77
+ end
78
+ end
79
+ end
80
+ end
81
+ return fValReturn
82
+ end
83
+ def loadIostatxRaw(sIostatx=nil)
84
+ aCpus = []
85
+ aDevices = []
86
+ aIostatx = sIostatx.split("\n")
87
+ sStage = ''
88
+ aCols = []
89
+ iLine = 0
90
+ iCpuCount = 0
91
+ sDevName = ''
92
+ aIostatx.each do |sLine|
93
+ sLine.strip!
94
+ next unless sLine.length>0
95
+ iLine += 1
96
+ aItems = sLine.split(" ")
97
+ if sLine =~ /^avg-cpu:/
98
+ aItems.shift
99
+ aCols = aItems
100
+ sStage = 'cpu'
101
+ iCpuCount += 1
102
+ next
103
+ elsif sLine =~ /^Device:/
104
+ aItems.shift
105
+ aCols = aItems
106
+ sStage = 'device'
107
+ next
108
+ elsif sStage == ''
109
+ next
110
+ elsif sStage == 'cpu'
111
+ if aItems.length == aCols.length
112
+ dCpu = {'Id' => 'cpu' + iCpuCount.to_s}
113
+ aCols.each_with_index do |sCol,iIdx|
114
+ dCpu[sCol] = aItems[iIdx].to_f
115
+ end
116
+ aCpus.push(dCpu)
117
+ else
118
+ raise ArgumentError, "E_BAD_MATCH_CPU"
119
+ end
120
+ elsif sStage == 'device'
121
+ if aItems.length == aCols.length + 1
122
+ sDevice = aItems.shift
123
+ dDevice = {'Id' => sDevice}
124
+ aCols.each_with_index do |sCol,iIdx|
125
+ dDevice[sCol] = aItems[iIdx].to_f
126
+ end
127
+ aDevices.push(dDevice)
128
+ sDevName = ''
129
+ elsif aItems.length == 1
130
+ sDevName = aItems[0]
131
+ next
132
+ elsif aItems.length == aCols.length && sDevName.length > 0
133
+ dDevice = {'Id' => sDevName}
134
+ aCols.each_with_index do |sCol,iIdx|
135
+ dDevice[sCol] = aItems[iIdx].to_f
136
+ end
137
+ aDevices.push(dDevice)
138
+ sDevName = ''
139
+ else
140
+ raise ArgumentError, "E_BAD_MATCH_DEVICE"
141
+ end
142
+ end
143
+ end
144
+ dIostatx = {
145
+ 'cpus' => aCpus,
146
+ 'devices' => aDevices
147
+ }
148
+ @dIostatx = dIostatx
149
+ return dIostatx
150
+ end
151
+ end
152
+ end
@@ -0,0 +1,3 @@
1
+ module Invoracle::Infra
2
+ autoload :IostatParser, 'infra_parser/iostat_parser'
3
+ end
@@ -38,12 +38,13 @@ module Invoracle
38
38
  :iCpuCount => { :default => -1, :type => 'number', :description => 'CPU Count' },
39
39
  :iCpuCoresCount => { :default => -1, :type => 'number', :description => 'CPU Cores' },
40
40
  :fCpuIdleAvg => { :default => -1, :type => 'number', :description => 'CPU Idle' },
41
+ :fCpuIdleMinMin => { :default => -1, :type => 'number', :description => 'CPU Idle Min Min' },
41
42
 
42
43
  :iDiskUsedKb => { :default => -1, :type => 'number', :description => 'Dsk KB Used' },
43
44
  :fDiskUsedGb => { :default => -1, :type => 'number', :description => 'Dsk GB Used' },
44
45
  :fDiskAvailableGb => { :default => -1, :type => 'number', :description => 'Dsk GB Avail' },
45
46
  :fDiskTotalGb => { :default => -1, :type => 'number', :description => 'Dsk GB Total' },
46
- :fDiskUtilMax => { :default => -1, :type => 'number', :description => 'Dsk Util Max' },
47
+ :fDiskUtilMaxMax => { :default => -1, :type => 'number', :description => 'Dsk Util Max Max' },
47
48
 
48
49
  :iIpmHasIpm => { :default => -1, :type => 'number', :description => 'IPM Present' },
49
50
  :sIpmType => { :default => '', :type => 'string', :description => 'IPM Type' },
data/lib/invoracle.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  module Invoracle
2
2
  autoload :System, 'invoracle/system'
3
+ autoload :Cluster, 'invoracle/cluster'
3
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: invoracle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-01 00:00:00.000000000 Z
11
+ date: 2014-02-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple generic inventory system for managing computer systems.
14
14
  email: john@johnwang.com
@@ -23,6 +23,8 @@ files:
23
23
  - VERSION
24
24
  - lib/invoracle.rb
25
25
  - lib/invoracle/cluster.rb
26
+ - lib/invoracle/infra.rb
27
+ - lib/invoracle/infra/iostat_parser.rb
26
28
  - lib/invoracle/system.rb
27
29
  - test/test_setup.rb
28
30
  homepage: http://johnwang.com/