Инструменты пользователя

Инструменты сайта


linux:metrics

Различия

Показаны различия между двумя версиями страницы.

Ссылка на это сравнение

Предыдущая версия справа и слева Предыдущая версия
Следующая версия
Предыдущая версия
linux:metrics [2022/06/03 07:03]
admin
linux:metrics [2023/11/05 06:05] (текущий)
admin [Мониторинг ZFS]
Строка 8: Строка 8:
 ==== Установка ==== ==== Установка ====
 Скачиваем дистр и ставим **dpkg -i** Скачиваем дистр и ставим **dpkg -i**
-<code bash>wget https://repos.influxdata.com/debian/pool/stable/t/telegraf/telegraf_1.19.1-1_amd64.deb</code>+<code bash>wget https://repos.influxdata.com/debian/pool/stable/t/telegraf/telegraf_1.19.1-1_amd64.deb # Debian 
 +wget https://repos.influxdata.com/centos/9/amd64/stable/telegraf-1.22.4-1.x86_64.rpm # CentOS 
 + 
 +   # Либо есть в тех же репозиториях что и influxdb 
 +cat <<EOF | sudo tee /etc/yum.repos.d/influxdata.repo 
 +[influxdata] 
 +name = InfluxData Repository - Stable 
 +baseurl = https://repos.influxdata.com/stable/\$basearch/main 
 +enabled = 1 
 +gpgcheck = 1 
 +gpgkey = https://repos.influxdata.com/influxdata-archive_compat.key 
 +EOF 
 + 
 +dnf install telegraf 
 +</code>
  
  
Строка 38: Строка 52:
  
  
-===== InfluxDB ===== 
-Платформа для создания и работы с приложениями временных рядов. (https://www.influxdata.com/)\\ 
  
-==== Подготовка сервера ==== +<details> 
-Для БД временных рядов важна синхронизация времени, настраиваем временную зону и ставим службу синхронизации времени\\ +<summary> :!: Пример конфига </summary> 
-*В каталоге /usr/share/zoneinfo список всех возможных вариантов временных зон +telegraf -test - проверка конфигурации
-<code bash># \cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime</code> +
-<code bash># apt install chrony && sudo systemctl enable chrony</code>+
  
-Открываем файервол: +<code bash> 
-<code bash># iptables -I INPUT 1 -p tcp --dport 8086 -j ACCEPT</code>+[global_tags] 
 +[agent] 
 +  interval = "60s" 
 +  round_interval = true 
 +  metric_buffer_limit = 1000 
 +  flush_buffer_when_full = true 
 +  collection_jitter = "0s" 
 +  flush_interval = "10s" 
 +  flush_jitter = "0s" 
 +  
 +  ## Logging configuration: 
 +  debug = false 
 +  quiet = false 
 +  logfile = "C:/Program Files/Telegraf/telegraf.log" 
 +  
 +  hostname = "" 
 +  
 +  
 +############################################################################### 
 +#                                  OUTPUTS                                    # 
 +############################################################################### 
 +  
 +[[outputs.influxdb]] 
 +  urls = ["http://:8086"] # required 
 +  database = "telegraf" # required 
 +  precision = "s" 
 +  retention_policy = "" 
 +  timeout = "10s" 
 +  username = "" 
 +  password = ""
  
  
-==== Установка ==== 
-Импортируем ключ: 
-<code bash># wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -</code> 
  
-Добавляем репо: +############################################################################### 
-<code bash>echo "deb https://repos.influxdata.com/debian buster stable" | sudo tee /etc/apt/sources.list.d/influxdb.list</code>+                                 INPUTS                                     # 
 +###############################################################################
  
-Ставим: 
-<code bash># apt update && sudo apt install influxdb</code> 
  
 +[[inputs.win_perf_counters]]
 +  [[inputs.win_perf_counters.object]]
 +    # Processor usage, alternative to native, reports on a per core.
 +    ObjectName = "Processor"
 +    Instances = ["*"]
 +    Counters = [
 +      "% Idle Time",
 +      "% Interrupt Time",
 +      "% Privileged Time",
 +      "% User Time",
 +      "% Processor Time",
 +      "% DPC Time",
 +    ]
 +    Measurement = "win_cpu"
 +    # Set to true to include _Total instance when querying for all (*).
 +    IncludeTotal=true
  
 +  [[inputs.win_perf_counters.object]]
 +    # Disk times and queues
 +    ObjectName = "LogicalDisk"
 +    Instances = ["*"]
 +    Counters = [
 +      "% Idle Time",
 +      "% Disk Time",
 +      "% Disk Read Time",
 +      "% Disk Write Time",
 +      "Current Disk Queue Length",
 +      "% Free Space",
 +      "Free Megabytes",
 +    ]
 +    Measurement = "win_disk"
 +    # Set to true to include _Total instance when querying for all (*).
 +    #IncludeTotal=false
  
-==== Управление ==== +  [[inputs.win_perf_counters.object]] 
-По умолчанию вход открытыйвключить надо в конфигев блоке "http", параметр - **auth-enabled true # Set to true**+    ObjectName "PhysicalDisk" 
 +    Instances ["*"
 +    Counters [ 
 +      "Disk Read Bytes/sec", 
 +      "Disk Write Bytes/sec", 
 +      "Current Disk Queue Length", 
 +      "Disk Reads/sec", 
 +      "Disk Writes/sec", 
 +      "% Disk Time", 
 +      "% Disk Read Time", 
 +      "% Disk Write Time", 
 +    ] 
 +    Measurement "win_diskio"
  
-<code bash># +  [[inputs.win_perf_counters.object]] 
 +    ObjectName = "Network Interface" 
 +    Instances = ["*"
 +    Counters = [ 
 +      "Bytes Received/sec", 
 +      "Bytes Sent/sec", 
 +      "Packets Received/sec", 
 +      "Packets Sent/sec", 
 +      "Packets Received Discarded", 
 +      "Packets Outbound Discarded", 
 +      "Packets Received Errors", 
 +      "Packets Outbound Errors", 
 +    ] 
 +    Measurement = "win_net"
  
-> CREATE USER admin WITH PASSWORD '<password>' WITH ALL PRIVILEGES +  [[inputs.win_perf_counters.object]] 
-> SHOW USERS+    ObjectName = "System" 
 +    Counters = [ 
 +      "Context Switches/sec", 
 +      "System Calls/sec", 
 +      "Processor Queue Length", 
 +      "System Up Time", 
 +    ] 
 +    Instances = ["------"
 +    Measurement = "win_system" 
 +    # Set to true to include _Total instance when querying for all (*). 
 +    #IncludeTotal=false
  
-> GRANT [READ,WRITE,ALLON <database_name> TO <username> +  [[inputs.win_perf_counters.object]
-> REVOKE [READ,WRITE,ALL] ON <database_name> FROM <username> +    # Example query where the Instance portion must be removed to get data back
-> GRANT ALL PRIVILEGES TO <username> +    # such as from the Memory object. 
-> REVOKE ALL PRIVILEGES FROM <username> +    ObjectName = "Memory" 
-> SHOW GRANTS FOR <user_name> +    Counters [ 
-> SET PASSWORD FOR <username> '<password>' +      "Available Bytes", 
-> DROP USER <username> +      "Cache Faults/sec", 
- +      "Demand Zero Faults/sec", 
-> CREATE DATABASE +      "Page Faults/sec", 
-> DROP DATABASE +      "Pages/sec", 
-> DROP SERIES +      "Transition Faults/sec", 
-> DROP MEASUREMENT +      "Pool Nonpaged Bytes", 
-> CREATE RETENTION POLICY +      "Pool Paged Bytes", 
-> ALTER RETENTION POLICY +      "Standby Cache Reserve Bytes", 
-> DROP RETENTION POLICY +      "Standby Cache Normal Priority Bytes", 
-> CREATE CONTINUOUS QUERY +      "Standby Cache Core Bytes",
-> DROP CONTINUOUS QUERY +
->+
  
 +    ]
 +    # Use 6 x - to remove the Instance bit from the query.
 +    Instances = ["------"]
 +    Measurement = "win_mem"
 +    # Set to true to include _Total instance when querying for all (*).
 +    #IncludeTotal=false
  
 +  [[inputs.win_perf_counters.object]]
 +    # Example query where the Instance portion must be removed to get data back,
 +    # such as from the Paging File object.
 +    ObjectName = "Paging File"
 +    Counters = [
 +      "% Usage",
 +    ]
 +    Instances = ["_Total"]
 +    Measurement = "win_swap"
 +
 +  [[inputs.win_perf_counters.object]]
 +    ObjectName = "Network Interface"
 +    Instances = ["*"]
 +    Counters = [
 +      "Bytes Sent/sec",
 +      "Bytes Received/sec",
 +      "Packets Sent/sec",
 +      "Packets Received/sec",
 +      "Packets Received Discarded",
 +      "Packets Received Errors",
 +      "Packets Outbound Discarded",
 +      "Packets Outbound Errors",
 +    ]
 +
 +[[inputs.win_perf_counters.object]]
 +    # Process metrics, in this case for IIS only
 +    ObjectName = "Process"
 +    Counters = ["% Processor Time","Handle Count","Private Bytes","Thread Count","Virtual Bytes","Working Set","wmiApSrv"]
 +    Instances = ["telegraf"]
 +    Measurement = "win_proc"
 +    #IncludeTotal=false #Set to true to include _Total instance when querying for all (*).
 +
 +#[[inputs.win_services]]
 +#  ## Names of the services to monitor. Leave empty to monitor all the available services on the host
 +#  service_names = ["wmiApSrv"]
 +
 +#[[inputs.ping]]
 +#  urls = ["10.10.10.250"]
 +
 +# # Read metrics about cpu usage
 +#[[inputs.cpu]]
 +#   ## Whether to report per-cpu stats or not
 +#   percpu = true
 +#   ## Whether to report total system cpu stats or not
 +#   totalcpu = true
 +#   ## Comment this line if you want the raw CPU time metrics
 +#   fielddrop = ["time_*"]
 +
 +
 +# # Read metrics about disk usage by mount point
 +[[inputs.disk]]
 +#   ## By default, telegraf gather stats for all mountpoints.
 +#   ## Setting mountpoints will restrict the stats to the specified mountpoints.
 +#   ## mount_points=["/"]
 +#
 +#   ## Ignore some mountpoints by filesystem type. For example (dev)tmpfs (usually
 +#   ## present on /run, /var/run, /dev/shm or /dev).
 +#   # ignore_fs = ["tmpfs", "devtmpfs"]
 +
 +
 +# # Read metrics about disk IO by device
 +[[inputs.diskio]]
 +#   ## By default, telegraf will gather stats for all devices including
 +#   ## disk partitions.
 +#   ## Setting devices will restrict the stats to the specified devices.
 +#   ## devices = ["sda", "sdb"]
 +#   ## Uncomment the following line if you do not need disk serial numbers.
 +#   ## skip_serial_number = true
 +
 +
 +# # Read metrics about memory usage
 +[[inputs.mem]]
 +#   # no configuration
 +
 +
 +# # Read metrics about swap memory usage
 +[[inputs.swap]]
 +#   # no configuration
 +
 +  
 +  
 +[[inputs.exec]]  
 + commands = ["C:/test.bat"]
 +  timeout = "30s"
 +# name_suffix = "Win_Run"
 +#  #name_override = "telegraf"
 + data_format = "influx"
 </code> </code>
 +</details>
 +
 +
 +
 +==== Мониторинг ZFS ====
 +
 +<details>
 +<summary>:!: Плагин для ZFS</summary>
 +[[https://github.com/influxdata/telegraf/blob/master/plugins/inputs/zfs/README.md|Doc]]\\
 +
 +Добавялем в конфиг, собсна достаточно с параметрами по умолчанию\\
 +Данные берутся из "/proc/spl/kstat/zfs"\\
 +<code bash>
 +[[inputs.zfs]]
 +
 +</code>
 +</details>
 +
 +
 +<details>
 +<summary>:!: Публикация в Prometheus </summary>
 +[[https://github.com/influxdata/telegraf/blob/master/plugins/outputs/prometheus_client/README.md|Doc]]\\
 +По некоторым причинам удобнее метрики передавать (настраивать в графане) через прометеус\\
 +Есть модуль который публикует содержимое телеграфа в формате прометеуса, в веб-страницу\\
 +Добавляем блок "output" в конфиг:\\
 +<code bash>
 +[[outputs.prometheus_client]]
 +  listen = ":9273"
 +  string_as_label = true
 +  metric_version = 2
 +</code>
 +</details>
 +
 +
 +
 +
 +
 +
 +<details>
 +<summary> </summary>
 +
 +<code bash>
 +
 +</code>
 +</details>
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
  
  
  
-====  ==== 
-<code bash># </code> 
  
linux/metrics.1654239799.txt.gz · Последнее изменение: 2022/06/03 07:03 — admin