[Nagiosplug-help] encoding of non-ascii plugin output in nagios3
John McPherson
jmcpherson+nagios at global-pix.com
Tue Apr 21 22:44:18 CEST 2009
On Mon, Apr 20, 2009 at 04:44:10PM +1200, John McPherson wrote:
> We've just upgraded our Debian GNU/Linux machine from nagios2 to nagios3.0.6.
>
> We have a custom check command that reads a temperature from the /sys
> filesystem, and outputs something like
>
> "OK - 30.1°C|temperature=30.1"
>
> with the degree sign, encoded with utf-8. This worked fine with nagios2.
>
> Now with nagios3, the string gets converted as if it were
> Latin1/iso-8859-1 because it appears in the CGI output as
> "OK - 30.1°C". The actual string in the HTML file looks like
> <TD CLASS='dataVal'>OK - 30.1°C</TD>
Looking at the source code, the culprit is the html_encode()
function in cgiutils.c, specifically the line:
1465 sprintf(temp_expansion,"&#%d;",(unsigned char)input[x]);
which assumes a single byte encoding.
Fortunately, by reading the source, I also found this behaviour can be
disabled completely by the 'escape_html_tags' config variable in
cgi.cfg, so now non-ascii characters get passed through as-is.
I'm not sure if the default setting changed between versions, or if
the defaults changed in the debian package.
John
More information about the Help
mailing list