eaton 0.1.0 → 0.2.0
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 +4 -4
- data/README.md +9 -7
- data/lib/eaton/cli.rb +5 -8
- data/lib/eaton/client.rb +2 -0
- data/lib/eaton/power.rb +6 -6
- data/lib/eaton/version.rb +1 -1
- data/lib/eaton.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 28bb3b2bbbe4ecc0ad0b791242d1c9e059a832e5efc056b59b3567a30bf4e0dd
|
|
4
|
+
data.tar.gz: 243a22e2fc3b36accc7f3b01090a4ce53d8309125b86948d9e84977581c80081
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 81f8dec09135247929258c73eadce8baecd45752dd9026d789b7bfb73a1033afb59fbfa75b40bcef3b7b8bd49c3747833781fda22bf9d1bfd72c01648b2d9492
|
|
7
|
+
data.tar.gz: 00f421eff32a8cdcac89de7433ec744de4cd85616e069ad6ff9069923904762d687768739860d43354b5775e1d31474502cfb020fa064b8d2f0685012449dbea
|
data/README.md
CHANGED
|
@@ -176,29 +176,31 @@ client = Eaton::Client.new(
|
|
|
176
176
|
verify_ssl: true
|
|
177
177
|
)
|
|
178
178
|
|
|
179
|
-
# Extend with power monitoring
|
|
180
|
-
client.extend(Eaton::Power)
|
|
181
|
-
|
|
182
179
|
# Get PDU info
|
|
183
|
-
info = client.
|
|
180
|
+
info = client.info
|
|
184
181
|
puts "#{info[:model]} - #{info[:serial_number]}"
|
|
185
182
|
|
|
186
183
|
# Get overall power
|
|
187
|
-
power = client.
|
|
184
|
+
power = client.power
|
|
188
185
|
puts "Current draw: #{power} watts"
|
|
189
186
|
|
|
190
187
|
# Get active outlets
|
|
191
|
-
outlets = client.
|
|
188
|
+
outlets = client.outlets
|
|
192
189
|
outlets.select { |o| o[:watts] > 0 }.each do |outlet|
|
|
193
190
|
puts "#{outlet[:name]}: #{outlet[:watts]}W"
|
|
194
191
|
end
|
|
195
192
|
|
|
196
193
|
# Get branch distribution
|
|
197
|
-
branches = client.
|
|
194
|
+
branches = client.branches
|
|
198
195
|
branches.each do |branch|
|
|
199
196
|
puts "#{branch[:name]}: #{branch[:current]}A @ #{branch[:voltage]}V"
|
|
200
197
|
end
|
|
201
198
|
|
|
199
|
+
# Get detailed metrics
|
|
200
|
+
detailed = client.detailed
|
|
201
|
+
puts "Power Factor: #{detailed[:overall][:power_factor]}"
|
|
202
|
+
puts "Frequency: #{detailed[:overall][:frequency]} Hz"
|
|
203
|
+
|
|
202
204
|
# Clean up
|
|
203
205
|
client.logout
|
|
204
206
|
```
|
data/lib/eaton/cli.rb
CHANGED
|
@@ -16,7 +16,7 @@ module Eaton
|
|
|
16
16
|
desc "power", "Get overall power consumption in watts"
|
|
17
17
|
def power
|
|
18
18
|
with_client do |client|
|
|
19
|
-
power = client.
|
|
19
|
+
power = client.power
|
|
20
20
|
output_result("Overall Power", { watts: power })
|
|
21
21
|
end
|
|
22
22
|
end
|
|
@@ -24,7 +24,7 @@ module Eaton
|
|
|
24
24
|
desc "outlets", "Get per-outlet power consumption"
|
|
25
25
|
def outlets
|
|
26
26
|
with_client do |client|
|
|
27
|
-
outlets = client.
|
|
27
|
+
outlets = client.outlets
|
|
28
28
|
# Filter out zero-power outlets in text mode
|
|
29
29
|
if options[:format] == "text"
|
|
30
30
|
outlets = outlets.select { |o| o[:watts] && o[:watts] > 0 }
|
|
@@ -36,7 +36,7 @@ module Eaton
|
|
|
36
36
|
desc "detailed", "Get detailed power information"
|
|
37
37
|
def detailed
|
|
38
38
|
with_client do |client|
|
|
39
|
-
info = client.
|
|
39
|
+
info = client.detailed
|
|
40
40
|
# Filter outlets in text mode
|
|
41
41
|
if options[:format] == "text" && info[:outlets]
|
|
42
42
|
info[:outlets] = info[:outlets].select { |o| o[:watts] && o[:watts] > 0 }
|
|
@@ -48,7 +48,7 @@ module Eaton
|
|
|
48
48
|
desc "branches", "Get power consumption per branch"
|
|
49
49
|
def branches
|
|
50
50
|
with_client do |client|
|
|
51
|
-
branches = client.
|
|
51
|
+
branches = client.branches
|
|
52
52
|
# Filter out zero-current branches in text mode
|
|
53
53
|
if options[:format] == "text"
|
|
54
54
|
branches = branches.select { |b| b[:current] && b[:current] > 0 }
|
|
@@ -60,7 +60,7 @@ module Eaton
|
|
|
60
60
|
desc "info", "Display PDU device information"
|
|
61
61
|
def info
|
|
62
62
|
with_client do |client|
|
|
63
|
-
info = client.
|
|
63
|
+
info = client.info
|
|
64
64
|
output_result("PDU Device Information", info)
|
|
65
65
|
end
|
|
66
66
|
end
|
|
@@ -88,9 +88,6 @@ module Eaton
|
|
|
88
88
|
host_header: options[:host_header]
|
|
89
89
|
)
|
|
90
90
|
|
|
91
|
-
# Mix in the Power module to add power monitoring methods
|
|
92
|
-
client.extend(Power)
|
|
93
|
-
|
|
94
91
|
yield client
|
|
95
92
|
rescue Client::AuthenticationError => e
|
|
96
93
|
error("Authentication failed: #{e.message}")
|
data/lib/eaton/client.rb
CHANGED
|
@@ -10,6 +10,8 @@ module Eaton
|
|
|
10
10
|
class AuthenticationError < StandardError; end
|
|
11
11
|
class APIError < StandardError; end
|
|
12
12
|
|
|
13
|
+
include Power
|
|
14
|
+
|
|
13
15
|
attr_reader :host, :username, :base_url
|
|
14
16
|
|
|
15
17
|
def initialize(host:, username:, password:, port: 443, verify_ssl: false, host_header: nil)
|
data/lib/eaton/power.rb
CHANGED
|
@@ -4,14 +4,14 @@ module Eaton
|
|
|
4
4
|
module Power
|
|
5
5
|
# Get overall power consumption for the PDU
|
|
6
6
|
# Returns power in watts
|
|
7
|
-
def
|
|
7
|
+
def power
|
|
8
8
|
data = get("/powerDistributions/1/inputs/1")
|
|
9
9
|
data.dig("measures", "activePower")
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
# Get per-outlet power consumption
|
|
13
13
|
# Returns an array of hashes with outlet info and power in watts
|
|
14
|
-
def
|
|
14
|
+
def outlets
|
|
15
15
|
# Get list of outlets
|
|
16
16
|
outlets_list = get("/powerDistributions/1/outlets")
|
|
17
17
|
member_count = outlets_list["members@count"] || 0
|
|
@@ -41,7 +41,7 @@ module Eaton
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
# Get detailed power information including voltage, current, and power factor
|
|
44
|
-
def
|
|
44
|
+
def detailed
|
|
45
45
|
input_data = get("/powerDistributions/1/inputs/1")
|
|
46
46
|
|
|
47
47
|
{
|
|
@@ -55,13 +55,13 @@ module Eaton
|
|
|
55
55
|
cumulated_energy: input_data.dig("measures", "cumulatedEnergy"),
|
|
56
56
|
partial_energy: input_data.dig("measures", "partialEnergy")
|
|
57
57
|
},
|
|
58
|
-
outlets:
|
|
58
|
+
outlets: outlets
|
|
59
59
|
}
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
# Get branch power information
|
|
63
63
|
# Returns an array of branch power data
|
|
64
|
-
def
|
|
64
|
+
def branches
|
|
65
65
|
branches_list = get("/powerDistributions/1/branches")
|
|
66
66
|
member_count = branches_list["members@count"] || 0
|
|
67
67
|
|
|
@@ -87,7 +87,7 @@ module Eaton
|
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
# Get PDU information
|
|
90
|
-
def
|
|
90
|
+
def info
|
|
91
91
|
data = get("/powerDistributions/1")
|
|
92
92
|
|
|
93
93
|
{
|
data/lib/eaton/version.rb
CHANGED
data/lib/eaton.rb
CHANGED