grafana搭建

Posted itsre

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了grafana搭建相关的知识,希望对你有一定的参考价值。

搭建环境

前置条件

操作系统版本:

Linux: /etc/issus

解压安装即可

#!/bin/bash
#-------------CopyRight-------------  
#   Name:Grafana start \\ stop script  
#   Version Number:V1.0
#   Type:online  
#   Language:bash shell  
#   Date:2018-03-14  
#   Author: zhangquan
#   Email:   
#------------Environment------------  
#   Terminal: column 80 line 24  
#   Linux 2.6.32-431.el6.x86_64  
#   GNU Bash 4.1.2  
#----------------------------------- 
    
# The working directory
# GRAFANA_HOME=$(cd `dirname $0`; pwd)
GRAFANA_HOME=/opt/grafana

PATH=/bin:/usr/bin:/sbin:/usr/sbin
NAME=grafana-server
DESC="Grafana Server"

CONF_DIR=${GRAFANA_HOME}/conf
WORK_DIR=${GRAFANA_HOME}
DATA_DIR=${GRAFANA_HOME}/data
PLUGINS_DIR=${GRAFANA_HOME}/plugins
LOG_DIR=${GRAFANA_HOME}/log
CONF_FILE=${CONF_DIR}/grafana.ini
MAX_OPEN_FILES=10000
PID_FILE_DIR=${GRAFANA_HOME}/var
PID_FILE=${PID_FILE_DIR}/$NAME.pid
DAEMON=${GRAFANA_HOME}/bin/$NAME
PID=""
FAIL="\\e[1;31m"
SUCC="\\e[1;32m"
END="\\033[0m"
TRUE=/bin/true
FALSE=/bin/false

if [ ! -x $DAEMON ]; then
  echo "Program not installed or not executable"
  exit 5
fi

#
# Source function library.
#
if [ -f /etc/init.d/functions ]; then
    . /etc/init.d/functions
    
fi

DAEMON_OPTS="--pidfile=${PID_FILE} --config=${CONF_FILE} cfg:default.paths.data=${DATA_DIR} cfg:default.paths.logs=${LOG_DIR} cfg:default.paths.plugins=${PLUGINS_DIR}"

function isRunning() {
  status -p $PID_FILE $NAME > /dev/null 2>&1
}

case "$1" in
  start)
    #action $"Starting $DESC: .... " $TRUE

    isRunning
    if [ $? -eq 0 ]; then
      action "$DESC Already running."    $FALSE
      exit 0
    fi

    # Prepare environment
    mkdir -p "$LOG_DIR"
    mkdir -p "$DATA_DIR" 
    mkdir -p "$PID_FILE_DIR"
    touch "$PID_FILE" 

    if [ -n "$MAX_OPEN_FILES" ]; then
      ulimit -n $MAX_OPEN_FILES
    fi

    # Start Daemon
    cd $GRAFANA_HOME
    nohup ${DAEMON} ${DAEMON_OPTS} >> /dev/null 2>&1 &
    return=$?
    if [ $return -eq 0 ]
    then
      sleep 1
      # check if pid file has been written two
      if ! [[ -s $PID_FILE ]]; then
        action "FAILED" $FAILED
        exit 1
      fi
      i=0
      timeout=10
      # Wait for the process to be properly started before exiting
      until { cat "$PID_FILE" | xargs kill -0; } >/dev/null 2>&1
      do
        sleep 1
        i=$(($i + 1))
        if [ $i -gt $timeout ]; then
          action "FAILED" $FAILED
          exit 1
        fi
      done
    fi

  action $"Starting $DESC: .... " $TRUE  
  exit $return
    ;;
  stop)
    #echo -n "Stopping $DESC ..."
    if [ -f "$PID_FILE" ]; then
      PID=`cat $PID_FILE`
      kill -9 $PID
      if [ $? -eq 0 ]; then
         action "Stopping $DESC ..." $TRUE
      else
         action "Failed, pls check it." $FAILED
         exit 1
      fi
      rm -f "$PID_FILE"
      exit 0
    else
      action "$DESC not running" $FAILED
    fi

    exit 0
    ;;
  status)
    status -p $PID_FILE $NAME
    exit $?
    ;;
  restart|force-reload)
    if [ -f "$PID_FILE" ]; then
      $0 stop
      sleep 1
    fi
    $0 start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|force-reload|status}"
    exit 3
    ;;
esac

标题111

正文 这里正文

标题222

正文 这里正文

标题333

正文 这里正文

标题444

正文 这里正文

技术图片

 

标题555

正文 这里正文

标题666

正文 这里正文

 

以上是关于grafana搭建的主要内容,如果未能解决你的问题,请参考以下文章

五分钟搭建基于 Prometheus + Grafana 实时监控系统

Promtail + Loki + Grafana 日志监控系统搭建

Prometheus+grafana搭建jenkins监控

grafana搭建

Grafana搭建-优化zabbix图形显示

collectd+influxDB+grafana搭建性能监控平台