tig 使用
在15分钟内监控您自己的主机 (Monitor Your Own Host Within 15 Minutes)
(This story/howto/tutorial assumes you have basic knowledge of linux, the command line and how computers work)
(此故事/方法/教程假定您具有linux的基本知识,命令行以及计算机的工作方式)
氩弧焊 (TIG)
You may have heard of the “TICK” stack: Telegraf, InfluxDB, Chronograf, Kapacitor. I heavily use Telegraf and InfluxDB, but as visualization frontend, Grafana has become the standard in the environments I work in. Kapacitor can still be used alongside for specific purposes. For this article it’s not needed.
您可能听说过“ TICK”堆栈:Telegraf,InfluxDB,Chronograf,Kapacitor。 我大量使用Telegraf和InfluxDB,但作为可视化前端,Grafana已成为我工作环境中的标准。Kapacitor仍可用于特定目的。 对于本文而言,它是不需要的。
Quite a few years ago — out of curiosity and desire to learn and grow — I started playing with Telegraf and InfluxDB. I got hold of a few older machines (dual cores) on which I installed linux for my two kids. And since I wanted to know more about monitoring, I decided to monitor them (the linux machines ofc!) with Telegraf (a small data collection tool written in golang).
几年前,出于好奇和学习和成长的渴望,我开始与Telegraf和InfluxDB一起玩。 我掌握了一些较旧的机器(双核),并为两个孩子安装了linux。 并且由于我想了解更多有关监视的信息,因此我决定使用Telegraf(一种用golang编写的小型数据收集工具)监视它们(Linux机器ofc!)。
So before we can monitor anything we need to setup the target database and the frontend to see something.
因此,在监视任何内容之前,我们需要设置目标数据库和前端以查看内容。
设置InfluxDB和Grafana (Setup InfluxDB And Grafana)
Since we want to focus more on gathering data, we’ll do this real quick.
由于我们希望更多地专注于收集数据,因此我们将很快地完成此操作。
Take the below docker-compose.yml
file and launch it on a host of your preference. For playing around with it, I recommend launching it on your local machine. If you have a dedicated or virtual linux box, that will do fine too.
取得以下docker-compose.yml
文件,并根据您的喜好启动它。 要使用它, 建议您在本地计算机上启动它 。 如果您有专用的或虚拟的linux机器,那也可以。
macOS前提条件: (macOS Prerequisites:)
install homebrew : https://brew.sh/
安装homebrew: https : //brew.sh/
install docker :
brew cask install docker
安装docker:
brew cask install docker
Linux先决条件: (Linux Prerequisites:)
install docker : https://docs.docker.com/get-docker/
安装docker: https : //docs.docker.com/get-docker/
Windows先决条件: (Windows Prerequisites:)
install docker : https://docs.docker.com/get-docker/
安装docker: https : //docs.docker.com/get-docker/
Docker撰写 (Docker Compose)
Download the following and save it as docker-compose.yml
file in a new directory.
下载以下内容并将其另存为docker-compose.yml
文件在新目录中。
# using version 2 because of https://docs.docker.com/compose/compose-file/#resources
version: "2.4"
services:
telegraf:
image: drpsychick/telegraf
restart: always
environment:
HOST_PROC: /rootfs/proc
HOST_SYS: /rootfs/sys
HOST_ETC: /rootfs/etc
TEL_AGENT_HOSTNAME: hostname = "myhostname"
TEL_OUTPUTS_INFLUXDB_0: "[[outputs.influxdb]]"
TEL_OUTPUTS_INFLUXDB_URLS: urls = ["http://localhost:8086"]
TEL_INPUTS_KERNEL_0: "[[inputs.kernel]]"
TEL_INPUTS_MEM_0: "[[inputs.mem]]"
TEL_INPUTS_SWAP_0: "[[inputs.swap]]"
TEL_INPUTS_PROCESSES_0: "[[inputs.processes]]"
TEL_INPUTS_SYSTEM_0: "[[inputs.system]]"
TEL_INPUTS_DISK_0: "[[inputs.disk]]"
TEL_INPUTS_DISKIO_0: "[[inputs.diskio]]"
TEL_INPUTS_NET_0: "[[inputs.net]]"
TEL_INPUTS_NETSTAT_0: "[[in