Token substitution : keep JSON format



I want to monitor several processes on a server BUT I don’t know how many so I can’t use standard token substitution on the command line.

So i created a plugin check_procs_multi.rb to do a loop on an array of process and call sensu check-procs.rb plugin for each one of them.

My plugin expect the option to be a valid JSON string but sensu client transforms my client configuration string into an inner representation (a tree ?) of the client options.

Here is my client configuration



                           "name": "MY_TEST_SERVER",

                           "address": "",

                           "subscriptions": ["ESB"],




                                                           "pid_file": "/my/path/to/pid/one",

                                                           "name": "name_one"



                                                           "pid_file": "/my/path/to/pid/two",

                                                           "name": "name_two"



                                                           "pid_file": "my/path/to/pid/three",

                                                           "name": "name_three"






Here is a sample of my plugin

    procs = config[:file_pid]

         parsed = JSON.parse(procs)

         parsed["procs"].each do |proc|

         result = `ruby /etc/sensu/plugins/check-procs.rb -f "#{proc["pid_file"]}"`


Here is my check configuration (command line only)

“command”: “ruby /etc/sensu/plugins/check_procs_multi.rb -f ‘:::ESB:::’”

But here is what the client send to the plugin (which is no longer a JSON string)

[{:pid_file=>"/my/path/to/pid/one", :name=>“name_one”}, {:pid_file=>"/my/path/to/pid/two", :name=>“name_two”}, {:pid_file=>“my/path/to/pid/three”, :name=>“name_three”}]

So i wonder if there is a simple way to manipulate these data as it is ? Or is there a way to keep the JSON string from the client configuration ?

For now I found a workaround by escaping my client configuration the way that sensu-client does not parse it because it sees it as a string.

Another workaround would be to put these information inside a file and load it in the plugin but i would rather keep all in my client configuration.

Thanks a lot for your help !