Hello, I try to create new agent via request: http://172.16.10.8/pandora\_console/include/api.php?&op=set&op2=new\_agent&other=ps90-cgr2010-1%7C172.16.41.10%7C%7C9%7C%7C300%7C7%7Clocalhost.localdomain%7C%7C%7C%7Ctest%20create%7C&other\_mode=url\_encode\_separator\_%7C&apipass=S7e3xd9Wa&user=admin&pass=S7e3xd9Wa all fields is from api doc. But I have this error: The OS don`t exist. I checked all fileds and try some other values and nothing changed. This os actualy exist db, its cisco with number 7. What can be wrong? P.s. PandoraFMS 7.05, centos 7
problem with set new aget via api
taraska90 · 5 abr 2017, 17:56 · 6 mensajes · 49 visitas
- Inicio del debate
Hello taraska90, Are you using the database ID of the operating system? What's the content of the table in your database? Kind regards, Antonio.
Hello antonio, I form the query as follows: other = agent_name + "%7C" + ip[0] + "%7C" + id_parent+ "%7C" + id_group + "%7C" + cascade_protection + "%7C" + interval_sec + "%7C" + id_os + "%7C" + name_server + "%7C" + custom_id + "%7C" + learning_mode + "%7C" + disabled + "%7C" + description + "%7C" + alias_as_name and learn the id os parametr like this: select id_os from tconfig_os where name='Cisco'; +-------+ | id_os | +-------+ | 7 | +-------+ and row url is: http://172.16.100.8/pandora\_console/include/api.php?&op=set&op2=new\_agent&other=ps730-2010-2.energo.ru|172.16.41.35||9||300|7|localhost.localdomain||||test%20create|&other\_mode=url\_encode\_separator\_|&apipass=123&user=admin&pass=123 I thought that I need to check what value api gets: nano /var/www/html/pandora_console/include/functions_api.php else if (db_get_value_sql('SELECT id_os FROM tconfig_os WHERE id_os = ' . $idOS) === false) { print $idOS; // I insert this construction in code returnError('id_os_not_exist', 'The OS don`t exist.'); } And now I have this error message: localhost.localdomainThe OS don`t exist. But this message appears everything, whatever values are substituted in different fields
Hello taraska90, If it is always retrieving the same message, you may be missing some parameter. I've tried myself and successfuly created an agent. I'll paste here the API call I used and each of the parameters: http://192.168.70.120/pandora\_console/include/api.php?op=set&op2=new\_agent&other=aliasname|192.168.70.120||2|0|0|300|1|pandorafms||1|0|description|agentalias2&other\_mode=url\_encode\_separator\_|&apipass=1234&user=admin&pass=pandora other= agent_alias(aliasname) | ip_address(192.168.70.120) | id_parent(empty) | id_group(2) | cascade_protection(0) | cascade_protection_module(0) | interval_sec(300) | id_os(1) | name_server(pandorafms) | custom_id(empty) | learning_mode(1) | disabled(0) | description(description) | alias_as_name(agentalias) With this parameters I've obtained a succesful agent creation. So taking a look at your API call, it looks like you are missing the "cascade_protection_module" parameter, so you are actually sending "localhost.localdomain" as id_group and "7" as interval_sec This is the wiki section where you can find the details: http://wiki.pandorafms.com/index.php?title=Pandora:Documentation\_es:Anexo\_API\_external#set\_new\_agent Give it a try and let me know if it works for you. Kind regards, Antonio.
Antonio, thank you, it works now. I really missed the cascade protection module. But there is mistake in api doc on english: http://wiki.pandorafms.com/index.php?title=Pandora:Documentation\_en:Annex\_ExternalAPI#Set\_new\_agent there is no mention of this module:
Hello taraska90, Thanks for mentioning it, I've added the missing information to the English docummentation. Sorry for not pasting the correct link, I'm so used to work with the two languages that sometimes I even mix them. Kind regards, Antonio.
Entra en tu cuenta para publicar.
