Thruk api : very nice work

(Arcrevich) #1

I just started using the CLI thruk command to automate some task, it works great.
Thanks to developers and contributors

Just one question … i have various services named “interface ge1/2/3” and like, I tried all the escape sequences I found in the docs withou success, so I used a side way

thruk r -m DELETE ‘/services/gencom.volta.sw-switch03/Interface Te/1/0/3 Traffic/config’ is not understood, same using *** and / to escape the backslashes in the service name.

Is someone cares … I cimcumvented it this way :

ID=$( thruk r -m GET ‘/config/objects’ | jq -c ‘.[] | select( .host_name ) | [ .host_name, .service_description, .":ID" ]’ | tr -d ‘[]"’ | grep $hostname | grep $service_description | awk -F, ‘{print $3 }’ )
thruk -m DELETE “/config/objects/$ID”
Thanks to jq too

BTW, is there a way to apply the running config to the files using the CLI ?



(Sven Nierlein) #2


you could simply urlencode the hostname and service, ex.:
thruk r -m DELETE ‘/services/gencom.volta.sw-switch03/Interface%20Te%2F1%2F0%2F3%20Traffic/config

config check and reload is available via:
thruk r -m POST /config/check
thruk r -m POST /config/reload

(Arcrevich) #3

Thanks, silly me, I didn’t pay the needed attention, check and reload are exlained here
Urlencode works too
Thanks again