I'm using Zabbix on which I can use give bash command to the agent.
This 1-liner will give me all the interfaces with their IPv4 addresses.
I have a 2nd expression which returns a checksum so I can detect a difference whenever someone deletes/adds/changes an ipv4 interface.
This is the output on my Ubuntu-server:
Code:
~# ifconfig | grep -B1 ' inet ' | grep -oE '(^[a-z0-9:]*|addr:[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)'
eth0
addr:192.168.10.100
lo
addr:127.0.0.1
This is the output on CentOS 5.5
Code:
# ifconfig | grep -B1 ' inet ' | grep -oE '(^[a-z0-9:]*|addr:[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)'
eth0
eth0:0
eth0:1
eth0:3
eth0:4
eth0:5
eth0:6
eth0:7
eth0:8
eth0:9
eth0:10
eth0:11
eth0:12
lo
I'm interested in 2 things.
I would really like a regular expression (as elegant as possible) which will give me the output similar to the first. It needs an output that can be checksummed so I can create a trigger on it.
I would also like to know which behaviour is the correct one.
This is my Ubuntu Lucid Lynx
Code:
# set | grep ^BASH
BASH=/bin/bash
BASHOPTS=checkwinsize:cmdhist:expand_aliases:extquote:force_fignore:histappend:hostcomplete:interactive_comments:login_shell:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="4" [1]="1" [2]="5" [3]="1" [4]="release" [5]="i486-pc-linux-gnu")
BASH_VERSION='4.1.5(1)-release'
This is CentOS5.5
Code:
# set | grep ^BASH
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="2" [2]="25" [3]="1" [4]="release" [5]="i686-redhat-linux-gnu")
BASH_VERSION='3.2.25(1)-release'