k3oni / pydash

Small web-based monitoring dashboard for linux in Python and Django
663 stars 125 forks source link

IP Address grep doesnt always work #10

Closed ssimpson89 closed 10 years ago

ssimpson89 commented 10 years ago

Hey guys,

I have an openvz node and ip addr does not always show "state UP". I t will show an UNKNOWN even though network is going, so the command in the main.py fails and on top of it I dont think the awk statement works on all systems:

pydash]# ip addr | grep -A3 'state UP' | awk '{printf \"%s,\",$2}' |awk -F, '{print $1, $2, $3}'
awk: {printf \"%s,\",$2}
awk:         ^ backslash not last character on line

I normally use the following:

ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'

or

ip add | grep inet\\s | grep -v 127.0.0.1 | awk '{ print $2 }' | sed 's/\/[0-9]\{1,\}//' 

Just figured I would throw it out there.

k3oni commented 10 years ago

What OS are you running on the node?

Btw if you run that command on the server manually you will need to remove the \ as those are needed inside python to escape the double quotes.

ssimpson89 commented 10 years ago

CentOS 6

k3oni commented 10 years ago

Is that inside the OpenVZ container or main node?

ssimpson89 commented 10 years ago

This issue is from inside the openvz container

-- Stephen Simpson

On Thu, Feb 13, 2014 at 7:50 PM, Florian N notifications@github.com wrote:

Is that inside the OpenVZ container or main node?

Reply to this email directly or view it on GitHubhttps://github.com/k3oni/pydash/issues/10#issuecomment-35048285 .

k3oni commented 10 years ago

Thanks, can you provide me with the output of: ip -V , until i get to setup a openvz instance. I'm trying to find the best way of grabbing the ip details across OSs and iproute package is one available across all or most at this point.

k3oni commented 10 years ago

Check out the latest version and open again if you still see the issue.