telegraf
采集监控数据组件一. telegraf
介绍 github
托管链接: https://github.com/influxdata/telegraf/tree/master/plugins
支持多种平台监控扩展性强
监控交换机等数通设备时mibs
文件映射见leancould
mibs
下载链接:http://lc-j2rHZR7P.cn-e1.lcfile.com/qP4oqwLcYwP7UPcDlvlV6IMOxyQwBY6u/mibs.zip
二. telegraf
部署 ( 建议采用容器化的方式部署 ) 1.
二进制部署 ( 比较简单了解即可 )1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 #!/bin/bash set -eversion=1.20.4 tarball=telegraf-${version} _linux_amd64.tar.gz wget https://dl.influxdata.com/telegraf/releases/$tarball tar xzvf $tarball mkdir -p /opt/telegrafcp -far telegraf-${version} /usr/bin/telegraf /opt/telegrafcat <<EOF > /opt/telegraf/telegraf.conf [global_tags] [agent] interval = "10s" flush_interval = "10s" round_interval = true metric_batch_size = 1000 metric_buffer_limit = 10000 collection_jitter = "0s" flush_jitter = "0s" precision = "" hostname = "" # 填为自己的服务器IP omit_hostname = false [[inputs.cpu]] percpu = true totalcpu = true collect_cpu_time = false report_active = true [[inputs.disk]] ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"] [[inputs.diskio]] [[inputs.kernel]] [[inputs.mem]] [[inputs.processes]] [[inputs.system]] fielddrop = ["uptime_format"] [[inputs.net]] ignore_protocol_stats = true [[outputs.prometheus_client]] listen = ":9273" metric_version = 2 path="/metrics" string_as_label = true export_timestamp = true EOF cat <<EOF > /etc/systemd/system/telegraf.service [Unit] Description="telegraf" After=network.target [Service] Type=simple ExecStart=/opt/telegraf/telegraf --config telegraf.conf WorkingDirectory=/opt/telegraf SuccessExitStatus=0 LimitNOFILE=65536 StandardOutput=syslog StandardError=syslog SyslogIdentifier=telegraf KillMode=process KillSignal=SIGQUIT TimeoutStopSec=5 Restart=always [Install] WantedBy=multi-user.target EOF systemctl daemon-reload systemctl enable telegraf systemctl restart telegraf systemctl status telegraf
2.
容器化部署( 此处镜像选择zznn
阿里云私有镜像 集成oracle
客户端 以及python
环境 方便使用telegraf
的exec
模块启用脚本监控 ) 部署脚本(docker-compose.yml)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 version: "3.0" services: telegraf-py: image: registry.cn-hangzhou.aliyuncs.com/zznn/mycentos:telegraf_oracle-py restart: always container_name: telegraf-py hostname: telegraf environment: TZ: Asia/Shanghai ports: - 9273:9273 volumes: - ./telegraf.conf:/opt/telegraf-1.20.4/etc/telegraf/telegraf.conf command : /opt/telegraf-1.20.4/usr/bin/telegraf --config /opt/telegraf-1.20.4/etc/telegraf/telegraf.conf --config-directory /opt/telegraf-1.20.4/etc/telegraf/telegraf.d networks: - tpng prometheus: image: prom/prometheus:latest restart: always container_name: prometheus hostname: prometheus environment: TZ: Asia/Shanghai ports: - 9090:9090 user: root volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml - ./data/monitor/prometheus:/prometheus/data:rw command : - "--config.file=/etc/prometheus/prometheus.yml" - "--storage.tsdb.path=/prometheus" - "--storage.tsdb.retention.time=15d" networks: - tpng influxdb: image: tutum/influxdb container_name: influx ports: - "8083:8083" - "8086:8086" expose: - 8090 - 8099 networks: - tpng grafana: image: grafana/grafana:7.0.4 container_name: grafana hostname: grafana restart: unless-stopped ports: - 3000:3000 user: root volumes: - ./grafana.ini:/etc/grafana/grafana.ini - ./data/monitor/grafana:/var/lib/grafana:rw environment: GF_SECURITY_ADMIN_PASSWORD: "admin" GF_USERS_ALLOW_SIGN_UP: "false" TZ: Asia/Shanghai GF_RENDERING_SERVER_URL: http://renderer:8081/render GF_RENDERING_CALLBACK_URL: http://grafana:3000/ GF_LOG_FILTERS: rendering:debug networks: - tpng renderer: image: grafana/grafana-image-renderer:2.0.0 restart: always ports: - "8081:8081" environment: - GF_RENDERER_PLUGIN_TZ=Asia/Shanghai - GF_RENDERER_PLUGIN_IGNORE_HTTPS_ERRORS=true networks: - tpng networks: tpng: driver: bridge
telegraf-py
版功能
具体监控方案见下篇。