Git Product home page Git Product logo

Comments (16)

elwood218 avatar elwood218 commented on September 23, 2024 1

@robin-tribe29 It is an issue of the API because I have tested it on shell. So I write you an email at feedback if you can't put a ticket yourself. This ticket can be closed.

from ansible-collection-checkmk.general.

lgetwan avatar lgetwan commented on September 23, 2024

Hi @elwood218,

I fixed the discovery module in the devel branch. The error message still looks a bit ugly, but at least it's no longer an "Exception", and it contains the actual error message from the API.
Can you please test it?

Best regards
Lars

from ansible-collection-checkmk.general.

elwood218 avatar elwood218 commented on September 23, 2024

@lgetwan This is the output now.

TASK [cmk_host_registration : service discovery] *********************************************************************
Friday 03 June 2022  11:09:39 +0200 (0:00:17.068)       0:01:15.787 ***********
Friday 03 June 2022  11:09:39 +0200 (0:00:17.068)       0:01:15.787 ***********
changed: [pgdb03 -> localhost]
changed: [pgdb02 -> localhost]
changed: [db01 -> localhost]
fatal: [pgdb01 -> localhost]: FAILED! => changed=false
  http_code: -1
  msg: 'Error calling API. HTTP Return Code is -1 Details: N/A'
fatal: [db02 -> localhost]: FAILED! => changed=false
  http_code: -1
  msg: 'Error calling API. HTTP Return Code is -1 Details: N/A'
fatal: [app01 -> localhost]: FAILED! => changed=false
  http_code: -1
  msg: 'Error calling API. HTTP Return Code is -1 Details: N/A'

from ansible-collection-checkmk.general.

lgetwan avatar lgetwan commented on September 23, 2024

Hi @elwood218,

I definitely didn't expect a "-1". :-o
But when checking the sources of fetch_url, I found some further information about that case. I improved the error message. Can you please check again?
Thanks so far for your help!

Best regards
Lars

from ansible-collection-checkmk.general.

elwood218 avatar elwood218 commented on September 23, 2024

Hi, if that git pull are your changes then the output is same:

From https://github.com/tribe29/ansible-collection-tribe29.checkmk
   3c52245..32ca914  devel                    -> origin/devel
   58aba7f..8315f77  fix-51-exceptionhandling -> origin/fix-51-exceptionhandling
Updating 3c52245..32ca914
 fatal: [pgdb03 -> localhost]: FAILED! => changed=false
  http_code: -1
  msg: 'Error calling API. HTTP Return Code is -1 Details: N/A'

from ansible-collection-checkmk.general.

lgetwan avatar lgetwan commented on September 23, 2024

Hi,
for some reason, my fix wasn't merged into the devel branch. I did that again and verified it. Can you please try again?
Best regards
Lars

from ansible-collection-checkmk.general.

elwood218 avatar elwood218 commented on September 23, 2024

Hi, now it looks like that:

fatal: [pgdb03 -> localhost]: FAILED! => changed=false
  http_code: -1
  msg: 'Error calling API. HTTP Return Code is -1 Details: Connection failure: The read operation timed out'

Btw. before when I was getting a 500 from the API sometimes a link to a crashreport was directly shown.. but it seems that this is not working anymore. Just wanted to mention it - don't know if it is related.

from ansible-collection-checkmk.general.

lgetwan avatar lgetwan commented on September 23, 2024

Hi,
for some reason, your API is not responding in time.
Probably you should try to do the call with curl for testing:

out=$(curl -v \
    --request POST \
    --write-out "\nxxx-status_code=%{http_code}\n" \
    --header "Authorization: Bearer <your_user> <your_password>" \
    --header "Accept: application/json" \
    --header "Content-Type: application/json" \
    --data '{ "alias": "SLES12_cgroup2", "name": "SLES12_cgroup2" }' \
    "http://<your_cmk_server>/<your_cmk_site>/check_mk/api/1.0/objects/host/<your_host>/actions/discover_services/invoke")

echo "$out"
resp=$( echo "${out}" | grep -v "xxx-status_code" )
code=$( echo "${out}" | awk -F"=" '/^xxx-status_code/ {print $2}')
echo "$resp" | jq
if [[ $code -lt 400 ]]; then
     echo "OK"
else
     echo "Request error"
fi

How long does this call take approximately?

from ansible-collection-checkmk.general.

elwood218 avatar elwood218 commented on September 23, 2024

Hi, I don't think that this is the problem.

xxx-status_code=302
OK

The problem only occurs after the first 2 or 3 hosts and only when called like I already described in #33.

But you can close the this issue if you want because it was more or less only about the body variable. At least we got now a "better" error message.
The issue with the API I don't really know how to debug and for now my workaround is at least working.

Thank you for your help.

from ansible-collection-checkmk.general.

elwood218 avatar elwood218 commented on September 23, 2024

I just recognized that the curl was missing a "follow" so I put https manually. Now this is the output:

{"title": "Bad Request", "status": 400, "detail": "These fields have problems: name, alias", "fields": {"name": ["Unknown field."], "alias": ["Unknown field."]}}
xxx-status_code=400
{
  "title": "Bad Request",
  "status": 400,
  "detail": "These fields have problems: name, alias",
  "fields": {
    "name": [
      "Unknown field."
    ],
    "alias": [
      "Unknown field."
    ]
  }
}
Request error

from ansible-collection-checkmk.general.

elwood218 avatar elwood218 commented on September 23, 2024

It must look like that I guess:

   --data '{
          "mode": "new"
        }' \

from ansible-collection-checkmk.general.

elwood218 avatar elwood218 commented on September 23, 2024
           http_code:  200
     time_namelookup:  0.072466s
        time_connect:  0.087947s
     time_appconnect:  0.250204s
    time_pretransfer:  0.250424s
       time_redirect:  0.000000s
  time_starttransfer:  0.250430s
                     ----------
          time_total:  4.760772s

But service discovery could take longer.. and like I said it is working when I "loop" over it in Ansible but when I run it for each inventory host (which could be parallel) then it fails.

from ansible-collection-checkmk.general.

elwood218 avatar elwood218 commented on September 23, 2024

I have just tested it on shell.

discover-all-hosts.sh -> this script does a "for" loop - so sequential and it takes about 4 secs for each host like in my last post.

But if I do that and run all those 4 scripts in parallel:

discover-host1.sh
discover-host2.sh
discover-host3.sh
discover-host4.sh

Then these are the times of each host:

      time_total:  4.544909s
      time_total:  9.610563s
      time_total:  13.358466s
      time_total:  17.429323s

from ansible-collection-checkmk.general.

robin-checkmk avatar robin-checkmk commented on September 23, 2024

If I understand this right, we are chasing another issue here, so @elwood218 would you be so kind to close this issue and move your research about the timing issue into a new issue? There we can then research, whether it is a collection issue or an API issue.

Thanks!

from ansible-collection-checkmk.general.

robin-checkmk avatar robin-checkmk commented on September 23, 2024

@elwood218 Alright, then please send an email, so all relevant information is in there. Thanks!

from ansible-collection-checkmk.general.

elwood218 avatar elwood218 commented on September 23, 2024

But maybe the module could use bulk discovery but I don't know how to solve that in Ansible.. (and the discovery and "accepting" is not working anyway - already opened a FEED for that)

from ansible-collection-checkmk.general.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.