Operating System - HP-UX
1753672 Members
5579 Online
108799 Solutions
New Discussion юеВ

Re: Script to gather some lan information in HPUX 11.11 - 11.23

 
SOLVED
Go to solution
Santos Vega
Occasional Advisor

Script to gather some lan information in HPUX 11.11 - 11.23

Hello,

I am trying to write a script to gather information about standby lan cards in clusters. I need to check which lans are standby and I need to obtain the values of MTU for these lans to pass them to a tcpdump:

tcpdump -i тАУn тАУv -s -c 1 'ether[20:2] == 0x2000'

I can obtain the standby lan cards from:

server1:/># cmviewcl -v |grep STANDBY | awk '{print$4}'
lan7
lan8

..and the MTU from:

server1:/># for i in `cmviewcl -v |grep STANDBY | awk '{print$4}'`^Jdo^Jnetstat -in | grep $i | awk '{print$1$2}'^Jdone
lan7*1500
lan8*1500

But I did not do shell scripting for a long time and I do not remember how to pass these values to the tcpdump. Any help will be appreciated !

Regards,
4 REPLIES 4
Dennis Handly
Acclaimed Contributor
Solution

Re: Script to gather some LAN information in HPUX 11.11 - 11.23

>I do not remember how to pass these values to the tcpdump.

for i in $(cmviewcl -v | grep STANDBY | awk '{print $4}'); do
   netstat -in | grep $i | awk'{print $1, $2}') |
    read LAN MTU dummy
    tcpdump -i $LAN -n -v -s $MTU -c 1 'ether[20:2] == 0x2000'
done

(I'm not sure why you had a "*" between the two?)

Dennis Handly
Acclaimed Contributor

Re: Script to gather some lan information in HPUX 11.11 - 11.23

Oops, I need a "," to separate the two awk fields:
netstat -in | grep $i | awk '{print $1, $2}') |
Santos Vega
Occasional Advisor

Re: Script to gather some lan information in HPUX 11.11 - 11.23

Hi,

Thank you very much! I had to add a "sed" to get rid of the "*", so the script is:

>for i in `cmviewcl -v |grep STANDBY | awk '{print$4}'`
>do
>netstat -in |sed 's/*//'| grep $i | awk '{print $1,$2}' | read LAN MTU dummy
>/usr/local/sbin/tcpdump -i $LAN -n -v -s $MTU -c 1 'ether[20:2] == 0x2000'
>done

..and now it works.

Regards,
Dennis Handly
Acclaimed Contributor

Re: Script to gather some lan information in HPUX 11.11 - 11.23

>I had to add a "sed" to get rid of the "*", so the script is:

You can change awk to do that, also the grep.
Where is the "*", attached to field $1 or $2?