Consul register script check via API not working









up vote
0
down vote

favorite












I am using chef to run a bash command that would register a script health check with consul and I am getting the below error with my example code. I tried looking at the docs but it will not seem to work out for me. Suggestions on what might be wrong?



I am wanting to iu



Error message



 ================================================================================
Error executing action `run` on resource 'bash[register_init_checks]'
================================================================================

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of "bash" "/tmp/chef-script20181110-4847-1tg4kmv" ----
STDOUT:
STDERR: /tmp/chef-script20181110-4847-1tg4kmv: line 1: [/work-disk/consul/data/mem-check.sh],: No such file or directory
---- End output of "bash" "/tmp/chef-script20181110-4847-1tg4kmv" ----
Ran "bash" "/tmp/chef-script20181110-4847-1tg4kmv" returned 1

Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/consul/recipes/default.rb

190: bash 'register_init_checks' do
191: code <<-EOH
192: curl --request PUT --data #mem_check http://127.0.0.1:8500/v1/agent/check/register
193: EOH
194: action :run
195: end

Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/consul/recipes/default.rb:190:in `from_file'

bash("register_init_checks") do
action [:run]
default_guard_interpreter :default
command nil
backup 5
interpreter "bash"
declared_type :bash
cookbook_name "consul"
recipe_name "default"
user nil
code " curl --request PUT --data "check"=>"id"=>"mem-check", "name"=>"Memory utilization", "args"=>["/work-disk/consul/data/mem-check.sh"], "interval"=>"10s", "timeout"=>"1s" http://127.0.0.1:8500/v1/agent/check/registern"
domain nil
end

System Info:
------------
chef_version=14.7.17
platform=ubuntu
platform_version=16.04
ruby=ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
program_name=/usr/bin/chef-client


Chef code I am trying to use



cookbook_file consul_data + '/mem-check.sh' do
source 'mem-check.sh'
owner consul_user
group consul_user
mode '0755'
action :create
end


mem_check =
"check" =>
"id" => "mem-check",
"name" => "Memory utilization",
"args" => [consul_data + "/mem-check.sh"],
"interval" => "10s",
"timeout" => "1s"



bash 'register_init_checks' do
code <<-EOH
curl --request PUT --data #mem_check http://127.0.0.1:8500/v1/agent/check/register
EOH
action :run
end









share|improve this question

























    up vote
    0
    down vote

    favorite












    I am using chef to run a bash command that would register a script health check with consul and I am getting the below error with my example code. I tried looking at the docs but it will not seem to work out for me. Suggestions on what might be wrong?



    I am wanting to iu



    Error message



     ================================================================================
    Error executing action `run` on resource 'bash[register_init_checks]'
    ================================================================================

    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of "bash" "/tmp/chef-script20181110-4847-1tg4kmv" ----
    STDOUT:
    STDERR: /tmp/chef-script20181110-4847-1tg4kmv: line 1: [/work-disk/consul/data/mem-check.sh],: No such file or directory
    ---- End output of "bash" "/tmp/chef-script20181110-4847-1tg4kmv" ----
    Ran "bash" "/tmp/chef-script20181110-4847-1tg4kmv" returned 1

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/consul/recipes/default.rb

    190: bash 'register_init_checks' do
    191: code <<-EOH
    192: curl --request PUT --data #mem_check http://127.0.0.1:8500/v1/agent/check/register
    193: EOH
    194: action :run
    195: end

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/consul/recipes/default.rb:190:in `from_file'

    bash("register_init_checks") do
    action [:run]
    default_guard_interpreter :default
    command nil
    backup 5
    interpreter "bash"
    declared_type :bash
    cookbook_name "consul"
    recipe_name "default"
    user nil
    code " curl --request PUT --data "check"=>"id"=>"mem-check", "name"=>"Memory utilization", "args"=>["/work-disk/consul/data/mem-check.sh"], "interval"=>"10s", "timeout"=>"1s" http://127.0.0.1:8500/v1/agent/check/registern"
    domain nil
    end

    System Info:
    ------------
    chef_version=14.7.17
    platform=ubuntu
    platform_version=16.04
    ruby=ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
    program_name=/usr/bin/chef-client


    Chef code I am trying to use



    cookbook_file consul_data + '/mem-check.sh' do
    source 'mem-check.sh'
    owner consul_user
    group consul_user
    mode '0755'
    action :create
    end


    mem_check =
    "check" =>
    "id" => "mem-check",
    "name" => "Memory utilization",
    "args" => [consul_data + "/mem-check.sh"],
    "interval" => "10s",
    "timeout" => "1s"



    bash 'register_init_checks' do
    code <<-EOH
    curl --request PUT --data #mem_check http://127.0.0.1:8500/v1/agent/check/register
    EOH
    action :run
    end









    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am using chef to run a bash command that would register a script health check with consul and I am getting the below error with my example code. I tried looking at the docs but it will not seem to work out for me. Suggestions on what might be wrong?



      I am wanting to iu



      Error message



       ================================================================================
      Error executing action `run` on resource 'bash[register_init_checks]'
      ================================================================================

      Mixlib::ShellOut::ShellCommandFailed
      ------------------------------------
      Expected process to exit with [0], but received '1'
      ---- Begin output of "bash" "/tmp/chef-script20181110-4847-1tg4kmv" ----
      STDOUT:
      STDERR: /tmp/chef-script20181110-4847-1tg4kmv: line 1: [/work-disk/consul/data/mem-check.sh],: No such file or directory
      ---- End output of "bash" "/tmp/chef-script20181110-4847-1tg4kmv" ----
      Ran "bash" "/tmp/chef-script20181110-4847-1tg4kmv" returned 1

      Resource Declaration:
      ---------------------
      # In /var/chef/cache/cookbooks/consul/recipes/default.rb

      190: bash 'register_init_checks' do
      191: code <<-EOH
      192: curl --request PUT --data #mem_check http://127.0.0.1:8500/v1/agent/check/register
      193: EOH
      194: action :run
      195: end

      Compiled Resource:
      ------------------
      # Declared in /var/chef/cache/cookbooks/consul/recipes/default.rb:190:in `from_file'

      bash("register_init_checks") do
      action [:run]
      default_guard_interpreter :default
      command nil
      backup 5
      interpreter "bash"
      declared_type :bash
      cookbook_name "consul"
      recipe_name "default"
      user nil
      code " curl --request PUT --data "check"=>"id"=>"mem-check", "name"=>"Memory utilization", "args"=>["/work-disk/consul/data/mem-check.sh"], "interval"=>"10s", "timeout"=>"1s" http://127.0.0.1:8500/v1/agent/check/registern"
      domain nil
      end

      System Info:
      ------------
      chef_version=14.7.17
      platform=ubuntu
      platform_version=16.04
      ruby=ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
      program_name=/usr/bin/chef-client


      Chef code I am trying to use



      cookbook_file consul_data + '/mem-check.sh' do
      source 'mem-check.sh'
      owner consul_user
      group consul_user
      mode '0755'
      action :create
      end


      mem_check =
      "check" =>
      "id" => "mem-check",
      "name" => "Memory utilization",
      "args" => [consul_data + "/mem-check.sh"],
      "interval" => "10s",
      "timeout" => "1s"



      bash 'register_init_checks' do
      code <<-EOH
      curl --request PUT --data #mem_check http://127.0.0.1:8500/v1/agent/check/register
      EOH
      action :run
      end









      share|improve this question













      I am using chef to run a bash command that would register a script health check with consul and I am getting the below error with my example code. I tried looking at the docs but it will not seem to work out for me. Suggestions on what might be wrong?



      I am wanting to iu



      Error message



       ================================================================================
      Error executing action `run` on resource 'bash[register_init_checks]'
      ================================================================================

      Mixlib::ShellOut::ShellCommandFailed
      ------------------------------------
      Expected process to exit with [0], but received '1'
      ---- Begin output of "bash" "/tmp/chef-script20181110-4847-1tg4kmv" ----
      STDOUT:
      STDERR: /tmp/chef-script20181110-4847-1tg4kmv: line 1: [/work-disk/consul/data/mem-check.sh],: No such file or directory
      ---- End output of "bash" "/tmp/chef-script20181110-4847-1tg4kmv" ----
      Ran "bash" "/tmp/chef-script20181110-4847-1tg4kmv" returned 1

      Resource Declaration:
      ---------------------
      # In /var/chef/cache/cookbooks/consul/recipes/default.rb

      190: bash 'register_init_checks' do
      191: code <<-EOH
      192: curl --request PUT --data #mem_check http://127.0.0.1:8500/v1/agent/check/register
      193: EOH
      194: action :run
      195: end

      Compiled Resource:
      ------------------
      # Declared in /var/chef/cache/cookbooks/consul/recipes/default.rb:190:in `from_file'

      bash("register_init_checks") do
      action [:run]
      default_guard_interpreter :default
      command nil
      backup 5
      interpreter "bash"
      declared_type :bash
      cookbook_name "consul"
      recipe_name "default"
      user nil
      code " curl --request PUT --data "check"=>"id"=>"mem-check", "name"=>"Memory utilization", "args"=>["/work-disk/consul/data/mem-check.sh"], "interval"=>"10s", "timeout"=>"1s" http://127.0.0.1:8500/v1/agent/check/registern"
      domain nil
      end

      System Info:
      ------------
      chef_version=14.7.17
      platform=ubuntu
      platform_version=16.04
      ruby=ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
      program_name=/usr/bin/chef-client


      Chef code I am trying to use



      cookbook_file consul_data + '/mem-check.sh' do
      source 'mem-check.sh'
      owner consul_user
      group consul_user
      mode '0755'
      action :create
      end


      mem_check =
      "check" =>
      "id" => "mem-check",
      "name" => "Memory utilization",
      "args" => [consul_data + "/mem-check.sh"],
      "interval" => "10s",
      "timeout" => "1s"



      bash 'register_init_checks' do
      code <<-EOH
      curl --request PUT --data #mem_check http://127.0.0.1:8500/v1/agent/check/register
      EOH
      action :run
      end






      consul






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 11 at 1:58









      Josh Kirby

      65




      65



























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245201%2fconsul-register-script-check-via-api-not-working%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245201%2fconsul-register-script-check-via-api-not-working%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Barbados

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3