Welcome to Pandora FMS Community!

Find answers, ask questions, and connect with our community around the world.

  • Using the Pandora API

    Posted by andrei-morarescu on July 11, 2017 at 16:29

    Hello,

    I kindly ask for some more info on how to get help / documentation on using the Pandora API.

    Of course that I have already checked: http://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Annex_ExternalAPI

    What I am interested in is “1.3.3.77 set planned_downtimes_created”, I would like to know all the valid possibilities that I have available on the API for all the options, parameters, values, etc – all.

    Also, I tried using the help, as mentioned exactly on the first page of the API documentation -> not clear, I was unable to retrieve any kind of info (I do not have an auth problem, the problem is “This operation does not exist.”).

    Would somebody please help me in clear this one out and maybe even make some push for updating the documentation with all the necessary information.

    PS: i am using “Pandora FMS v6.0SP5 – Build PC170120”

    Thank you very much,
    Andrei Morarescu

    andrei-morarescu replied 8 years, 11 months ago 2 Members · 5 Replies
  • 5 Replies
  • vic

    Administrator
    July 13, 2017 at 12:01
    1592 Karma points
    Community awards: bulb Bright ideas
    Community rank: tentacle_master_icon Tentacle Master
    Like it
    Up
    0
    Down
    Drop it
    ::

    Hi Andrei Morarescu,

    Use this example:

    http://pandoraserverIP/pandora_console/include/api.php?op=set&apipass=apipassword&user=pandorauser&pass=pandorauserpass&op2=planned_downtimes_created&id=ididentificator&other=testing|07/22/2017|07/30/2017|0|1|1|1|1|1|1|1|09:00:00|18:00:00|1|31|quiet|periodically|weekly&other_mode=url_encode_separator_|

    Go to the configuration to modify the parameters of access. “Setup” -> “Setup” -> “General Setup”

    Here is set the IPs allowed and the password of the Api.

    On the Pandora6.0SP6 version the problem not happens, you can update with .rpm files or with the Update manager online.
    If you have any problem tell me.

    Best regards,

    vic.

  • andrei-morarescu

    Member
    July 13, 2017 at 12:13
    0 Karma points
    Community rank: tentacle-noob-1 Tentacle noob
    Like it
    Up
    0
    Down
    Drop it
    ::

    Hi,

    Thank you, Vic, but this is not the problem.

    The thing is that I want to dynamically set a downtime via API and I have been successful with this, just that I do not want to create recurrent downtime, I want them with the ‘once’ setting.

    When I am using the keyword ‘once’ in the API call, it creates a new downtime entry but with some blank fields and doesn’t actually seem valid.

    I have even opened the PHP source code and at a first sight it did not seem to be implemented yet – could I get a confirmation / clarification from a developer, please ?

    Also, I am able to do other stuff via API, so this is not an authentication / authorization problem.

    Kind regards,
    Andrei Morarescu

  • andrei-morarescu

    Member
    July 13, 2017 at 14:07
    0 Karma points
    Community rank: tentacle-noob-1 Tentacle noob
    Like it
    Up
    0
    Down
    Drop it
    ::

    Hello again,

    OK, so I did more digging through the source code and performed some more tests.

    I got to a point, based on the findings from: functions_api.php, functions_planned_downtimes.php, planned_downtime.editor.php.

    I have the following part of the API call: op=set&op2=planned_downtimes_created&id=LALA&other=testing|08/04/2018|08/05/2018|1|1|1|1|1|1|1|1|17:06:00|19:06:00|1|31|quiet|once|weekly

    The awkward part is that I actually did more than one test with similar call (small changes around there) and it returns the ID of the new planned downtime created (so seems ok) but I am unable to see in the GUI the newly created downtime entries.

    I am not sure if I have understood correctly the part from planned_downtime.editor.php – lines 240-280, but for me it seems that I simply need to put a ‘1’ after the end_date and that would be a true for ‘only alerts’, but at the same time it doesn’t seem that the variable is actually getting the value -> more likely to get a hardcode on ‘0’.

    While writing this post I performed another test with:
    op=set&op2=planned_downtimes_created&id=LALA3&other=testing|08/04/2018|08/05/2018|0|0|1|1|1|1|1|1|1|1|17:06:00|19:06:00|1|31|quiet|once|weekly

    The call returned again an ID and this time I am able to see it in the GUI, just that I see it with the following settings:
    Name: LALA3
    Group: all
    Description: testing
    Type: Disable agents
    Execution: once
    Set time – From 2018/08/04 – 00:00:00
    To 2018/08/05 – 00:00:00

    All seems fine, except two things:
    a) i want the type to be disable_only_alerts
    b) the hours are not correct (i did not set it at midnight)
    and another side note: it doesn’t allow me to have the end_date the same day as the start_date -> room for improvement

    Any thoughts on the matter ?

    To be honest, I am now considering in creating downtime by tapping directly on the DB as it seems that the API call simply makes some checks and afterwards an insert in the DB.

    Thank you very much,
    Andrei M.

  • vic

    Administrator
    July 17, 2017 at 15:26
    1592 Karma points
    Community awards: bulb Bright ideas
    Community rank: tentacle_master_icon Tentacle Master
    Like it
    Up
    0
    Down
    Drop it
    ::

    Hi Andrei Morarescu,

    When you create a planed downtimes, you need put “other_mode=url_encode_separator_|” for separate the fields and that the api takes the value of the fields in each variable.

    Best regards,

    vic.

  • andrei-morarescu

    Member
    July 17, 2017 at 15:28
    0 Karma points
    Community rank: tentacle-noob-1 Tentacle noob
    Like it
    Up
    0
    Down
    Drop it
    ::

    Hi Andrei Morarescu,

    When you create a planed downtimes, you need put “other_mode=url_encode_separator_|” for separate the fields and that the api takes the value of the fields in each variable.

    Best regards,

    vic.

    Hi Vic,

    Yes, I used that in the link.. i just didn’t copy in my post everything.. the same for the api token and password 🙂

    Thank you!

Log in to reply.