Skip to content

Commit

Permalink
added ping-exporter role
Browse files Browse the repository at this point in the history
  • Loading branch information
acjohnson committed May 4, 2021
1 parent a5a0de1 commit 95e3211
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
4 changes: 4 additions & 0 deletions playbook_ping_exporter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- hosts: all
roles:
- ping_exporter
3 changes: 3 additions & 0 deletions roles/ping_exporter/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
ping_exporter_download_url: https://raw.githubusercontent.com/frankiexyz/ping-exporter/master/ping-exporter.py
ping_exporter_checksum: sha256:0e70e1cdd6c82155b11a71486bde6657b733f3479ffaf428ea4a6a0760ca5aec
44 changes: 44 additions & 0 deletions roles/ping_exporter/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
- block:
- name: Download ping_exporter into /opt
get_url:
url: "{{ ping_exporter_download_url }}"
dest: /opt
mode: '0755'
checksum: "{{ ping_exporter_checksum }}"

- name: Install fping
package:
name: fping
state: latest

- name: Create ping_exporter user
user:
name: ping_exporter
shell: /sbin/nologin
state: present

- name: Copy the ping_exporter systemd unit file
template:
src: ping_exporter.service.j2
dest: /etc/systemd/system/ping_exporter.service
mode: 0644

- name: Reload systemd daemon if unit file is changed.
systemd:
daemon_reload: true

- name: Ensure ping_exporter is running and enabled
service:
name: ping_exporter
enabled: yes
state: restarted

- name: Verify node_exporter is responding to requests.
uri:
url: http://127.0.0.1:8085/?target=127.0.0.1"
return_content: true
register: metrics_output
failed_when: "'ping_min' not in metrics_output.content"

become: true
10 changes: 10 additions & 0 deletions roles/ping_exporter/templates/ping_exporter.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Ping Exporter for Prometheus (Created By Frankie)
After=multi-user.target

[Service]
Type=idle
ExecStart=/usr/bin/python /opt/ping-exporter.py

[Install]
WantedBy=multi-user.target

0 comments on commit 95e3211

Please sign in to comment.