lmcadm 0.16.1 → 0.19.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/.github/workflows/build-win.yaml +35 -0
- data/README.md +55 -0
- data/lib/lmcadm/account_commands.rb +6 -9
- data/lib/lmcadm/cloud_commands.rb +1 -0
- data/lib/lmcadm/commands/monitor.rb +69 -1
- data/lib/lmcadm/version.rb +1 -1
- data/lmcadm.gemspec +1 -0
- data/makeocragemfile.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e0ecc30a7bc65586b2e252af05a701c4facd81c950378d147ccdf1583ee4dac
|
4
|
+
data.tar.gz: a807ad57a2d8d40419b2cf28e0ba997ba800ce6113f496e950c8be6dfa5c95bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc6a607055a7c4a02245df5eae5110ed7dc874a3cdd14dc16280082a9066a27f25563fd5a0b95dfc7afdd1a28eaf92531ae0dd1bc7fc776ce6e081693ce63606
|
7
|
+
data.tar.gz: 451a67308f2a0b4420e667019272e33f1a23ee4d2bcf07a56d8ff3d4ccc23fad364cca5a7928010b259ac81fd86db0e658ac3f3845b78672ffa7c0fb39a351a1
|
@@ -0,0 +1,35 @@
|
|
1
|
+
name: build-win
|
2
|
+
on:
|
3
|
+
release:
|
4
|
+
types:
|
5
|
+
- published
|
6
|
+
|
7
|
+
# push:
|
8
|
+
# tags:
|
9
|
+
# - 'v*.*.*'
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
build:
|
13
|
+
runs-on: windows-latest
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
- uses: ruby/setup-ruby@v1
|
17
|
+
- run: gem install eventmachine --platform ruby
|
18
|
+
- run: gem install ocra lmcadm
|
19
|
+
- run: ruby makeocragemfile.rb
|
20
|
+
- run: ocra --gemfile ocra_gemfile --gem-full exe/lmcadm
|
21
|
+
- name: Setup tmate session
|
22
|
+
uses: mxschmitt/action-tmate@v3
|
23
|
+
if: false
|
24
|
+
- run: ./lmcadm.exe --version
|
25
|
+
- uses: papeloto/action-zip@v1
|
26
|
+
with:
|
27
|
+
files: lmcadm.exe LICENSE.txt
|
28
|
+
dest: lmcadm-${{ github.event.release.tag_name }}-win.zip
|
29
|
+
- name: Release
|
30
|
+
uses: softprops/action-gh-release@v1
|
31
|
+
with:
|
32
|
+
files: lmcadm-${{ github.event.release.tag_name }}-win.zip
|
33
|
+
env:
|
34
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
35
|
+
|
data/README.md
CHANGED
@@ -20,6 +20,11 @@ Lmcadm works with https://rubyinstaller.org/downloads/, use the recommended vers
|
|
20
20
|
Installation can continue with rubygems.
|
21
21
|
|
22
22
|
#### Known issues
|
23
|
+
*Installing lmcadm fails with `ERROR: Failed to build gem native extension.`*
|
24
|
+
|
25
|
+
Ruby headers and some tools to build software (C compiler, make) are needed.
|
26
|
+
On Ubuntu for example, the packages `ruby-dev` and `build-essential` should be enough.
|
27
|
+
apt install ruby-dev build-essential
|
23
28
|
|
24
29
|
*Unable to load the EventMachine C extension ; To use the pure-ruby reactor, require 'em/pure_ruby'*
|
25
30
|
|
@@ -59,3 +64,53 @@ The sentence above is patently wrong currently.
|
|
59
64
|
## License
|
60
65
|
|
61
66
|
The gem is available as open source under the terms of the BSD 3-Clause License.
|
67
|
+
|
68
|
+
# Advanced usage or experimental features
|
69
|
+
|
70
|
+
## Using lmcadm to query monitoring data
|
71
|
+
|
72
|
+
Example use:
|
73
|
+
|
74
|
+
lmcadm monitor -A "ExampleProject" raw device_info cloud_rtt 42adf60b-0fe7-4187-af4f-9ee97669bfb0
|
75
|
+
|
76
|
+
### --type scalar (default)
|
77
|
+
|
78
|
+
When specifying a period longer than MINUTE1, the name must be suffixed with a dot, followed by an aggregation type.
|
79
|
+
Available types are
|
80
|
+
* .min
|
81
|
+
* .max
|
82
|
+
* .avg
|
83
|
+
|
84
|
+
Example use:
|
85
|
+
|
86
|
+
$ lmcadm monitor -A "ExampleProject" raw --type scalar --period MINUTE10 \
|
87
|
+
device_info cloud_rtt.max 3e19ada7-86fa-4809-a14e-7174b018603d
|
88
|
+
|
89
|
+
|
90
|
+
### --type json
|
91
|
+
|
92
|
+
This dumps the raw values response as json.
|
93
|
+
To further extract data, use something that can parse json, like `jq`[1].
|
94
|
+
|
95
|
+
Example use:
|
96
|
+
|
97
|
+
$lmcadm monitor -A "ExampleProject" raw --type json --period MINUTE1 \
|
98
|
+
wan_info_json interfaces a6871a81-84f3-4c57-a20e-c3410b47e895 | jq ' .[]["DSL-CH-1"].rxRate'
|
99
|
+
|
100
|
+
### --type table
|
101
|
+
|
102
|
+
Prints table data as one row per sample.
|
103
|
+
Empty row handling is shaky, as is error handling in general.
|
104
|
+
|
105
|
+
$ lmcadm monitor -A "ExampleProject" raw --type table device_info \
|
106
|
+
device 3a096938-87b4-47c8-a388-fda75f30eacc
|
107
|
+
CLOUD_RTT | CPU_LOAD | UPTIME | TOTAL_MEMORY | FREE_MEMORY | CONTROL_RX | CONTROL_TX | MONITORING_RX | MONITORING_TX
|
108
|
+
----------|----------|----------|--------------|-------------|------------|------------|---------------|--------------
|
109
|
+
29 | 1 | 19512712 | 248064 | 27228 | 513704725 | 291602474 | 119108008 | 936963871
|
110
|
+
29 | 0 | 19512652 | 248064 | 27228 | 513701635 | 291600722 | 119107296 | 936957306
|
111
|
+
30 | 1 | 19512592 | 248064 | 27228 | 513698545 | 291598970 | 119106584 | 936950729
|
112
|
+
77 | 6 | 19512533 | 248064 | 27228 | 513695455 | 291597218 | 119105872 | 936944149
|
113
|
+
...
|
114
|
+
|
115
|
+
# Footnotes
|
116
|
+
[1] https://stedolan.github.io/jq/manual/
|
@@ -262,21 +262,18 @@ module LMCAdm
|
|
262
262
|
account = LMC::Account.get_by_uuid_or_name(options[:account])
|
263
263
|
account.cloud.auth_for_account account
|
264
264
|
membership = account.find_member_by_name args.first
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
puts membership if global_options[:verbose]
|
265
|
+
if global_options[:verbose]
|
266
|
+
puts "membership class: #{membership.class}"
|
267
|
+
puts "membership.authorities first class: #{membership.authorities.first.class}"
|
268
|
+
puts membership
|
269
|
+
end
|
273
270
|
authority_ids = membership.authorities.map do |a|
|
274
271
|
a.id
|
275
272
|
end
|
276
273
|
puts "Existing authority ids: #{authority_ids}"
|
277
274
|
if options['add-authority']
|
278
275
|
add_str = options['add-authority']
|
279
|
-
new_authority = Helpers::find_by_id_or_name
|
276
|
+
new_authority = Helpers::find_by_id_or_name account.authorities, add_str
|
280
277
|
authority_ids = authority_ids.concat [new_authority.id]
|
281
278
|
puts "Adding #{authority_ids}"
|
282
279
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'chronic'
|
2
3
|
|
3
4
|
module LMCAdm #:nodoc:
|
4
5
|
desc 'Retrieve montoring data'
|
@@ -15,7 +16,7 @@ module LMCAdm #:nodoc:
|
|
15
16
|
monitor_device.action do |_g, options, args|
|
16
17
|
record_name = args.shift
|
17
18
|
account = LMC::Account.get_by_uuid_or_name options[GLI::Command::PARENT][:account]
|
18
|
-
device = account.devices.find {|d| d.name == options[:device]}
|
19
|
+
device = account.devices.find { |d| d.name == options[:device] }
|
19
20
|
record = device.record record_name
|
20
21
|
|
21
22
|
options[:scalar].each do |datapoint|
|
@@ -48,5 +49,72 @@ module LMCAdm #:nodoc:
|
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
52
|
+
|
53
|
+
monitor.desc 'Make raw monitoring requests'
|
54
|
+
monitor.arg_name '<record> <name> <id>'
|
55
|
+
monitor.command :raw do |raw|
|
56
|
+
raw.flag :t, :type, default_value: 'scalar'
|
57
|
+
raw.flag :g, :group, default_value: 'DEVICE'
|
58
|
+
raw.flag :p, :period, default_value: 'MINUTE1'
|
59
|
+
raw.desc 'Start time'
|
60
|
+
raw.flag :start, default_value: 'one hour ago'
|
61
|
+
raw.flag :end, default_value: 'now'
|
62
|
+
raw.action do |_g, options, args|
|
63
|
+
record = args.shift
|
64
|
+
name = args.shift
|
65
|
+
groupId = args.shift
|
66
|
+
account = LMC::Account.get_by_uuid_or_name options[GLI::Command::PARENT][:account]
|
67
|
+
account.cloud.auth_for_account account
|
68
|
+
|
69
|
+
startTime = Chronic.parse(options[:start])
|
70
|
+
puts "Start time: #{startTime}" if _g[:verbose]
|
71
|
+
endTime = Chronic.parse(options[:end])
|
72
|
+
puts "End time: #{endTime}" if _g[:verbose]
|
73
|
+
|
74
|
+
# https://cloud.lancom.de/cloud-service-monitoring/accounts/399bc33a-7f53-4757-a6bd-cac3cbb6ebdd/records/wlan_info_json?type=scalar&name=stations&group=ACCOUNT&groupId=399bc33a-7f53-4757-a6bd-cac3cbb6ebdd&period=MINUTE1&start=1623417748&end=1623421348
|
75
|
+
# https://cloud.lancom.de/cloud-service-monitoring/accounts/399bc33a-7f53-4757-a6bd-cac3cbb6ebdd/records/device_info?type=scalar&name=cloud_rtt&group=DEVICE&groupId=efec12e1-ac4d-459d-bb5d-a9b6c1410eb5&period=MINUTE1&start=1623419874&end=1623423474
|
76
|
+
# https://cloud.lancom.de/cloud-service-monitoring/accounts/399bc33a-7f53-4757-a6bd-cac3cbb6ebdd/records/device_info?type=scalar&name=cloud_rtt&group=DEVICE&group_id=efec12e1-ac4d-459d-bb5d-a9b6c1410eb5&period=MINUTE1&start=1623419874&end=1623423474
|
77
|
+
result = account.cloud.get ['cloud-service-monitoring', 'accounts', account.id, 'records', record], {
|
78
|
+
type: options[:type],
|
79
|
+
name: name,
|
80
|
+
group: options[:group],
|
81
|
+
groupId: groupId,
|
82
|
+
period: options[:period],
|
83
|
+
start: startTime.to_i,
|
84
|
+
end: endTime.to_i,
|
85
|
+
}
|
86
|
+
base_timestamp = result.body.base
|
87
|
+
delta = result.body.delta
|
88
|
+
monitordata = result.body.items[name]
|
89
|
+
puts result.body.inspect if _g[:debug]
|
90
|
+
if options[:type] == 'scalar'
|
91
|
+
table_data = monitordata.values.map.with_index { |value, row_index|
|
92
|
+
{
|
93
|
+
timestamp: DateTime.strptime((base_timestamp + delta * (monitordata.values.length - row_index)).to_s,'%s'),
|
94
|
+
value: value,
|
95
|
+
}
|
96
|
+
}
|
97
|
+
tp table_data
|
98
|
+
elsif options[:type] == 'json'
|
99
|
+
puts JSON.pretty_generate monitordata.to_h[:values]
|
100
|
+
elsif options[:type] == 'table'
|
101
|
+
table_data = monitordata.values.map.with_index { |v, row_index|
|
102
|
+
hash = { timestamp: DateTime.strptime((base_timestamp + delta * (monitordata.values.length - row_index)).to_s,'%s') }
|
103
|
+
unless v.nil?
|
104
|
+
row = v.first
|
105
|
+
monitordata.keys.each_with_index { |k, column_index|
|
106
|
+
unless row[column_index].nil?
|
107
|
+
hash[k] = v.first[column_index]
|
108
|
+
end
|
109
|
+
}
|
110
|
+
end
|
111
|
+
hash
|
112
|
+
}
|
113
|
+
tp table_data
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
51
119
|
end
|
52
120
|
end
|
data/lib/lmcadm/version.rb
CHANGED
data/lmcadm.gemspec
CHANGED
@@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_runtime_dependency 'table_print', '~> 1.5'
|
30
30
|
spec.add_runtime_dependency 'colorize', '~> 0.8'
|
31
31
|
spec.add_runtime_dependency 'websocket-eventmachine-client', '~> 1.3.0'
|
32
|
+
spec.add_runtime_dependency 'chronic', '~> 0.10.2'
|
32
33
|
end
|
data/makeocragemfile.rb
CHANGED
@@ -4,7 +4,7 @@ GEMFILE = 'ocra_gemfile'
|
|
4
4
|
# Add gems from gemspec.
|
5
5
|
ocra_gemfile = File.new(GEMFILE, 'w')
|
6
6
|
File.open("lmcadm.gemspec",'r') do |file|
|
7
|
-
file.each { |line| ocra_gemfile.write "gem #{$1}\n" if line =~ /spec.
|
7
|
+
file.each { |line| ocra_gemfile.write "gem #{$1}\n" if line =~ /spec.add_runtime_dependency (.+)/ }
|
8
8
|
end
|
9
9
|
ocra_gemfile.close
|
10
10
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lmcadm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- erpel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 1.3.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: chronic
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.10.2
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.10.2
|
139
153
|
description:
|
140
154
|
email:
|
141
155
|
- philipp@copythat.de
|
@@ -144,6 +158,7 @@ executables:
|
|
144
158
|
extensions: []
|
145
159
|
extra_rdoc_files: []
|
146
160
|
files:
|
161
|
+
- ".github/workflows/build-win.yaml"
|
147
162
|
- ".gitignore"
|
148
163
|
- ".idea/encodings.xml"
|
149
164
|
- ".idea/inspectionProfiles/Project_Default.xml"
|