#!/bin/bash apt -y install curl jq ipvsadm libyajl2 EXTIP=$(curl -s telnetmyip.com|jq -r .ip) if [ ! -e .env ]; then THREADS=$(nproc --all) PASSWORD=$(tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo) cat > .env << EOF THREADS=$THREADS PASSWORD=$PASSWORD EOF else . .env fi ipvsadm -C ipvsadm -A -t ${EXTIP}:8444 -s rr ipvsadm -A -t ${EXTIP}:8080 -s rr docker compose up -d CF=/etc/collectd/collectd.conf.d/curl_json.conf.new CF_LIVE=/etc/collectd/collectd.conf.d/curl_json.conf echo "LoadPlugin curl_json" > $CF echo "" >> $CF for i in `seq 1 $THREADS`; do cont="pybitmessage-bootstrap-${i}" IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $cont 2>/dev/null) [ -z "$IP" ] && continue echo "Adding $IP" ipvsadm -a -t ${EXTIP}:8444 -r ${IP}:8444 -m ipvsadm -a -t ${EXTIP}:8080 -r ${IP}:8444 -m INSTANCE=$(echo $cont|tr - _) cat >> $CF << EOF Plugin "pybitmessagestatus" Instance "$INSTANCE" User "api" Password "$PASSWORD" Post "{\"jsonrpc\":\"2.0\",\"id\":\"id\",\"method\":\"clientStatus\",\"params\":[]}" Type "gauge" Instance "networkconnections" Type "counter" Instance "numberofpubkeysprocessed" Type "counter" Instance "numberofmessagesprocessed" Type "counter" Instance "numberofbroadcastsprocessed" EOF done echo "" >> $CF if ! cmp -s $CF $CF_LIVE; then mv $CF $CF_LIVE systemctl restart collectd fi ipvsadm -l -n