Page 1 of 1

cannot change locale warning?

Posted: Tue Oct 23, 2018 12:00 am
by sitaonair
Hi,

I have the same check running on 4 different servers and on 2 of the servers there is this setlocale warning shown below when running check_nrpe from Nagios:

[nagios@nagxi-01 ~]$ /usr/local/nagios/libexec/check_nrpe -H "HOST IP" -t 30 -c check_service
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US)
redis-server is running
Checking MySQL Proxy daemon... mysql-proxy is running.
cron is running.
Apache2 is running (pid 15753).
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US)
Axess Configurator up and running.
Axess management system (Zeo) is running.
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US)
collectd is running.
All services are running

Below is the output from running the check_service on the server itself:

[root@prd]# /usr/bin/sudo /usr/local/nagios/libexec/check_service.sh -o linux -t "/etc/init.d/axess_all_daemons status"
redis-server is running
Checking MySQL Proxy daemon... mysql-proxy is running.
cron is running.
Apache2 is running (pid 15753).
Axess Configurator up and running.
Axess management system (Zeo) is running.
collectd is running.
All services are running.


I have checked locale on both my Nagios XI and the remote host, both are showing same locale as below:

LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

Any suggestions on where I can check for this issue? Thanks in advance

Re: cannot change locale warning?

Posted: Tue Oct 23, 2018 10:40 am
by lmiltchev
How is the "check_service" command defined on the remote machine?

Can you run the command below logged in as nagios user, and show the output?

Code: Select all

su - nagios
/usr/bin/sudo /usr/local/nagios/libexec/check_service.sh -o linux -t "/etc/init.d/axess_all_daemons status"
Can you upload the "/etc/init.d/axess_all_daemons" file to the forum? What is the OS/architecture of the client machine?

Re: cannot change locale warning?

Posted: Thu Oct 25, 2018 10:35 pm
by sitaonair
nrpe.cfg:

command[check_service]=/usr/bin/sudo /usr/local/nagios/libexec/check_service.sh -o linux -t "/etc/init.d/axess_all_daemons status"

visudo:
nagios ALL=NOPASSWD: /usr/local/nagios/libexec/check_service.sh

command as nagios user on server:
[nagios@001 ~]$ /usr/bin/sudo /usr/local/nagios/libexec/check_service.sh -o linux -t "/etc/init.d/axess_all_daemons status"
redis-server is not running
cron is running.
Apache2 is running (pid 27093).
Axess Configurator up and running.
Axess management system (Zeo) is running.
collectd is running.

These services are running: mysql-proxy cron apache2 axess_configurator axess_zeo collectd.
These services are NOT running: redis-server ... failed!

client machine:
cat /etc/centos-release
CentOS release 6.9 (Final)

/etc/init.d/axess_all_daemons:
#!/bin/sh
# Startup script for the AXESS.ACS Server #
# chkconfig: - 85 15 #
### BEGIN INIT INFO
# Provides:
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start:
# Default-Stop:
# Short-Description: Start/stop ALL daemons for Axess ### END INIT INFO
PATH="$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
set -e
chroot /opt/production_axess /etc/init.d/axess_all_daemons $@
exit $?

Re: cannot change locale warning?

Posted: Fri Oct 26, 2018 9:14 am
by lmiltchev
In your script, you are changing the environment via chroot. That's why you are getting setlocale errors... Perhaps, you need to somehow set the locale inside your script in order to eliminate these errors. See if chrooting with LC_ALL=C would fix the issue for you.

https://serverfault.com/questions/35087 ... ith-chroot

Re: cannot change locale warning?

Posted: Wed Nov 14, 2018 2:17 am
by sitaonair
sorry but how do I chroot with LC_ALL=C?

Re: cannot change locale warning?

Posted: Wed Nov 14, 2018 3:02 pm
by lmiltchev
To be honest, I am not sure and this is out of Nagios support scope, but you can try something like this in your script:

Code: Select all

chroot /opt/production_axess env LC_ALL=C /etc/init.d/axess_all_daemons $@
If this doesn't work, modify your script as such:

Code: Select all

#!/bin/sh
# Startup script for the AXESS.ACS Server #
# chkconfig: - 85 15 #
### BEGIN INIT INFO
# Provides:
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start:
# Default-Stop:
# Short-Description: Start/stop ALL daemons for Axess ### END INIT INFO
PATH="$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
set -e
LC_ALL=C
chroot /opt/production_axess /etc/init.d/axess_all_daemons $@
exit $?
Hope this helps.

Re: cannot change locale warning?

Posted: Thu Nov 15, 2018 1:20 am
by sitaonair
Hi, the first one worked perfectly. Many thanks for helping though it is not a Nagios issue. Could you close this thread?

Re: cannot change locale warning?

Posted: Thu Nov 15, 2018 10:32 am
by scottwilkerson
sitaonair wrote:Hi, the first one worked perfectly. Many thanks for helping though it is not a Nagios issue. Could you close this thread?
Great

Closing