dropsonde 0.0.3 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +58 -0
- data/README.md +47 -16
- data/bin/dropsonde +18 -9
- data/lib/dropsonde/cache.rb +37 -33
- data/lib/dropsonde/metrics/dependencies.rb +37 -32
- data/lib/dropsonde/metrics/environments.rb +53 -0
- data/lib/dropsonde/metrics/modules.rb +75 -66
- data/lib/dropsonde/metrics/platforms.rb +126 -0
- data/lib/dropsonde/metrics/puppetfiles.rb +35 -32
- data/lib/dropsonde/metrics.rb +94 -82
- data/lib/dropsonde/monkeypatches.rb +12 -11
- data/lib/dropsonde/version.rb +3 -1
- data/lib/dropsonde.rb +64 -26
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2b344789cd257a8cae81d53150c1ab50fe0cf20716c4fce306446a2c207c7e2
|
4
|
+
data.tar.gz: 563788ccfcf13c75feb8529e4870ba65a0679a1d461eda2413cd401c0c52decd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5006cf40dd17e018b6af805ae6192d5cc8b1842b981a4eba6895966a7ace7ee13365b9bae976169adaad1399ee9ca767d10b56cef56542ba5420cd04cecafdb6
|
7
|
+
data.tar.gz: ebda439d8baeec73d04887fb03b745acb2a11b9af8621f8992ad585b9ea9380f4c5732f88a5c17661f8123cba8125dc781d2929302a0954511bd6fae221c78f4
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [0.0.7](https://github.com/puppetlabs/dropsonde/tree/0.0.7) (2022-02-10)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/puppetlabs/dropsonde/compare/v0.0.6...0.0.7)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- update server language [\#20](https://github.com/puppetlabs/dropsonde/pull/20) ([binford2k](https://github.com/binford2k))
|
10
|
+
- Updates the telemetry endpoint to a stable URL [\#19](https://github.com/puppetlabs/dropsonde/pull/19) ([MikaelSmith](https://github.com/MikaelSmith))
|
11
|
+
- docs updates now that it's shipped [\#18](https://github.com/puppetlabs/dropsonde/pull/18) ([binford2k](https://github.com/binford2k))
|
12
|
+
|
13
|
+
## [v0.0.6](https://github.com/puppetlabs/dropsonde/tree/v0.0.6) (2021-11-17)
|
14
|
+
|
15
|
+
[Full Changelog](https://github.com/puppetlabs/dropsonde/compare/v0.0.5...v0.0.6)
|
16
|
+
|
17
|
+
**Merged pull requests:**
|
18
|
+
|
19
|
+
- \(MAINT\) Update gemspec license param to 'Apache-2.0' [\#17](https://github.com/puppetlabs/dropsonde/pull/17) ([sanfrancrisko](https://github.com/sanfrancrisko))
|
20
|
+
- \(MAINT\) Release prep for 0.0.6 [\#16](https://github.com/puppetlabs/dropsonde/pull/16) ([sanfrancrisko](https://github.com/sanfrancrisko))
|
21
|
+
- \(MAINT\) Fix Rubocop violations [\#15](https://github.com/puppetlabs/dropsonde/pull/15) ([sanfrancrisko](https://github.com/sanfrancrisko))
|
22
|
+
- \(SERVER-3079\) Allow overriding Puppet's base settings [\#14](https://github.com/puppetlabs/dropsonde/pull/14) ([Magisus](https://github.com/Magisus))
|
23
|
+
- Load Ruby's CA certificates instead of using httpclient defaults [\#13](https://github.com/puppetlabs/dropsonde/pull/13) ([Magisus](https://github.com/Magisus))
|
24
|
+
- \(IAC-1676\) - Add nightly workflow [\#12](https://github.com/puppetlabs/dropsonde/pull/12) ([adrianiurca](https://github.com/adrianiurca))
|
25
|
+
- \(IAC-1659\) - Add Acceptance Tests [\#11](https://github.com/puppetlabs/dropsonde/pull/11) ([adrianiurca](https://github.com/adrianiurca))
|
26
|
+
- \(IAC-1624\) - Expand unit test case suit [\#9](https://github.com/puppetlabs/dropsonde/pull/9) ([adrianiurca](https://github.com/adrianiurca))
|
27
|
+
- \(IAC-1620\) - replace travis workflow with github actions [\#8](https://github.com/puppetlabs/dropsonde/pull/8) ([adrianiurca](https://github.com/adrianiurca))
|
28
|
+
- \(IAC-1605\) - add static checks - rubocop [\#5](https://github.com/puppetlabs/dropsonde/pull/5) ([adrianiurca](https://github.com/adrianiurca))
|
29
|
+
- Allow to specify siteid with a flag [\#4](https://github.com/puppetlabs/dropsonde/pull/4) ([raphink](https://github.com/raphink))
|
30
|
+
|
31
|
+
## [v0.0.5](https://github.com/puppetlabs/dropsonde/tree/v0.0.5) (2020-06-11)
|
32
|
+
|
33
|
+
[Full Changelog](https://github.com/puppetlabs/dropsonde/compare/v0.0.4...v0.0.5)
|
34
|
+
|
35
|
+
## [v0.0.4](https://github.com/puppetlabs/dropsonde/tree/v0.0.4) (2020-06-05)
|
36
|
+
|
37
|
+
[Full Changelog](https://github.com/puppetlabs/dropsonde/compare/v0.0.3...v0.0.4)
|
38
|
+
|
39
|
+
## [v0.0.3](https://github.com/puppetlabs/dropsonde/tree/v0.0.3) (2020-05-24)
|
40
|
+
|
41
|
+
[Full Changelog](https://github.com/puppetlabs/dropsonde/compare/v0.0.2...v0.0.3)
|
42
|
+
|
43
|
+
## [v0.0.2](https://github.com/puppetlabs/dropsonde/tree/v0.0.2) (2020-05-08)
|
44
|
+
|
45
|
+
[Full Changelog](https://github.com/puppetlabs/dropsonde/compare/v0.0.1...v0.0.2)
|
46
|
+
|
47
|
+
## [v0.0.1](https://github.com/puppetlabs/dropsonde/tree/v0.0.1) (2020-02-27)
|
48
|
+
|
49
|
+
[Full Changelog](https://github.com/puppetlabs/dropsonde/compare/502bce39de366c8d6816676e0cf7ca6284b90734...v0.0.1)
|
50
|
+
|
51
|
+
**Merged pull requests:**
|
52
|
+
|
53
|
+
- Add simple puppetfile metric [\#2](https://github.com/puppetlabs/dropsonde/pull/2) ([binford2k](https://github.com/binford2k))
|
54
|
+
- MVP workable tool [\#1](https://github.com/puppetlabs/dropsonde/pull/1) ([binford2k](https://github.com/binford2k))
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/README.md
CHANGED
@@ -15,8 +15,7 @@ data in a way that lets you signal approval simply by using a module is the
|
|
15
15
|
primary goal of this project.
|
16
16
|
|
17
17
|
> **This means that the best way for you to help yourself find new modules is to
|
18
|
-
>
|
19
|
-
> data.** ✅
|
18
|
+
> opt in and use this telemetry tool to share your module usage data.** ✅
|
20
19
|
|
21
20
|
|
22
21
|
## Design
|
@@ -34,19 +33,24 @@ You can see exactly what will be phoned home by running the command:
|
|
34
33
|
$ dropsonde preview
|
35
34
|
```
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
> *Note:* as of Puppetserver 7.5.0, Dropsonde is bundled in as a standard `puppetserver`
|
37
|
+
> command. You should run it as `puppetserver dropsonde` (or `/opt/puppetlabs/bin/puppetserver
|
38
|
+
> dropsonde` if your `$PATH` isn't configured.)
|
39
|
+
|
40
|
+
Dropsonde is a simple telemetry probe designed to run both as a command-line
|
41
|
+
tool and optionally as a regularly scheduled task. Metrics are defined by
|
42
|
+
plugins that gather data, but also export a schema that constrains the data
|
43
|
+
allowed to be reported on. Dropsonde will reject metrics that don't meet these
|
44
|
+
constraints. The backend database is also defined by this schema so the system
|
45
|
+
cannot gather any data that's not described in the schema.
|
42
46
|
|
43
47
|
See the full schema of all enabled plugins by running the command:
|
44
48
|
|
45
49
|
```
|
46
|
-
$ dropsonde schema
|
50
|
+
$ dropsonde dev schema
|
47
51
|
```
|
48
52
|
|
49
|
-
All information in the report is keyed off a non-reversible SHA512
|
53
|
+
All information in the report is keyed off a non-reversible SHA512 hashed site-id
|
50
54
|
to make it unidentifiable; this report cannot be linked back to you or to your
|
51
55
|
infrastructure. Now that said, we know that the more bits of data shared about a
|
52
56
|
specific site, the easier it is to fingerprint that site. See
|
@@ -63,6 +67,8 @@ For example, this aggregated data might include records that show a count of how
|
|
63
67
|
many sites are using various combinations of modules together, but it will never
|
64
68
|
include a record showing the full list of modules that any single site is using.
|
65
69
|
|
70
|
+
![Data aggregation workflow](./aggregation.png)
|
71
|
+
|
66
72
|
With your own Google Cloud account, you can use that [dataset](https://console.cloud.google.com/bigquery?p=dataops-puppet-public-data&d=community&t=forge_modules&page=table)
|
67
73
|
in your own tooling and you can see/contribute to the aggregation queries in its
|
68
74
|
own [repository](https://github.com/puppetlabs/dropsonde-aggregation).
|
@@ -85,9 +91,11 @@ possible: [privacy@puppet.com](mailto:privacy@puppet.com)
|
|
85
91
|
|
86
92
|
## Installation
|
87
93
|
|
88
|
-
|
89
|
-
|
90
|
-
|
94
|
+
As of Puppetserver 7.5.0, Dropsonde is bundled in as a standard `puppetserver`
|
95
|
+
command. If you're running an older version, you can install it yourself with
|
96
|
+
`gem install dropsonde` or let the
|
97
|
+
[Puppet module](https://github.com/puppetlabs/puppetlabs-dropsonde) manage it
|
98
|
+
for you.
|
91
99
|
|
92
100
|
|
93
101
|
## Configuration
|
@@ -100,11 +108,33 @@ will not report the `:puppetfiles` metrics.
|
|
100
108
|
``` yaml
|
101
109
|
---
|
102
110
|
:update: false
|
103
|
-
:
|
111
|
+
:disable:
|
104
112
|
- puppetfiles
|
105
113
|
```
|
106
114
|
|
107
|
-
The `puppetlabs-dropsonde`
|
115
|
+
The [`puppetlabs-dropsonde`](https://github.com/puppetlabs/puppetlabs-dropsonde)
|
116
|
+
Puppet module manages this configuration for you.
|
117
|
+
|
118
|
+
|
119
|
+
## Scheduled Reporting
|
120
|
+
|
121
|
+
Dropsonde is intended to run on a regular schedule to submit usage reports back
|
122
|
+
to Puppet. The [`puppetlabs-dropsonde`](https://github.com/puppetlabs/puppetlabs-dropsonde)
|
123
|
+
Puppet module will manage this for you, or you can follow the instructions below
|
124
|
+
to configure a schedule manually.
|
125
|
+
|
126
|
+
If you're running Puppetserver 7.5.0 or above, it's already set up so you can
|
127
|
+
simply opt in. Add or update the following stanza of
|
128
|
+
`/etc/puppetlabs/puppetserver/conf.d/puppetserver.conf`:
|
129
|
+
|
130
|
+
``` hocon
|
131
|
+
dropsonde: {
|
132
|
+
enabled: true
|
133
|
+
}
|
134
|
+
```
|
135
|
+
|
136
|
+
If you're running an older version of Puppetserver, then create a cron job that
|
137
|
+
runs `dropsonde submit` once a week.
|
108
138
|
|
109
139
|
|
110
140
|
## Running
|
@@ -137,7 +167,7 @@ Developer comands
|
|
137
167
|
|
138
168
|
## Architecture
|
139
169
|
|
140
|
-
Dropsonde is a simple telemetry probe designed to run as a
|
170
|
+
Dropsonde is a simple telemetry probe designed to run as a scheduled task. It
|
141
171
|
will gather metrics defined by self-contained plugins that each defines its own
|
142
172
|
partial schema and then gathers the data to meet that schema.
|
143
173
|
|
@@ -153,7 +183,8 @@ of modules is updated.
|
|
153
183
|
|
154
184
|
## Limitations
|
155
185
|
|
156
|
-
|
186
|
+
The output format of individual metrics is not yet formally defined. If you write
|
187
|
+
tooling to use it, then make your tooling resilient to changes.
|
157
188
|
|
158
189
|
|
159
190
|
Contact
|
data/bin/dropsonde
CHANGED
@@ -5,6 +5,9 @@ require 'dropsonde'
|
|
5
5
|
class Dropsonde
|
6
6
|
extend GLI::App
|
7
7
|
|
8
|
+
@cache = nil
|
9
|
+
@puppetdb_session = Dropsonde.new
|
10
|
+
|
8
11
|
program_desc 'A simple telemetry tool for Puppet infrastructures'
|
9
12
|
config_file "#{File.dirname(Puppet.settings[:confdir])}/telemetry.yaml"
|
10
13
|
version Dropsonde::VERSION
|
@@ -22,20 +25,26 @@ class Dropsonde
|
|
22
25
|
flag [:ttl], :default_value => 7, :type => Integer
|
23
26
|
|
24
27
|
desc 'List of metrics to omit'
|
25
|
-
flag [:
|
28
|
+
flag [:disable, :d], :type => Array
|
29
|
+
|
30
|
+
desc 'Only load these metrics'
|
31
|
+
flag [:enable, :e], :type => Array
|
26
32
|
|
27
33
|
desc 'Any number or string used to generate the randomized site ID.'
|
28
34
|
flag [:seed]
|
29
35
|
|
36
|
+
desc 'Static site ID'
|
37
|
+
flag [:siteid]
|
38
|
+
|
30
39
|
pre do |global, command, options, args|
|
31
40
|
Dropsonde.settings = global
|
32
|
-
Dropsonde::Cache.
|
41
|
+
@cache = Dropsonde::Cache.new(global[:cachepath], global[:ttl], global[:update])
|
33
42
|
end
|
34
43
|
|
35
44
|
desc 'Manually update the Forge module name cache'
|
36
45
|
command :update do |c|
|
37
46
|
c.action do |global, options, args|
|
38
|
-
|
47
|
+
@cache.update
|
39
48
|
end
|
40
49
|
end
|
41
50
|
|
@@ -52,21 +61,21 @@ class Dropsonde
|
|
52
61
|
c.flag [:format], :default_value => 'human'
|
53
62
|
|
54
63
|
c.action do |global, options, args|
|
55
|
-
|
56
|
-
Dropsonde.generate_report(options[:format])
|
64
|
+
@cache.autoupdate
|
65
|
+
Dropsonde.generate_report(options[:format], @puppetdb_session)
|
57
66
|
end
|
58
67
|
end
|
59
68
|
|
60
69
|
desc 'Submit a telemetry report'
|
61
70
|
command :submit do |c|
|
62
71
|
c.desc 'Telemetry endpoint'
|
63
|
-
c.flag [:endpoint], :default_value => 'https://
|
72
|
+
c.flag [:endpoint], :default_value => 'https://updates.puppet.com'
|
64
73
|
|
65
74
|
c.desc 'Telemetry port'
|
66
75
|
c.flag [:port], :default_value => 443, :type => Integer
|
67
76
|
|
68
77
|
c.action do |global, options, args|
|
69
|
-
|
78
|
+
@cache.autoupdate
|
70
79
|
Dropsonde.submit_report(options[:endpoint], options[:port])
|
71
80
|
end
|
72
81
|
end
|
@@ -102,13 +111,13 @@ class Dropsonde
|
|
102
111
|
This is in jsonl format for direct upload to BigQuery."
|
103
112
|
t.command :example do |c|
|
104
113
|
c.desc 'How many rows to generate'
|
105
|
-
c.flag [:size], :default_value => 100
|
114
|
+
c.flag [:size], :default_value => 100, :type => Integer
|
106
115
|
|
107
116
|
c.desc 'Filename for the output (in jsonl format).'
|
108
117
|
c.flag [:filename], :default_value => 'example.jsonl'
|
109
118
|
|
110
119
|
c.action do |global, options, args|
|
111
|
-
|
120
|
+
@cache.autoupdate
|
112
121
|
Dropsonde.generate_example(options[:size], options[:filename])
|
113
122
|
end
|
114
123
|
end
|
data/lib/dropsonde/cache.rb
CHANGED
@@ -1,34 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'date'
|
2
4
|
require 'json'
|
3
5
|
require 'fileutils'
|
4
6
|
require 'puppet_forge'
|
5
7
|
|
8
|
+
# cache class
|
6
9
|
class Dropsonde::Cache
|
7
|
-
|
10
|
+
@autoupdate = false
|
8
11
|
|
9
|
-
def
|
12
|
+
def initialize(path, ttl, autoupdate)
|
10
13
|
FileUtils.mkdir_p(path)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
if File.file?
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
PuppetForge.user_agent =
|
14
|
+
@path = "#{File.expand_path(path)}/forge.json"
|
15
|
+
@ttl = ttl
|
16
|
+
@autoupdate = autoupdate
|
17
|
+
|
18
|
+
@@cache = if File.file? @path # rubocop:disable Style/ClassVars
|
19
|
+
JSON.parse(File.read(@path))
|
20
|
+
else
|
21
|
+
{
|
22
|
+
'timestamp' => '2000-1-1', # long before any puppet modules were released!
|
23
|
+
'modules' => [],
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
PuppetForge.user_agent = 'Dropsonde Telemetry Client/0.0.1'
|
25
28
|
end
|
26
29
|
|
27
|
-
def
|
30
|
+
def modules
|
28
31
|
@@cache['modules']
|
29
32
|
end
|
30
33
|
|
31
|
-
def
|
34
|
+
def cache
|
35
|
+
@@cache
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.forge_module?(mod)
|
32
39
|
case mod
|
33
40
|
when Puppet::Module
|
34
41
|
modname = mod.forge_slug
|
@@ -39,12 +46,12 @@ class Dropsonde::Cache
|
|
39
46
|
end
|
40
47
|
return unless modname
|
41
48
|
|
42
|
-
modules.include? modname.tr('/','-')
|
49
|
+
@@cache['modules'].include? modname.tr('/', '-')
|
43
50
|
end
|
44
51
|
|
45
|
-
def
|
46
|
-
puts
|
47
|
-
iter = PuppetForge::Module.all(:
|
52
|
+
def update
|
53
|
+
puts 'Updating module cache...'
|
54
|
+
iter = PuppetForge::Module.all(sort_by: 'latest_release')
|
48
55
|
newest = DateTime.parse(@@cache['timestamp'])
|
49
56
|
|
50
57
|
@@cache['timestamp'] = iter.first.updated_at
|
@@ -53,7 +60,7 @@ class Dropsonde::Cache
|
|
53
60
|
# stop once we reach modules we've already cached
|
54
61
|
break if DateTime.parse(iter.first.updated_at) <= newest
|
55
62
|
|
56
|
-
@@cache['modules'].concat
|
63
|
+
@@cache['modules'].concat(iter.map { |mod| mod.slug })
|
57
64
|
|
58
65
|
iter = iter.next
|
59
66
|
print '.'
|
@@ -62,22 +69,19 @@ class Dropsonde::Cache
|
|
62
69
|
@@cache['modules'].sort!
|
63
70
|
@@cache['modules'].uniq!
|
64
71
|
|
65
|
-
File.write(
|
72
|
+
File.write(@path, JSON.pretty_generate(@@cache))
|
66
73
|
end
|
67
74
|
|
68
|
-
def
|
69
|
-
return unless
|
75
|
+
def autoupdate
|
76
|
+
return unless @autoupdate
|
70
77
|
|
71
|
-
unless File.file?
|
72
|
-
puts
|
73
|
-
puts
|
78
|
+
unless File.file? @path
|
79
|
+
puts 'Dropsonde caches a list of all Forge modules to ensure that it only reports'
|
80
|
+
puts 'usage data on public modules. Generating this cache may take some time on'
|
74
81
|
puts "the first run and you'll see your screen fill up with dots."
|
75
82
|
update
|
76
83
|
end
|
77
84
|
|
78
|
-
if (Date.today - File.mtime(
|
79
|
-
update
|
80
|
-
end
|
85
|
+
return update if (Date.today - File.mtime(@path).to_date).to_i > @ttl
|
81
86
|
end
|
82
|
-
|
83
87
|
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# dependencies plugin
|
1
4
|
class Dropsonde::Metrics::Dependencies
|
2
5
|
def self.initialize_dependencies
|
3
6
|
# require any libraries needed here -- no need to load puppet; it's already initialized
|
@@ -5,10 +8,10 @@ class Dropsonde::Metrics::Dependencies
|
|
5
8
|
end
|
6
9
|
|
7
10
|
def self.description
|
8
|
-
<<~
|
11
|
+
<<~DESCRIPTION
|
9
12
|
This group of metrics discovers dependencies between modules in all
|
10
13
|
environments. It will omit dependencies on private modules.
|
11
|
-
|
14
|
+
DESCRIPTION
|
12
15
|
end
|
13
16
|
|
14
17
|
def self.schema
|
@@ -18,23 +21,23 @@ class Dropsonde::Metrics::Dependencies
|
|
18
21
|
{
|
19
22
|
"fields": [
|
20
23
|
{
|
21
|
-
"description":
|
22
|
-
"mode":
|
23
|
-
"name":
|
24
|
-
"type":
|
24
|
+
"description": 'The depended on module name',
|
25
|
+
"mode": 'NULLABLE',
|
26
|
+
"name": 'name',
|
27
|
+
"type": 'STRING',
|
25
28
|
},
|
26
29
|
{
|
27
|
-
"description":
|
28
|
-
"mode":
|
29
|
-
"name":
|
30
|
-
"type":
|
31
|
-
}
|
30
|
+
"description": 'The depended on module version requirement',
|
31
|
+
"mode": 'NULLABLE',
|
32
|
+
"name": 'version_requirement',
|
33
|
+
"type": 'STRING',
|
34
|
+
},
|
32
35
|
],
|
33
|
-
"description":
|
34
|
-
"mode":
|
35
|
-
"name":
|
36
|
-
"type":
|
37
|
-
}
|
36
|
+
"description": 'List of modules that private modules in all environments depend on.',
|
37
|
+
"mode": 'REPEATED',
|
38
|
+
"name": 'dependencies',
|
39
|
+
"type": 'RECORD',
|
40
|
+
},
|
38
41
|
]
|
39
42
|
end
|
40
43
|
|
@@ -42,26 +45,25 @@ class Dropsonde::Metrics::Dependencies
|
|
42
45
|
# run just before generating this metric
|
43
46
|
end
|
44
47
|
|
45
|
-
def self.run
|
48
|
+
def self.run(_puppetdb_session = nil)
|
46
49
|
# return an array of hashes representing the data to be merged into the combined checkin
|
47
|
-
environments = Puppet.lookup(:environments).list.map{|e|e.name}
|
48
|
-
modules = environments.map
|
50
|
+
environments = Puppet.lookup(:environments).list.map { |e| e.name }
|
51
|
+
modules = environments.map { |env|
|
49
52
|
Puppet.lookup(:environments).get(env).modules
|
50
|
-
|
53
|
+
}.flatten
|
51
54
|
|
52
55
|
# we want only PUBLIC modules that PRIVATE modules depend on
|
53
|
-
dependencies = modules.map
|
56
|
+
dependencies = modules.map { |mod|
|
54
57
|
next unless mod.dependencies
|
55
|
-
next if Dropsonde::Cache.
|
58
|
+
next if Dropsonde::Cache.forge_module? mod # skip unless this is a private module
|
56
59
|
|
57
60
|
# and return a list of all public modules it depends on
|
58
|
-
mod.dependencies.select {|
|
59
|
-
|
61
|
+
mod.dependencies.select { |dep| Dropsonde::Cache.forge_module? dep }
|
62
|
+
}.flatten.compact
|
60
63
|
|
61
64
|
[
|
62
|
-
{ :
|
65
|
+
{ dependencies: dependencies },
|
63
66
|
]
|
64
|
-
|
65
67
|
end
|
66
68
|
|
67
69
|
def self.example
|
@@ -69,14 +71,17 @@ class Dropsonde::Metrics::Dependencies
|
|
69
71
|
# make it easier to write data aggregation queries without access to the
|
70
72
|
# actual private data that users have submitted.
|
71
73
|
|
74
|
+
dropsonde_cache = Dropsonde::Cache.new('foo', 7, true)
|
72
75
|
versions = ['>= 1.5.2', '>= 4.3.2', '>= 3.0.0 < 4.0.0', '>= 2.2.1 < 5.0.0', '>= 5.0.0 < 7.0.0', '>= 4.11.0']
|
73
76
|
[
|
74
|
-
:
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
dependencies: dropsonde_cache.modules
|
78
|
+
.sample(rand(250))
|
79
|
+
.map do |item|
|
80
|
+
{
|
81
|
+
name: item,
|
82
|
+
version_requirement: versions.sample,
|
83
|
+
}
|
84
|
+
end,
|
80
85
|
]
|
81
86
|
end
|
82
87
|
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# environments plugin
|
4
|
+
class Dropsonde::Metrics::Environments
|
5
|
+
def self.initialize_environments
|
6
|
+
# Require any libraries needed here -- no need to load puppet or puppetdb;
|
7
|
+
# they're already loaded. This hook is named after the class name.
|
8
|
+
# All plugins are initialized at startup before any metrics are generated.
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.description
|
12
|
+
# This is a Ruby squiggle heredoc; just a multi-line string with indentation removed
|
13
|
+
<<~DESCRIPTION
|
14
|
+
This group of metrics gathers information about environments.
|
15
|
+
DESCRIPTION
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.schema
|
19
|
+
# return an array of hashes of a partial schema to be merged into the complete schema
|
20
|
+
[
|
21
|
+
{
|
22
|
+
"description": 'The number of environments',
|
23
|
+
"mode": 'NULLABLE',
|
24
|
+
"name": 'environment_count',
|
25
|
+
"type": 'INTEGER',
|
26
|
+
},
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.setup
|
31
|
+
# run just before generating this metric
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.run(_puppetdb_session = nil)
|
35
|
+
# return an array of hashes representing the data to be merged into the combined checkin
|
36
|
+
[
|
37
|
+
environment_count: Puppet.lookup(:environments).list.count,
|
38
|
+
]
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.example
|
42
|
+
# this method is used to generate a table filled with randomized data to
|
43
|
+
# make it easier to write data aggregation queries without access to the
|
44
|
+
# actual private data that users have submitted.
|
45
|
+
[
|
46
|
+
environment_count: rand(1..100),
|
47
|
+
]
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.cleanup
|
51
|
+
# run just after generating this metric
|
52
|
+
end
|
53
|
+
end
|