escaping dollar signs in plugin output
Posted: Wed Apr 24, 2019 1:11 am
I have a plugin, written in Python.
I'm using Nagios 3.5.1; mail alerts are sent using mailx.
To get the web UI to display a literal dollar sign in the web UI, I have to escape the literal dollar sign; this seems to work Ok there:
that is:
will display
OK: no transactions exceeding threshold ($123) in the previous 23 seconds.
however, if I get a message via email or via integration with OpsGenie, the text will show the literal backslash instead, with the dollar sign presumably getting interpolated, and not showing up:
OK: no transactions exceeding threshold (\123) in the previous 23 seconds.
Is there any magic combination that will result in a literal dollar sign in both cases? I've tried some other combinations, but so far, nothing that works for both. Most of the suggestions online relate to slightly different use cases that don't seem to line up with the problem I'm seeing.
I'm using Nagios 3.5.1; mail alerts are sent using mailx.
To get the web UI to display a literal dollar sign in the web UI, I have to escape the literal dollar sign; this seems to work Ok there:
that is:
Code: Select all
'OK: no transactions exceeding threshold (\${}) in the previous {} seconds.'
.format(args.upper_alert_threshold, args.time_seconds))
OK: no transactions exceeding threshold ($123) in the previous 23 seconds.
however, if I get a message via email or via integration with OpsGenie, the text will show the literal backslash instead, with the dollar sign presumably getting interpolated, and not showing up:
OK: no transactions exceeding threshold (\123) in the previous 23 seconds.
Is there any magic combination that will result in a literal dollar sign in both cases? I've tried some other combinations, but so far, nothing that works for both. Most of the suggestions online relate to slightly different use cases that don't seem to line up with the problem I'm seeing.