0
点赞
收藏
分享

微信扫一扫

Telegraph和Influxdb监控Ubuntu18.04硬件信息

水墨_青花 2022-04-08 阅读 65
linux

Telegraph和Influxdb监控Ubuntu18.04硬件信息

在bc大佬的帮助下给某显卡服务器上了监控服务,用于监测nvidia-smi的输出信息。写出bc大佬的操作过程。

首先,给服务器上influxdata源。
清华源有相关内容。到tuna开源镜像站官网,搜索influxdata,找到相关内容,按照清华源的帮助文档(搜索后点黑色问号)

curl -s https://repos.influxdata.com/influxdb.key | sudo apt-key add -
sudo apt edit-sources influxdb

把如下内容填进去

deb https://mirrors.tuna.tsinghua.edu.cn/influxdata/ubuntu/ bionic stable

这行内容是根据系统发行版选的,具体在tuna说明文档有下拉框可选择

然后

sudo apt update
sudo apt install telegraf influxdb2

启动系统服务

sudo systemctl enable --now telegraf
sudo systemctl enable --now influxdb

检查一下

sudo lsof -i|grep influx

不应为空,应看到一个 *.8086 (LISTEN)

实际上,当时是先start了influxdb.service ,然后enable --now了telegraf,最后都配置好了才enbale了influxdb

接下来就可以用http服务访问influxdb的前端了,默认端口8086,即浏览器中输入127.0.0.1:8086.实际上服务器在远程且只开了22端口,用ssh本地端口转发发过来。

ssh -L 8086:127.0.0.1:8086 huyunfan@[服务器ip地址]

访问上述http服务,注册,创建organization bucket,获取token
在Data --> API Tokens中找token 写到/etc/telegraf/telegraf.conf中
这个config中做以下内容
取消[[outputs.influxdb_v2]]一行的注释
取消下边urls一行的注释
取消token注释,将前端获取到的token填进去
取消下笔那organization和bucket的注释,填进去的内容和注册时填的一致。我的长成这样(下边那个Token换成了我随便给的随机数)

# # Configuration for sending metrics to InfluxDB
[[outputs.influxdb_v2]]
#   ## The URLs of the InfluxDB cluster nodes.
#   ##
#   ## Multiple URLs can be specified for a single cluster, only ONE of the
#   ## urls will be written to each interval.
#   ##   ex: urls = ["https://us-west-2-1.aws.cloud2.influxdata.com"]
    urls = ["http://127.0.0.1:8086"]
#
#   ## Token for authentication.
    token = "aB-24sdfdgfsEsdfDDDfdgvsVsAs da fFFgEi4rgp6xTAN36_edeYndsfDsdfas41Rft3E8=="
 
#
#   ## Organization is the name of the organization you wish to write to; must exist.
    organization = "mylab"
#
#   ## Destination bucket to write into.
    bucket = "mylab"
#
#   ## The value of this tag will be used to determine the bucket.  If this
#   ## tag is not set the 'bucket' option is used as the default.
#   # bucket_tag = ""
#
#   ## If true, the bucket tag will not be added to the metric.
#   # exclude_bucket_tag = false
#
#   ## Timeout for HTTP messages.
#   # timeout = "5s"
#

由于要看显卡,取消[[inputs.nvidia-smi]]的注释

保存后,重启telegraf服务

sudo systemctl restart telegraf.service

完成

举报

相关推荐

0 条评论