Grepping chef-client output

Running chef-client 10.24.0 on some hosts I get a veritable deluge of WARN
messages about things that aren’t being done quite right and should be
changed (many things, I’ll add, that had not issued WARN messages in prior
versions of chef-client). I’d like to be able to grep out those WARN
messages, but when I do it kills all chef-client output. Trying to
redirect STDERR doesn’t make a difference.

Is there a best practice way of filtering chef-client output?


Dylan Northrup

Change log_level :info
to
log_level :warn

for one run?

That's an easy way. :slight_smile:

On Fri, Mar 1, 2013 at 1:37 PM, Dylan Northrup chef@doc-x.net wrote:

Running chef-client 10.24.0 on some hosts I get a veritable deluge of WARN
messages about things that aren't being done quite right and should be
changed (many things, I'll add, that had not issued WARN messages in prior
versions of chef-client). I'd like to be able to grep out those WARN
messages, but when I do it kills all chef-client output. Trying to redirect
STDERR doesn't make a difference.

Is there a best practice way of filtering chef-client output?

--
Dylan Northrup

Is this just an issue with greps buffering? Does it work if you use

grep --line-buffered -v [WARN]

On Fri, Mar 1, 2013 at 2:39 PM, Mike miketheman@gmail.com wrote:

Change log_level :info
to
log_level :warn

for one run?

That's an easy way. :slight_smile:

On Fri, Mar 1, 2013 at 1:37 PM, Dylan Northrup chef@doc-x.net wrote:

Running chef-client 10.24.0 on some hosts I get a veritable deluge of
WARN
messages about things that aren't being done quite right and should be
changed (many things, I'll add, that had not issued WARN messages in
prior
versions of chef-client). I'd like to be able to grep out those WARN
messages, but when I do it kills all chef-client output. Trying to
redirect
STDERR doesn't make a difference.

Is there a best practice way of filtering chef-client output?

--
Dylan Northrup

That would filter out the INFO messsages (which I actually still want to
see) and only show me the WARN messages (which I do not want to see).
Because WARN is higher priority than INFO, there's not an easy way I can
see to filter out that specific level of message that I can see.

On Fri, Mar 1, 2013 at 2:39 PM, Mike miketheman@gmail.com wrote:

Change log_level :info
to
log_level :warn

for one run?

That's an easy way. :slight_smile:

On Fri, Mar 1, 2013 at 1:37 PM, Dylan Northrup chef@doc-x.net wrote:

Running chef-client 10.24.0 on some hosts I get a veritable deluge of
WARN
messages about things that aren't being done quite right and should be
changed (many things, I'll add, that had not issued WARN messages in
prior
versions of chef-client). I'd like to be able to grep out those WARN
messages, but when I do it kills all chef-client output. Trying to
redirect
STDERR doesn't make a difference.

Is there a best practice way of filtering chef-client output?

--
Dylan Northrup

Nope. I don't get any of the INFO lines when I do that.

On Fri, Mar 1, 2013 at 2:46 PM, Andrew Gross andrew@yipit.com wrote:

Is this just an issue with greps buffering? Does it work if you use

grep --line-buffered -v [WARN]

On Fri, Mar 1, 2013 at 2:39 PM, Mike miketheman@gmail.com wrote:

Change log_level :info
to
log_level :warn

for one run?

That's an easy way. :slight_smile:

On Fri, Mar 1, 2013 at 1:37 PM, Dylan Northrup chef@doc-x.net wrote:

Running chef-client 10.24.0 on some hosts I get a veritable deluge of
WARN
messages about things that aren't being done quite right and should be
changed (many things, I'll add, that had not issued WARN messages in
prior
versions of chef-client). I'd like to be able to grep out those WARN
messages, but when I do it kills all chef-client output. Trying to
redirect
STDERR doesn't make a difference.

Is there a best practice way of filtering chef-client output?

--
Dylan Northrup

I thought you wanted only WARN.

How about this?

chef-client 2>1 | grep -v WARN

On Fri, Mar 1, 2013 at 4:59 PM, Dylan Northrup chef@doc-x.net wrote:

That would filter out the INFO messsages (which I actually still want to
see) and only show me the WARN messages (which I do not want to see).
Because WARN is higher priority than INFO, there's not an easy way I can see
to filter out that specific level of message that I can see.

On Fri, Mar 1, 2013 at 2:39 PM, Mike miketheman@gmail.com wrote:

Change log_level :info
to
log_level :warn

for one run?

That's an easy way. :slight_smile:

On Fri, Mar 1, 2013 at 1:37 PM, Dylan Northrup chef@doc-x.net wrote:

Running chef-client 10.24.0 on some hosts I get a veritable deluge of
WARN
messages about things that aren't being done quite right and should be
changed (many things, I'll add, that had not issued WARN messages in
prior
versions of chef-client). I'd like to be able to grep out those WARN
messages, but when I do it kills all chef-client output. Trying to
redirect
STDERR doesn't make a difference.

Is there a best practice way of filtering chef-client output?

--
Dylan Northrup

To slip into pedantry, it should be 'chef-client 2>&1 | grep -v WARN' and
that also doesn't show any of the INFO messages.

On Fri, Mar 1, 2013 at 6:06 PM, Mike miketheman@gmail.com wrote:

I thought you wanted only WARN.

How about this?

chef-client 2>1 | grep -v WARN

On Fri, Mar 1, 2013 at 4:59 PM, Dylan Northrup chef@doc-x.net wrote:

That would filter out the INFO messsages (which I actually still want to
see) and only show me the WARN messages (which I do not want to see).
Because WARN is higher priority than INFO, there's not an easy way I can
see
to filter out that specific level of message that I can see.

On Fri, Mar 1, 2013 at 2:39 PM, Mike miketheman@gmail.com wrote:

Change log_level :info
to
log_level :warn

for one run?

That's an easy way. :slight_smile:

On Fri, Mar 1, 2013 at 1:37 PM, Dylan Northrup chef@doc-x.net wrote:

Running chef-client 10.24.0 on some hosts I get a veritable deluge of
WARN
messages about things that aren't being done quite right and should be
changed (many things, I'll add, that had not issued WARN messages in
prior
versions of chef-client). I'd like to be able to grep out those WARN
messages, but when I do it kills all chef-client output. Trying to
redirect
STDERR doesn't make a difference.

Is there a best practice way of filtering chef-client output?

--
Dylan Northrup

Mine worked.

On Fri, Mar 1, 2013 at 5:09 PM, Dylan Northrup chef@doc-x.net wrote:

To slip into pedantry, it should be 'chef-client 2>&1 | grep -v WARN' and
that also doesn't show any of the INFO messages.

On Fri, Mar 1, 2013 at 6:06 PM, Mike miketheman@gmail.com wrote:

I thought you wanted only WARN.

How about this?

chef-client 2>1 | grep -v WARN

On Fri, Mar 1, 2013 at 4:59 PM, Dylan Northrup chef@doc-x.net wrote:

That would filter out the INFO messsages (which I actually still want to
see) and only show me the WARN messages (which I do not want to see).
Because WARN is higher priority than INFO, there's not an easy way I can
see
to filter out that specific level of message that I can see.

On Fri, Mar 1, 2013 at 2:39 PM, Mike miketheman@gmail.com wrote:

Change log_level :info
to
log_level :warn

for one run?

That's an easy way. :slight_smile:

On Fri, Mar 1, 2013 at 1:37 PM, Dylan Northrup chef@doc-x.net wrote:

Running chef-client 10.24.0 on some hosts I get a veritable deluge of
WARN
messages about things that aren't being done quite right and should
be
changed (many things, I'll add, that had not issued WARN messages in
prior
versions of chef-client). I'd like to be able to grep out those WARN
messages, but when I do it kills all chef-client output. Trying to
redirect
STDERR doesn't make a difference.

Is there a best practice way of filtering chef-client output?

--
Dylan Northrup

Mine didn't.

root@testbox:~# uname -a
Linux testbox 3.2.0-31-virtual #50-Ubuntu SMP Fri Sep 7 16:36:36 UTC 2012
x86_64 x86_64 x86_64 GNU/Linux
root@testbox:~# env | grep SHELL
SHELL=/bin/bash
root@testbox:~# cat /etc/*ease
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.1 LTS"
root@testbox:~# chef-client -v
Chef: 10.24.0
root@testbox:~# chef-client 2>&1 | grep -v WARN
root@testbox:~# chef-client
[2013-03-01T18:28:54-05:00] INFO: *** Chef 10.24.0 ***
[2013-03-01T18:28:54-05:00] INFO: [inet6] no default interface, picking the
first ipaddress

... and more output as expected

On Fri, Mar 1, 2013 at 6:10 PM, Mike miketheman@gmail.com wrote:

Mine worked.

On Fri, Mar 1, 2013 at 5:09 PM, Dylan Northrup chef@doc-x.net wrote:

To slip into pedantry, it should be 'chef-client 2>&1 | grep -v WARN' and
that also doesn't show any of the INFO messages.

On Fri, Mar 1, 2013 at 6:06 PM, Mike miketheman@gmail.com wrote:

I thought you wanted only WARN.

How about this?

chef-client 2>1 | grep -v WARN

On Fri, Mar 1, 2013 at 4:59 PM, Dylan Northrup chef@doc-x.net wrote:

That would filter out the INFO messsages (which I actually still want
to
see) and only show me the WARN messages (which I do not want to see).
Because WARN is higher priority than INFO, there's not an easy way I
can
see
to filter out that specific level of message that I can see.

On Fri, Mar 1, 2013 at 2:39 PM, Mike miketheman@gmail.com wrote:

Change log_level :info
to
log_level :warn

for one run?

That's an easy way. :slight_smile:

On Fri, Mar 1, 2013 at 1:37 PM, Dylan Northrup chef@doc-x.net
wrote:

Running chef-client 10.24.0 on some hosts I get a veritable deluge
of
WARN
messages about things that aren't being done quite right and should
be
changed (many things, I'll add, that had not issued WARN messages
in
prior
versions of chef-client). I'd like to be able to grep out those
WARN
messages, but when I do it kills all chef-client output. Trying to
redirect
STDERR doesn't make a difference.

Is there a best practice way of filtering chef-client output?

--
Dylan Northrup

Dylan,

I don't know why your system is doing what you think is the wrong
thing - I've just reproduced the same environment, and can confirm
that the WARN messages no longer appear.

Here's mine:

root@vagrant:~# uname -a
Linux vagrant 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC
2012 x86_64 x86_64 x86_64 GNU/Linux
root@vagrant:~# env | grep SHELL
SHELL=/bin/bash
root@vagrant:~# cat /etc/*ease
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.1 LTS"
NAME="Ubuntu"
VERSION="12.04.1 LTS, Precise Pangolin"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu precise (12.04.1 LTS)"
VERSION_ID="12.04"
root@vagrant:~# chef-client -v
Chef: 10.24.0

root@vagrant:~# chef-client
[2013-03-01T23:58:46+00:00] WARN: *****************************************
[2013-03-01T23:58:46+00:00] WARN: Did not find config file:
/etc/chef/client.rb, using command line options.
[2013-03-01T23:58:46+00:00] WARN: *****************************************
[2013-03-01T23:58:46+00:00] INFO: *** Chef 10.24.0 ***
[2013-03-01T23:58:46+00:00] INFO: [inet6] no default interface,
picking the first ipaddress
...

root@vagrant:~# chef-client 2>&1 | grep -v WARN
[2013-03-01T23:58:54+00:00] INFO: *** Chef 10.24.0 ***
[2013-03-01T23:58:54+00:00] INFO: [inet6] no default interface,
picking the first ipaddress
...

Hope this works out for you,
-M
...

On Fri, Mar 1, 2013 at 5:38 PM, Dylan Northrup chef@doc-x.net wrote:

Mine didn't.

root@testbox:~# uname -a
Linux testbox 3.2.0-31-virtual #50-Ubuntu SMP Fri Sep 7 16:36:36 UTC 2012
x86_64 x86_64 x86_64 GNU/Linux
root@testbox:~# env | grep SHELL
SHELL=/bin/bash
root@testbox:~# cat /etc/*ease
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.1 LTS"
root@testbox:~# chef-client -v
Chef: 10.24.0
root@testbox:~# chef-client 2>&1 | grep -v WARN
root@testbox:~# chef-client
[2013-03-01T18:28:54-05:00] INFO: *** Chef 10.24.0 ***
[2013-03-01T18:28:54-05:00] INFO: [inet6] no default interface, picking the
first ipaddress

... and more output as expected

On Fri, Mar 1, 2013 at 6:10 PM, Mike miketheman@gmail.com wrote:

Mine worked.

On Fri, Mar 1, 2013 at 5:09 PM, Dylan Northrup chef@doc-x.net wrote:

To slip into pedantry, it should be 'chef-client 2>&1 | grep -v WARN'
and
that also doesn't show any of the INFO messages.

On Fri, Mar 1, 2013 at 6:06 PM, Mike miketheman@gmail.com wrote:

I thought you wanted only WARN.

How about this?

chef-client 2>1 | grep -v WARN

On Fri, Mar 1, 2013 at 4:59 PM, Dylan Northrup chef@doc-x.net wrote:

That would filter out the INFO messsages (which I actually still want
to
see) and only show me the WARN messages (which I do not want to see).
Because WARN is higher priority than INFO, there's not an easy way I
can
see
to filter out that specific level of message that I can see.

On Fri, Mar 1, 2013 at 2:39 PM, Mike miketheman@gmail.com wrote:

Change log_level :info
to
log_level :warn

for one run?

That's an easy way. :slight_smile:

On Fri, Mar 1, 2013 at 1:37 PM, Dylan Northrup chef@doc-x.net
wrote:

Running chef-client 10.24.0 on some hosts I get a veritable deluge
of
WARN
messages about things that aren't being done quite right and
should
be
changed (many things, I'll add, that had not issued WARN messages
in
prior
versions of chef-client). I'd like to be able to grep out those
WARN
messages, but when I do it kills all chef-client output. Trying
to
redirect
STDERR doesn't make a difference.

Is there a best practice way of filtering chef-client output?

--
Dylan Northrup