#!/bin/bash


host=127.0.0.1
port=19090

read -p 'please enter user: ' user
read -s -p 'please enter password' pass
echo ''

if [ -n "$user" ] && [ -n "$pass" ];then
  authorize="-u ${user}:${pass}"
fi

curl ${authorize} -XPOST http://${host}:${port}/-/reload
if [ $? -eq 0 ];then
  echo "success: prometheus server reload"
else
  echo "error: prometheus server reload failed"
fi
