Skip to content

Commit 9034abc

Browse files
Merge branch 'master' into aph/trailing-newline
2 parents 5350c95 + 4e4fc3b commit 9034abc

14 files changed

+525
-25
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,3 +694,6 @@ Style/YodaCondition:
694694
Enabled: false
695695
Style/ZeroLengthPredicate:
696696
Enabled: false
697+
GetText/DecorateString:
698+
Exclude:
699+
- 'files/generate_system_metrics'

README.md

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,27 @@ This module collects metrics provided by the status endpoints of Puppet Enterpri
2929

3030
Install this module with `puppet module install puppetlabs-puppet_metrics_collector` or add it to your Puppetfile.
3131

32-
To activate this module, classify your Primary Master (aka Master of Masters or MoM) with the `puppet_metrics_collector` class using your preferred classification method.
32+
To activate this module, classify your Primary Master (aka Master of Masters or MoM) with the `puppet_metrics_collector` class using your preferred classification method. Below is an example when using the `site.pp`.
3333

3434
```
3535
node 'master.example.com' {
3636
include puppet_metrics_collector
3737
}
3838
```
3939

40+
Optionally, you can also gather some basic system metrics. Unlike the service metrics, this has to be enabled on each host you want metrics from, and the resulting data will be only on that host. Do not include the top level puppet_metrics_collector on anything other than the master as it will collect the same data as the one on the master. This functionality depends on sysstat.
41+
42+
```
43+
node 'master.example.com' {
44+
include puppet_metrics_collector
45+
include puppet_metrics_collector::system
46+
}
47+
48+
node 'compilerA.example.com', 'compilerB.example.com,' {
49+
include puppet_metrics_collector::system
50+
}
51+
```
52+
4053
### Configuration
4154

4255
This module automatically configures the hosts it queries by querying PuppetDB for PE Infrastructure Hosts. If there is an error with automatic configuration of hosts, refer to [Manual Configuration of Hosts](#manual-configuration-of-hosts).
@@ -95,11 +108,18 @@ Optional String: Allows you to override the command that is run to gather metric
95108

96109
### Grepping Metrics
97110

111+
The metrics come in a JSON hash on one line. In order to convert the metric files into a pretty format, they can be processed with `python -m json.tool` like below.
112+
113+
```bash
114+
cd /opt/puppetlabs/puppet-metrics-collector
115+
for i in <service_name>/master.example.com/*.json; do echo "$(python -m json.tool < $i)" > $i; done
116+
```
117+
98118
You can search for useful information by performing a `grep` in the following format, run from inside the directory containing the metrics.
99119

100120
```
101121
cd /opt/puppetlabs/puppet-metrics-collector
102-
grep <metric_name> <service_name>/127.0.0.1/*.json
122+
grep <metric_name> <service_name>/master.example.com/*.json
103123
```
104124

105125
Since the metrics are compressed every night, you can only search metrics for the current day. To search older metrics, decompress the compressed files into a subdirectory of `/tmp` and run from inside that directory.
@@ -110,36 +130,36 @@ Since the metrics are compressed every night, you can only search metrics for th
110130
Example:
111131

112132
```
113-
grep average-free-jrubies puppetserver/127.0.0.1/*.json
114-
puppetserver/127.0.0.1/20170404T170501Z.json: "average-free-jrubies": 0.9950009285369501,
115-
puppetserver/127.0.0.1/20170404T171001Z.json: "average-free-jrubies": 0.9999444653324225,
116-
puppetserver/127.0.0.1/20170404T171502Z.json: "average-free-jrubies": 0.9999993830655706,
133+
grep average-free-jrubies puppetserver/master.example.com/*.json
134+
puppetserver/master.example.com/20170404T170501Z.json: "average-free-jrubies": 0.9950009285369501,
135+
puppetserver/master.example.com/20170404T171001Z.json: "average-free-jrubies": 0.9999444653324225,
136+
puppetserver/master.example.com/20170404T171502Z.json: "average-free-jrubies": 0.9999993830655706,
117137
```
118138

119139
#### Grepping PuppetDB Metrics
120140

121141
Example:
122142

123143
```
124-
grep queue_depth puppetdb/127.0.0.1/*.json
125-
puppetdb/127.0.0.1/20170404T170501Z.json: "queue_depth": 0,
126-
puppetdb/127.0.0.1/20170404T171001Z.json: "queue_depth": 0,
127-
puppetdb/127.0.0.1/20170404T171502Z.json: "queue_depth": 0,
144+
grep queue_depth puppetdb/master.example.com/*.json
145+
puppetdb/master.example.com/20170404T170501Z.json: "queue_depth": 0,
146+
puppetdb/master.example.com/20170404T171001Z.json: "queue_depth": 0,
147+
puppetdb/master.example.com/20170404T171502Z.json: "queue_depth": 0,
128148
```
129149

130150
Example for PE 2016.5 and older:
131151

132152
```
133-
grep Cursor puppetdb/127.0.0.1/*.json
134-
puppetdb/127.0.0.1/20170404T171001Z.json: "CursorMemoryUsage": 0,
135-
puppetdb/127.0.0.1/20170404T171001Z.json: "CursorFull": false,
136-
puppetdb/127.0.0.1/20170404T171001Z.json: "CursorPercentUsage": 0,
137-
puppetdb/127.0.0.1/20170404T171502Z.json: "CursorMemoryUsage": 0,
138-
puppetdb/127.0.0.1/20170404T171502Z.json: "CursorFull": false,
139-
puppetdb/127.0.0.1/20170404T171502Z.json: "CursorPercentUsage": 0,
140-
puppetdb/127.0.0.1/20170404T172002Z.json: "CursorMemoryUsage": 0,
141-
puppetdb/127.0.0.1/20170404T172002Z.json: "CursorFull": false,
142-
puppetdb/127.0.0.1/20170404T172002Z.json: "CursorPercentUsage": 0,
153+
grep Cursor puppetdb/master.example.com/*.json
154+
puppetdb/master.example.com/20170404T171001Z.json: "CursorMemoryUsage": 0,
155+
puppetdb/master.example.com/20170404T171001Z.json: "CursorFull": false,
156+
puppetdb/master.example.com/20170404T171001Z.json: "CursorPercentUsage": 0,
157+
puppetdb/master.example.com/20170404T171502Z.json: "CursorMemoryUsage": 0,
158+
puppetdb/master.example.com/20170404T171502Z.json: "CursorFull": false,
159+
puppetdb/master.example.com/20170404T171502Z.json: "CursorPercentUsage": 0,
160+
puppetdb/master.example.com/20170404T172002Z.json: "CursorMemoryUsage": 0,
161+
puppetdb/master.example.com/20170404T172002Z.json: "CursorFull": false,
162+
puppetdb/master.example.com/20170404T172002Z.json: "CursorPercentUsage": 0,
143163
```
144164

145165

@@ -171,14 +191,14 @@ Example:
171191

172192
```
173193
/opt/puppetlabs/puppet-metrics-collector/puppetserver
174-
├── 127.0.0.1
194+
├── master.example.com
175195
│   ├── 20170404T020001Z.json
176196
│   ├── ...
177197
│ ├── 20170404T170501Z.json
178198
│ └── 20170404T171001Z.json
179199
└── puppetserver-2017.04.04.02.00.01.tar.bz2
180200
/opt/puppetlabs/puppet-metrics-collector/puppetdb
181-
└── 127.0.0.1
201+
└── master.example.com
182202
│ ├── 20170404T020001Z.json
183203
│ ├── ...
184204
│ ├── 20170404T170501Z.json
@@ -316,13 +336,13 @@ If the future parser is enabled, globally or in the environment, the following c
316336

317337
```
318338
class { 'puppet_metrics_collector':
319-
output_dir => '/opt/puppet/puppet_metrics_collector'
339+
output_dir => '/opt/puppet/puppet-metrics-collector'
320340
}
321341
```
322342

323343
Otherwise, use the following commands.
324344

325345
```
326346
puppet module install puppetlabs-puppet_metrics_collector --modulepath /tmp;
327-
puppet apply -e "class { 'puppet_metrics_collector' : output_dir => '/opt/puppet/puppet_metrics_collector' }" --modulepath /tmp --parser=future
347+
puppet apply -e "class { 'puppet_metrics_collector' : output_dir => '/opt/puppet/puppet-metrics-collector' }" --modulepath /tmp --parser=future
328348
```

0 commit comments

Comments
 (0)