1

I am not particularly fluent with linux, so would appreciate some help.

My system is running with an external drive mounted at /mnt/SSD_240GB and contains two directories that I am trying to monitor the size of, with Telegraf and InfluxDB. These directories are:

/mnt/SSD_240GB/docker_data/InfluxDB/data and

/mnt/SSD_240GB/docker_data/InfluxDB/wal

Telegraf and InfluxDB are both running in seperate docker containers.

Following this answer, I have made a shell script which contains the following code, which just uses du to get the sizes of any directories that you pass in as arguments:

#!/bin/bash

echo "["
du -s -B1 "$@" | awk '{if (NR!=1) {printf ",\n"};printf "  { \"dir_size_bytes\": "$1", \"path\": \""$2"\" }";}'
echo
echo "]"

Running this script directly inside the Telegraf container works as expected, giving the correct file sizes : enter image description here

Now I try to get Telegraf to automatically run this script at regular intervals by using the exec plugin, by adding the following code to my telegraf.conf file:

[[inputs.exec]]
  commands = [ "/etc/telegraf/scripts/get_disk_usage.sh /mnt/SSD_240GB/docker_data/InfluxDB/wal /mnt/SSD_240GB/docker_data/InfluxDB/data" ]
  timeout = "1m"
  name_override = "du"
  name_suffix = ""
  data_format = "json"
  tag_keys = [ "path" ]

The problem is that now the data which arrives in InfluxDB does not match this. In fact the file sizes returned are always the same (20480 bytes and 4096 bytes, respectively): enter image description here

Does anyone know how to resolve this? Thanks!


Here is the telegraf section of the docker-compose.yaml file:

  telegraf:
    image: telegraf
    container_name: telegraf_container
    restart: always
    ports:
      - 8125:8125
    networks:
      - docker_monitoring_network
    volumes:
      - /mnt/SSD_240GB/docker_config_files/Telegraf/telegraf.conf:/etc/telegraf/telegraf.conf
      - /mnt/SSD_240GB/docker_config_files/Telegraf/scripts:/etc/telegraf/scripts
      - /mnt/SSD_240GB:/mnt/SSD_240GB:ro
teeeeee
  • 641
  • 5
  • 15

0 Answers0