#!/bin/bash
if [ $# -lt 1 ]; then
    echo usage: $0 gpu_hostname1 gpu_hostname2 ...
    exit 1
fi

if [ -z $CB_ENVDIR ]; then
    echo AIP environment not found. Exit.
    exit 1
fi

echo '- job_name: "dcgm-exporter"' 
echo '  scrape_interval: 5s'
echo '  scrape_timeout: 5s'
echo '  static_configs:'

for host in $@; do
    ip=$(grep $host $CB_ENVDIR/hosts | awk '{print $1}')
    if [ _$ip == '_' ]; then
        continue
    fi
    echo '  - targets: ["'$ip':9400"]'
    echo '    lablels:'
    echo '      hostname:' $host
done
