Search code examples
urlbrowserwebserverzabbix

Is there a way that i can pass a string uninterpreted in a url?


I have a zabbix server that sends me a mail whenever there is an issue.

It uses a template like this, to generate the mail

Issue: {TRIGGER.ISSUE}
Description: "Node: {TRIGGER.NODE}, {TRIGGER.DESCRIPTION}"

And the mail would look like:

Issue: "memory usage"
Description: "Node: abc.def.com, high memory usage (>90%)"

I need to pass this information on to a web server after which appropriate action will be taken. The way I thought is by putting the url inside that template something like this

http://localhost:4567?issue={TRIGGER.ISSUE}&nodename={TRIGGER.NODE}&description={TRIGGER.DESCRIPTION}

But this sometimes generates a string that will not be properly encoded into a URI and I often run into Bad URI issues on my browser.

Is there a way that I can pass on the strings such that it goes through as a raw string and does not get interpreted by the browser?


Solution

  • Some characters (white space, &, ...) in {TRIGGER.DESCRIPTION} or {TRIGGER.NODE} macros are your problem. Unfortunately, Zabbix doesn't provide any urlencode function in the template. Fortunately, you can write your own alertscript which will solve your problem. Just pick up your favorite language, which support urlencode function (or write your own) and use urlencode function for any macro, which you use in the URL. Your script must be able to send also email.

    Doc: