Skip to content

Commit

Permalink
Merge pull request #25 from idealista/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
dortegau authored Feb 22, 2018
2 parents 1d8c649 + 8a8ee84 commit 18a4eef
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 18 deletions.
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# jmx_exporter-role changelog
# prometheus_jmx_exporter-role changelog

All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a changelog](https://github.com/olivierlacan/keep-a-changelog).


## [Unreleased](https://github.com/idealista/prometheus_jmx_exporter-role/tree/develop)

## [1.5.0](https://github.com/idealista/prometheus_jmx_exporter-role/tree/1.5.0)
[Full Changelog](https://github.com/idealista/prometheus_jmx_exporter-role/compare/1.4.0...1.5.0)
### Added
- *[#23](https://github.com/idealista/prometheus_jmx_exporter-role/issues/23) JMX Exporter classpath is now configurable* @dortegau

## [1.4.0](https://github.com/idealista/prometheus_jmx_exporter-role/tree/1.4.0)
[Full Changelog](https://github.com/idealista/prometheus_jmx_exporter-role/compare/1.3.1...1.4.0)
### Added
Expand Down Expand Up @@ -35,8 +40,8 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a ch
## [1.1.1](https://github.com/idealista/prometheus_jmx_exporter-role/tree/1.1.1)
[Full Changelog](https://github.com/idealista/prometheus_jmx_exporter-role/compare/1.1.0...1.1.1)
### Added
- *[PLATFORM-303](http://jira.sys.idealista/browse/PLATFORM-303) Exporter refactor* @jmonterrubio
- *Exporter refactor* @jmonterrubio

## [1.1.0](https://github.com/idealista/prometheus_jmx_exporter-role/tree/1.1.0)
### Added
- *[PLATFORM-162](http://jira.sys.idealista/browse/PLATFORM-162) Utilizar systemd con ansible, reducir el número de métricas que generamos para java y tomcat*
- *Using Systemd, decreasing the number of metrics generated for Java & Tomcat*
21 changes: 17 additions & 4 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,26 @@ jmx_exporter_service_enabled: True
jmx_exporter_service_state: started

# Files & Paths
jmx_exporter_root_path: /opt/jmx_exporter
jmx_exporter_conf_path: /etc/jmx_exporter
jmx_exporter_log_path: /var/log/jmx_exporter
jmx_exporter_root_directory: /opt/jmx_exporter

jmx_exporter_jar_path: "{{ jmx_exporter_root_directory }}/{{ jmx_exporter_jar_file }}"

jmx_exporter_conf_directory: /etc/jmx_exporter
jmx_exporter_conf_file: "jmx_config.yml"
jmx_exporter_conf_path: "{{ jmx_exporter_conf_directory }}/{{ jmx_exporter_conf_file }}"

jmx_exporter_log_directory: /var/log/jmx_exporter
jmx_exporter_log_file: "jmx_exporter.log"
jmx_exporter_log_path: "{{ jmx_exporter_log_directory }}/{{ jmx_exporter_log_file }}"

jmx_exporter_classpath_entries: []
# - jar_path_1
# - jar_path_2
# - ...

jmx_exporter_config_template_path: "{{ playbook_dir }}/templates/jmx_exporter/config"

# Port & path
# Ports
jmx_exporter_port: 9110
jmx_exporter_internal_port: 5555

Expand Down
2 changes: 1 addition & 1 deletion tasks/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- name: JMX_EXPORTER | Copy exporter config
template:
src: "{{ item }}"
dest: "{{ jmx_exporter_conf_path }}/jmx_config.yml"
dest: "{{ jmx_exporter_conf_path }}"
owner: "{{ jmx_exporter_user }}"
group: "{{ jmx_exporter_group }}"
mode: 0640
Expand Down
12 changes: 6 additions & 6 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
group: "{{ jmx_exporter_user }}"
state: directory
with_items:
- "{{ jmx_exporter_root_path }}"
- "{{ jmx_exporter_conf_path }}"
- "{{ jmx_exporter_log_path }}"
- "{{ jmx_exporter_root_directory }}"
- "{{ jmx_exporter_conf_directory }}"
- "{{ jmx_exporter_log_directory }}"

- name: JMX_EXPORTER | Download binary
get_url:
Expand All @@ -33,7 +33,7 @@
- name: JMX_EXPORTER | Copy binary
copy:
src: "/tmp/{{ jmx_exporter_bin_name }}"
dest: "{{ jmx_exporter_root_path }}/{{ jmx_exporter_bin_name }}"
dest: "{{ jmx_exporter_root_directory }}/{{ jmx_exporter_bin_name }}"
owner: "{{ jmx_exporter_user }}"
group: "{{ jmx_exporter_group }}"
remote_src: True
Expand All @@ -42,8 +42,8 @@

- name: JMX_EXPORTER | Link binary
file:
src: "{{ jmx_exporter_root_path }}/{{ jmx_exporter_bin_name }}"
dest: "{{ jmx_exporter_root_path }}/jmx_exporter.jar"
src: "{{ jmx_exporter_root_directory }}/{{ jmx_exporter_bin_name }}"
dest: "{{ jmx_exporter_jar_path }}"
state: link

- name: JMX_EXPORTER | Copy Daemon script
Expand Down
7 changes: 5 additions & 2 deletions templates/jmx_exporter.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ Environment='JAVA_OPTS=-Djava.awt.headless=true \
{% endif %}'

Environment='JAVA_MEM=-Xmx{{ jmx_exporter_xmx }} -Xms{{ jmx_exporter_xms }}'
ExecStart=/bin/sh -c "/usr/bin/java $JAVA_OPTS $JAVA_MEM -jar {{ jmx_exporter_root_path }}/jmx_exporter.jar {{ jmx_exporter_port }} {{ jmx_exporter_conf_path }}/jmx_config.yml > {{ jmx_exporter_log_path }}/{{ jmx_exporter_log_file }} 2>&1"
ExecStart=/bin/sh -c "/usr/bin/java $JAVA_OPTS $JAVA_MEM \
-cp {{ ([jmx_exporter_jar_path] + jmx_exporter_classpath_entries)|join(":") }} {{ jmx_exporter_main_class }} \
{{ jmx_exporter_port }} {{ jmx_exporter_conf_path }} \
> {{ jmx_exporter_log_path }} 2>&1"
ExecStartPost=/bin/sh -c "echo $MAINPID > /run/jmx_exporter/jmx_exporter.pid"
ExecReload=/bin/kill -HUP $MAINPID
WorkingDirectory={{ jmx_exporter_root_path }}
WorkingDirectory={{ jmx_exporter_root_directory }}
PIDFile=/run/jmx_exporter/jmx_exporter.pid
KillSignal=SIGTERM
SuccessExitStatus=143
Expand Down
2 changes: 1 addition & 1 deletion templates/logrotate.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ jmx_exporter_log_path }}/{{ jmx_exporter_log_file }} {
{{ jmx_exporter_log_path }} {
daily
sharedscripts
notifempty
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_jmx_exporter_user(User, Group, AnsibleDefaults):


def test_jmx_exporter_conf(File, AnsibleDefaults):
jmx_exporter_config = File(AnsibleDefaults["jmx_exporter_conf_path"] + "/jmx_config.yml")
jmx_exporter_config = File(AnsibleDefaults["jmx_exporter_conf_path"])
assert jmx_exporter_config.is_file
assert jmx_exporter_config.group == AnsibleDefaults["jmx_exporter_group"]
assert jmx_exporter_config.user == AnsibleDefaults["jmx_exporter_user"]
Expand Down
3 changes: 3 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

jmx_exporter_bin_name: "jmx_prometheus_httpserver-{{ jmx_exporter_version }}-jar-with-dependencies.jar"
jmx_exporter_url: "https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_httpserver/{{ jmx_exporter_version }}/{{ jmx_exporter_bin_name }}"

jmx_exporter_jar_file: "jmx_exporter.jar"
jmx_exporter_main_class: "io.prometheus.jmx.WebServer"

0 comments on commit 18a4eef

Please sign in to comment.