Telegraf: Difference between revisions

From Leo's Notes
This page was last edited on 30 December 2021, at 01:12.
m Added categories and navbox
Line 18: Line 18:
| lang = terminal
| lang = terminal
}}
}}
{{Navbox Linux}}
[[Category:Linux]]
[[Category:LinuxUtilities]]

Revision as of 01:12, 30 December 2021

Telegraf is an agent that pushes metrics to a server, such as InfluxDB.

Tasks

Monitoring CPU frequency

Simplest way is to use an exec input:

[[inputs.exec]]
  commands = ["bash -c \"grep MHz /proc/cpuinfo | /bin/awk -F: '{freq += \\$2; n++} END{printf(\\\"%f\\\", freq/n); }'\" "]
  name_override = "cpu_freq"
  data_format = "value"
  data_type = "float"

This will just retrieve the CPU speeds which awk will average out as a single value.

$ grep MHz /proc/cpuinfo | awk -F: '{freq+=$2; n++} END {printf("%f", freq/n);}'
3099.926000