escape command from the ssh connexion node exporter
This commit is contained in:
parent
2a77b24fac
commit
a1666d9254
|
|
@ -7,27 +7,28 @@ if [[ -n "$RECEIVING_IP" && -n "$RECEIVING_USER" && -n "$RECEIVING_PORT" ]]; the
|
||||||
ufw allow $node_exporter_port
|
ufw allow $node_exporter_port
|
||||||
|
|
||||||
node_exporter_version="1.8.1"
|
node_exporter_version="1.8.1"
|
||||||
wget https://github.com/prometheus/node_exporter/releases/download/v${node_exporter_version}/node_exporter-${node_exporter_version}.linux-amd64.tar.gz
|
wget https://github.com/prometheus/node_exporter/releases/download/v${node_exporter_version}/node_exporter-${node_exporter_version}.linux-amd64.tar.gz -P /root/
|
||||||
tar tar xvfz node_exporter-*.*-amd64.tar.gz
|
tar xvfz /root/node_exporter-*.*-amd64.tar.gz -C /root/
|
||||||
rm node_exporter-*.*-amd64.tar.gz
|
rm /root/node_exporter-*.*-amd64.tar.gz
|
||||||
|
|
||||||
install_pkg tmux
|
install_pkg tmux
|
||||||
tmux new-session -d -s node-exporter
|
tmux new-session -d -s node-exporter
|
||||||
tmux send-keys -t node-exporter "cd node_exporter-*.*-amd64 && ./node_exporter" C-m
|
tmux send-keys -t node-exporter "cd node_exporter-*.*-amd64 && ./node_exporter" C-m
|
||||||
|
|
||||||
get_ip
|
get_ip
|
||||||
|
# si l'url est pas set set l'url
|
||||||
|
|
||||||
ssh -p $RECEIVING_PORT $RECEIVING_USER@$RECEIVING_IP << EOF
|
ssh -p $RECEIVING_PORT $RECEIVING_USER@$RECEIVING_IP << EOF
|
||||||
if command -v yq >/dev/null 2>&1; then
|
if command -v yq >/dev/null 2>&1; then
|
||||||
cd prometheus/prometheus
|
cd prometheus/prometheus
|
||||||
|
|
||||||
if [ -z "$(yq '.scrape_configs[] | select(.job_name == "node-exporter") | .static_configs[] | select(.targets[] == "${ip}:${node_exporter_port}")' prometheus.yml)" ]; then
|
if [ -z "\$(yq '.scrape_configs[] | select(.job_name == "node-exporter") | .static_configs[] | select(.targets[] == "${ip}:${node_exporter_port}")' prometheus.yml)" ]; then
|
||||||
yq '(.scrape_configs[] | select(.job_name == "node-exporter") | .static_configs) += [{"targets": ["${ip}:${node_exporter_port}"]}]' prometheus.yml -y > prometheus.temp.yml && mv prometheus.temp.yml prometheus.yml
|
yq '(.scrape_configs[] | select(.job_name == "node-exporter") | .static_configs) += [{"targets": ["${ip}:${node_exporter_port}"]}]' prometheus.yml -y > prometheus.temp.yml && mv prometheus.temp.yml prometheus.yml
|
||||||
else
|
else
|
||||||
echo "the node exporter config is already operational"
|
echo "the node exporter config is already operational"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$(yq '.scrape_configs[] | select(.job_name == "blackbox-http") | .static_configs[] | select(.targets[] == "https://${DOMAIN_NAME}")' prometheus.yml)" ]; then
|
if [ -z "\$(yq '.scrape_configs[] | select(.job_name == "blackbox-http") | .static_configs[] | select(.targets[] == "https://${DOMAIN_NAME}")' prometheus.yml)" ]; then
|
||||||
yq '(.scrape_configs[] | select(.job_name == "blackbox-http") | .static_configs) += [{"targets": ["https://${DOMAIN_NAME}"]}]' prometheus.yml -y > prometheus.temp.yml && mv prometheus.temp.yml prometheus.yml
|
yq '(.scrape_configs[] | select(.job_name == "blackbox-http") | .static_configs) += [{"targets": ["https://${DOMAIN_NAME}"]}]' prometheus.yml -y > prometheus.temp.yml && mv prometheus.temp.yml prometheus.yml
|
||||||
else
|
else
|
||||||
echo "the html prober config is already operational"
|
echo "the html prober config is already operational"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue