123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #!/usr/bin/env bash
- set +u
- set -e
- # set -x
- base_dir=$(
- cd "$(dirname "$0")"
- pwd
- )
- cd $base_dir
- # ./auto_del_log.sh
- function log_warn() {
- local date=$(date "+%Y-%m-%d-%H:%M:%S")
- local para=$1
- echo "[WARN] $date $1" | tee -a "./log/run_log"
- }
- function log_info() {
- local date=$(date "+%Y-%m-%d-%H:%M:%S")
- local para=$1
- echo "[INFO] $date $1" | tee -a "./log/run_log"
- }
- function log_err() {
- local date=$(date "+%Y-%m-%d-%H:%M:%S")
- local para=$1
- echo "[ERROR] $date $1" | tee -a "./log/run_log"
- }
- prometheuslog_path="./log/prometheus/"
- # prometheus section
- if ps -auxc | grep "prometheus" | grep -v grep > /dev/null; then
- log_info "prometheus 已在运行"
- elif [[ ! -f "./lib/prometheus" ]]; then
- log_info "no prometheus found, skip"
- else
- if [[ ! -d $prometheuslog_path ]]; then
- mkdir "$prometheuslog_path"
- fi
- log_prometheus_file="prometheus_$(date "+%Y-%m-%d-%H:%M:%S").log"
- ./lib/prometheus --config.file=prometheus.yml --web.listen-address=:9990 --web.enable-lifecycle &>> "${prometheuslog_path}${log_prometheus_file}" &
- sleep 1
- if grep -E 'cannot|not defined|License does not exist' "${prometheuslog_path}${log_prometheus_file}" >> /dev/null; then
- log_err "prometheus 启动遇到问题,请检查${log_exporter_file}"
- else
- log_info "prometheus 启动成功!"
- fi
- fi
- alertmanagerlog_path="./log/alertmanager/"
- # alertmanager section
- if ps -auxc | grep "alertmanager" | grep -v grep > /dev/null; then
- log_info "alertmanager 已在运行"
- elif [[ ! -f "./lib/alertmanager" ]]; then
- log_info "no alertmanager found, skip"
- else
- if [[ ! -d $alertmanagerlog_path ]]; then
- mkdir "$alertmanagerlog_path"
- fi
- log_alertmanager_file="alertmanager_$(date "+%Y-%m-%d-%H:%M:%S").log"
- ./lib/alertmanager --config.file=alertmanager.yml --web.listen-address=:9993 &>> "${alertmanagerlog_path}${log_alertmanager_file}" &
- sleep 1
- if grep -E 'cannot|not defined|License does not exist' "${alertmanagerlog_path}${log_alertmanager_file}" >> /dev/null; then
- log_err "alertmanager 启动遇到问题,请检查${log_alertmanager_file}"
- else
- log_info "alertmanager 启动成功!"
- fi
- fi
- #dingtalklog_path="./log/dingtalk/"
- ## dingtalk section
- #if ps -auxc | grep "dingtalk" | grep -v grep > /dev/null; then
- # log_info "dingtalk 已在运行"
- #elif [[ ! -f "./lib/dingtalk" ]]; then
- # log_info "no dingtalk found, skip"
- #else
- #
- # if [[ ! -d $dingtalklog_path ]]; then
- # mkdir "$dingtalklog_path"
- # fi
- #
- # log_dingtalk_file="dingtalk_$(date "+%Y-%m-%d-%H:%M:%S").log"
- # ./lib/dingtalk --config.file=dingtalk.yml --web.listen-address=:9994 --web.enable-ui &>> "${dingtalklog_path}${log_dingtalk_file}" &
- # sleep 1
- # if grep -E 'cannot|not defined|License does not exist' "${dingtalklog_path}${log_dingtalk_file}" >> /dev/null; then
- # log_err "dingtalk 启动遇到问题,请检查${log_dingtalk_file}"
- # else
- # log_info "dingtalk 启动成功!"
- # fi
- #fi
|