Announcement

Collapse
No announcement yet.

API Rest - Poller applycfg

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • API Rest - Poller applycfg

    Hello,

    I have to manage our new centreon installation via API.
    The Rest API is great for adding hosts.

    But how can I export & apply the new generated hosts?
    With the command line API I can do this:

    Code:
    ./centreon -u admin -p centreon -a APPLYCFG -v 1
    But how can I do this with the REST API?

    Best regards,
    bugfix

  • #2
    Hi there.

    I got the same issue.
    do someone have an answer?

    Comment


    • #3
      I found it!!
      { "action": "APPLYCFG", "values": "Central" }

      Comment


      • #4
        Hello

        Here is a solution with rest api. I add a host and reload the configuration.

        add a host
        Code:
        curl -s 'http://127.0.0.1/centreon/api/index.php?action=action&object=centreon_clapi' -H 'Content-Type: application/json' -H "centreon-auth-token: $(curl -s -d "username=admin&password=password" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://127.0.0.1/centreon/api/index.php?action=authenticate | sed -e 's/^{"authToken":"//' -e 's/"}$//')" --data '{"action":"add", "object":"host", "values":"test;Test host;127.0.0.1;generic-host;central;"}'
        apply config
        Code:
        curl -s 'http://127.0.0.1/centreon/api/index.php?action=action&object=centreon_clapi' -H 'Content-Type: application/json' -H "centreon-auth-token: $(curl -s -d "username=admin&password=password" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://127.0.0.1/centreon/api/index.php?action=authenticate | sed -e 's/^{"authToken":"//' -e 's/"}$//')" --data '{"object":"host", "action":"applytpl", "values":"test"}'
        create conf centreon
        Code:
        curl -s 'http://127.0.0.1/centreon/api/index.php?action=action&object=centreon_clapi' -H 'Content-Type: application/json' -H "centreon-auth-token: $(curl -s -d "username=admin&password=password" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://127.0.0.1/centreon/api/index.php?action=authenticate | sed -e 's/^{"authToken":"//' -e 's/"}$//')" --data '{"action":"pollergenerate", "values":"1"}'
        move conf to poller
        Code:
        curl -s 'http://127.0.0.1/centreon/api/index.php?action=action&object=centreon_clapi' -H 'Content-Type: application/json' -H "centreon-auth-token: $(curl -s -d "username=admin&password=password" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://127.0.0.1/centreon/api/index.php?action=authenticate | sed -e 's/^{"authToken":"//' -e 's/"}$//')" --data '{"action":"cfgmove", "values":"1"}'
        reload poller
        Code:
        curl -s 'http://127.0.0.1/centreon/api/index.php?action=action&object=centreon_clapi' -H 'Content-Type: application/json' -H "centreon-auth-token: $(curl -s -d "username=admin&password=password" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://127.0.0.1/centreon/api/index.php?action=authenticate | sed -e 's/^{"authToken":"//' -e 's/"}$//')" --data '{"action":"pollerreload", "values":"1"}'
        Visiter mon site perso http://eric.coquard.free.fr/atelier/

        Comment

        Working...
        X