[Nagiosplug-devel] [ nagiosplug-Bugs-1433114 ] check_procs does not work with german locale

SourceForge.net noreply at sourceforge.net
Wed Mar 8 07:45:08 CET 2006


Bugs item #1433114, was opened at 2006-02-16 21:00
Message generated for change (Comment added) made by lbruun
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1433114&group_id=29880

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Parsing problem
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Hadmut Danisch (hadmut)
Assigned to: Nobody/Anonymous (nobody)
Summary: check_procs does not work with german locale

Initial Comment:
Hi,

check_procs does not work properly if used in Germany. 

Reason:

In Germany/Europe floating numbers are written with a
decimal comma
instead of a decimal point. When you set LC_NUMERIC to
something like
de_DE, the function sscanf expects a decimal comma, not
a decimal
point.


check_procs calls 

  /bin/ps axwo 'stat uid pid ppid vsz rss pcpu comm args'

and then parses the output. That's where trouble begins. 
The %CPU is written as 0.0, but sscanf now expects a
comma. It
therefore scans only "0", and leaves ".0" for the next
argument, thus
shifting all subsequent arguments one to the right. 

check_procs -C something
therefore does not work anymore.

regards
Hadmut


----------------------------------------------------------------------

Comment By: NotDisplayed123 (lbruun)
Date: 2006-03-08 16:44

Message:
Logged In: YES 
user_id=1468749

Right you are. I'm looking at version 1.46 of check_procs 
which seems to try to get around this by doing a 

setlocale(LC_ALL,"")

before using the sscanf function.

The point is that while the sscanf changes with the locale 
the ps command does not, at least not on my platform 
(Solaris). Whether or not the ps command changes its 
behavior according to the locale might be different from 
platform to platform. (just a guess, but this would surely 
complicate things)

Anyway on the Solaris platform the correct behaviour should 
be to do the following in the C code:

setlocale(LC_ALL,"C")

i.e. force the C locale to be used before calling sscanf 
function.

rgds,

Lars



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1433114&group_id=29880




More information about the Devel mailing list