Skip to content

Instantly share code, notes, and snippets.

@dirtycajunrice
Created December 11, 2018 00:01
Show Gist options
  • Save dirtycajunrice/874323897a5476734665b13678f219e6 to your computer and use it in GitHub Desktop.
Save dirtycajunrice/874323897a5476734665b13678f219e6 to your computer and use it in GitHub Desktop.
Get folder size(s) in bytes in telegraf
#!/bin/bash
echo "["
du -bs "$@" | awk '{if (NR!=1) {printf ",\n"};printf " { \"directory_size_bytes\": "$1", \"path\": \""$2"\" }";}'
echo
echo "]"
[[inputs.exec]]
commands = [ "/etc/telegraf/scripts/get_folder_size.sh /mnt/movies /mnt/movies4k /mnt/tv /mnt/tv4k /mnt/disk_backup /mnt/ebooks /mnt/mwserver_backups /mnt/vm_image_backups" ]
timeout = "5s"
name_override = "dirsize"
name_suffix = ""
data_format = "json"
tag_keys = [ "path" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment