Simple Grafana-Prometheus exporter to ping Servers
On your workstation check-out this repo, cd
into it and execute the following commands:
sudo apt update; sudo apt install python3 virtualenv direnv
virtualenv -p /usr/bin/python3 venv
venv/bin/pip install -r requirements.txt
venv/bin/pre-commit install
sed -nr '/direnv hook bash/!p;$aeval "\$(direnv hook bash)"' -i ~/.bashrc
source ~/.bashrc
echo -e "source venv/bin/activate\nunset PS1" > .envrc
direnv allow
sudo docker buildx create --name multi-arch --platform "linux/arm64,linux/amd64,linux/arm/v7" --driver "docker-container"
sudo docker buildx use multi-arch
sudo docker buildx inspect --bootstrap
The easiest way to start the exporter via docker, like shown in the example docker-compose.yml
You just need one instance of this exporter to ping a bunch of hosts, as shown in the following Prometheus example:
scrape_configs:
- job_name: 'ping'
static_configs:
- targets: ['192.168.1.1']
labels:
server: 'router'
- targets: ['192.168.1.2']
labels:
server: 'dns'
- targets: ['192.168.1.3']
labels:
server: 'switch'
metrics_path: /ping
relabel_configs:
- source_labels: [__address__]
target_label: __param_host
- source_labels: [__param_host]
target_label: instance
- target_label: __address__
replacement: 192.168.1.7:8080 # The ping exporter's real hostname:port