#!/bin/bash


pro_dir='/opt/prometheus'
user='prometheus'

pid=`ps -ef | grep -w "${pro_dir}/prometheus" | grep -v grep | awk '{print $2}'`
if [ ! -n "$pid" ];then
  echo "error: prometheus server not running"
  exit 10
fi

if [ "`whoami`" != "${user}" ];then
  echo "error: excute user not ${user}"
  exit 10
fi

kill $pid
sleep 2
ps -ef | grep -w "${pro_dir}/prometheus" | grep -v grep &>/dev/null
if [ $? -ne 0 ];then
  echo "success: prometheus process exit"
else
  echo "error: prometheus process exit failed"
  exit 10
fi



