Closed kermith72 closed 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"}]
An issue has been opened on Centreon Github ?
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
Issue has been solved with 2.0.3 release.
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
And when I export,
./centctl --server=centos import -f testtemplate.csv
this gives me this: