Skip to content

Instantly share code, notes, and snippets.

@horus
Created August 22, 2013 08:54
Show Gist options
  • Select an option

  • Save horus/6304749 to your computer and use it in GitHub Desktop.

Select an option

Save horus/6304749 to your computer and use it in GitHub Desktop.
Generate JSON config file from the contents of the Sensu plugins directory
#!/bin/sh
echo "{"
echo " \"checks\": {"
for i in `ls /etc/sensu/plugins/*metrics.rb`; do
[ -z $trc ] || echo $trc
name=`basename $i | sed 's/\..*//'`
echo " \"$name\": {"
echo " \"type\": \"metric\","
echo " \"handlers\": [\"graphite\"],"
echo " \"command\": \"$i\","
echo " \"subscribers\": [ \"test\" ],"
echo " \"interval\": 10"
echo -n " }"
trc=','
sed -i '1c\#!/opt/sensu/embedded/bin/ruby' $i
done
echo
echo " }"
echo "}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment