Using "Host Action" to fill form doesn't work because of special characters

I’ve had a “Host Action” in Icinga Web 2 with which I could fill a web form in an intermediate system that was able to create a ticket in Jira SD via Jira API.
That system will be shut down due to internal technology changes.
Unfortunately I don’t have direct access to the Jira SD API so that’s no option.
The idea was to have a form directly in Jira SD that could handle the content of the URL directly (without an intermediate system).

My problem is that some output of check plugins does contain special characters that corrupts the URL (e.g. “%”, “/”, etc.) which wasn’t a problem in the old system.
Examples:

“PING CRITICAL - Packet loss = 100%”
“check_ping: Invalid hostname/address”

The link for the “Host Action” is built like that:

https://jira.company.net/servicedesk/customer/portal/123/create/1234?customfield_13230=68100&summary=$host.name$&description=$host.state.output$&customfield_13214=$host.state.soft_state$

Are there any ideas how to realize that?
Getting the fields in an URL encoded format would help I guess.

Thanks in advance!
AlexR

The built-in action feature does not encode urls.
It sound reasonable to have a syntax like urlencode($host.name$). You can open a feature request on github:

or you could create an icingaweb2 module by yourself.

Here is an example of an IcingaDb Hostaction:

don’ forget to load it via run.php

In your code you can encode whatever you want, access the host object variables and so on…

Make sure you start with the training module to get all the basics right, like namespaces/ folders… :

Why not just encode macro values if they’re used in a URL? By default, I mean. No need for a new syntax element. :thinking:

@nilmerg with which encoding? The one with where spaces are %20 or the one where they’re +?

There is one strange case I can think of that will break with this behaviour:

  • put a full url in a host.var
  • use the hostvar
  • the full url will be encoded

@rivad %20, the de-facto standard in Icinga Web

@moreamazingnick

if they’re used in a URL

A simple $host.vars.action_url$ is not a URL yet :wink:

$host.vars.action_url$$host.state.output$

with

$host.vars.action_url$ = https://icinga.com/index.php?=

might not evaluate correctly depending on the implementation

Doesn’t matter if the action isn’t targeting Icingaweb2 but an external system.

I guess I’ll go with an own module. That’ll also help me for further customizations :grinning_face:

Thanks for all your replies!

Regards,
AlexR