InfluxDB
InfluxDB
安装
- 下载压缩包
wget https://dl.influxdata.com/influxdb/releases/influxdb2-2.5.0-linux-amd64.tar.gz
- 解压
tar -xzvf influxdb2-2.5.0-linux-amd64.tar.gz -C /opt/module/
- 启动
/opt/module/influxdb2_linux_amd64/influxd
- 访问web页面,初始化数据库
- 访问页面 http://192.168.50.223:8086/
- 点击
get start
- 初始化用户 Bucket相当于数据库概念,所有都填influxdb
- Telegraf 下载
官方地址:https://portal.influxdata.com/downloads/
wget https://dl.influxdata.com/telegraf/releases/telegraf-1.24.2_linux_amd64.tar.gz
tar -xzvf telegraf-1.24.2_linux_amd64.tar.gz -C /opt/module/
Telegraf 启停脚本
#!/bin/bash
is_exist() {
pid=$(ps -ef | grep telegraf | grep -v grep | awk '{print $2}')
# 如果不存在返回 1,存在返回 0
if [ -z "${pid}" ]; then
return 1
else
return 0
fi
}
stop() {
is_exist
if [ $? -eq "0" ]; then
kill ${pid}
if [ $? -eq "0" ]; then
echo "进程号:${pid},弄死你"
else
echo "进程号:${pid},没弄死"
fi
else
echo "本来没有 telegraf 进程"
fi
}
start() {
is_exist
if [ $? -eq "0" ]; then
echo "跑着呢,pid 是${pid}"
else
export INFLUX_TOKEN=OnWjITC4VQiK1DKdSXMgzyeFheTECp7fOxc0onjSWIt_zL76A5QNX1jHicmlyXCV3RTvg7sBHDN_82613tKRQA==
/opt/module/telegraf-1.24.2/usr/bin/telegraf --config http://192.168.50.223:8086/api/v2/telegrafs/0a3a1c0e414c9000
fi
}
status() {
is_exist
if [ $? -eq "0" ]; then
echo "telegraf 跑着呢"
else
echo "telegraf 没有跑"
fi
}
usage() {
echo "哦!请你 start 或 stop 或 status"
exit 1
}
case "$1" in
"start")
start
;;
"stop")
stop
;;
"status")
status
;;
*)
usage
;;
esac
- node_exporter
官方地址:https://prometheus.io/download/
wget https://github.com/prometheus/node_exporter/releases/download/v1.4.0/node_exporter-1.4.0.linux-amd64.tar.gz
tar -xzvf node_exporter-1.4.0.linux-amd64.tar.gz -C /opt/module/
/opt/module/node_exporter-1.4.0.linux-amd64/node_exporter
访问页面: http://192.168.50.223:9100/metrics