You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/templates/collect-endlesshdata.sh.j2

27 lines
1.2 KiB

#!/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