Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using the Pandora API
#1
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: [url]http://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Annex_ExternalAPI[/url]

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
 Reply
#2
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"

[Image: 0JrNuJ9.png]

Here is set the IPs allowed and the password of the Api.
[Image: p6Jxc3v.png]

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.
 Reply
#3
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
 Reply
#4
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.
 Reply
#5
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.
 Reply
#6
(07-17-2017, 11:26 AM)vic Wrote: 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 Smile

Thank you!
 Reply


Users browsing this thread: 2 Guest(s)


(c) 2006-2017 Artica Soluciones Tecnológicas. Contents of this wiki are under Create Common Attribution v3 licence. | pandorafms.com | pandorafms.org

Theme © MyBB Themes