コンテンツにスキップ

telegrafをインストールしてリソース監視

https://docs.influxdata.com/telegraf/v1.14/

Add repository

wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -
source /etc/lsb-release
echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list

Install telegraf packages

sudo apt-get update && sudo apt-get install telegraf
sudo systemctl start telegraf
sudo systemctl enable telegraf

Backup original config file

sudo cp /etc/telegraf/telegraf.conf{,.org}

Write config file on /etc/telegraf/telegraf.conf

cat | sudo tee /etc/telegraf/telegraf.conf
# Pasting raw text
# Ctrl + D

/etc/telegraf/telegraf.conf

[global_tags]
  user = "$USER"

[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  precision = ""
  ## Override default hostname, if empty use os.Hostname()
  hostname = ""
  ## If set to true, do no set the "host" tag in the telegraf agent.
  omit_hostname = false

# On using nginx
# [[inputs.nginx]]
#   urls = ["http://localhost:8088/nginx_status"]
#   response_timeout = "5s"

[[inputs.cpu]]
  percpu = true
  totalcpu = true
  collect_cpu_time = false
  report_active = false

[[inputs.disk]]
  ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]

[[inputs.cpu]]
  # Whether to report per-cpu stats or not
  percpu = false
  # Whether to report total system cpu stats or not
  totalcpu = true

[[inputs.diskio]]
[[inputs.kernel]]
[[inputs.mem]]
[[inputs.processes]]
[[inputs.swap]]
[[inputs.system]]
[[inputs.net]]

[[outputs.influxdb]]
  urls = ["http://dmz-logging.dmz.tak-cslab.org:8086"]
  database = "server_metrics"
  # name_override = ""

  ## The value of this tag will be used to determine the database.  If this
  ## tag is not set the 'database' option is used as the default.
  # database_tag = ""

  ## When true, Telegraf will output unsigned integers as unsigned values,
  ## i.e.: "42u".  You will need a version of InfluxDB supporting unsigned
  ## integer values.  Enabling this option will result in field type errors if
  ## existing data has been written.
  # influx_uint_support = false

Restart telegraf

sudo systemctl restart telegraf

Trouble shooting:

check datetime on node

date

check syslog and telegraf's log

sudo less /var/log/syslog
sudo less /var/log/telegraf/*