Xymon Mailing List Archive search

Strange issue when using local scripts (in linux)

10 messages in this thread

list David Boyer · Mon, 3 Aug 2020 18:31:57 -0400 ·
Hi,
    I've got a strange date issue.  I've written some local scripts to pad
information onto the combo message. Here is the background:

1. When you run the script by hand locally (take note of the date):

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020

2. When I pull the information from xymon server:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog xymonsvr
section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26


Notice how the date field gets modified?  I can't figure out why. The only
thing I can think of is something within the xymon code, but I don't know
why it would?

Here's the simple script:

[davieb at xymonsvr ~]$ cat ~xymon/client/local/dateinfo
#!/bin/sh

OS=`uname -s`
RPM=dhcp-common

if [ ${OS} = "Linux" ]; then
   VERSION=`rpm -q ${RPM} --qf "%{VERSION}\n"`
   INSTALLED=`rpm -q ${RPM} --qf "%{INSTALLTIME:date}\n"|awk {'print $2"
"$3" "$4'}`
fi

echo "${RPM},${VERSION},${INSTALLED}"

Does anybody have any idea what is going on?

Thanks,
Dave
list Jeremy Laidman · Tue, 4 Aug 2020 10:11:25 +1000 ·
David

Update your script to, display the value of the LANG variable in addition
to the RPM details (perhaps on a separate line), and see if the value
differs between the script output (run from your shell) and the clientlog.

I suspect LANG is set in your shell differently from how it's set in the
xymon user's shell. RPM (or probably glibc) uses LANG to format the date
according to the environment's locale. I'm guessing your shell has LANG set
to something like en_US, whereas the xymon user's LANG is set to something
like C, or is not set at all.

Cheers
Jeremy
quoted from David Boyer

On Tue, 4 Aug 2020 at 08:32, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Hi,
    I've got a strange date issue.  I've written some local scripts to pad
information onto the combo message. Here is the background:

1. When you run the script by hand locally (take note of the date):

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020

2. When I pull the information from xymon server:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26


Notice how the date field gets modified?  I can't figure out why. The only
thing I can think of is something within the xymon code, but I don't know
why it would?

Here's the simple script:

[davieb at xymonsvr ~]$ cat ~xymon/client/local/dateinfo
#!/bin/sh

OS=`uname -s`
RPM=dhcp-common

if [ ${OS} = "Linux" ]; then
   VERSION=`rpm -q ${RPM} --qf "%{VERSION}\n"`
   INSTALLED=`rpm -q ${RPM} --qf "%{INSTALLTIME:date}\n"|awk {'print $2"
"$3" "$4'}`
fi

echo "${RPM},${VERSION},${INSTALLED}"

Does anybody have any idea what is going on?

Thanks,
Dave

list David Boyer · Mon, 3 Aug 2020 20:56:17 -0400 ·
Jeremy,
       If you notice, both iterations are being run from the xymonsvr.
I've added the LANG to see if the
two report it differently.

So, by hand it looks:

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020,en_US.UTF-8

Pulling the info out of xymon looks:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog xymonsvr
section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26,*C*

Humm, there does appear to be a difference!  Checking the xymon user
itself, it UTF-8.
[xymon at xymonsvr ~]$ echo $LANG
en_US.UTF-8


That appears to be the issue though, I set the LANG=C and ran the script by
hand and get the same results when I pull it from xymon!
[davieb at xymonsvr ~]$ LANG=C;export LANG
[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,Jul 18 17:44:26,C

Looking at the xymon.sh start script, it does not appear to set it
anywhere!  Guess I'll need to run that
to ground in the morning.

Thanks for pointing me in the right direction!

Dave
quoted from Jeremy Laidman

On Mon, Aug 3, 2020 at 8:11 PM Jeremy Laidman <user-0608abae5e7c@xymon.invalid> wrote:
David

Update your script to, display the value of the LANG variable in addition
to the RPM details (perhaps on a separate line), and see if the value
differs between the script output (run from your shell) and the clientlog.

I suspect LANG is set in your shell differently from how it's set in the
xymon user's shell. RPM (or probably glibc) uses LANG to format the date
according to the environment's locale. I'm guessing your shell has LANG set
to something like en_US, whereas the xymon user's LANG is set to something
like C, or is not set at all.

Cheers
Jeremy

On Tue, 4 Aug 2020 at 08:32, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Hi,
    I've got a strange date issue.  I've written some local scripts to
pad information onto the combo message. Here is the background:

1. When you run the script by hand locally (take note of the date):

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020

2. When I pull the information from xymon server:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26


Notice how the date field gets modified?  I can't figure out why. The
only thing I can think of is something within the xymon code, but I don't
know why it would?

Here's the simple script:

[davieb at xymonsvr ~]$ cat ~xymon/client/local/dateinfo
#!/bin/sh

OS=`uname -s`
RPM=dhcp-common

if [ ${OS} = "Linux" ]; then
   VERSION=`rpm -q ${RPM} --qf "%{VERSION}\n"`
   INSTALLED=`rpm -q ${RPM} --qf "%{INSTALLTIME:date}\n"|awk {'print $2"
"$3" "$4'}`
fi

echo "${RPM},${VERSION},${INSTALLED}"

Does anybody have any idea what is going on?

Thanks,
Dave

list Jeremy Laidman · Tue, 4 Aug 2020 11:21:06 +1000 ·
Great to see that the problem has been identified.

I would recommend forcing LANG in your script to a known value, because
that's the code that makes an assumption about the output of rpm.

J
quoted from David Boyer

On Tue, 4 Aug 2020 at 10:56, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Jeremy,
       If you notice, both iterations are being run from the xymonsvr.
I've added the LANG to see if the
two report it differently.

So, by hand it looks:

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020,en_US.UTF-8

Pulling the info out of xymon looks:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26,*C*

Humm, there does appear to be a difference!  Checking the xymon user
itself, it UTF-8.
[xymon at xymonsvr ~]$ echo $LANG
en_US.UTF-8


That appears to be the issue though, I set the LANG=C and ran the script
by hand and get the same results when I pull it from xymon!
[davieb at xymonsvr ~]$ LANG=C;export LANG
[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,Jul 18 17:44:26,C

Looking at the xymon.sh start script, it does not appear to set it
anywhere!  Guess I'll need to run that
to ground in the morning.

Thanks for pointing me in the right direction!

Dave

On Mon, Aug 3, 2020 at 8:11 PM Jeremy Laidman <user-0608abae5e7c@xymon.invalid> wrote:
David

Update your script to, display the value of the LANG variable in addition
to the RPM details (perhaps on a separate line), and see if the value
differs between the script output (run from your shell) and the clientlog.

I suspect LANG is set in your shell differently from how it's set in the
xymon user's shell. RPM (or probably glibc) uses LANG to format the date
according to the environment's locale. I'm guessing your shell has LANG set
to something like en_US, whereas the xymon user's LANG is set to something
like C, or is not set at all.

Cheers
Jeremy

On Tue, 4 Aug 2020 at 08:32, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Hi,
    I've got a strange date issue.  I've written some local scripts to
pad information onto the combo message. Here is the background:

1. When you run the script by hand locally (take note of the date):

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020

2. When I pull the information from xymon server:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26


Notice how the date field gets modified?  I can't figure out why. The
only thing I can think of is something within the xymon code, but I don't
know why it would?

Here's the simple script:

[davieb at xymonsvr ~]$ cat ~xymon/client/local/dateinfo
#!/bin/sh

OS=`uname -s`
RPM=dhcp-common

if [ ${OS} = "Linux" ]; then
   VERSION=`rpm -q ${RPM} --qf "%{VERSION}\n"`
   INSTALLED=`rpm -q ${RPM} --qf "%{INSTALLTIME:date}\n"|awk {'print $2"
"$3" "$4'}`
fi

echo "${RPM},${VERSION},${INSTALLED}"

Does anybody have any idea what is going on?

Thanks,
Dave

list David Boyer · Mon, 3 Aug 2020 22:25:53 -0400 ·
Jeremy,
           You read my mind!  But, it didn't seem to help... :(
quoted from Jeremy Laidman

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020,en_US.UTF-8

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog xymonsvr
section=local:dateinfo"
[local:dateinfo]

dhcp-common,4.3.6,Jul 18 17:44:26,en_US.UTF-8

[davieb at xymonsvr ~]$ cat ~xymon/client/local/dateinfo
#!/bin/sh

OS=`uname -s`
RPM=dhcp-common
LANG=en_US.UTF-8;export LANG
quoted from Jeremy Laidman

if [ ${OS} = "Linux" ]; then
   VERSION=`rpm -q ${RPM} --qf "%{VERSION}\n"`
   INSTALLED=`rpm -q ${RPM} --qf "%{INSTALLTIME:date}\n"|awk {'print $2"
"$3" "$4'}`
fi

echo "${RPM},${VERSION},${INSTALLED},${LANG}"

Good thing I'm grey already... This is the kinda stuff that would turn me
grey!
quoted from Jeremy Laidman

Dave


On Mon, Aug 3, 2020 at 9:21 PM Jeremy Laidman <user-0608abae5e7c@xymon.invalid> wrote:
Great to see that the problem has been identified.

I would recommend forcing LANG in your script to a known value, because
that's the code that makes an assumption about the output of rpm.

J

On Tue, 4 Aug 2020 at 10:56, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Jeremy,
       If you notice, both iterations are being run from the xymonsvr.
I've added the LANG to see if the
two report it differently.

So, by hand it looks:

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020,en_US.UTF-8

Pulling the info out of xymon looks:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26,*C*

Humm, there does appear to be a difference!  Checking the xymon user
itself, it UTF-8.
[xymon at xymonsvr ~]$ echo $LANG
en_US.UTF-8


That appears to be the issue though, I set the LANG=C and ran the script
by hand and get the same results when I pull it from xymon!
[davieb at xymonsvr ~]$ LANG=C;export LANG
[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,Jul 18 17:44:26,C

Looking at the xymon.sh start script, it does not appear to set it
anywhere!  Guess I'll need to run that
to ground in the morning.

Thanks for pointing me in the right direction!

Dave

On Mon, Aug 3, 2020 at 8:11 PM Jeremy Laidman <user-0608abae5e7c@xymon.invalid> wrote:
David

Update your script to, display the value of the LANG variable in
addition to the RPM details (perhaps on a separate line), and see if the
value differs between the script output (run from your shell) and the
clientlog.

I suspect LANG is set in your shell differently from how it's set in the
xymon user's shell. RPM (or probably glibc) uses LANG to format the date
according to the environment's locale. I'm guessing your shell has LANG set
to something like en_US, whereas the xymon user's LANG is set to something
like C, or is not set at all.

Cheers
Jeremy

On Tue, 4 Aug 2020 at 08:32, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Hi,
    I've got a strange date issue.  I've written some local scripts to
pad information onto the combo message. Here is the background:

1. When you run the script by hand locally (take note of the date):

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020

2. When I pull the information from xymon server:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26


Notice how the date field gets modified?  I can't figure out why. The
only thing I can think of is something within the xymon code, but I don't
know why it would?

Here's the simple script:

[davieb at xymonsvr ~]$ cat ~xymon/client/local/dateinfo
#!/bin/sh

OS=`uname -s`
RPM=dhcp-common

if [ ${OS} = "Linux" ]; then
   VERSION=`rpm -q ${RPM} --qf "%{VERSION}\n"`
   INSTALLED=`rpm -q ${RPM} --qf "%{INSTALLTIME:date}\n"|awk {'print
$2" "$3" "$4'}`
fi

echo "${RPM},${VERSION},${INSTALLED}"

Does anybody have any idea what is going on?

Thanks,
Dave

list David Boyer · Mon, 3 Aug 2020 22:44:08 -0400 ·
Jeremy,
            So I thought about changing the output..  I compressed the
spaces and then I put a _ in lieu of the spaces.

As you can see below, they both get mangled...

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18_Jul_2020,en_US.UTF-8
[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog xymonsvr
section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul_18_17:44:26,en_US.UTF-8

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18Jul2020,en_US.UTF-8
[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog xymonsvr
section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul1817:44:26,en_US.UTF-8
quoted from David Boyer


On Mon, Aug 3, 2020 at 10:25 PM David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Jeremy,
           You read my mind!  But, it didn't seem to help... :(

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020,en_US.UTF-8

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26,en_US.UTF-8

[davieb at xymonsvr ~]$ cat ~xymon/client/local/dateinfo
#!/bin/sh

OS=`uname -s`
RPM=dhcp-common
LANG=en_US.UTF-8;export LANG

if [ ${OS} = "Linux" ]; then
   VERSION=`rpm -q ${RPM} --qf "%{VERSION}\n"`
   INSTALLED=`rpm -q ${RPM} --qf "%{INSTALLTIME:date}\n"|awk {'print $2"
"$3" "$4'}`
fi

echo "${RPM},${VERSION},${INSTALLED},${LANG}"

Good thing I'm grey already... This is the kinda stuff that would turn me
grey!

Dave


On Mon, Aug 3, 2020 at 9:21 PM Jeremy Laidman <user-0608abae5e7c@xymon.invalid> wrote:
Great to see that the problem has been identified.

I would recommend forcing LANG in your script to a known value, because
that's the code that makes an assumption about the output of rpm.

J

On Tue, 4 Aug 2020 at 10:56, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Jeremy,
       If you notice, both iterations are being run from the xymonsvr.
I've added the LANG to see if the
two report it differently.

So, by hand it looks:

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020,en_US.UTF-8

Pulling the info out of xymon looks:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26,*C*

Humm, there does appear to be a difference!  Checking the xymon user
itself, it UTF-8.
[xymon at xymonsvr ~]$ echo $LANG
en_US.UTF-8


That appears to be the issue though, I set the LANG=C and ran the script
by hand and get the same results when I pull it from xymon!
[davieb at xymonsvr ~]$ LANG=C;export LANG
[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,Jul 18 17:44:26,C

Looking at the xymon.sh start script, it does not appear to set it
anywhere!  Guess I'll need to run that
to ground in the morning.

Thanks for pointing me in the right direction!

Dave

On Mon, Aug 3, 2020 at 8:11 PM Jeremy Laidman <user-0608abae5e7c@xymon.invalid>
wrote:
David

Update your script to, display the value of the LANG variable in
addition to the RPM details (perhaps on a separate line), and see if the
value differs between the script output (run from your shell) and the
clientlog.

I suspect LANG is set in your shell differently from how it's set in
the xymon user's shell. RPM (or probably glibc) uses LANG to format the
date according to the environment's locale. I'm guessing your shell has
LANG set to something like en_US, whereas the xymon user's LANG is set to
something like C, or is not set at all.

Cheers
Jeremy

On Tue, 4 Aug 2020 at 08:32, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Hi,
    I've got a strange date issue.  I've written some local scripts to
pad information onto the combo message. Here is the background:

1. When you run the script by hand locally (take note of the date):

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020

2. When I pull the information from xymon server:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26


Notice how the date field gets modified?  I can't figure out why. The
only thing I can think of is something within the xymon code, but I don't
know why it would?

Here's the simple script:

[davieb at xymonsvr ~]$ cat ~xymon/client/local/dateinfo
#!/bin/sh

OS=`uname -s`
RPM=dhcp-common

if [ ${OS} = "Linux" ]; then
   VERSION=`rpm -q ${RPM} --qf "%{VERSION}\n"`
   INSTALLED=`rpm -q ${RPM} --qf "%{INSTALLTIME:date}\n"|awk {'print
$2" "$3" "$4'}`
fi

echo "${RPM},${VERSION},${INSTALLED}"

Does anybody have any idea what is going on?

Thanks,
Dave

list Jeremy Laidman · Tue, 4 Aug 2020 13:21:30 +1000 ·
Hmm, interesting.

I wonder if the sub-shell that is spawned by the backticks is overriding
the environment somehow. Perhaps do it this way:

   INSTALLED=`LANG=en_US.UTF-8 rpm -q ${RPM} --qf
"%{INSTALLTIME:date}\n"|awk {'print $2" "$3" "$4'}`

This sets the environment only for the "rpm" command.

Alternatively, just assume the date format will be as if LANG=C, by some
as-yet unknown magic, and change the positional parameters printed by awk
to include $3 $2 $5. This would not be my preferred solution, but it'll
probably work, and will get you results while you investigate why the other
solution doesn't work.

I noticed that xymonclient.sh sets LANG=C. You now override LANG in your
script, so this shouldn't cause the behaviour you're seeing. However,
xymonclient.sh also sets both LC_MESSAGES and LC_ALL to C, so they might be
a problem.
quoted from David Boyer

Cheers
Jeremy


On Tue, 4 Aug 2020 at 12:26, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Jeremy,
           You read my mind!  But, it didn't seem to help... :(

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020,en_US.UTF-8

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26,en_US.UTF-8

[davieb at xymonsvr ~]$ cat ~xymon/client/local/dateinfo
#!/bin/sh

OS=`uname -s`
RPM=dhcp-common
LANG=en_US.UTF-8;export LANG

if [ ${OS} = "Linux" ]; then
   VERSION=`rpm -q ${RPM} --qf "%{VERSION}\n"`
   INSTALLED=`rpm -q ${RPM} --qf "%{INSTALLTIME:date}\n"|awk {'print $2"
"$3" "$4'}`
fi

echo "${RPM},${VERSION},${INSTALLED},${LANG}"

Good thing I'm grey already... This is the kinda stuff that would turn me
grey!

Dave


On Mon, Aug 3, 2020 at 9:21 PM Jeremy Laidman <user-0608abae5e7c@xymon.invalid> wrote:
Great to see that the problem has been identified.

I would recommend forcing LANG in your script to a known value, because
that's the code that makes an assumption about the output of rpm.

J

On Tue, 4 Aug 2020 at 10:56, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Jeremy,
       If you notice, both iterations are being run from the xymonsvr.
I've added the LANG to see if the
two report it differently.

So, by hand it looks:

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020,en_US.UTF-8

Pulling the info out of xymon looks:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26,*C*

Humm, there does appear to be a difference!  Checking the xymon user
itself, it UTF-8.
[xymon at xymonsvr ~]$ echo $LANG
en_US.UTF-8


That appears to be the issue though, I set the LANG=C and ran the script
by hand and get the same results when I pull it from xymon!
[davieb at xymonsvr ~]$ LANG=C;export LANG
[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,Jul 18 17:44:26,C

Looking at the xymon.sh start script, it does not appear to set it
anywhere!  Guess I'll need to run that
to ground in the morning.

Thanks for pointing me in the right direction!

Dave

On Mon, Aug 3, 2020 at 8:11 PM Jeremy Laidman <user-0608abae5e7c@xymon.invalid>
wrote:
David

Update your script to, display the value of the LANG variable in
addition to the RPM details (perhaps on a separate line), and see if the
value differs between the script output (run from your shell) and the
clientlog.

I suspect LANG is set in your shell differently from how it's set in
the xymon user's shell. RPM (or probably glibc) uses LANG to format the
date according to the environment's locale. I'm guessing your shell has
LANG set to something like en_US, whereas the xymon user's LANG is set to
something like C, or is not set at all.

Cheers
Jeremy

On Tue, 4 Aug 2020 at 08:32, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Hi,
    I've got a strange date issue.  I've written some local scripts to
pad information onto the combo message. Here is the background:

1. When you run the script by hand locally (take note of the date):

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020

2. When I pull the information from xymon server:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26


Notice how the date field gets modified?  I can't figure out why. The
only thing I can think of is something within the xymon code, but I don't
know why it would?

Here's the simple script:

[davieb at xymonsvr ~]$ cat ~xymon/client/local/dateinfo
#!/bin/sh

OS=`uname -s`
RPM=dhcp-common

if [ ${OS} = "Linux" ]; then
   VERSION=`rpm -q ${RPM} --qf "%{VERSION}\n"`
   INSTALLED=`rpm -q ${RPM} --qf "%{INSTALLTIME:date}\n"|awk {'print
$2" "$3" "$4'}`
fi

echo "${RPM},${VERSION},${INSTALLED}"

Does anybody have any idea what is going on?

Thanks,
Dave

list Jeremy Laidman · Tue, 4 Aug 2020 13:25:07 +1000 ·
David

I think the problem is that xymonclient.sh sets LC_ALL=C, which essentially
overrides the value of LANG. For example:

$ *LANG=en_US.UTF-8 rpm -q dhcp-common --qf "%{INSTALLTIME:date}\n"*
Tue 21 Apr 2020 01:14:57 PM AEST

$ *LANG=en_US.UTF-8 LC_ALL=C rpm -q dhcp-common --qf
"%{INSTALLTIME:date}\n"*
Tue Apr 21 13:14:57 2020

$ *LC_ALL=en_US.UTF-8 LANG=C rpm -q dhcp-common --qf
"%{INSTALLTIME:date}\n"*
Tue 21 Apr 2020 01:14:57 PM AEST

So, your script should only need to set LC_ALL=en_US.UTF-8, and it should
work.

But it seems like the world is trying to conspire against you changing
LANG/LC_ALL/LC_MESSAGES to anything but C, and I'd be inclined to go with
the flow, and assume that format; but also, set LC_ALL to C just in case.
quoted from Jeremy Laidman

J


On Tue, 4 Aug 2020 at 12:44, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Jeremy,
            So I thought about changing the output..  I compressed the
spaces and then I put a _ in lieu of the spaces.

As you can see below, they both get mangled...

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18_Jul_2020,en_US.UTF-8
[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul_18_17:44:26,en_US.UTF-8

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18Jul2020,en_US.UTF-8
[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul1817:44:26,en_US.UTF-8


On Mon, Aug 3, 2020 at 10:25 PM David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Jeremy,
           You read my mind!  But, it didn't seem to help... :(

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020,en_US.UTF-8

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26,en_US.UTF-8

[davieb at xymonsvr ~]$ cat ~xymon/client/local/dateinfo
#!/bin/sh

OS=`uname -s`
RPM=dhcp-common
LANG=en_US.UTF-8;export LANG

if [ ${OS} = "Linux" ]; then
   VERSION=`rpm -q ${RPM} --qf "%{VERSION}\n"`
   INSTALLED=`rpm -q ${RPM} --qf "%{INSTALLTIME:date}\n"|awk {'print $2"
"$3" "$4'}`
fi

echo "${RPM},${VERSION},${INSTALLED},${LANG}"

Good thing I'm grey already... This is the kinda stuff that would turn me
grey!

Dave


On Mon, Aug 3, 2020 at 9:21 PM Jeremy Laidman <user-0608abae5e7c@xymon.invalid> wrote:
Great to see that the problem has been identified.

I would recommend forcing LANG in your script to a known value, because
that's the code that makes an assumption about the output of rpm.

J

On Tue, 4 Aug 2020 at 10:56, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Jeremy,
       If you notice, both iterations are being run from the xymonsvr.
I've added the LANG to see if the
two report it differently.

So, by hand it looks:

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020,en_US.UTF-8

Pulling the info out of xymon looks:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26,*C*

Humm, there does appear to be a difference!  Checking the xymon user
itself, it UTF-8.
[xymon at xymonsvr ~]$ echo $LANG
en_US.UTF-8


That appears to be the issue though, I set the LANG=C and ran the
script by hand and get the same results when I pull it from xymon!
[davieb at xymonsvr ~]$ LANG=C;export LANG
[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,Jul 18 17:44:26,C

Looking at the xymon.sh start script, it does not appear to set it
anywhere!  Guess I'll need to run that
to ground in the morning.

Thanks for pointing me in the right direction!

Dave

On Mon, Aug 3, 2020 at 8:11 PM Jeremy Laidman <user-0608abae5e7c@xymon.invalid>
wrote:
David

Update your script to, display the value of the LANG variable in
addition to the RPM details (perhaps on a separate line), and see if the
value differs between the script output (run from your shell) and the
clientlog.

I suspect LANG is set in your shell differently from how it's set in
the xymon user's shell. RPM (or probably glibc) uses LANG to format the
date according to the environment's locale. I'm guessing your shell has
LANG set to something like en_US, whereas the xymon user's LANG is set to
something like C, or is not set at all.

Cheers
Jeremy

On Tue, 4 Aug 2020 at 08:32, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Hi,
    I've got a strange date issue.  I've written some local scripts
to pad information onto the combo message. Here is the background:

1. When you run the script by hand locally (take note of the date):

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020

2. When I pull the information from xymon server:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26


Notice how the date field gets modified?  I can't figure out why. The
only thing I can think of is something within the xymon code, but I don't
know why it would?

Here's the simple script:

[davieb at xymonsvr ~]$ cat ~xymon/client/local/dateinfo
#!/bin/sh

OS=`uname -s`
RPM=dhcp-common

if [ ${OS} = "Linux" ]; then
   VERSION=`rpm -q ${RPM} --qf "%{VERSION}\n"`
   INSTALLED=`rpm -q ${RPM} --qf "%{INSTALLTIME:date}\n"|awk {'print
$2" "$3" "$4'}`
fi

echo "${RPM},${VERSION},${INSTALLED}"

Does anybody have any idea what is going on?

Thanks,
Dave

list David Boyer · Wed, 5 Aug 2020 18:17:14 -0400 ·
Jeremy,
            I forgot to get back to you on this.   SUCCESS !!!   Changed
the LC_ALL and it is working as expected now...
Thanks very very much... I owe ya!
quoted from Jeremy Laidman

Dave

On Mon, Aug 3, 2020 at 11:25 PM Jeremy Laidman <user-0608abae5e7c@xymon.invalid> wrote:
David

I think the problem is that xymonclient.sh sets LC_ALL=C, which
essentially overrides the value of LANG. For example:

$ *LANG=en_US.UTF-8 rpm -q dhcp-common --qf "%{INSTALLTIME:date}\n"*
Tue 21 Apr 2020 01:14:57 PM AEST

$ *LANG=en_US.UTF-8 LC_ALL=C rpm -q dhcp-common --qf
"%{INSTALLTIME:date}\n"*
Tue Apr 21 13:14:57 2020

$ *LC_ALL=en_US.UTF-8 LANG=C rpm -q dhcp-common --qf
"%{INSTALLTIME:date}\n"*
Tue 21 Apr 2020 01:14:57 PM AEST

So, your script should only need to set LC_ALL=en_US.UTF-8, and it should
work.

But it seems like the world is trying to conspire against you changing
LANG/LC_ALL/LC_MESSAGES to anything but C, and I'd be inclined to go with
the flow, and assume that format; but also, set LC_ALL to C just in case.

J


On Tue, 4 Aug 2020 at 12:44, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Jeremy,
            So I thought about changing the output..  I compressed the
spaces and then I put a _ in lieu of the spaces.

As you can see below, they both get mangled...

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18_Jul_2020,en_US.UTF-8
[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul_18_17:44:26,en_US.UTF-8

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18Jul2020,en_US.UTF-8
[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul1817:44:26,en_US.UTF-8


On Mon, Aug 3, 2020 at 10:25 PM David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Jeremy,
           You read my mind!  But, it didn't seem to help... :(

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020,en_US.UTF-8

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26,en_US.UTF-8

[davieb at xymonsvr ~]$ cat ~xymon/client/local/dateinfo
#!/bin/sh

OS=`uname -s`
RPM=dhcp-common
LANG=en_US.UTF-8;export LANG

if [ ${OS} = "Linux" ]; then
   VERSION=`rpm -q ${RPM} --qf "%{VERSION}\n"`
   INSTALLED=`rpm -q ${RPM} --qf "%{INSTALLTIME:date}\n"|awk {'print $2"
"$3" "$4'}`
fi

echo "${RPM},${VERSION},${INSTALLED},${LANG}"

Good thing I'm grey already... This is the kinda stuff that would turn
me grey!

Dave


On Mon, Aug 3, 2020 at 9:21 PM Jeremy Laidman <user-0608abae5e7c@xymon.invalid>
wrote:
Great to see that the problem has been identified.

I would recommend forcing LANG in your script to a known value, because
that's the code that makes an assumption about the output of rpm.

J

On Tue, 4 Aug 2020 at 10:56, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Jeremy,
       If you notice, both iterations are being run from the
xymonsvr.  I've added the LANG to see if the
two report it differently.

So, by hand it looks:

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020,en_US.UTF-8

Pulling the info out of xymon looks:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26,*C*

Humm, there does appear to be a difference!  Checking the xymon user
itself, it UTF-8.
[xymon at xymonsvr ~]$ echo $LANG
en_US.UTF-8


That appears to be the issue though, I set the LANG=C and ran the
script by hand and get the same results when I pull it from xymon!
[davieb at xymonsvr ~]$ LANG=C;export LANG
[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,Jul 18 17:44:26,C

Looking at the xymon.sh start script, it does not appear to set it
anywhere!  Guess I'll need to run that
to ground in the morning.

Thanks for pointing me in the right direction!

Dave

On Mon, Aug 3, 2020 at 8:11 PM Jeremy Laidman <user-0608abae5e7c@xymon.invalid>
wrote:
David

Update your script to, display the value of the LANG variable in
addition to the RPM details (perhaps on a separate line), and see if the
value differs between the script output (run from your shell) and the
clientlog.

I suspect LANG is set in your shell differently from how it's set in
the xymon user's shell. RPM (or probably glibc) uses LANG to format the
date according to the environment's locale. I'm guessing your shell has
LANG set to something like en_US, whereas the xymon user's LANG is set to
something like C, or is not set at all.

Cheers
Jeremy

On Tue, 4 Aug 2020 at 08:32, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Hi,
    I've got a strange date issue.  I've written some local scripts
to pad information onto the combo message. Here is the background:

1. When you run the script by hand locally (take note of the date):

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020

2. When I pull the information from xymon server:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26


Notice how the date field gets modified?  I can't figure out why.
The only thing I can think of is something within the xymon code, but I
don't know why it would?

Here's the simple script:

[davieb at xymonsvr ~]$ cat ~xymon/client/local/dateinfo
#!/bin/sh

OS=`uname -s`
RPM=dhcp-common

if [ ${OS} = "Linux" ]; then
   VERSION=`rpm -q ${RPM} --qf "%{VERSION}\n"`
   INSTALLED=`rpm -q ${RPM} --qf "%{INSTALLTIME:date}\n"|awk {'print
$2" "$3" "$4'}`
fi

echo "${RPM},${VERSION},${INSTALLED}"

Does anybody have any idea what is going on?

Thanks,
Dave

list Jeremy Laidman · Thu, 6 Aug 2020 09:17:24 +1000 ·
Dave

Good to hear it worked. Thanks for reporting back.

Cheers
Jeremy
quoted from David Boyer


On Thu, 6 Aug 2020 at 08:17, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Jeremy,
            I forgot to get back to you on this.   SUCCESS !!!   Changed
the LC_ALL and it is working as expected now...
Thanks very very much... I owe ya!

Dave

On Mon, Aug 3, 2020 at 11:25 PM Jeremy Laidman <user-0608abae5e7c@xymon.invalid> wrote:
David

I think the problem is that xymonclient.sh sets LC_ALL=C, which
essentially overrides the value of LANG. For example:

$ *LANG=en_US.UTF-8 rpm -q dhcp-common --qf "%{INSTALLTIME:date}\n"*
Tue 21 Apr 2020 01:14:57 PM AEST

$ *LANG=en_US.UTF-8 LC_ALL=C rpm -q dhcp-common --qf
"%{INSTALLTIME:date}\n"*
Tue Apr 21 13:14:57 2020

$ *LC_ALL=en_US.UTF-8 LANG=C rpm -q dhcp-common --qf
"%{INSTALLTIME:date}\n"*
Tue 21 Apr 2020 01:14:57 PM AEST

So, your script should only need to set LC_ALL=en_US.UTF-8, and it should
work.

But it seems like the world is trying to conspire against you changing
LANG/LC_ALL/LC_MESSAGES to anything but C, and I'd be inclined to go with
the flow, and assume that format; but also, set LC_ALL to C just in case.

J


On Tue, 4 Aug 2020 at 12:44, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Jeremy,
            So I thought about changing the output..  I compressed the
spaces and then I put a _ in lieu of the spaces.

As you can see below, they both get mangled...

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18_Jul_2020,en_US.UTF-8
[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul_18_17:44:26,en_US.UTF-8

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18Jul2020,en_US.UTF-8
[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul1817:44:26,en_US.UTF-8


On Mon, Aug 3, 2020 at 10:25 PM David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Jeremy,
           You read my mind!  But, it didn't seem to help... :(

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020,en_US.UTF-8

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26,en_US.UTF-8

[davieb at xymonsvr ~]$ cat ~xymon/client/local/dateinfo
#!/bin/sh

OS=`uname -s`
RPM=dhcp-common
LANG=en_US.UTF-8;export LANG

if [ ${OS} = "Linux" ]; then
   VERSION=`rpm -q ${RPM} --qf "%{VERSION}\n"`
   INSTALLED=`rpm -q ${RPM} --qf "%{INSTALLTIME:date}\n"|awk {'print
$2" "$3" "$4'}`
fi

echo "${RPM},${VERSION},${INSTALLED},${LANG}"

Good thing I'm grey already... This is the kinda stuff that would turn
me grey!

Dave


On Mon, Aug 3, 2020 at 9:21 PM Jeremy Laidman <user-0608abae5e7c@xymon.invalid>
wrote:
Great to see that the problem has been identified.

I would recommend forcing LANG in your script to a known value,
because that's the code that makes an assumption about the output of rpm.

J

On Tue, 4 Aug 2020 at 10:56, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Jeremy,
       If you notice, both iterations are being run from the
xymonsvr.  I've added the LANG to see if the
two report it differently.

So, by hand it looks:

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020,en_US.UTF-8

Pulling the info out of xymon looks:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26,*C*

Humm, there does appear to be a difference!  Checking the xymon user
itself, it UTF-8.
[xymon at xymonsvr ~]$ echo $LANG
en_US.UTF-8


That appears to be the issue though, I set the LANG=C and ran the
script by hand and get the same results when I pull it from xymon!
[davieb at xymonsvr ~]$ LANG=C;export LANG
[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,Jul 18 17:44:26,C

Looking at the xymon.sh start script, it does not appear to set it
anywhere!  Guess I'll need to run that
to ground in the morning.

Thanks for pointing me in the right direction!

Dave

On Mon, Aug 3, 2020 at 8:11 PM Jeremy Laidman <user-0608abae5e7c@xymon.invalid>
wrote:
David

Update your script to, display the value of the LANG variable in
addition to the RPM details (perhaps on a separate line), and see if the
value differs between the script output (run from your shell) and the
clientlog.

I suspect LANG is set in your shell differently from how it's set in
the xymon user's shell. RPM (or probably glibc) uses LANG to format the
date according to the environment's locale. I'm guessing your shell has
LANG set to something like en_US, whereas the xymon user's LANG is set to
something like C, or is not set at all.

Cheers
Jeremy

On Tue, 4 Aug 2020 at 08:32, David Boyer <user-a6c09f28d9d2@xymon.invalid> wrote:
Hi,
    I've got a strange date issue.  I've written some local scripts
to pad information onto the combo message. Here is the background:

1. When you run the script by hand locally (take note of the date):

[davieb at xymonsvr ~]$ ~xymon/client/local/dateinfo
dhcp-common,4.3.6,18 Jul 2020

2. When I pull the information from xymon server:

[davieb at xymonsvr ~]$ ~xymon/server/bin/xymon localhost "clientlog
xymonsvr section=local:dateinfo"
[local:dateinfo]
dhcp-common,4.3.6,Jul 18 17:44:26


Notice how the date field gets modified?  I can't figure out why.
The only thing I can think of is something within the xymon code, but I
don't know why it would?

Here's the simple script:

[davieb at xymonsvr ~]$ cat ~xymon/client/local/dateinfo
#!/bin/sh

OS=`uname -s`
RPM=dhcp-common

if [ ${OS} = "Linux" ]; then
   VERSION=`rpm -q ${RPM} --qf "%{VERSION}\n"`
   INSTALLED=`rpm -q ${RPM} --qf "%{INSTALLTIME:date}\n"|awk
{'print $2" "$3" "$4'}`
fi

echo "${RPM},${VERSION},${INSTALLED}"

Does anybody have any idea what is going on?

Thanks,
Dave