lmcadm 0.16.2 → 0.17.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 +8 -3
- data/README.md +37 -0
- data/lib/lmcadm/cloud_commands.rb +1 -0
- data/lib/lmcadm/commands/monitor.rb +47 -1
- data/lib/lmcadm/version.rb +1 -1
- data/lmcadm.gemspec +1 -0
- metadata +16 -3
- data/.github/workflows/gem-push.yml +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38c8fafe1ca6ada1a72b6d9e77d3c356c2ebfe59951494ce39df0264551493d9
|
4
|
+
data.tar.gz: 25c529b60448aabcab330df1b6827179a914cbf51e23e91dbdd70c8df6221413
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df4eeae40e1204dcb9cf34974db6f5ee96ea39929a4bb6f0a8991f968d937def265ce304a6398ed78b007594726cf60307304d0098e7ca0ac3d6c1d98793cef3
|
7
|
+
data.tar.gz: 5ac6a4adc086263d8d06fe8e76c7c200b5c4ca65a53df89d003bfca74d74ddf53f94806e7590ba789a1625bd86158f3aec989f7c2120104a4b5179808d941777
|
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,35 @@ 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
|
+
|
85
|
+
lmcadm monitor -A "ExampleProject" raw --type scalar --period MINUTE10 \
|
86
|
+
device_info cloud_rtt.max 3e19ada7-86fa-4809-a14e-7174b018603d
|
87
|
+
|
88
|
+
|
89
|
+
### --type json
|
90
|
+
|
91
|
+
This dumps the raw values response as json.
|
92
|
+
To further extract data, use something that can parse json, like `jq`[1].
|
93
|
+
|
94
|
+
lmcadm monitor -A "SDN-DEMO (LANCOM Visitor)" raw --type json --period MINUTE1 \
|
95
|
+
wan_info_json interfaces a6871a81-84f3-4c57-a20e-c3410b47e895 | jq ' .[]["DSL-CH-1"].rxRate'
|
96
|
+
|
97
|
+
# Footnotes
|
98
|
+
[1] https://stedolan.github.io/jq/manual/
|
@@ -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,50 @@ 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
|
+
monitordata = result.body.items[name]
|
87
|
+
puts result.body.inspect if _g[:debug]
|
88
|
+
if options[:type] == "scalar"
|
89
|
+
puts monitordata.values
|
90
|
+
elsif options[:type] == "json"
|
91
|
+
puts JSON.pretty_generate monitordata.to_h[:values]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
51
97
|
end
|
52
98
|
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
|
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.17.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-06-
|
11
|
+
date: 2021-06-17 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
|
@@ -145,7 +159,6 @@ extensions: []
|
|
145
159
|
extra_rdoc_files: []
|
146
160
|
files:
|
147
161
|
- ".github/workflows/build-win.yaml"
|
148
|
-
- ".github/workflows/gem-push.yml"
|
149
162
|
- ".gitignore"
|
150
163
|
- ".idea/encodings.xml"
|
151
164
|
- ".idea/inspectionProfiles/Project_Default.xml"
|
@@ -1,45 +0,0 @@
|
|
1
|
-
name: Ruby Gem
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches: [ master ]
|
6
|
-
pull_request:
|
7
|
-
branches: [ master ]
|
8
|
-
|
9
|
-
jobs:
|
10
|
-
build:
|
11
|
-
name: Build + Publish
|
12
|
-
runs-on: ubuntu-latest
|
13
|
-
permissions:
|
14
|
-
contents: read
|
15
|
-
packages: write
|
16
|
-
|
17
|
-
steps:
|
18
|
-
- uses: actions/checkout@v2
|
19
|
-
- name: Set up Ruby 2.6
|
20
|
-
uses: actions/setup-ruby@v1
|
21
|
-
with:
|
22
|
-
ruby-version: 2.6.x
|
23
|
-
|
24
|
-
- name: Publish to GPR
|
25
|
-
run: |
|
26
|
-
mkdir -p $HOME/.gem
|
27
|
-
touch $HOME/.gem/credentials
|
28
|
-
chmod 0600 $HOME/.gem/credentials
|
29
|
-
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
30
|
-
gem build *.gemspec
|
31
|
-
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
32
|
-
env:
|
33
|
-
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
|
34
|
-
OWNER: ${{ github.repository_owner }}
|
35
|
-
|
36
|
-
- name: Publish to RubyGems
|
37
|
-
run: |
|
38
|
-
mkdir -p $HOME/.gem
|
39
|
-
touch $HOME/.gem/credentials
|
40
|
-
chmod 0600 $HOME/.gem/credentials
|
41
|
-
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
42
|
-
gem build *.gemspec
|
43
|
-
gem push *.gem
|
44
|
-
env:
|
45
|
-
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|