0

I need to execute this command in Python:

curl "http://robot:<automation secret>@127.0.0.1/monitor/check_mk/webapi.py?action=edit_host" -d 'request={"attributes": {"tag_check_puppet": "check_puppet"}, "hostname":"test.test.ch"}'

Problem is i'm new to python and it needs to be dynamic, so i can adapt it with variables like the hostname and tag_check_puppet value.

Any idea how to help me?

5
  • curl converters: curl.trillworks.com and shibukawa.github.io/curl_as_dsl . Or use subprocess module Commented Dec 21, 2016 at 14:38
  • oh well that makes it easy. Thank you! Commented Dec 21, 2016 at 14:39
  • @Damon, did you check my answer? Commented Dec 22, 2016 at 0:06
  • @Dekel yes i did, sorry for the long time, i was on holidays.. can you put it in as an answer to i can check it as correct? Commented Dec 23, 2016 at 9:54
  • It's already in the answer :) check Commented Dec 23, 2016 at 12:29

2 Answers 2

4

You can use the requests library for that:

import requests
requests.post("http://robot:<automation secret>@127.0.0.1/monitor/check_mk/webapi.py?action=edit_host", data={"attributes": {"tag_check_puppet": "check_puppet"}, "hostname":"test.test.ch"})
Sign up to request clarification or add additional context in comments.

Comments

0

If you are used to working with curl, you might want to try out the pyCURL package.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.