Created
November 24, 2015 16:46
-
-
Save hughsaunders/4ea07983e9a2f1ca6271 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
run_plugin(){ | |
config_file="$1" | |
# skip config files that don't define plugin checks | |
grep agent.plugin $config_file &>/dev/null || continue | |
plugin_file="$(awk '/^\s*file\s*:/{print $3}' <$config_file)" | |
plugin_args="$(awk '/args/{gsub(/\s*args\s*:\s*/, ""); print}' <$config_file |tr -d "\",'][")" | |
/usr/lib/rackspace-monitoring-agent/plugins/"$plugin_file" $plugin_args | |
} | |
for path in /etc/rackspace-monitoring-agent.conf.d/*.yaml | |
do | |
file=$(basename $path) | |
# run each plugin, prepending the file name to each line of output, store output in temp file | |
run_plugin "$file" |sed "s/^/$file /" >/tmp/maastesting | |
#output status line if pass, otherwise log full output. | |
grep 'status okay' /tmp/maastesting || cat /tmp/maastesting | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment