Added endlessh collection script

main
WhatTheMike 2 years ago
parent 2504800429
commit 9cf1463a75

@ -47,3 +47,21 @@
state: present state: present
become: true become: true
become_method: sudo become_method: sudo
####- endlessh monitoring script
- name: Verify certificate script is deployed
ansible.builtin.template:
dest: /opt/sublight/scripts/collect-endlesshdata.sh
src: ~/ansible/templates/collect-endlesshdata.sh.j2
mode: '0744'
- name: Ensure cert monitoring script is scheduled
ansible.builtin.cron:
name: "Poll endlessh data"
minute: "*"
job: "/opt/sublight/scripts/collect-endlesshdata.sh"
user: root
state: present
become: true
become_method: sudo

@ -6,8 +6,8 @@
influx_host="{{ influx_host }}" influx_host="{{ influx_host }}"
influx_path="/api/v2/write" influx_path="/api/v2/write"
influx_org="{{ influx_org }}" influx_org="{{ influx_org }}"
influx_bucket="{{ influx_bucket }}" influx_bucket="{{ influx_bucket_cert }}"
influx_token="{{ influx_token }}" influx_token="{{ influx_token_cert }}"
influx_metric="certificate" influx_metric="certificate"
domains=({% for dns in certificate_monitor_domains %}"{{dns}}" {% endfor %}) domains=({% for dns in certificate_monitor_domains %}"{{dns}}" {% endfor %})

@ -0,0 +1,26 @@
#!/bin/bash
# Recommended crontab:
# * * * * * /path/to/collect-certdata.sh
influx_host="{{ influx_host }}"
influx_path="/api/v2/write"
influx_org="{{ influx_org }}"
influx_bucket="{{ influx_bucket_endlessh }}"
influx_token="{{ influx_token_endlessh }}"
influx_metric="endlessh"
endless_hosts=({% for endless_host in endlessh_hostnames %}"{{endless_host}}" {% endfor %})
# https://aperture.dismyserver.net/.endlessh.stats.html
influx_url="${influx_host}${influx_path}?org=${influx_org}&bucket=${influx_bucket}"
influx_header_auth="Authorization: Token ${influx_token}"
influx_header_content="Content-Type: text/plain; charset=utf-8"
influx_header_accept="Accept: application/json"
for endless_host in ${endless_hosts[@]}; do
endless_stats="$(curl -s https://${endless_host}/.endlessh.stats.html)"
endless_active="$(echo ${endless_stats} | cut -d/ -f1)"
endless_total="$(echo ${endless_stats} | cut -d/ -f2)"
data="${influx_metric},host=${endless_host} active=${endless_active}i,total=${endless_total}i"
curl --request POST "${influx_url}" --header "${influx_header_auth}" --header "${influx_header_content}" --header "${influx_header_accept}" --data-binary "${data}"
done
Loading…
Cancel
Save