Skip to content

Instantly share code, notes, and snippets.

@mda590
Created April 21, 2019 16:05
Show Gist options
  • Save mda590/beeb6ebd81b0fb36b565ba8eeba9e06c to your computer and use it in GitHub Desktop.
Save mda590/beeb6ebd81b0fb36b565ba8eeba9e06c to your computer and use it in GitHub Desktop.
Looks in a directory and echos out a YAML formatted string containing a list of rules files which can be put into a Prometheus configuration file
#!/bin/bash
FILES=$(ls -1)
BASE_RULES_PATH="/etc/rules"
FILE_LIST=""
for file in $FILES; do
if [[ $file =~ .*.yaml|.*.yml ]]; then
FILE_LIST+=" - $BASE_RULES_PATH/$file\n"
fi
done
echo -e "$FILE_LIST"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment