YPSI-SAS / centctl

Centctl is a Go CLI which allows to manage multiple Centreon servers.
MIT License
11 stars 4 forks source link

problem with export template service #5

Closed kermith72 closed 3 years ago

kermith72 commented 3 years ago

Centctl version 2.01 When I export a service template with macros

./centctl --server=centos export template service -r 'OS-Windows-Cpu-NRPE-03-custom' --append -f testtemplate.csv

the macros are exported as below

modify,templateService,"OS-Windows-Cpu-NRPE-03-custom",macro,"$_SERVICEWARNING$|80|0|"
modify,templateService,"OS-Windows-Cpu-NRPE-03-custom",macro,"$_SERVICECRITICAL$|90|0|"
modify,templateService,"OS-Windows-Cpu-NRPE-03-custom",macro,"$_SERVICEEXTRAOPTIONS$|time=5m time=1m time=30s|0|"

And when I export,

./centctl --server=centos import -f testtemplate.csv

this gives me this: image

kermith72 commented 3 years ago

Hello, I just realized that the problem is in the API here are the tests for host macros, it works

curl -s 'http://192.168.1.42/centreon/api/index.php?action=action&object=centreon_clapi' -H "Content-Type: application/json" -H 'centreon-auth-token: 'hhm4V7ljNjAaq8AELMXj6MYhrWxa+pJQ0oLRQtvsCJ8='' -d '{ "action": "getmacro", "object": "htpl", "values": "OS-Windows-NSClient-03-NRPE-custom"}'
{"result":[{"macro name":"NRPECLIENT","macro value":"check_centreon_nrpe","is_password":"","description":"","source":"direct"},{"macro name":"NRPEEXTRAOPTIONS","macro value":"-u -m 1024","is_password":"","description":"","source":"direct"},{"macro name":"NRPEPORT","macro value":"5666","is_password":"","description":"","source":"direct"},{"macro name":"NRPETIMEOUT","macro value":"30","is_password":"","description":"","source":"direct"}]}

but for the service macros, it's not good

curl -s 'http://192.168.1.42/centreon/api/index.php?action=action&object=centreon_clapi' -H "Content-Type: application/json" -H 'centreon-auth-token: 'hhm4V7ljNjAaq8AELMXj6MYhrWxa+pJQ0oLRQtvsCJ8='' -d '{ "action": "getmacro", "object": "stpl", "values": "OS-Windows-Cpu-NRPE-03-custom"}'
{"result":[{"macro name":"$_SERVICE$_SERVICEWARNING$$","macro value":"80","description":"0","is_password":"0"},{"macro name":"$_SERVICE$_SERVICECRITICAL$$","macro value":"90","description":"0","is_password":"0"},{"macro name":"$_SERVICE$_SERVICEEXTRAOPTIONS$$","macro value":"time=5m time=1m time=30s","description":"0","is_password":"0"}]
ypilpre commented 3 years ago

An issue has been opened on Centreon Github ?

kermith72 commented 3 years ago

It is done, verified on version 21.10 and 21.04 https://github.com/centreon/centreon/issues/9984 Tips: you can remove the prefix and suffix using this command sed -i -e "s/\"\$_SERVICE/\"/g" -e "s/\$|/|/g" testtemplate.csv

MelissaB79 commented 3 years ago

Issue has been solved with 2.0.3 release.