Environment

  • Shell name
SHELL_NAME=${0##*/}
SHELL_NAME=${SHELL_NAME%.*}
  • Execute directory
DIR="$( cd "$( dirname "${0}" )" >/dev/null 2>&1 && pwd )"

Prometheus(PUSHING METRICS)

monitor()
{
  local MONITOR_DATA="
# TYPE some_shell gauge\n
# HELP some_shell this is some shell.\n
some_shell"

  echo  -e  "${MONITOR_DATA} ${1}" | curl -sS -X POST --data-binary @- http://PrometheusPushgateway:9091/metrics/job/${SHELL_NAME}/instance/SomeHostName
}