Browse Source

Added a node_exporter role initially built for...

peregrine.
feature/molgenis-ssl
Egon Rijpkema 5 years ago
parent
commit
2ec22760af
  1. 5
      node_exporter.yml
  2. 22
      promtools/Dockerfile
  3. 34
      promtools/addport.py
  4. 6
      promtools/build.sh
  5. BIN
      promtools/client
  6. BIN
      promtools/proxy
  7. 36
      roles/node_exporter/tasks/main.yml
  8. 16
      roles/node_exporter/templates/node-exporter.service

5
node_exporter.yml

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
---
- hosts: all
become: True
roles:
- node_exporter

22
promtools/Dockerfile

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
FROM golang:1.9-stretch
MAINTAINER Egon Rijpkema <e.m.a.rijpkema@rug.nl>
RUN mkdir /results
RUN go get github.com/prometheus/node_exporter && \
cd ${GOPATH-$HOME/go}/src/github.com/prometheus/node_exporter && \
make && \
cp node_exporter /results
RUN go get github.com/robustperception/pushprox/proxy && \
cd ${GOPATH-$HOME/go}/src/github.com/robustperception/pushprox/proxy && \
go build && \
cp /go/bin/proxy /results
RUN go get github.com/robustperception/pushprox/client && \
cd ${GOPATH-$HOME/go}/src/github.com/robustperception/pushprox/client && \
go build && \
cp /go/bin/client /results
CMD /go/bin/proxy

34
promtools/addport.py

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
#!/usr/bin/env python3
'''
Pushprox: does not include the port number in its targets json
on the /clients endpoint. while Prometheus does seem to need it.
for more info see: https://github.com/RobustPerception/PushProx
'''
import json
from urllib import request
url = 'http://knyft.hpc.rug.nl:6060/clients'
outfile = 'targets.json'
data = json.loads(request.urlopen(url).read().decode('utf-8'))
targets = []
for node in data:
for target in node['targets']:
if target[-5:] != '9100':
target = '{}:9100'.format(target)
targets.append(target)
with open(outfile, 'w') as handle:
handle.write(json.dumps(
[{
"targets" : targets,
"labels": {
"env": "peregrine",
"job": "node"
}
}]
,indent=4 ))

6
promtools/build.sh

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
#!/bin/bash -ex
mkdir -p results
docker build . -t promtools
docker run -d --name promtools --rm promtools sleep 3
docker cp promtools:/results .

BIN
promtools/client

Binary file not shown.

BIN
promtools/proxy

Binary file not shown.

36
roles/node_exporter/tasks/main.yml

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
---
- file:
path: /usr/local/prometheus
state: directory
mode: 0755
- name: Install node exporter
copy:
src: "{{ playbook_dir }}/promtools/results/node_exporter"
dest: /usr/local/prometheus/node_exporter
mode: 0755
- name: Install service files.
template:
src: templates/node-exporter.service
dest: /etc/systemd/system/node-exporter.service
mode: 644
owner: root
group: root
tags:
- service-files
- name: install service files
command: systemctl daemon-reload
- name: enable service at boot
systemd:
name: node-exporter
enabled: yes
- name: make sure servcies are started.
systemd:
name: node-exporter.service
state: restarted
tags:
- start-service

16
roles/node_exporter/templates/node-exporter.service

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
[Unit]
Description=prometheus node exporter
[Service]
TimeoutStartSec=0
Restart=always
ExecStart=/usr/local/prometheus/node_exporter \
--collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)" \
{% if 'login' in role_names %}
--collector.filesystem.ignored-fs-types="^(sys|proc|auto|cgroup|devpts|ns|au|fuse\.lxc|mqueue|overlay)(fs|)$$"
{% else %}
--collector.filesystem.ignored-fs-types="^(sys|proc|auto|cgroup|devpts|ns|au|fuse\.lxc|mqueue|overlay|lustre)(fs|)$$"
{% endif %}
[Install]
WantedBy=multi-user.target